To create a symbolic polynomial, initialize the symbolic variable with x = poly(0,"x"), where x is the name of the variable to be used in the polynomial. Then proceed to computing it in the same way as in a function lagrange. I essentially copied your function to symboliclagrangebelow, cutting out a numerical parameter and an intermediate display:
function symboliclagrange(X,Y)
x = poly(0,"x")
for i=1:length(Y)
l(i)=1
for j=1:length(Y)
if i~=j
l(i) = l(i)*(x-X(j))/(X(i)-X(j))
end
end
end
L=0
for i=1:length(Y)
L = L+Y(i)*l(i)
end
disp(L)
endfunction
X = [0 1 5 8], Y = [0 1 8 16.4] 0,85x + 0,15x 2 .
user3717023