Sei sulla pagina 1di 56

# CSpline

## Fit a cubic spline to a a series of XY coordinates

=CSplineA(X Coords, Y Coords, Interpolation X Coords, Optional Output type, Optional End condition, Optional End1

## Input (optional input in italics):

X Coords
} X and Y coordinates of the line, x must be in ascending order
Y Coords
} Values must be in single column or row ranges
Interpolation X Coords X coordinates where output is required in ascending order; single column or row
Output Type
1 (default) for Y values, slope, curvature, radius, and segment lengths
2 for polynomial coefficients and related data
End condition
1 (default) specified curvature
2 Specified slope
End1, End2
Curvature or slope at ends of spline, default = 0
TransposeH
If the Interpolation X Coords range is a row, and TransposeH = False then output in columns
Otherwise the output is oriented as the X Coord range (default).

Output:
Output is a 6 or 5 column or row array, enter as an array function:
To enter an array function:
Enter the function in the top left cell of the output range
Select the entire output range
Press F2
Press Ctrl-shift-enter
Out = 1
Out = 2 (see algorithm and fuction code)
Column 1
Spline Y values
f''(x)
Column 2
Slope
a = y(j)
Column 3
Curvature
b = (y(j+1) - y(j)) / h(j) - h(j) * c(j+1) + 2* c(j) / 3
Column 4
c = z(j) - mu(j) * c(j+1); c(n) = 0
Column 5
Arc length
d = (c(j+1) - c(j)) / (3 * h(j))
Column 6
Chord Length

Data1
X
Y
0.0
-1.0
2.0
0.0
3.0
0.1
4.0
3.0
5.0
4.0
Fix Curvature:
Spline1:
End 1
End 2
Spline2:
End 1
End 2

0
0
-2
2

1.4
X
0
0.2
0.4
0.6
0.8
1
1.2
1.4
1.6
1.8
2
2.2
2.4

#VALUE!
Spline1
Y
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!

Page 1

Spline2
Y
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!

Spline3
Y
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!

Spline4
Y
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!

CSpline

#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!

#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!

End Curvature
-1.2
Data1
Spline1
X
Y
X
Y
Slope
Curvature
-3.33
2.22
-2.83
#VALUE!
#VALUE!
#VALUE!
-2.66
2.99
-2.55
#VALUE!
#VALUE!
#VALUE!
-2.00
3.47
-2.26
#VALUE!
#VALUE!
#VALUE!
-1.33
3.77
-1.98
#VALUE!
#VALUE!
#VALUE!
-0.67
3.94
-1.70
#VALUE!
#VALUE!
#VALUE!
0.00
4.00
-1.41
#VALUE!
#VALUE!
#VALUE!
0.67
3.94
-1.13
#VALUE!
#VALUE!
#VALUE!
1.33
3.77
-0.85
#VALUE!
#VALUE!
#VALUE!
2.00
3.47
-0.57
#VALUE!
#VALUE!
#VALUE!
2.66
2.99
-0.28
#VALUE!
#VALUE!
#VALUE!
3.33
2.22
0.00
#VALUE!
#VALUE!
#VALUE!
0.28
#VALUE!
#VALUE!
#VALUE!
0.57
#VALUE!
#VALUE!
#VALUE!
0.85
#VALUE!
#VALUE!
#VALUE!
1.13
#VALUE!
#VALUE!
#VALUE!
1.41
#VALUE!
#VALUE!
#VALUE!
1.70
#VALUE!
#VALUE!
#VALUE!
1.98
#VALUE!
#VALUE!
#VALUE!
2.26
#VALUE!
#VALUE!
#VALUE!
2.55
#VALUE!
#VALUE!
#VALUE!
2.83
#VALUE!
#VALUE!
#VALUE!

#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!

Fix Slope:
Spline3:
End 1
End 2
Spline4:
End 1
End 2

2.6
2.8
3
3.2
3.4
3.6
3.8
4
4.2

0
0
4
-3

#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!

#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!

Curve
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!

a
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!

b
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!

Page 2

c
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!

d
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!

CSpline

#VALUE!
#VALUE!
#VALUE!

#VALUE!
#VALUE!
#VALUE!

#VALUE!
#VALUE!
#VALUE!

## Example 3; Fit spline to the deflected shape of a 3 span beam

