I have been blocked for a very long time on this so any help would really help me as I am completely stuck there. I am new to Julia so please pardon my errors.
I have a system of equations (very simplified below) and keep getting “domain error”. It works for certain initial values, or for some equations. I noticed that whenever the value of equations evaluated at the initial values are below zero, it seems to generate a domain error.
For instance, when i change equation F of the sytem from
F= x * D , it works i.e. I do not get domain error (- the algorithm does not converge but as this is a simplified version of my true system, I am not concerned about that for now).
But when I change it to
F= x * D + 2 , I get a domain error (so this is even before looking into convergence for a solution).
Would anyone know why? Understanding what is going on here would help me solve this error and the future ones. Many thanks for your help!
using QuantEcon using NLsolve using ForwardDiff Re=5.0 Rl=2.0 E=4.0 D=0.1 function foc2(θlow::AbstractFloat, D::AbstractFloat) v(c) = 4 * c c21(θ) = 1/ (1 - θ) val2(θ) = θ * D * v(c21(θ)) val22 = quadgk(val2, 0, θlow) return val22 end function f!(F ,x) F= x * D F= foc2(x, D) F= D - x - x F= E - x - D F= x * D - x * ((Re-Rl)/Rl) F= x - x - x F= x - x / x F= x - x/ (D * x) F= x * D * x + x * D * (1 - x) * (x/Re) - x - x * x end initial_x = [D; D; 0.0; E/2.0; 0.01; E/2.0; 0.3; 0.1; 0.1 ] initial_F = similar(initial_x) df = OnceDifferentiable(f!, initial_x, initial_F) results1_bk = mcpsolve(df, [0.01, 0.01, 0.01, 0.01, 0.01, 0.01, 0.01, 0.01 , 0.0], [D, D, D, E, E, D, 0.9, 0.99, 0.9], initial_x )