paolog
02-10-2006, 06:49 AM
(If you reply to this thread, please also look at my earlier one ("Potential crash in spline?"), posted over two weeks ago, as no one has replied to that one yet - it would be great if someone could throw some light on that issue. Thanks.)
I would like to be able to invert the splines I have generated to get splines that map y to x. I would have thought the principle here would be:
* Take the nodes (x1, y1), ..., (xn, yn) used to generate the original spline
* Swap x and y in each coordinate pair
* Set the first derivatives at the ends to their reciprocals
* Fit splines through this revised data
This gives me splines that appear, when plotted, to be a reflection of the original splines in y = x, but do not tally in fact with the original splines. If I look up the value of y given by the original splines for a given value of x and then feed that value of y into the inverted splines, I get a value of x that is right to only two or sometimes only one decimal place. This level of precision is not adequate for my application.
Is there something wrong with what the procedure I have described above, or have I overlooked something? It looks mathematically sound to me. The second derivatives are set by the spline-fitting function and do not need to be set by the calling function, as far as I can see. Why should it be that the precision is so poor? Are there accumulated rounding errors in the code or something? I notice that the second derivatives are computed as a recurrence relation, so this might be a source of error.
Note that my splines are strictly monotonic and so are functions when inverted, so it is not a question of there being multiple solutions.
Can any of the authors comment?
Thanks,
Paul Giaccone
I would like to be able to invert the splines I have generated to get splines that map y to x. I would have thought the principle here would be:
* Take the nodes (x1, y1), ..., (xn, yn) used to generate the original spline
* Swap x and y in each coordinate pair
* Set the first derivatives at the ends to their reciprocals
* Fit splines through this revised data
This gives me splines that appear, when plotted, to be a reflection of the original splines in y = x, but do not tally in fact with the original splines. If I look up the value of y given by the original splines for a given value of x and then feed that value of y into the inverted splines, I get a value of x that is right to only two or sometimes only one decimal place. This level of precision is not adequate for my application.
Is there something wrong with what the procedure I have described above, or have I overlooked something? It looks mathematically sound to me. The second derivatives are set by the spline-fitting function and do not need to be set by the calling function, as far as I can see. Why should it be that the precision is so poor? Are there accumulated rounding errors in the code or something? I notice that the second derivatives are computed as a recurrence relation, so this might be a source of error.
Note that my splines are strictly monotonic and so are functions when inverted, so it is not a question of there being multiple solutions.
Can any of the authors comment?
Thanks,
Paul Giaccone