Span lengths
m
20
30
End Action
2
-0.002
Mid-span deflection
mm
5
-11
Beam EI
2000000
-0.002
Data1
X
0.00
10.00
20.00
35.00
50.00
57.50
65.00

#VALUE!
#VALUE!
#VALUE!

15
0.001
10

#VALUE!
#VALUE!
#VALUE!

Slope
1.00E-03

0.001

Spline1
Y
0.000
0.005
0.000
-0.011
0.000
0.010
0.000

X
0
2.5
5
7.5
10
12.5
15
17.5
20
23.75
27.5
31.25
35
38.75
42.5
46.25
50
51.875
53.75
55.625
57.5
59.375
61.25
63.125
65

Y
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!

Slope
Curvature
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!

Curve
#VALUE!
#VALUE!
#VALUE!

a
#VALUE!
#VALUE!
#VALUE!

b
#VALUE!
#VALUE!
#VALUE!

Page 3

c
#VALUE!
#VALUE!
#VALUE!

d
#VALUE!
#VALUE!
#VALUE!

Bending
Moment
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!

CSpline

#VALUE!
#VALUE!
#VALUE!

#VALUE!
#VALUE!
#VALUE!

#VALUE!
#VALUE!
#VALUE!

Page 4

#VALUE!
#VALUE!
#VALUE!

#VALUE!
#VALUE!
#VALUE!

CSpline

## ondition, Optional End1, Optional End2)

utput in columns

ction code)
Output from Example 1 with interpolation X values in a row.
X
0
0.2
0.4
Y
#VALUE!
#VALUE!
#VALUE!
Slope
#VALUE!
#VALUE!
#VALUE!
Curvature
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
Arc Length
#VALUE!
#VALUE!
#VALUE!
Chord Length
#VALUE!
#VALUE!
#VALUE!

0.6
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!

0.8
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!

5.00
4.00

3.00
2.00
1.00
0.00
0
-1.00

Page 5 2

2.00
CSpline

1.00
0.00
0

-1.00
-2.00
x
Data Points

Spline1

Spline2

Spline3

Spline4

#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!

4.5
4
3.5
3
y

2.5
2
1.5
1
0.5

-4.00

-3.00

-2.00

-1.00

0
0.00
x

Page 6

1.0

CSpline

0.015

0.010

0.005

0.000
0

10

20

30

40

-0.005

-0.010

-0.015
x

Bending Moment

12

10

Page 7

50

10
CSpline

0
0

10

20

30

40

Page 8

50

CSpline

1
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!

1.2
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!

1.4
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!

1.6
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!

Page 9

1.8
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!

2
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!

2.2
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!

CSpline

Spline4

1.00

#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!

4.5
4
3.5
3
2.5
2
1.5
1
0.5
0
0.00

1.00

2.00

3.00

4.00

Page 10

CSpline

of a 3 span beam

50

60

70

Page 11

CSpline

50

60

70

Page 12

CSpline

2.4
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!

2.6
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!

2.8
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!

3
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!

3.2
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!

3.4
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!

Page 13

3.6
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!

3.8
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!

4
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!

CSpline

Page 14

CSpline

Page 15

CSpline

Page 16

CSpline

4.2
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!

Page 17

CSpline

Page 18

CSpline

Page 19

CSpline

Page 20

## Solve Spline Function

Find the X value for a specified Y on a cubic spline defined by a series of XY coordinates
=SolveSplineA(X Coords, Y Coords, Y Values, X Range, NumOut, End condition, End1, End2)

X Coords
Y Coords
Y values
X Range
NumOut
End condition
End1, End2

## } X and Y coordinates defining the cubic spline, x must be in ascending order

} Values must be in single column ranges
Y values for which the X value will be found; single column range or single cell
Allowable range of solution values, 2 row or 2 col range, must be within X Coords, default = xcoords r
Number of output values; default = number of Y Values
1 (default) specified curvature
2 Specified slope
Curvature or slope at ends of spline, default = 0

