Saturday, April 21, 2012

10.25

Polynomial interpolation consists of determining the unique (n - 1)th-order polynomial that fits n data points. Such polynomials have the general form.

 f(x) = P1x^n-1 + P2x^n-2 +... + Pn-1x +Pn                (eq10.25)

 where the p's are constant coefficients. A straightforward way for computing the coefficients is to generate n linear algebraic equations that we can solve simultaneously for the coefficients. Suppose that we want to determine the coefficients of the fourth-order polynomial f(x) =  p1x^4 + p2x^3 +p3x^2 +p4x +p5 that passes through the following five points:(200,0.746),(250, .675), (300,.616), (400, .525) and (500, .457). Each of these pairs can be substituted into Eq. (P10.25) to yield a system of five equations with five unknowns (the p's). Use this approach to solve for the coefficients. In addition, determine and interpret the condition number.



Matlab code:



B = [ .746; .675; .616; .525; .457]
x = [200, 250, 300, 400, 500];
xx = [1,1,1,1,1];

A = [ x.^4 ;x.^3; x.^2 ;x.^1; xx]'

p = A\B

A * p

cond(A)

RESULTS

B =

   7.4600e-01
   6.7500e-01
   6.1600e-01
   5.2500e-01
   4.5700e-01


A =

   1.6000e+09   8.0000e+06   4.0000e+04   2.0000e+02   1.0000e+00
   3.9062e+09   1.5625e+07   6.2500e+04   2.5000e+02   1.0000e+00
   8.1000e+09   2.7000e+07   9.0000e+04   3.0000e+02   1.0000e+00
   2.5600e+10   6.4000e+07   1.6000e+05   4.0000e+02   1.0000e+00
   6.2500e+10   1.2500e+08   2.5000e+05   5.0000e+02   1.0000e+00


p =

   1.3333e-12                P1
  -4.5333e-09                P2
   5.2967e-06                P3
  -3.1737e-03                P4
   1.2030e+00               P5


ans =

   7.4600e-01
   6.7500e-01
   6.1600e-01
   5.2500e-01
   4.5700e-01


cond(A) =

   1.1712e+13

A has a large condition number, meaning it is ill-formed, and there is a high potential for error


No comments:

Post a Comment