Questions about syntax

Below is an implementation to compute Lagrange basis in Lagrange interpolation. I understand what this is supposed to do, but I don’t understand the syntax and I would appreciate some help. Particularly, what is ‘./’ – is it some sort of division? Also, what does the function/method ‘prod()’ do?

function LagrangePoly(x, i, z)

L=zeros(size(z))

for j=1:length(z)
    L[j]=prod( (z[j]-x[1:i-1])./(x[i]-x[1:i-1]))*prod( (z[j]-x[i+1:end])./(x[i]-x[i+1:end]))
end

return L

end

  1. https://docs.julialang.org/en/stable/manual/arrays/#Broadcasting-1
  2. https://docs.julialang.org/en/stable/stdlib/collections/#Base.prod. Also, you can type ?prod in the Julia REPL to get the documentation for prod.
2 Likes

Please don’t double post, or if you do, at least link to the other discussion https://stackoverflow.com/questions/47027566/julia-syntax-and-implementation-of-lagrange-polynomials