PDA

View Full Version : inconsistent cubic spline results



handberg
08-23-2006, 09:46 AM
I am experiencing problems with the SPLINE function from the math library.

I have collected a particular data set: The position data, call it x, has spacing of 0.036 mm, strictly increasing, over the domain -3.8 to 3.8. The profile, call it y, is gaussian in nature over the range 0 to 140.5. I would like to refine the spacing to 0.025 mm over the same domain.

To do this, I have created position data using the FINDGEN function, and modified it to get the correct spacing and correct range. This data set, call it t, is also strictly increasing.

When I run the spline function:
> result = spline(x, y, t)

The result data is all undefined (-1.#IND0).

However, I can create garbage data following the procedure outlined in the Reference text, and it works just fine. I have also taken one step farther and created a gaussian curve, added random noise, and further refined that data with the same function call and it works fine.

This is probably an obvious problem, but it's frustrating! Any ideas??

SebGR
08-24-2006, 10:00 AM
Hi handberg,

Is it possible for you to post a simple example code that illustrates this?

allan
09-07-2006, 10:59 AM
i could not reproduce the problem:
x = 0.036*findgen(7.6/0.036+1) - 3.8
y = 140.5 * exp(-!pi*(140.5*x)^2)
t = 0.025*findgen(7.6/0.025+1) - 3.8
z = spline(x,y,t)
plot, x, y
oplot, t, z, color=255
maybe you have version 7.51 or earlier:
in 8.00 the routine was forced to compute
in double precision even for single precision input;
anyway linear interpolation would probably be better
for this curve because of its extremely sharp corners
and nearly linear segments;