0
votes

I am writing a function, actually translating it from a pseudocode form to julia. I keep getting the following complaint:

julia> include("coefficients.jl") ERROR: syntax: incomplete: "function" at /Users/comerduncan/MarkFiniteDiffDerivativs/coefficients.jl:1 requires end in include at boot.jl:244 while loading /Users/comerduncan/MarkFiniteDiffDerivativs/coefficients.jl, in expression starting on line 1

Here is my current version of the function:

function coefficients(order, x_list, x0)
    M = order
    N = length(x_list) - 1
delta = [0 for i=0:N,j=0:N,k=0:M]
delta[0,0,0]= 1
c1 = 1
for n =1:N+1
    c2 = 1
        for nu =0:n
            c3 = x_list[n]-x_list[nu]
            c2 = c2 * c3
            if n <= M
        delta[n,n-1,nu]=0
            for k=0:min(n,M)+1
                delta[k,n,nu] = (x_list[n]-x0)*delta[k,n-1,nu] -\
                k*delta[k-1,n-1,nu]
                delta[k,n,nu] /= c3
    end # k

    end # nu

        for m=0:min(n,M)+1
            delta[m,n,n] = c1/c2*(m*delta[m-1,n-1,n-1] \
            - (x_list[n-1]-x0)*delta[m,n-1,n-1] )
    end # m
        c1 = c2
end # n

return delta

end
1
It does not seem that the pasting of my function preserved the indentions. Please note that all "end"s of for loops are at the same indention level as the for at the head of the loop. Sorry if that is confusing.comer

1 Answers

2
votes

Unless I'm missing something, you have four ends, and four loops: but you also write if n <= M, and that isn't ended.

So your end # nu isn't actually closing the nu loop, it's closing the if, and you have one too few.