I am trying to find the steady state (or roots) of a system with 9 states using the Krawczyk method. For that I need to find a Jacobian, but I am getting the following error-
" BoundsError: attempt to access 0-element Vector{ForwardDiff.Dual{ForwardDiff.Tag{Main.var"workspace#44".var"#1#2"{typeof(Main.var"workspace#44".large_model)}, Float64}, Float64, 0}} at index [1] "
A section of code which is giving error is-
"
local XYnew = [(0…50), (0…50), (0…50), (0…50), (0…50), (0…50), (0…50), (0…50), (0…50)]
jacobian(large_model, XYnew) = ForwardDiff.jacobian(x → large_model(x[1], x[2], x[3], x[4], x[5], x[6], x[7], x[8], x[9]), XYnew)
"
I am using “IntervalArithmetic.jl” package in Julia.
Please resolve the issue.
julia> local mid_XYnew = [mid(XYnew[1]), mid(XYnew[2]), mid(XYnew[3]), mid(XYnew[4]),
mid(XYnew[5]), mid(XYnew[6]), mid(XYnew[7]), mid(XYnew[8]), mid(XYnew[9])]
ERROR: UndefVarError: XYnew not defined
Stacktrace:
[1] top-level scope
@ REPL[24]:1
Can you check?
Also your indentation is a bit strange. Global code is usually not indented, but most of your code is global. And I am not sure if it makes sense to use the “local” keyword outside of a function.