Question: What is wrong with my code?

f:=proc(x)
return 2^x
n:=5
M:=-2,-1,0,1,2
P:=1
for k to n+1 do
L:=1
for i to n+1 do
if i<>k then
L:=L*(x-M[i])/(M[k]-M[i]); end if; end do;
P:=P+f(M[k])*L;
end do;
I write Lagran algorithm. sorry, my english is not very good

Please Wait...