MethodError: no method matching Lagrange_Polynomials(::Float64, ::LinRange{Float64}, ::Array{Float64,1})

Hi, I’m new to Julia,
for this function in main I got an error message:
MethodError: no method matching LagrangePolynomial(::Float64, ::LinRange{Float64}, ::Array{Float64,1})
Closest candidates are:
LagrangePolynomial(::T, !Matched::Array{T,1}, ::Array{T,1}) where T<:AbstractFloat at In[8]:3

 using PyPlot

function Lagrange_Polynomials(x::T,vector_x::Vector{T},vector_y::Vector{T}) where T <: AbstractFloat # define an infinitely many large set of functions
n = length(vector_x)
length(vector_y)==n  || error("Incompatible vector size")
S = zero(T)
for i ∈ 1:n
     P = one(T)
          for j ∈ 1:n
                   if j != i
                   end  #chiude l'if
          end    #chiude il ciclo for interno
    S += vector_y[i]*P
end       #chiude il ciclo for esterno
 return S

f(x) = 1/sqrt(2π)*exp(-x^2/2);
a=-2;                                      #estremi dell' intervallo
b = 2;
n = 12                                     #number of interpolating points
vector_x = LinRange(a,b,n);                  #suddivisione dell' intervallo [a,b] in n punti equispaziati
xinterval = LinRange(a,b,1024);            #Una suddivisione più precisa dell' intervallo
ypoly = [Lagrange_Polynomials(x,vector_x,f.(vector_x)) for x in xinterval]
plot(xinterval, ypoly)
plot(xinterval, f.(xinterval), "k");
plot(vector_x, f.(vector_x), "ro");
plt[:legend](["f(x)","interpolation points",L"L_{n-1}(x)"])

Please, help me

In your definition of the Lagrange_Polynomials function, you restricted the second argument to Vector. Then you try to pass a LinRange as argument. That’s why you get an error. Vector and LinRange are different types.

The solution would be to relax the restrictions of the argument types of your Lagrange_Polynomials function, for example like this:

function Lagrange_Polynomials(x::T, vector_x::AbstractVector{T}, vector_y::AbstractVector{T}) where T <: AbstractFloat

Here, Vector{T} was changed to AbstractVector{T}, an abstract type which includes ranges.

You could also completely remove the argument type restrictions:

function Lagrange_Polynomials(x, vector_x, vector_y)