I have this function (1-6*x^2)^-1 and i want to polynomial interpolation (lagrange and spline) in 21 equidistant points [-1,1](adsbygoogle = window.adsbygoogle || []).push({});

I made this function

x =linspace(-1,1,21);

y = (1-6*x^2)^-1;

z=[-1:0.01:1]

c=polyfit(x,y,20)

p=polyval(c,z)

s=spline(x,y,z)

plot(z,(1-6*x^2)^-1, z, p, z, s);

and I receive error at y = (1-6*x^2)^-1;

if I use a function with x only instead of x^2 it works.

How can I fix it?

**Physics Forums | Science Articles, Homework Help, Discussion**

Dismiss Notice

Join Physics Forums Today!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

# MATLAB Matlab polynomial interpolation

**Physics Forums | Science Articles, Homework Help, Discussion**