4 a Implement the Barycentric Formula for evaluating the interpolating

# 4 a implement the barycentric formula for evaluating

• Homework Help
• 3
• 50% (2) 1 out of 2 people found this document helpful

This preview shows page 2 - 3 out of 3 pages.

4. (a) Implement the Barycentric Formula for evaluating the interpolating polynomial forarbitrarily distributed nodesx0, . . . , xn; you need to write a function or script thatcomputes the barycentric weightsλ(n)j= 1/Qk6=j(xj-xk) first and another code touse these values in the Barycentric Formula. Make sure to test your implementation.(b) Consider the following table of dataxjf(xj)0.000.00000.250.70710.501.00000.750.70711.25-0.70711.50-1.0000Use your code in (a) to findP5(2) as an approximation off(2).5.The Runge Example. Letf(x) =11 + 25x2x[-1,1].(3)Using your Barycentric Formula code (Prob. 3) and (4) and (5) below, evaluate andplot the interpolating polynomial off(x) corresponding to(a) the equidistributed nodesxj=-1 +j(2/n),j= 0, . . . , nforn= 4, 8, and 12.(b) the nodesxj= cos(n),j= 0, . . . , nforn= 4, 8, 12, and 100.As seen in class, for equidistributed nodes one can use the barycentric weightsλ(n)j= (-1)jnjj= 0, . . . , n,(4)where(nj)is the binomial coefficient. It can be shown that for the nodesxj=a+b2+b-a2cos(n),j= 0, . . . , n, in [a, b], one can useλ(n)j=(12(-1)jforj= 0 orj=n,(-1)jj= 1, . . . , n-1.(5)Make sure to employ (4) and (5) in your Barycentric Formula code for this problem.To plot the correspondingPn(x) evaluate this at sufficiently large number of pointsne2
as in Prob. 2.Note that your Barycentric Formula cannot be used to evaluatePn(x)whenxcoincides with an interpolating node! Plot alsoffor comparison. Compare (a)and (b) and comment on the result in view of what you observed in Prob. 2.(c) Repeat (a) forf(x) =e-x2forx[-1,1] and comment on the result.3
• • • 