`X = [1,2,4,5, 17, 34];Y = [8,14,25,1,-3,27];syms x;sum = 0;for i = 1: length(X) u = 1; l = 1; for j = 1: length(X) if j ~= i u = u * (x - X(j)); l = l * (X(i)-X(j)); end end sum = sum + ((u/l)*Y(i));enddisp(simplify(sum)); fplot(sum(x));`

I´m trying to use Lagrange´s method for finding a polynomial, but after finding it i can´t plot the function "sum".

Is there a way to do that?

## Best Answer