I'm attempting to find the root of a non-linear equation using mata. Running Stata 15.1 on MacOS Mojave 10.14.6. Here is my code:
mata
maxu = 2.63506
u3 = 836.8054
u4 = 117.3982
u2 = 4.283902
w = 60.069
function myfunc(x, maxu, u3, u4, u2, w) return(maxu - ln(u3+u4+u2*exp(.0175134(w-x))))
rc = mm_root(x=., &myfunc(), 0, 1, 0 , 1000, maxu, u3, u4, u2, w)
x
end
This is the error message I'm getting:
: function myfunc(x, maxu, u3, u4, u2, w) return(maxu - ln(u3+u4+u2*exp(.0175134(w-x))))
invalid expression
r(3000);
Any suggestions? Thanks.
mata
maxu = 2.63506
u3 = 836.8054
u4 = 117.3982
u2 = 4.283902
w = 60.069
function myfunc(x, maxu, u3, u4, u2, w) return(maxu - ln(u3+u4+u2*exp(.0175134(w-x))))
rc = mm_root(x=., &myfunc(), 0, 1, 0 , 1000, maxu, u3, u4, u2, w)
x
end
This is the error message I'm getting:
: function myfunc(x, maxu, u3, u4, u2, w) return(maxu - ln(u3+u4+u2*exp(.0175134(w-x))))
invalid expression
r(3000);
Any suggestions? Thanks.
Comment