JuliaNLSolvers / NLsolve.jl

Julia solvers for systems of nonlinear equations and mixed complementarity problems

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

No Method Matching Error with nlsolve

castrovjm opened this issue · comments

Hello, I am having a problem with nlsolve, and I would really appreciate any feedback.

Here is a MWE

using NLsolve, QuantEcon

κ=0.19
η=0.5
b=0.4
β=0.99
δ=0.02
α=1/3
ρ=0.97
σ=0.002
N=10
mc=tauchen(N,ρ,σ)
z=exp.(mc.state_values)
Γ=mc.p


      LHS(ϕ)=κ/β*ϕ.^(-1)
      RHS(ϕ)=Γ*(1-η)*(z.-b*ones(N))-η*κ*ϕ+(1-δ)*κ*ϕ.^(-1)
      function F(ϕ::Vector{Float64})
          eq=zeros(length(ϕ))
          eq=LHS(ϕ).-RHS(ϕ)
          return eq
      end

      init=0.5*ones(N)
      F(init)
      res=nlsolve(F,init)

Thanks a lot

julia> res=nlsolve(F,init; inplace=false)
Results of Nonlinear Solver Algorithm
 * Algorithm: Trust-region with dogleg and autoscaling
 * Starting Point: [0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5]
 * Zero: [3.01409, 3.04061, 3.06845, 3.09645, 3.1246, 3.1529, 3.18134, 3.20993, 3.23866, 3.2663]
 * Inf-norm of residuals: 0.000000
 * Iterations: 4
 * Convergence: true
   * |x - x'| < 0.0e+00: false
   * |f(x)| < 1.0e-08: true
 * Function Calls (f): 5
 * Jacobian Calls (df/dx): 5

in the next version of NLsolve.jl, this will be detected automatically.