Question: Interpolation of a function from two data lists

Dear,

I paste below a simple code illustrating what I want to do: interpolate a function from two lists . I wonder it is a very simple task but I the function and the graph I get don't match with the correct ones in the end (both are plotted below).

> y_data:=[0.5266426348e-1, 0.7090942099e-1, 0.9392192453e-1, .1228458380, .1598545751, .2107200296, .3127241088, .4144428927, .5679723063, .6817484378, .7973388763, .9326799232, 1.393259472, 1.493936979, 1.566845149, 1.624353545, 1.670898228, 1.708874880, 1.739919717, 1.765298377, 1.786042765, 1.803007037, 1.816897481, 1.828294327, 1.837670808, 1.845410531, 1.851823072, 1.857157571, 1.861614283, 1.865354162, 1.868506707, 1.871176289, 1.873447229, 1.875387839, 1.877053637, 1.878489894, 1.879733654, 1.880815343, 1.881760039, 1.882588494, 1.883317935, 1.883962726, 1.884534877, 1.885044474, 1.885500010, 1.885908668, 1.886276537, 1.886608800, 1.886909882, 1.887183573, 1.887433127, 1.887661351, 1.887870669, 1.888063180, 1.888240711, 1.888404854, 1.888557000, 1.888698365, 1.888830022, 1.888952911, 1.889067865];

> x_data:=[10, 53/5, 56/5, 59/5, 62/5, 13, 68/5, 68/5, 13, 62/5, 59/5, 56/5, 56/5, 59/5, 62/5, 13, 68/5, 71/5, 74/5, 77/5, 16, 83/5, 86/5, 89/5, 92/5, 19, 98/5, 101/5, 104/5, 107/5, 22, 113/5, 116/5, 119/5, 122/5, 25, 128/5, 131/5, 134/5, 137/5, 28, 143/5, 146/5, 149/5, 152/5, 31, 158/5, 161/5, 164/5, 167/5, 34, 173/5, 176/5, 179/5, 182/5, 37, 188/5, 191/5, 194/5, 197/5, 40];

inverted_pairs:=[seq([y_[i], x_[i]], i = 1 .. nops(y_))]; 

interp := LeastSquares(y_data, x_data, k_, curve = a*k_^3+b*k_^2+c*k_+d);

 

I've tried different kinds of interpolation methods. In this code I use LeastSquares() function. I'm sure it has a quick solution but I'm really stuck and would appreciate any help/advice.  

Thanks in advance!

 

 

PS: I didn't mention in above, but it is really important for me to get the associated function of the curve (e.g. ak_^3+bk_^2+ck_+d). I can get it using LeastSquares() function but with your code (where you use ArrayInterpolation()) the function is not generated in the end. Could you please indicate some way to do that? Thanks!

Please Wait...