Output:
Output is a two column array (X values and Y Values), enter as an array function:
To enter an array function:
Enter the function in the top left cell of the output range
Select the entire output range
Press F2
Press Ctrl-shift-enter
Example 1; Find X for Y = 2 for a Spline defined by 5 data points and various end conditions
Curves are the same as CSpline Example 1
Data1
X
Y
1
0.75
2
0
3
-1
4
3
5
3
Fix Curvature:
Spline1:
End 1
End 2
Spline2:
End 1
End 2
Fix Slope:
Spline3:
End 1
End 2
Spline4:
End 1
End 2

Solution for Y =
0
0

2
#VALUE! #VALUE!

-2
2

#VALUE! #VALUE!

0
0

#VALUE! #VALUE!

2
-2

#VALUE! #VALUE!

Example 2; Find X for Y = -0.5 for two X ranges, using the same data

Xmin
Xmax
Y
X
X

2
3
-0.5
#VALUE!
#VALUE!

3
4
#VALUE!
#VALUE!

Example 3; Find X between 3 and 4 for 6 different Y values, using the same data
Y
-0.5
0
0.5
1
1.5
2

X
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!

Y
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!

Data 2
X
0
0.5
1
1.5
2
2.5
3
3.5
4
4.5
5
5.5
6
6.5
7
7.5
8
8.5
9
9.5
10

Y Values
80
75
82
85
90
91
99.9
98
102.9
102
96
90
87
91
96
102
110
115
120
125
120

95
100
105
110
115

Results
X
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!

Y
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!

y
0
0.5
1
1.5
2
2.5
3
3.5
4
4.5
5
5.5
6
6.5
7
7.5
8
8.5
9
9.5
10

50
63
75
85
90
91
99.9
98
102.9
102
96
90
87
91
96
102
110
115
120
125
130

120
115
110
105
100
95
90
85
80
75
0

10

## Cubic Hermite Spline Function

Fit a cubic spline to a a series of XY coordinates
=CHSplineA(X Coords, Y Coords, Interpolation X Coords, Optional Mono, Optional Output type)

## Input (optional input in italics):

X Coords
} X and Y coordinates of the line, x must be in ascending order
Y Coords
} Values must be in single column or row ranges
Interpolation X Coords X coordinates where output is required in ascending order
Mono
0 or False (default) for standard spline
1 or TRUE for monotonic spline
Output Type
1 (default) for Y values
2 for slope and curvature
TransposeH
If the Interpolation X Coords range is a row, and TransposeH = False then output in columns
Otherwise the output is oriented as the X Coord range (default).

Output:
Output is a 1 or 2 column or row array, enter as an array function:
To enter an array function:
Enter the function in the top left cell of the output range
Select the entire output range
Press F2
Press Ctrl-shift-enter
Out = 1
Out = 2
Column 1
Spline Y values
Slope
Column 2
Curvature

## Example 1; Fit spline to 5 data points

Data1
X
1
2
3
4
5

Y
0
0.00E+00
1
1
3.1

X
1
1.2
1.4
1.6
1.8
2
2.2
2.4
2.6
2.8
3
3.2
3.4
3.6
3.8
4
4.2
4.4
4.6
4.8
5

CSpline
Y
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!

CHSpline, Mono =
FALSE
Y
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!

output in columns

## Output from Example 1 with interpolation X values in a row.

X
1
1.2
1.4
1.6
1.8
2
2.2
2.4
Y
#VALUE! #VALUE! #VALUE! #VALUE! #VALUE! #VALUE! #VALUE! #VALUE!

## Example 1; Fit Hermite S

pline to 5 data points
3.50
3.00
2.50
2.00
y

CHSpline,
Mono = TRUE
Y
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!

1.50
1.00
0.50
0.00
0.5

1.5

2.5

3.5

4.5

x
Data Points

CSpline

0.50
0.00
0.5

1.5

2.5

3.5

4.5

x
Data Points

CSpline

## CHSpline, Mono = TRUE

2.6
2.8
3
3.2
3.4
3.6
3.8
4
4.2
4.4
#VALUE! #VALUE! #VALUE! #VALUE! #VALUE! #VALUE! #VALUE! #VALUE! #VALUE! #VALUE!

mite S
nts

3.5

ALSE

4.5

5.5

3.5

ALSE

4.5

## CHSpline, Mono = TRUE

5.5

4.6
4.8
5
#VALUE! #VALUE! #VALUE!

## Cardinal Spline Function

Fit a Cardinal Spline to a a series of XY coordinates
=CardSplineA(X Coords, Y Coords, Interpolation points, Tension, Optional Interpolation Point Type)

