Group Abstract Group Abstract

Message Boards Message Boards

0
|
11.1K Views
|
2 Replies
|
1 Total Like
View groups...
Share
Share this post:

Spline method for interpolation doesn't seem to be working

Posted 11 years ago

So I was trying to show the difference between a polynomial interpolation and a spline interpolation for an assignment and I wrote the below code.

f[x_] := 1/(1 + 25 x^2)
data[n_] := Table[{x, f[x]}, {x, -1, 1, 2/n}];
polyinterpolate[order_, n_] := LinearModelFit[data[n], Table[X^i, {i, 1, order, 1}], X]
cubicspline[order_, n_] := Interpolation[data[n], Method -> "Spline", InterpolationOrder -> order]

"f" is the function I want to fit to in the domain -1 to 1, "data" creates a table of n evenly spaced points on the function. "polyinterpolate" fits the points to a polynomial of order o. "cubicspline" interpolates using the spline method to order o.

I'm not sure what is wrong with my code but polyinterpolate and cubicspline give the same fits to any n points. Could InterpolationOrder be overriding Method-> in some way?

Thanks!

POSTED BY: Jack Madden
2 Replies
Posted 11 years ago

Hello I have the same OK result with Version 10.0 for Microsoft Windows (64-bit). We do not know with what version the problem arises.

POSTED BY: wojtek potocki
Posted 11 years ago
POSTED BY: Michael Helmle
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard