I am using Ted Ersek's RootSearch
function in Mathematica 9.0 (http://library.wolfram.com/infocenter/Demos/4482/) to create a function that I am using for graphing. Now, I'd like to use this function inside of a FindRoot
s call to find specific solutions.
To begin, we have a function f[t_, Rb_, N2_]
:
f[t_, Rb_, N2_] =(4.22153*10^6 (45.5182 + 5.226*10^-6 N2^2 + Rb) (0.106 -
0.106 E^(-9.43396 t) - Sin[120 \[Pi] t]/(120 \[Pi])))/N2^2
Then we define the tsat2[Rb_, N2_]
function using Ersek's RootSearch
function to find the t
values where f[t,Rb,N2] = 0.9
4 and return the minimum value.
tsat2[Rb_, N2_] := N[60*Min[t /. RootSearch[f[t, Rb, N2] - 0.94` == 0, {t, 0, 1}]]]
The above RootSearch
function works great, it's this next step that's the trouble. We play a little trick to turn tsat2
into a function of only Rb
to satisfy some other conditions to obtain tsat2[Rb,97.65*Rb]
Here's the problem: I need to find find f[Rb,97.65*Rb]==1.5
using numerical methods. Before I go and write my own numerical solver, I'd like to see if I can get FindRoots
to work:
FindRoots[tsat2[Rb, 97.65*Rb] - 1.5 == 0, {Rb, 10}]
However the problem is Mathematica doesn't even seem to evaluate this ambitious function call and only returns:
FindRoots[-1.5 + 60. (t /. $Failed) == 0, {Rb, 10}]
I suspect that somehow the tsat2
function is not actually being evaluated inside the FindRoot
statement, or more specifically, the RootSearch
function isn't being passed the values from the higher FindRoots
function call. I have tried this also using the RootSearch
function (so we essentially have a nested RootSearch
) and received the same error:
In[203]:= RootSearch[tsat2[Rb, Rb 97.65
] - 1.5
== 0, {Rb, 10}]Out[203]= RootSearch[-1.5 + 60. (t /. $Failed) == 0, {Rb, 10}]
My question is: How do I get the tsat2
function to act like any other function evaluation inside the FindRoots
call?
Thanks in advance!