Figure 1 Values YI[1],...,YI[4], at locations XI[1],...,XI[4]
The function described in passes through the points XI[2],YI[2] and XI[3],YI[3], but not through XI[1],YI[1] and XI[4],YI[4]. The first derivatives at the mid points between the data points have errors propotional to the size of the intervals squared (equation ). The difference between the first derivatives in the first and last region gives an accurate estimate of the second derivative in the middle region (equation ). The value of the function in the middle region is accurate to third order in the difference cubed and as shown in Figure 3 and Figure 4 extrapolates fairly well.
Expand through fourth order
Define
Let
So that
The odd terms integrate to zero across these regions so that
Values of f, f’’, and fiv at (x3+x4)/2 are needed
The second and fourth derivatives should be checked numerically.
..\Derivatives\GDc2nd.zip in ../Derivatives/NumericalDerivatives.docx#Numeircal2nd
Figure 2 Simulated values of the h3 and h5 terms as a function of 1/Pow
In figure 2 the term proportional to h3 is at 0.133, the one proportional to h5 is at 0.2 and the first missing term at h7 is found by extrapolating to 0.14. This gives a best estimate of the error in the integral.
Note that gives the magnitude. The sign will be positive if T3 and T5 are positive, negative if these are both negative and then in accord with the two signs.
In general the error will be min (T7,T5,T3). In summing over regions, the error estimate
will be
ENTER X,DELTA TO CHECK FOURTH DERIV O 0 TO STOP
3 1D-7
ANALYTIC 3.0000000000000000 0.0858932236443290
NUMERICAL 3.0000000000000000 0.0858932236443290
ENTER X,DELTA TO CHECK FOURTH DERIV O 0 TO STOP
3.7
1D-7
ANALYTIC 3.7000000000000002 0.0022591934880722
NUMERICAL 3.7000000000000002 0.0022591934880722
Run a Lagrange Polynomial through the six points
Subtract from
Subtract from
Subtract from
Use these in
And in
And the third derivative as
Evaluate at (x1+x2)/2 and (x3+x3)/2
Simplify the parenthesis
Subtract line 1 from line 2
Or
Write equation for points 2 and 3
Simplify the parenthesis
Add the two lines in. The f’’’ term cancels.
Assume that the term containing f’’’ can always be taken to be zero
The two values of f’ are given by and
In the region between x2 and x3
Xm=(x2+x3)/2
Fp34=(dat(4)-dat(3))/(x(4)-x(3))
Fp23=(dat(3)-dat(2))/(x(3)-x(2))
Fp12=(dat(2)-dat(1))/(x(2)-x(1))
Fpp23=2*(fp34-fp12)/((x3+x4)-(x1+x2))
F23=(dat(2)+dat(3))/2-(x3-x2)**2*Fpp23/2
a=F23
b=Fp12
c=Fpp23/2
FUNCTION
QUAD(XI,YI,X,DQUADDX)
IMPLICITREAL*8 (A-H,O-Z)
DIMENSION
XI(4),YI(4)
B=(YI(3)-YI(2))/(XI(3)-XI(2))
FP12=(YI(2)-YI(1))/(XI(2)-XI(1))
FP34=(YI(4)-YI(3))/(XI(4)-XI(3))
C=(FP34-FP12)/(XI(3)+XI(4)-XI(1)-XI(2)) !FPP23/2
A=(YI(2)+YI(3))/2-(XI(3)-XI(2))**2*C/4
XM=X-(XI(2)+XI(3))/2
DQUADDX=B+2*XM*C
QUAD=A+XM*(B+XM*C)
RETURN
END
function Quad(xi,yi:TALAG4;x:double;var dQuaddx:double):double;
var
a,b,c,xm,fp12,fp34,fpp23:double;
begin
b:=(yi[3]-yi[2])/(xi[3]-xi[2]);
fp12:=(yi[2]-yi[1])/(xi[2]-xi[1]);
fp34:=(yi[4]-yi[3])/(xi[4]-xi[3]);
c:=(fp34-fp12)/(xi[3]+xi[4]-xi[1]-xi[2]);
a:=(yi[2]+yi[3])/2-sqr(xi[3]-xi[2])*c/4;
xm:=(xi[2]+xi[3])/2;
dQuaddx:=b+2*(x-xm)*c;
Result:=a+(x-xm)*(b+(x-xm)*c);
end;
Figure 3 The fit is from 25.05 to 2526.47. The nuclides were fitted, but are not shown.
The values from the origin to 25.05 are outside the fit. The falling blue line is from equation which is centered between the second and third fitted point. The rising dotted curve is from the Lagrange polynomial.
Figure 4 Upper end of fit.
The flatter blue line is from equation . The dotted lower line is from the Lagrange polynomials. The last fitted point is at about 2505. The blue line is actually centered before the last point at 2505, while the dotted line goes through this point.
Figure 5 the 344 KeV peak is a bit off. the continuum approximations are not different to graphical accuracy.