## Input (optional input in italics):

X Coords
Y Coords
Interpolation Points
Tension
Interpolation point type
TransposeH

## } X and Y coordinates of the line, Ascending x is not required

} Values must be in single column or row ranges
L, X or Y values where output is required.
Value controlling the shape of the curve between interpolation points
"L", decimal number indicating segment number and position of point along line segment.
"X" or "Y", x or y coordinates
If the Interpolation X Coords range is a row, and TransposeH = False then output in columns
Otherwise the output is oriented as the X Coord range (default).

Output:

## Output is a 2 column or row array, enter as an array function:

To enter an array function:
Enter the function in the top left cell of the output range
Select the entire output range
Press F2
Press Ctrl-shift-enter
Interpolation Point Type
Function OutPut
Output from Example 1 wit
Col 1
Col 2
L
L
X
Y
Y
X
Y
L
Y
X
L
Example 1; Fit spline to 5 data points + 2 dummy end points
Data1
Ptype = L
X
Y
L
X
1
0.5
1
#VALUE!
2
0
1.2
#VALUE!
3
-0.5
1.4
#VALUE!
5
3
1.6
#VALUE!
4
4
1.8
#VALUE!
2
3
2
#VALUE!
1
2.5
2.2
#VALUE!
2.4
#VALUE!
Tension
0.1
2.6
#VALUE!
2.8
#VALUE!
3
#VALUE!
3.2
#VALUE!
3.4
#VALUE!
3.6
#VALUE!
3.8
#VALUE!
4
#VALUE!
4.2
#VALUE!
4.4
#VALUE!
4.6
#VALUE!
4.8
#VALUE!
5
#VALUE!

L
Y
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!

X
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!

Ptype = X
Y
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!

X
L
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!

## Output from Example 1 with interpolation X values in a row.

1
1.2
1.4
1.6
1.8
2
2.2
2.4
2.6
2.8
#VALUE! #VALUE! #VALUE! #VALUE! #VALUE! #VALUE! #VALUE! #VALUE! #VALUE! #VALUE!

Y
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!

Ptype = Y
X
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!

Y
L
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!

12.000

10.000

8.000

6.000

4.000

2.000

0.000
0.000

5.000

10.000Ptype = X15.000
Ptype = L
Ptype = Y

20.000

25.000

=Y

3
3.2
3.4
3.6
3.8
4
4.2
4.4
4.6
4.8
#VALUE! #VALUE! #VALUE! #VALUE! #VALUE! #VALUE! #VALUE! #VALUE! #VALUE! #VALUE!

20.000

25.000

5
#VALUE!

## Procedure to fit cubic spline to ordered list of x,y points

Aim: For a list of XY coordinates, X(1 to n) and Y(1 to n), to find a, b, c, d in
Y = a + b(x - X(i)) + c(x - X(i))^2 + d(x- X(i))^3
for each segment, where x lies between X(i) and X(i+1)
It can be shown that:
a = Y(i)
b = m(i) - l(i)/6(2c(i) + c(i+1))
c = c(i)/2
d = (c(i+1) - c(i)) / (6l(i))
where:
l(i) = x(i+1) - x(i)
m(i) = (y(i+1) - y(i)) / l(i)
c(i) = d2y/dx2 at point i
The values of l and m are defined by the x,y coordinates, so it remains to find the values of c
Since m and c (the first and second derivative of f(x)) are defined to be equal for the splines meeting at any node
it can be shown that for any point, i:
l(i-1)c(i-1) + 2(l(i-1) + l(i))c(i) + l(i)(c(i+1)) = 6(m(i) - m(i-1))
In matrix form:
[
[ l(i-1)
[

]
l(i) ]
]

2(l(i-1) + l(i))

[ c(i-1) ]
[ c(i)
]
[ c(i+1) ]

[
]
[ 6(m(i) - m(i-1)) ]
[
]

A spline with n segments will have n+1 nodes and n-1 internal nodes, so 2 more equations are required to define the c values
Commonly used end conditions include:
Specified second derivative. Where the second derivative = 0 the spline is known as a natural spline.
Specified first derivative. This is known as a clamped spline
Examples are given below of each of these end conditions
Points to be splined:
X
1
2
3
4
5

