Maximum error in not-a-knot spline of bessel function

1 view (last 30 days)
The syntax is as follows: If Xdata and Ydata are vectors with the same number of elements, then four various splines can be created as
SN = splineE7(Xdata,Ydata,'N'); % Natural
SK = splineE7(Xdata,Ydata,'K'); % not-a-knot
SP = splineE7(Xdata,Ydata,'P'); % Periodic
SE = splineE7(Xdata,Ydata,'E',v1,vN); % end-slope
If xG is an array, then the various splines can be evaluated at the values in xG using splinevalueE7, for example
yG = splinevalueE7(S,xG)
where S is one of the created splines.
Define a function using Bessel functions of the 2nd kind, which is the solution to an important differential equation arising in acoustics and other engineering disciplines. Define a function f via an anonymous function,
f = @(x) besselj(x,2);
Consider a not-a-knot-spline fit to the function f(x), using 10 points, with {xi}10i=1 linearly spaced from 0 to 2. Associated with this spline, compute the maximum absolute value of the error, evaluated on a denser grid, with 500 points linearly spaced from 0 to 2. Which of the numbers below is approximately equal to that maximum absolute error?
Now consider a natural spline fit to the function f(x), using 10 points, with {xi}10i=1 linearly spaced from 0 to 2. Associated with this spline, compute the maximum absolute value of the error, evaluated on a denser grid, with 500 points linearly spaced from 0 to 2. Which of the numbers below is approximately equal to that maximum absolute error?
Here is my attempt
f = @(x) besselj(x,2);
x = linspace(0,2,10);
y = f(x);
S = splineE7(x,f(x),'K')
S =
Coeff: [4x9 double]
x: [0 0.2222 0.4444 0.6667 0.8889 1.1111 1.3333 1.5556 1.7778 2]
y: [1x10 double]
I don't understand how to find the maximum error. I attached the p-files for the spline functions given to us.

Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!