Re: How to express a Product (special case) in Mathematica?

• To: mathgroup at smc.vnet.net
• Subject: [mg59117] Re: How to express a Product (special case) in Mathematica?
• From: Peter Pein <petsie at dordos.net>
• Date: Fri, 29 Jul 2005 00:41:58 -0400 (EDT)
• References: <dc9vqf$cr8$1@smc.vnet.net>
• Sender: owner-wri-mathgroup at wolfram.com

vdavidster at gmail.com schrieb:
> If you're familiar with the Lagrange interpolation polynomial, you'll
> know that the coefficient term, phi, is defined as follows:
>
>             n
> phi_j (t) = TT     (t - t_i)
>             i=0   -----------
>             i!=j  (t_j - t_i)
>
> Or in LaTeX notation:
>
> \phi_j(t) = \prod^{n}_{\stackrel{i=0}{i \neq j}} \frac{(t - t_i)}{(t_j
> - t_i)}
>
> Or in graphical form:
> http://mathworld.wolfram.com/LagrangeInterpolatingPolynomial.html
>
> How do I do that in Mathematica?
> How do I specify a product that skips a value in its iterator, i? (i.e.
> i != j)
>
> Thanks!
>
> David
>

Well, delete t_j, build the quotients out of the rest and multiply:

In[1]:= xvalues = Range[-2, 2]
Out[1]= {-2, -1, 0, 1, 2}

In[2]:=
phi[j_][t_, tk_] := Times@@((t - #)/(tk[[j]] - #)& /@ Delete[tk, j])

In[3]:=(phi[#1][x, xvalues] & ) /@ Range[Length[xvalues]]
Out[3]=
{(-(1/24))*(-1 - x)*(1 - x)*(2 - x)*x,
(-(1/6))*(1 - x)*(2 - x)*x*(2 + x),
(1/4)*(1 - x)*(2 - x)*(1 + x)*(2 + x),
(1/6)*(2 - x)*x*(1 + x)*(2 + x),
(1/24)*(-1 + x)*x*(1 + x)*(2 + x)}

--
Peter Pein
Berlin



• Prev by Date: Re: How to express a Product (special case) in Mathematica?
• Next by Date: Re: How to express a Product (special case) in Mathematica?
• Previous by thread: Re: How to express a Product (special case) in Mathematica?
• Next by thread: PlotLegend & Tick marks in MultipleListPlot