L
0.75
0
-1
3
2

1
0
1
4
0
1
0
0
0
0
Spline No
1

0
1
4
1
0

b
0.75 -0.236607

1
1
1
1

M
-0.75
-1
4
-1

0
0
1
4
0

0
0
0
1
1

d
0 -0.5133929

c
0
c(2)
c(3)
c(4)
0
x(i.5)-x(i)
0.5

6(m(i) - m(i-1))
0
-1.5
30
-30
0
y(i.5)
0.5675

Inverted Matrix
1
-0.267857
0.071429
-0.017857
0

2
3
4

## 0 -1.776786 -1.540179 2.3169643

-1 2.09375 5.410714 -3.5044643
3 2.401786 -5.102679 1.7008929

## Specified second derivative: c(1) = 1; c(5) = -1

1
0
0
0
1
4
1
0
0
1
4
1
0
0
1
4
0
0
0
0
Spline
1
2
3
4

a
0.75
0
-1
3

Clamped Spline 1:
2
1
0
0
0

1
4
1
0
0

Spline
1
2
3
4

m(1)
m(5)
0
1
4
1
0

0.75
0
0 -1.888393
-1 2.303571
3 1.674107

2
1
0
0
0

1
4
1
0
0

Spline
1
2
3
4

m(1)
m(5)
0
1
4
1
0
b

0.75
-1
0 -1.602679
-1 2.160714
3 1.959821

b
c
d
-0.528274
0.5 -0.7217262
-1.693452 -1.665179 2.358631
2.052083 5.410714 -3.4627976
2.485119 -4.977679 1.4925595

Clamped Spline 2:

0
0
0
1
1

0.5
0.5
0.5

0
0
0
0
1
4
1

0
0
0
1
2

c
-0.361607
-1.526786
5.71875
-6.348214

d
-0.3883929
2.4151786
-4.0223214
3.6741071

-1
-1
0
0
1
4
1

0
0
0
1
2

c
1.352679
-1.955357
5.71875
-5.919643

d
-1.1026786
2.5580357
-3.8794643
2.9598214

c
0
c(2)
c(3)
c(4)
0

-0.9838
0.9615
3.1378

x(i.5)-x(i)
0.5
0.5
0.5
0.5

c
c(1)
c(2)
c(3)
c(4)
c(5)

x(i.5)-x(i)
0.5
0.5
0.5
0.5

Inverted Matrix
1
-0.267857
0.071429
-0.017857
0

y(i.5)
0.5206
-0.9682
0.9459
3.1847

x(i.5)-x(i)
0.5
0.5
0.5
0.5

c
c(1)
c(2)
c(3)
c(4)
c(5)

6(m(i) - m(i-1))
1
-1.5
30
-30
-1

6(m(i) - m(i-1))
-4.5
-1.5
30
-30
6

Inverted Matrix
0.577381
-0.154762
0.041667
-0.011905
0.005952

y(i.5)
0.6110
-1.0240
1.0787
2.7093

6(m(i) - m(i-1))
1.5
-1.5
30
-30
0
y(i.5)
0.4503
-0.9704
1.0251
2.8700

Splines Compared

Inverted Matrix
0.577381
-0.154762
0.041667
-0.011905
0.005952

Splines Compared

0
0

-1

-2
Natural S pline: c (1) = c (5) = 0

Spline

a
1
2
3
4

0.75
0
-1
3

0.2

b
-0.75
-1
4
-1

d
0
0
0
0

x(n.5)-xn
0.5
0.5
0.5
0.5

y(n.5)
0.375
-0.5
1
2.5

## -0.236607 -0.528269 -3.62E-006

-0.999986

0
0
0
0

C lamped S pline 1:

1
1
1.00001
1.4
1.6
1.8
2
2.2
2.4
2.6
2.8
3
3.2

0
0.00001
0.4
0.6
0.8
0
0.2
0.4
0.6
0.8
0
0.2

0.75
0.749998
0.6225
0.497143
0.297857
0
-0.398429
-0.808857
-1.120071
-1.220857
-1
-0.392857

0.75
0.749995
0.5725
0.457143
0.277857
0
-0.386429
-0.792857
-1.106071
-1.212857
-1
-0.400857

