I’ve tried both NSolve and RootFind to solve a very complex function. It seems that it always passes a variable into the as a first step.
f(x_} : = Module[{},
Print["this is x: ", x];
ComplicatedFunction[x];
Return[x];
]
RootFind[F[x], {x,0}];
This is x: x
x is never a number it’s always a variable. The “ComplicatedFunction” cannot handle symbolic input, but is designed for a real. NSolve does the same thing. Is there a way around?
This does not contain enough actual code to diagnose whatever might be the issue (and from the description I really cannot say what might be the issue either).
Thanks for replying to my post. I tried to be brief, and maybe it appeared to be too brief. Let me try to explain it again.
First, the “ComplicatedFunction” is to is designed for a numeric input. A real number. Giving it a symbolic input will choke it. The Documentation states:
“FindRoot first localizes the values of all variables, then evaluates f with the variables being symbolic, and then repeatedly evaluates the result numerically.”
This is consistent with my observation that a symbolic variable is passed instead of a numeric value. The result of the print statement is:
this is x: x
instead of:
this is x: 0.83
I googled the problem extensively last night and discovered that mathematica offers a means of limiting the input of a function, and by doing so get it to fail on the symbolic pass. f(x_} becomes:
f(x_?NumberQ}
This appears to work on for a small test case. The actual case now gives me an error:
FindRoot::nveq: "The number of equations does not match the number of variables in FindRoot[{radRRunFun[r]==0},{r,radRF$319342}].
Let me work on this again and see if I can find a solution on my own.