# Fit polynomial to data with prescribed second derivative

16 views (last 30 days)
Andrea on 24 Jan 2015
Answered: Unai San Miguel on 15 Mar 2017
Hi!!
In desperate need for help. I have a set of data for the upper surface of an airfoil. I am trying to fit a polynomial to this set so that I can evaluate the second derivative. The current problem is that basic fitting does not produce great accuracy at the end. What I am trying desperately is to prescribe the second derivative at the left end so that this equals -0.001. I have tried csape(x,y,"second") and tried to place -0.001 everywhere but without much success. I keep getting very strange shapes or error saying that the matrices being concatenated is inconsistent.
What I am doing wrong?
Thanks everybody :(

Matt J on 24 Jan 2015
Edited: Matt J on 24 Jan 2015
It might be worth having a look at this spline fitting tool,
which provides a pretty convenient and flexible interface for constraints on the derivatives. In particular, one of the input option parameters 'xypp' lets you fix the second derivative at arbitrary points.
John D'Errico on 25 Jan 2015
Of course, I might be biased in agreeing with this suggestion.
Spline models should be preferred to polynomial models anyway. Lower order polynomials are too inflexible too often, and higher order polynomials blow up too easily due to numerical problems.

Andrea on 24 Jan 2015
This is what I was using, the general shape is good. It only needs the second derivative correction at the endpoints and I cant get the command right

Unai San Miguel on 15 Mar 2017
The help page for csape says that you would have to use csape(x, [-0.001, y, -0.001], 'second') or csape(x, [-0.001, y, -0.001], [2, 2]) to fit a cubic polynomial spline to (x, y) with second derivative of y wrt to x equal to -0.001 at both ends of x.
But, is this really what you want to do? Are the second derivatives the same at both ends of the upper side of your airfoil?