0.75
0.75
0.6672857
0.5359286
0.3197143
0
-0.4194286
-0.8450714
-1.161
-1.2512857
-1
-0.3427143

0.75
0.74999
0.495857
0.398786
0.251143
0
-0.378286
-0.790214
-1.113
-1.223857
-1
-0.370143

0
0
0
0
0
0
0
0
0
0
0
0

a
b
c
d

1
2
3
4
2

a
b
c
d

1
2
3
4
3

a
b

1
2

3.4
3.6
3.8
4
4.2
4.4
4.6
4.8
5
5.2
5.4
5.6

0.4
0.6
0.8
0
0.2
0.4
0.6
0.8
1
1.2
1.4
1.6

0.478929
1.447143
2.343571
3
3.289857
3.253143
2.9715
2.526571
2
1.459821
0.919643
0.379464

0.464929
1.431143
2.331571
3
3.309857
3.293143
3.0215
2.566571
2
1.401488
0.802976
0.204464

0.579
1.5720714
2.4434286
3
3.1102857
2.8890714
2.5127143
2.1575714
2
2
2
2

0.531
1.517214
2.402286
3
3.178857
3.026214
2.684143
2.294714
2
1.8
1.6
1.4

0
0
0
0
0
0
0
0
0
0
0
0

-1.473571

c
d

3
4
4

a
b
c
d

1
2
3
4

## to define the c values

Inverted Matrix

c
0
0
0
0
0
0.267857 -0.071429 0.017857 -0.017857 -3.080357
-0.071429 0.285714 -0.071429 0.071429 10.82143
0.017857 -0.071429 0.267857 -0.267857 -10.20536
0
0
0
1
0

Inverted Matrix

c
0
0
0
0
1
0.267857 -0.071429 0.017857 -0.017857 -3.330357
-0.071429 0.285714 -0.071429 0.071429 10.82143
0.017857 -0.071429 0.267857 -0.267857 -9.955357
0
0
0
1
-1

Inverted Matrix
-0.154762
0.309524
-0.083333
0.02381
-0.011905

0.041667
-0.083333
0.291667
-0.083333
0.041667

-0.011905
0.02381
-0.083333
0.309524
-0.154762

0.005952
-0.011905
0.041667
-0.154762
0.577381

c
-0.723214
-3.053571
11.4375
-12.69643
9.348214

Inverted Matrix
-0.154762
0.309524
-0.083333
0.02381
-0.011905

0.041667
-0.083333
0.291667
-0.083333
0.041667

-0.011905
0.02381
-0.083333
0.309524
-0.154762

0.005952
-0.011905
0.041667
-0.154762
0.577381

c
2.705357
-3.910714
11.4375
-11.83929
5.919643

amped S pline 1:

Nat1

Nat2

Con1

Con2

0.75
-0.236607
0
-0.513393
Nat1
0
-1.776786
-1.540179
2.316964
Nat1
-1
2.09375

0.75
-0.528274
0.5
-0.721726
Nat2
0
-1.693452
-1.665179
2.358631
Nat2
-1
2.052083

0.75
0
-0.361607
-0.388393
Con1
0
-1.888393
-1.526786
2.415179
Con1
-1
2.303571

0.75
-1
1.352679
-1.102679
Con2
0
-1.602679
-1.955357
2.558036
Con2
-1
2.160714

5.410714
-3.504464
Nat1
3
2.401786
-5.102679
1.700893

5.410714
-3.462798
Nat2
3
2.485119
-4.977679
1.49256

5.71875
-4.022321
Con1
3
1.674107
-6.348214
3.674107

5.71875
-3.879464
Con2
3
1.959821
-5.919643
2.959821

2
-2.700893
0
0

2
-2.99256
0
0

2
0

2
-1

## Cubic Spline Area Function

Having found the coefficients of the cubic curve for each segment it is a simple matter to find the area under the curve.
If for the list of XY coordinates, X(1 to n) and Y(1 to n), we have coefficients, a, b, c, d, for each segment such that:
Y = a + b(x - X(i)) + c(x - X(i))^2 + d(x- X(i))^3
where x lies between X(i) and X(i+1)
and the length of the segment = L(i) = X(i+1) - X(i)
Then the area under the curve for segnment i is given by:
Area(i) = a L(i) + b(L(i)^2)/2 + c(L(i)^3)/3 + d(L(i)^4)/4
The function CSArea() carries out this procedure for a cubic spline specified by a list of XY coordinates.
=CSArea(X Coords, Y Coords, Integration Limits, Optional End condition, Optional End1, Optional End2)

