I am new to Julia and the Julia community. I’d appreciate it if someone can help me with this error. I have also opened an issue in the package NLsolve.jl.

I tried to use variables and parameters with type Float64 and auto differentiation with`autodiff=: forward`

. Because the package ForwardDiff.jl requires variables to be of type Real, see here, I changed the initial guess to be of type Real, with parameters remain of type Float64. In this case, the function `f!`

can be evaluated(as in the MWE), while the `nlsolve`

doesn’t work.

Here is the error information.

```
ERROR: UndefRefError: access to undefined reference
Stacktrace:
[1] getindex at ./array.jl:788 [inlined]
[2] seed! at /Users/pearson/.julia/packages/ForwardDiff/cXTw0/src/apiutils.jl:59 [inlined]
[3] seed! at /Users/pearson/.julia/packages/ForwardDiff/cXTw0/src/apiutils.jl:58 [inlined]
[4] vector_mode_dual_eval(::var"#1071#1072", ::Array{Real,1}, ::Array{Float64,1}, ::ForwardDiff.JacobianConfig{ForwardDiff.Tag{var"#1071#1072",Real},Real,1,Tuple{Array{ForwardDiff.Dual{ForwardDiff.Tag{var"#1071#1072",Real},Real,1},1},Array{ForwardDiff.Dual{ForwardDiff.Tag{var"#1071#1072",Real},Real,1},1}}}) at /Users/pearson/.julia/packages/ForwardDiff/cXTw0/src/apiutils.jl:43
[5] vector_mode_jacobian!(::DiffResults.MutableDiffResult{1,Array{Real,1},Tuple{Array{Float64,2}}}, ::var"#1071#1072", ::Array{Real,1}, ::Array{Float64,1}, ::ForwardDiff.JacobianConfig{ForwardDiff.Tag{var"#1071#1072",Real},Real,1,Tuple{Array{ForwardDiff.Dual{ForwardDiff.Tag{var"#1071#1072",Real},Real,1},1},Array{ForwardDiff.Dual{ForwardDiff.Tag{var"#1071#1072",Real},Real,1},1}}}) at /Users/pearson/.julia/packages/ForwardDiff/cXTw0/src/jacobian.jl:164
[6] jacobian! at /Users/pearson/.julia/packages/ForwardDiff/cXTw0/src/jacobian.jl:74 [inlined]
[7] (::NLSolversBase.var"#fj_forwarddiff!#24"{var"#1071#1072",ForwardDiff.JacobianConfig{ForwardDiff.Tag{var"#1071#1072",Real},Real,1,Tuple{Array{ForwardDiff.Dual{ForwardDiff.Tag{var"#1071#1072",Real},Real,1},1},Array{ForwardDiff.Dual{ForwardDiff.Tag{var"#1071#1072",Real},Real,1},1}}},Array{Real,1}})(::Array{Real,1}, ::Array{Float64,2}, ::Array{Float64,1}) at /Users/pearson/.julia/packages/NLSolversBase/mGaJg/src/objective_types/oncedifferentiable.jl:160
[8] value_jacobian!!(::OnceDifferentiable{Array{Real,1},Array{Float64,2},Array{Float64,1}}, ::Array{Real,1}, ::Array{Float64,2}, ::Array{Float64,1}) at /Users/pearson/.julia/packages/NLSolversBase/mGaJg/src/interface.jl:124
[9] value_jacobian!! at /Users/pearson/.julia/packages/NLSolversBase/mGaJg/src/interface.jl:122 [inlined]
[10] newton_(::OnceDifferentiable{Array{Real,1},Array{Float64,2},Array{Float64,1}}, ::Array{Real,1}, ::Int64, ::Float64, ::Int64, ::Bool, ::Bool, ::Bool, ::Static, ::NLsolve.var"#27#29", ::NLsolve.NewtonCache{Array{Float64,1}}) at /Users/pearson/.julia/packages/NLsolve/ZBTu4/src/solvers/newton.jl:48
[11] newton(::OnceDifferentiable{Array{Real,1},Array{Float64,2},Array{Float64,1}}, ::Array{Real,1}, ::Int64, ::Float64, ::Int64, ::Bool, ::Bool, ::Bool, ::Static, ::NLsolve.NewtonCache{Array{Float64,1}}; linsolve::Function) at /Users/pearson/.julia/packages/NLsolve/ZBTu4/src/solvers/newton.jl:134
[12] nlsolve(::OnceDifferentiable{Array{Real,1},Array{Float64,2},Array{Float64,1}}, ::Array{Real,1}; method::Symbol, xtol::Int64, ftol::Float64, iterations::Int64, store_trace::Bool, show_trace::Bool, extended_trace::Bool, linesearch::Static, linsolve::NLsolve.var"#27#29", factor::Int64, autoscale::Bool, m::Int64, beta::Int64, aa_start::Int64, droptol::Float64) at /Users/pearson/.julia/packages/NLsolve/ZBTu4/src/nlsolve/nlsolve.jl:23
[13] nlsolve(::Function, ::Array{Real,1}; method::Symbol, autodiff::Symbol, inplace::Bool, kwargs::Base.Iterators.Pairs{Symbol,Real,Tuple{Symbol,Symbol},NamedTuple{(:ftol, :show_trace),Tuple{Float64,Bool}}}) at /Users/pearson/.julia/packages/NLsolve/ZBTu4/src/nlsolve/nlsolve.jl:52
[14] top-level scope at none:0
```

Here is the MWE.

```
using NLsolve
function f!(res::AbstractArray,guess::AbstractArray,param::Float64)
x = similar(guess)
x[1] = guess[1]
res[1] = x[1]^param-param*x[1]+1
return res
end
# Initialize initial guess
guess = Array{Real,1}(undef,1)
guess[1] = 5.0
# Parameter
param = 2.0
# First evaluate(this works)
res = similar(guess)
init_f = f!(res,guess,param)
# Solve the problem(this goes with the error)
result = nlsolve((res,guess) -> f!(res,guess,param),
guess,
ftol = 1e-6,
method = :newton,
autodiff = :forward,
show_trace = true,
)
```

Thank you in advance.