math - Lagrange polynomial: Unexpected interpolation results -
i trying interpolate series of data points using 2nd lagrange polinomial. having
point1:(5;100) point2: (9;17) point3: (12;17)
and formula
y=(x-x2)*(x-x3)/(x1-x2)*(x1-x3)*y1+ (x-x1)*(x-x3)/(x2-x1)*(x2-x3)*y2+ (x-x1)*(x-x2)/(x3-x1)*(x3-x2)*y3
it obvious quadratic function might not fit data.. example.
but wonder why value surprisingly high x=7
. if not wrong y=1500
.
is above formula correct?
answer:
in summary:
- for same
x
, can't have 2 differenty
values; violates definition of function. - you missing brackets in formula! not
(x-x2)*(x-x3)/(x1-x2)*(x1-x3)
,((x-x2)*(x-x3)) / ((x1-x2)*(x1-x3))
. - back 1>, note interpolation formula has
x3-x2
in denominator. if have tied values, dividing 0. - how can make interpolation on such small data set? yet asking quadratic interpolation!
follow-up:
1) fixed it. accidentally switched x , y values. points in format (y,x).
ah, haha, no wonder.
2) thank you! brackets improved approximation. regarding missing brackets: got formula accepted answer here: best way find quadratic regression curve in java, don't understand rule.
this famous, yet fundamental interpolation: lagrange interpolation. can verify formula @ wolfram mathworld: lagrange interpolating polynomial. don't give wikipedia link because 1 looks more beautiful.
the link found must contain typo. since have suggest edit fix that, approved.
3) (significant larger (which answers 4th question) time series. impossible have tied values.
yes, time series won't have tied values.
Comments
Post a Comment