Input:
X Coords
Y Coords
Integration limits
End condition
End1, End2
Note:

## } X and Y coordinates of the line, x must be in ascending order

} Values must be in single column ranges
Lower and upper bound X values for the integration; if omitted first and last values from X Coords ar
Must be a single column or single row range with two cells
1 (default) specified curvature
2 Specified slope
Curvature or slope at ends of spline, default = 0
Since each segment area is evaluated independently, there is no requirement for the segments to be
of equal length

Output:
Output is the area under the curve between the specified limits
Example: area of a semi-circle
5 Area from CSArea
Exact Area
Error
0.1570796327
X
Y
3.1415926536
-5.0000
0.0000
2.9845130209
-4.9384
0.7822
2.8274333882
-4.7553
1.5451
2.6703537556
-4.4550
2.2700
2.5132741229
-4.0451
2.9389
2.3561944902
-3.5355
3.5355
2.1991148575
-2.9389
4.0451
2.0420352248
-2.2700
4.4550
1.8849555922
-1.5451
4.7553
1.7278759595
-0.7822
4.9384
1.5707963268
0.0000
5.0000
1.4137166941
0.7822
4.9384
1.2566370614
1.5451
4.7553
1.0995574288
2.2700
4.4550
0.9424777961
2.9389
4.0451
0.7853981634
3.5355
3.5355
0.6283185307
4.0451
2.9389

#VALUE!
39.26991
#VALUE!

0.471238898
0.3141592654
0.1570796327
0

4.4550
4.7553
4.9384
5.0000

2.2700
1.5451
0.7822
0.0000

## On-sheet Spline Interpolation Methods

Linear Spline Interpolation
Sample Data (concrete creep coefficients)
Strength Creep Coef
*
15
6.2
20
5.2
25
4.2
32
3.4
40
2.8
50
2.4
65
2
80
1.7
100
1.5
*
120
1.3
* Top and bottom rows are dummy values to allow Cardinal splines to extend to the last segment
To find the creep coefficient for a concrete strength of 60 Mpa:
1.
Find the position of the highest tabulated strength less than 60, using the Match Function:
60
5
2.
Find the strength values bracketing 60 Mpa, and the associated creep coefficients using
the IndexIndex
or Offset functions: Offset
(=INDEX(B\$6:B\$13,\$A
(=OFFSET(B6,A2121))
1,0,2,2))
5
50
2.4
50
2.4
6
65
2
65
2
3.
Find the interpolated value using simple arithmetic, or the Trend Function
Arithmetic: =C21+(C22-C21)*(A17-B21)/(B22-B21)
2.133333
Trend function =TREND(E21:E22,D21:D22,A17)
2.133333
Linear and Non-Linear Spline Interpolation and curve fitting
Note: the following formulas are taken from a comment by lhem at Jon Peltier's Blog:
http://peltiertech.com/WordPress/excel-interpolation-formulas/#more-3322
Trend Cubic polynomial (equivalent to polynomial trend line order 3):
=TREND(B6:B13,A6:A13^{1,2,3},A17^{1,2,3})
Err:502
Linear For decreasing data (or for increasing omit the 1- after first comma):
=PERCENTILE(C6:C13,1-PERCENTRANK(A6:B13,A17,20))
2.133333
Lagrange A cubic fit based on the surrounding 4 points:
=TREND(OFFSET(C6,MATCH(A17,B6:B13)-2,,4),OFFSET(B6,MATCH(A17,B6:B13)-2,,4)^{1,2,3},A17^{1,2,3})
Err:502
Spline Catmull-Rom (equivalent to smooth line option):
=SUM((1+1/IRR(MMULT({0,0,2,0;0,1,0,-1;-1,4,-5,2;1,-3,3,-1},OFFSET(B6,MATCH(A17,B6:B13)-2,,4)-A17 )))
^-{0;1;2;3}*MMULT({0,2,0,0;-1,0,1,0;2,-5,4,-1;-1,3,-3,1},OFFSET(C6,MATCH(A17,B6:B13)-2,,4)))/2
Err:504

