Help with finding and plotting interpolating polynomials
Mostrar comentarios más antiguos
I already plot using lagrange and newton polynomial but I need help with finding and plotting the interpolating polynomials by system of equations. It doesn't say anywhere in my textbook on how to do this so I need help.
Here is the data I'm given for the problem:
Given the (fictitious) gasoline price data over 10 years,
Year, x 1986 1988 1990 1992 1994 1996
Price (¢),y 113.5 132.2 138.7 141.5 137.6 144.2
a simple interpolating polynomial is proposed as:
y(x)= c0 + c1x + c2x^2 + c3x^3 + c4 x^4 + c5 x^5
Then I am asked to find it by using:
a) System of equations
b) Lagrange polynomial
c) Newton polynomial
Please I need help for the system of equations part.
1 comentario
Walter Roberson
el 20 de Abr. de 2012
duplicate is at http://www.mathworks.com/matlabcentral/answers/35883-help-with-an-interpolation-problem
Respuestas (1)
Richard Brown
el 20 de Abr. de 2012
0 votos
I presume you mean c0 + c1x + c2x^2 + c3x^3 + c4 x^4 + c5 x^5
The system of equations method means treating c0 ... c5 as unknowns, plugging each data point into the equation, and forming a matrix (Vandermonde) equation to solve for the resulting linear equations in c0 ... c5. That should hopefully be enough to get you back underway
4 comentarios
Steven
el 20 de Abr. de 2012
Walter Roberson
el 20 de Abr. de 2012
No, definitely not.
Steven
el 20 de Abr. de 2012
Walter Roberson
el 20 de Abr. de 2012
Suppose you had x = 1, 2, 3, and y = 5, 8, 13. That would correspond to y = x^2 + 4, or y = 1 * x^2 + 0*x + 4, or c0 = 4, c1 = 0, c2 = 1. In order of descending coefficients, [1 0 4] . Now, does the 1 or the 4 correspond to one of the values [1 2 3] or [5 8 13]? No --the [1 0 4] are simply coefficients that make the polynomial work.
Extending this example with three values to the more generalized form,
y1 = c2*x1^2 + c1*x1 + c0
y2 = c2*x2^2 + c1*x2 + c0
y3 = c2*x3^2 + c1*x3 + c0
where x1, x2, x3 and y1, y2, y3 are known, then
let D = ((-x2+x1) * (-x3+x2) * (-x3+x1))
and then
c0 = ((x2*y3-x3*y2)*x1^2+(-x2^2*y3+x3^2*y2)*x1+x2*y1*x3*(-x3+x2)) / D
c1 = ((-y3+y2)*x1^2+(y3-y1)*x2^2+x3^2*(y1-y2)) / D
c2 = ((y3-y2)*x1+(-y3+y1)*x2-x3*(y1-y2)) / D
You can see that there is a _relationship_ between the x/y values and the c* coefficients, but you can also see that the c* are certainly not either the x or y values directly.
Categorías
Más información sobre Polynomials en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!