Question: Problem with functions

i got this code, but for any n = 2N (par) i get some high errors, my M goes nuts.  anyone knwos wheres my mistake?

With(CurveFitting); Digits; 5; f := proc (x) options operator, arrow; abs(x) end proc; n := 8; h := 2/n; for i from 0 to n do x[i] := h*i-1 end do; for i from 0 to n-1 do L[i] := (product((x-x[j])/(x[i]-x[j]), j = 0 .. i-1))*(product((x-x[k])/(x[i]-x[k]), k = i+1 .. n-1)) end do; lagr := sum(f(x[p])*L[p], p = 0 .. n-1); P := expand(lagr); plot({P, f(x)}, x = -1 .. 1, y = 0 .. 2); M := maximize(abs(abs(x)-P), x = -1 .. 1); M1 := numapprox:-infnorm(abs(abs(x)-P),

x = -1 .. 1)

 

Thanks in advance

Please Wait...