These functions are compared with the equivalent UDF results in the table below
Linear Spline
Cubic fit or spline
Strength
20
22.5
25
27.5
30
32.5
35
37.5
40
42.5
45
47.5
50
52.5
55
57.5
60
62.5
65
67.5
70
72.5
75
77.5
80
82.5
85
87.5
90
92.5
95
97.5
100
5.500
5.000
4.500
4.000
3.500
3.000
2.500

InterpA
Percentile
#VALUE!
5.200
#VALUE!
4.700
#VALUE!
4.200
#VALUE!
3.914
#VALUE!
3.629
#VALUE!
3.363
#VALUE!
3.175
#VALUE!
2.988
#VALUE!
2.800
#VALUE!
2.700
#VALUE!
2.600
#VALUE!
2.500
#VALUE!
2.400
#VALUE!
2.333
#VALUE!
2.267
#VALUE!
2.200
#VALUE!
2.133
#VALUE!
2.067
#VALUE!
2.000
#VALUE!
1.950
#VALUE!
1.900
#VALUE!
1.850
#VALUE!
1.800
#VALUE!
1.750
#VALUE!
1.700
#VALUE!
1.675
#VALUE!
1.650
#VALUE!
1.625
#VALUE!
1.600
#VALUE!
1.575
#VALUE!
1.550
#VALUE!
1.525
#VALUE!
1.500

CsplineA CardSplineA
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!
#VALUE!

Trend,
Cubic Lagrange
5.065 Err:502
4.678 Err:502
4.324 Err:502
4.002 Err:502
3.710 Err:502
3.447 Err:502
3.211 Err:502
3.001 Err:502
2.815 Err:502
2.651 Err:502
2.509 Err:502
2.385 Err:502
2.280 Err:502
2.190 Err:502
2.115 Err:502
2.053 Err:502
2.003 Err:502
1.962 Err:502
1.930 Err:502
1.905 Err:502
1.884 Err:502
1.867 Err:502
1.853 Err:502
1.838 Err:502
1.823 Err:502
1.804 Err:502
1.782 Err:502
1.753 Err:502
1.717 Err:502
1.672 Err:502
1.616 Err:502
1.548 Err:502
1.466

3.500
3.000
2.500
2.000
1.500
1.000
10

20
Base Data

30
InterpA

40
50
CsplineA

60
CardSplineA

70
80
Trend, Cubic

90
Lagrange

100

## the last segment

{1,2,3},A17^{1,2,3})

6:B13)-2,,4)-A17 )))
B13)-2,,4)))/2

ne
CatmullRom
Err:504
Err:504
Err:504
Err:504
Err:504
Err:504
Err:504
Err:504
Err:504
Err:504
Err:504
Err:504
Err:504
Err:504
Err:504
Err:504
Err:504
Err:504
Err:504
Err:504
Err:504
Err:504
Err:504
Err:504
Err:504
Err:504
Err:504
Err:504
Err:504
Err:504
Err:504
Err:504

90
Lagrange

100

Disclaimer
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
A copy of the GNU General Public License may be obtained from:
The Free Software Foundation, Inc.
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.

dougjenkins@interactiveds.com.au
www.interactiveds.com.au
http://newtonexcelbach.wordpress.com/

Revision History
Current Version
Rev
1.00
1.01
1.02
1.03
1.04
1.05
1.06
1.07
1.08
1.09
1.10
1.11
1.12

1.12

###

Date

By

Description

2-Jul-09
12-Jul-09
###
3-May-10
8-May-10
###
###
7-Jul-10
###
4-Sep-11
###
###
###

DAJ

First release

DAJ

Spline procedures modified, provision for specified end slope or curvature added

DAJ
DAJ
DAJ
DAJ
DAJ
DAJ
DAJ
DAJ
DAJ
DAJ
DAJ

Corrected for points with x < first spline point. Area function added
Cardinal Spline and Chart Spline functions added
Documentation corrected for Cardinal Spline and Chart Spline functions
Slope and curvature output for Cubic Hermite Spline function corrected
CHSplinea corrected for Monotonic = true and segments with exactly zero slope.
SolveSplineA function modified to return multiple solutions
Code modified to accept single interpolant value
Modified for horizontal output array when XInt values arranged in a row.

s reserved