Spline approximation for $g(t) = \frac{t e^{-t}}{(x+t^2)^2}$

70 Views Asked by At

Is there any nice way to do a spline approximation for

$$ g(t) = \frac{t e^{-t}}{(x+t^2)^2}\,, $$

where $x$ is some constant? I tried finding nice interpolation points, however this proved very hard. Is the function easier to interpolate using sines and cosines instead of polynomials?

2

There are 2 best solutions below

0
On

I haven't thought much about your particular function or any special properties that might make it problematic. But, in general, for any polynomial approximation, I would recommend the Chebfun package. Depending on what you're doing, maybe you can either use Chebfun, or you can copy its algorithms (it's written in the Matlab language). There is also a partial port of Chebfun to the Python language, which might make it easier to read or borrow the code: Pychebfun on Github.

The algorithms are well described in their documentation, and in a book by Lloyd Trefethen, which I also recommend. The basic idea is to use polynomials of increasingly higher degree (up to degree 100), to try to get a good fit, and then switch to piecewise polynomials (i.e. splines) if necessary.

I don't think sines and cosines would help. They are periodic, and your function is not.

0
On

Here is a simple procedure you can follow to approximate the function by cubic Hermite spline:

1) Find the interval of the function you want to approximate. Say, it is [a, b].

2) Approximate the function within [a, b] by a single cubic Hermite curve by taking function values and function derivatives at t=a and t=b. You can google cubic Hermite curve to see how this is done. Please note that many cubic Hermite curve is defined between [0, 1], instead of an arbitrary domain like [a, b]. You will need to do some adjustments here.

3) Check the deviation at several points within [a,b] to see if the approximation is good enough. If the approximation is good enough, you are done.

4) If the approximation is not good enough, subdivide the interval in half and repeat steps (2) and (3) for every interval until all spline approximation within each interval has a sufficiently small deviation.