Group Abstract Group Abstract

Message Boards Message Boards

0
|
12.9K Views
|
3 Replies
|
0 Total Likes
View groups...
Share
Share this post:

How to use Nsolve or findroot for a function / over a range

Posted 12 years ago
3 Replies

OMG, finally I got this old post to appear formatted not only in the post-preview, but also in the community itself.

Secondly, resources to learn Mathematica have been mentioned here How to learn Mathematica and here Where can I find examples of good Mathematica programming practice? and here Are there good online video tutorials for learning Mathematica? ... and then it depends on the knowledge you do have already to find an insightful learning path ... for example, if you are a theoretical physicist and you read German by chance, why not look into Mathematica und C in der modernen Theoretischen Physik ... a substantial body of work represent Trott's Mathematica Guide Books

POSTED BY: Udo Krause

First one has to solve the non-linear functional equation in eta. To avoid the Overflow error message, you define a function

In[77]:= Clear[leila]
leila[[Eta]_, R_] := Block[{x = (vLinf/Av)*(PL - Psat1)/(k*T) - N2*k*T/(N1*k*T - qc*Vv[R]*([Eta] *Psat1 - KH))}, Exp[x]]

this function is rather dull, because you can do

In[87]:= Table[{R, FindRoot[[Eta] == leila[[Eta], R], {[Eta], 0}]}, {R, 0, 10, 1}]
Out[87]= {{0, {[Eta] -> 1.0007}}, {1, {[Eta] -> 1.00072}}, {2, {[Eta] -> 1.00072}}, {3, {[Eta] -> 1.00072}}, 
              {4, {[Eta] -> 1.00072}}, {5, {[Eta] -> 1.00072}}, {6, {[Eta] -> 1.00072}}, {7, {[Eta] -> 1.00072}}, 
              {8, {[Eta] -> 1.00072}}, {9, {[Eta] -> 1.00072}}, {10, {[Eta] -> 1.00072}}}

with

In[95]:= leila[1.00072, 8]
Out[95]= 1.00072

as well as

In[96]:= Table[{R, FindRoot[[Eta] == leila[[Eta], R], {[Eta], 0}]}, {R, 0, 10^8, 10^7}] 
Out[96]= {{0, {[Eta] -> 1.0007}}, {10000000, {[Eta] -> 1.00072}}, {20000000, {[Eta] -> 1.00072}}, 
              {30000000, {[Eta] -> 1.00072}}, {40000000, {[Eta] -> 1.00072}}, {50000000, {[Eta] -> 1.00072}}, 
              {60000000, {[Eta] -> 1.00072}}, {70000000, {[Eta] -> 1.00072}}, {80000000, {[Eta] -> 1.00072}}, 
              {90000000, {[Eta] -> 1.00072}}, {100000000, {[Eta] -> 1.00072}}}

which means Eta is nearly a constant over R with the constants given. Anyway, in case you had a non-constant Eta you could fit its value table {R, Eta}

In[97]:= Table[{R, FindRoot[[Eta] == leila[[Eta], R], {[Eta], 0}][[-1, -1]]}, {R, 0,10^8, 10^7}]
Out[97]= {{0, 1.0007}, {10000000, 1.00072}, {20000000, 1.00072}, {30000000, 1.00072}, 
    {40000000, 1.00072}, {50000000, 1.00072}, {60000000, 1.00072}, {70000000, 1.00072},
     {80000000, 1.00072}, {90000000, 1.00072}, {100000000, 1.00072}}

e.g. with Interpolation and use it afterwards because you know it's a function of R now. A symbolic solution for Eta is unavailable as the simplest examples show

In[100]:= Reduce[[Eta] == Exp[b/(a - [Eta])], [Eta]]
During evaluation of In[100]:= Reduce::nsmet: This system cannot be solved with the methods available to Reduce. >>
Out[100]= Reduce[[Eta] == E^(b/(a - [Eta])), [Eta]]
POSTED BY: Udo Krause
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard