For this example the difference plot crosses the x-axis, so the functions intersect at this point. We
choose this point as the splice center, so that the splice will not have to span a large distance between
the two functions. Solving for the root gives
x
2
= 0.549220479094
In some cases, the two functions will not intersect at all, or at least in the desired splice range. In this
case, a good choice for the splice center is the value of x at which the function difference is a
minimum.
The next step is to set the width of the splice, which in turn sets the half-width h. Assuming the two
estimating functions are both reasonably accurate, we want to make the splice rather narrow, but if we
make it too narrow, accuracy degrades because of loss of significant digits when solving for the splice
coefficients. For this example, I set h = 0.001, and we will verify that this is not too small. This means
that the splice will be fit from about x
1
= 0.54822 to x
3
= 0.55022.
All that remains is to calculate the other splice4() arguments, with these steps.
In the Y= editor, define some functions to make the calculations (and plotting) easier. Note that the
coefficients k1 to k6 have already been stored.
y1= polyEval({k1,k2,k3,k4},x)
y2= polyEval({k5,k6,k6},x)
y3= sin(x)
y4= y1(x)-y3(x)
y5= y2(x)-y3(x)
y6= polyEval(spl4,(x-x2)*k)
y7= y6(x)-y3(x)
y1 and y2 are f
1
(x) and f
2
(x). y3 is the function to be estimated. y4 and y5 find the error between the
model equations and the function to be estimated. y6 will calculate the splice function, and y7 will find
the splice function error. Note that k = 1/h.
Next, enter these commands in the entry line:
.54922048→x2
.001→h
1/h→k
y1(x2-h)→yy1
y1(x2)→yy2
y2(x2+h)→yy3
h*(y1(x),x)|x=x2-h→yd1
h*(y2(x),x)|x=x2+h→yd2
Finally, call the splice4() with the calculated arguments and save the result in spl4:
math\splice4(yy1,yy2,yy3,yd1,yd2)→spl4
Next we will ensure that the splice function meets the requirements. First, check the errors at x
1
, x
2
and
x
3
. These expressions should all be near zero:
y1(x2-h)-y6(x2-h) returns 2E-14
y1(x2)-y6(x2) returns 0
y2(x2+h)-y6(x2+h) returns 2E-14
Next check the derivative errors at the splice endpoints. The derivative errors should be near zero. If
we calculate the derivative errors (incorrectly!) by directly differentiating the splice function, we get
6 - 99