I am attempting to implement the multivariate Newton's method in Julia, but have run into a "no metehod matching" error. Below is my implementation and the code I use to call it.
function newton(f::Vector, J::Matrix, x::Vector)
h = Inf64
tolerance = 10^(-10)
while (norm(h) > tolerance)
h = J(x)\f(x)
x = x - h
end
return x
end
Invokation Attempt 1
f(x::Vector) = [(93-x[1])^2 + (63-x[2])^2 - 55.1^2,
(6-x[1])^2 + (16-x[2])^2 - 46.2^2]
J(x::Vector) = [-2*(93-x[1]) -2*(63-x[2]); -2*(6-x[1]) -2*(16-x[2])]
x = [35, 50]
newton(f, J, x)
When running the above code the following error is thrown:
ERROR: LoadError: MethodError: no method matching newton(::typeof(f), ::typeof(J), ::Array{Int64,1})
Closest candidates are:
newton(::Array{T,1} where T, ::Array{T,2} where T, ::Array{Int64,1})
newton(::Array{T,1} where T, ::Array{T,2} where T, ::Array{T,1} where T)
newton(::Array{T,1} where T, ::Array{T,2} where T, ::Array)
Invokation Attempt 2
f(x::Vector) = [(93-x[1])^2 + (63-x[2])^2 - 55.1^2,
(6-x[1])^2 + (16-x[2])^2 - 46.2^2]
J(x::Vector) = [-2*(93-x[1]) -2*(63-x[2]); -2*(6-x[1]) -2*(16-x[2])]
x = [35, 50]
newton(f(x), J(x), x) # passing x into f and J
When trying to invoke the method as in attempt 2 I encounter no error, but the process never terminates. For reference, the corresponding implementation of multivariate Newton's method that I have written in MATLB solves the system of equations from the examples in about 10 seconds.
How can I properly implement and invoke multivariate Newton's method in Julia?