This is an example of a clamped spline where all of the equations are listed out in the resulting system of equations. Uses exactly four points plus prescribed slopes at the two ends.
This data is from "TeaTime" question #9 in section 5.2.
xs = 0.1 0.2 0.3 0.4 ys = -0.62 -0.28 0.0066 0.24 mleft = 0.5 mright = 0.1 0.4 |--------------------------------------------------------------------| | + + + + + | | | 0.2 |-+ +-| | | | | | | 0 |-+ A +-| | | | | -0.2 |-+ +-| | A | | | -0.4 |-+ +-| | | | | | | -0.6 |-+ +-| | | | + + + + + | -0.8 |--------------------------------------------------------------------| 0.1 0.15 0.2 0.25 0.3 0.35 0.4 xs = 0.1 0.2 0.3 0.4 ys = -0.62 -0.28 0.0066 0.24 mleft = 0.5 mright = 0.1 0.4 |--------------------------------------------------------------------| | + + + + + | | | 0.2 |-+ +-| | | | | | | 0 |-+ A +-| | | | | -0.2 |-+ +-| | A | | | -0.4 |-+ +-| | | | | | | -0.6 |-+ +-| | | | + + + + + | -0.8 |--------------------------------------------------------------------| 0.1 0.15 0.2 0.25 0.3 0.35 0.4 |
A = 1 0.1 0.01 0.001 0 0 0 0 0 0 0 0 -0.62 1 0.2 0.04 0.008 0 0 0 0 0 0 0 0 -0.28 0 0 0 0 1 0.2 0.04 0.008 0 0 0 0 -0.28 0 0 0 0 1 0.3 0.09 0.027 0 0 0 0 0.0066 0 0 0 0 0 0 0 0 1 0.3 0.09 0.027 0.0066 0 0 0 0 0 0 0 0 1 0.4 0.16 0.064 0.24 0 1 0.4 0.12 0 -1 -0.4 -0.12 0 0 0 0 0 0 0 0 0 0 1 0.6 0.27 0 -1 -0.6 -0.27 0 0 0 2 1.2 0 0 -2 -1.2 0 0 0 0 0 0 0 0 0 0 0 2 1.8 0 0 -2 -1.8 0 0 1 0.2 0.03 0 0 0 0 0 0 0 0 0.5 0 0 0 0 0 0 0 0 0 1 0.8 0.48 0.1 c = 1 0 0 0 0 0 0 0 0 0 0 0 0.110773 0 1 0 0 0 0 0 0 0 0 0 0 -17.5693 0 0 1 0 0 0 0 0 0 0 0 0 127.155 0 0 0 1 0 0 0 0 0 0 0 0 -245.387 0 0 0 0 1 0 0 0 0 0 0 0 -2.6744 0 0 0 0 0 1 0 0 0 0 0 0 24.2083 0 0 0 0 0 0 1 0 0 0 0 0 -81.7333 0 0 0 0 0 0 0 1 0 0 0 0 102.76 0 0 0 0 0 0 0 0 1 0 0 0 4.56736 0 0 0 0 0 0 0 0 0 1 0 0 -48.2093 0 0 0 0 0 0 0 0 0 0 1 0 159.659 0 0 0 0 0 0 0 0 0 0 0 1 -165.453 a1 = 0.110773 b1 = -17.5693 c1 = 127.155 d1 = -245.387 a2 = -2.6744 b2 = 24.2083 c2 = -81.7333 d2 = 102.76 a3 = 4.56736 b3 = -48.2093 c3 = 159.659 d3 = -165.453 A = 1 0.1 0.01 0.001 0 0 0 0 0 0 0 0 -0.62 1 0.2 0.04 0.008 0 0 0 0 0 0 0 0 -0.28 0 0 0 0 1 0.2 0.04 0.008 0 0 0 0 -0.28 0 0 0 0 1 0.3 0.09 0.027 0 0 0 0 0.0066 0 0 0 0 0 0 0 0 1 0.3 0.09 0.027 0.0066 0 0 0 0 0 0 0 0 1 0.4 0.16 0.064 0.24 0 1 0.4 0.12 0 -1 -0.4 -0.12 0 0 0 0 0 0 0 0 0 0 1 0.6 0.27 0 -1 -0.6 -0.27 0 0 0 2 1.2 0 0 -2 -1.2 0 0 0 0 0 0 0 0 0 0 0 2 1.8 0 0 -2 -1.8 0 0 1 0.2 0.03 0 0 0 0 0 0 0 0 0.5 0 0 0 0 0 0 0 0 0 1 0.8 0.48 0.1 c = 1 0 0 0 0 0 0 0 0 0 0 0 0.110773 0 1 0 0 0 0 0 0 0 0 0 0 -17.5693 0 0 1 0 0 0 0 0 0 0 0 0 127.155 0 0 0 1 0 0 0 0 0 0 0 0 -245.387 0 0 0 0 1 0 0 0 0 0 0 0 -2.6744 0 0 0 0 0 1 0 0 0 0 0 0 24.2083 0 0 0 0 0 0 1 0 0 0 0 0 -81.7333 0 0 0 0 0 0 0 1 0 0 0 0 102.76 0 0 0 0 0 0 0 0 1 0 0 0 4.56736 0 0 0 0 0 0 0 0 0 1 0 0 -48.2093 0 0 0 0 0 0 0 0 0 0 1 0 159.659 0 0 0 0 0 0 0 0 0 0 0 1 -165.453 a1 = 0.110773 b1 = -17.5693 c1 = 127.155 d1 = -245.387 a2 = -2.6744 b2 = 24.2083 c2 = -81.7333 d2 = 102.76 a3 = 4.56736 b3 = -48.2093 c3 = 159.659 d3 = -165.453 |
|
y = -0.62 ans = -0.62 y = -0.62 ans = -0.62 |
y = 0.0066 ans = 0.0066 y = 0.0066 ans = 0.0066 |
y = 0.24 ans = 0.24 y = 0.24 ans = 0.24 |
Now, let's put this all together into one cell that we can paste into sagecell.sagemath.org......
|