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

Click For Summary

Discussion Overview

The discussion revolves around the computation of maximum error in a not-a-knot spline fit to the Bessel function of the second kind, specifically focusing on numerical estimation methods for error evaluation. The context includes homework-related tasks involving spline functions and their application in approximating mathematical functions.

Discussion Character

  • Homework-related
  • Mathematical reasoning

Main Points Raised

  • One participant outlines the process of creating splines using the provided functions and specifies the use of a Bessel function as the target function for fitting.
  • Another participant suggests that the maximum error should be estimated numerically by evaluating both the splines and the Bessel function at a dense set of points and calculating the absolute differences.
  • A participant expresses confusion regarding the inputs required for the spline evaluation functions, indicating a lack of clarity on how to proceed with the calculations.
  • One participant clarifies that the spline variable contains necessary data, including x-values, and explains how to use the spline evaluation function with the correct inputs.
  • A later reply indicates that the initial confusion has been resolved, suggesting progress in understanding the task.

Areas of Agreement / Disagreement

Participants generally agree on the approach of estimating the error numerically, but there is some initial confusion regarding the inputs for the spline evaluation functions. The discussion reflects a progression from uncertainty to clarity without any explicit consensus on the final error values.

Contextual Notes

Participants have not fully resolved the specifics of the error calculation process, and there may be assumptions regarding the behavior of the spline functions that are not explicitly stated.

gfd43tg
Gold Member
Messages
949
Reaction score
48

Homework Statement


If you didn't already, download splineFunctions.zipView in a new window. This contains the splineE7.p and splinevalueE7.p function files.

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

Code:
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

Code:
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,

Code:
f = @(x) besselj(x,2);

Consider a not-a-knot-spline fit to the function ##f(x)##, using 10 points, with ##\left\{ x_i \right\}_{i=1}^{10}## 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 ##\left\{ x_i \right\}_{i=1}^{10}## 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?

Homework Equations


The Attempt at a Solution


Code:
f = @(x) besselj(x,2);
x = linspace(0,2,10);
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 uploaded the p-files for the spline functions.
 

Attachments

Last edited:
Physics news on Phys.org
I think they want you to estimate the error numerically, not by trying to do some clever math.

Evaluate the splines and the Bessel function at 500 points in the interval, and find the biggest absolute difference.
 
How would I do that? None of the inputs in either splineE7 or splinevalueE7 are points in the interval.
 
Your variable S contains all data about the spline. You don't need to know the details of what it contains, but from what you printed out, it's a reasonable guess that the "x" values you printed out are 10 points between 0 and 2.

Splineval takes two arguments, the variable S, and an array of X values (i.e. the x coordinate of the 500 points between 0 and 2). It returns the y coordinates of the points on the spline.
 
Okay I got it, thanks
 

Similar threads

  • · Replies 3 ·
Replies
3
Views
3K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 13 ·
Replies
13
Views
2K
Replies
8
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 3 ·
Replies
3
Views
2K
Replies
3
Views
2K
Replies
2
Views
2K
  • · Replies 14 ·
Replies
14
Views
3K