I am trying to use a list which is passed to a function in such a way that I can
- get the length of that list
- get the individual x and y values to manipulate
The list I am trying to manipulate can be seen below:
dataTan = Table[{x, Tan[x]}, {x, -1.5, 1.5, .75}];
this question is a sort of a follow-up to the question seen here. I eventually want to write my own function in mathematica that generates the Lagrange Interpolation polynomial for a given set of points
{{x0, y0}, ... , {xn, yn}}
I need some way to access the points above so that I may utilize the code below:
Sum[Subscript[y, j]*Product[If[j != m, (x - Subscript[x, m])/
(Subscript[x, j] - Subscript[x, m]), 1], {m, 0, k}], {j, 0, k}]
Given your last question, I’m guessing that you mean a Lagrange Polynomial, so
We can test it against the tangent function,
In this case, the interpolation is good, the maximum deviation from the original function is
Also note, that interpolating polynomials are actually built into Mathematica:
I had to expand them both before comparison, since
InterpolatingPolynomialreturns the result in the efficientHornerForm, while myLagrangePolyis returned in a very inefficient form.