Message Boards Message Boards

How to choose a solution

Posted 11 years ago
I've solved a equation which gives me tree solutions for x. Then i want to plot it, but i only want the second solution to appear in the graphic, but i'm not able to do that. I'm using :
Manipulate[
 s = Solve[A == (1/(1 - Exp*x)^2 + B*Exp/(1 + x *Exp))*x ,
   x], {EA, 0, 30}, {A, 0, 2.709*10^-5}, {B, 0, 1.161*10^-5}]Manipulate[
 s = Solve[A == (1/(1 - Exp*x)^2 + B*Exp/(1 + x *Exp))*x ,
   x], {EA, 0, 30}, {A, 0, 2.709*10^-5}, {B, 0, 1.161*10^-5}]
 
gives me the 3 solutions (all complicated, if anyone know how to get it directly a numeric solution is welcome)
Then i use this to plot
Plot[x /. s, {y, 0, 15}]Plot[x /. s, {y, 0, 15}]
where s is the equation mentioned before. How can i choose it to plot the second solution and/or the third? I think that using that it only takes the first one, and it's the only which i want to discard. 

Thank you!
POSTED BY: Oscar Boher
3 Replies
Plot can take all three solutions at the same time. In this example Chop helps by filtering out small complex components.
Manipulate[
s = Solve[A == (1/(1 - Exp[EA]*x)^2 + B*Exp[y]/(1 + x*Exp[y]))*x, x];
Plot[Chop[x /. s], {y, 0, 15}, PlotRange -> All]
, {EA, 0, 30}, {A, 0, 2.709*10^-5}, {B, 0, 1.161*10^-5}]

Selection criteria can be anything that you need or want to find in a good solution or anything that you want to keep out of the resuts. In this example, the solutions are tested at y = 0.
With[{EA = 5, A = 2.709*10^-5, B = 1.161*10^-5},
s = Solve[A == (1/(1 - Exp[EA]*x)^2 + B*Exp[y]/(1 + x*Exp[y]))*x, x];
Select[s, Chop[x /. # /. y -> 0] < 0 &]
]
Posted 11 years ago
Sorry, I pasted it wrong. The code for the formula is 
Manipulate[
 s = Solve[A == (1/(1 - Exp [ EA ]  *x)^2 + B*Exp [ y ] /(1 + x *Exp [ y ] ))*x  ,
   x], {EA, 0, 30}, {A, 0, 2.709*10^-5}, {B, 0, 1.161*10^-5}]
Where the exponential is well defined. I used Manipulate so you can change EA, A and B, and the graph is in function of y (related to EA). Obviously the solution with these constants equal to 0 is not what I want, I'd prefer those with the maxim value that i enabled to use. 

So, when choosing the solution I have to pick it from the result? There is no way to graph the 3 solutions without having to pick them before? Also, if the solution is a y function it could be positive or negative for some values so I don't see how to segregate them individually.
POSTED BY: Oscar Boher
Exp gives the exponential of z. E^z.

E the symbol, is the exponential constant E (base of natural logarithms), with numerical value ~2.71828.

E can be entered as Esc ee Esc (for "exponential e")

If the expression Exp in your equation is exponential e constant and A and B are zero, then the graph can be plotted like this.
Plot[0 == (1/(1 - E*x)^2)*x, {x, 0, 15}]

With B = 1.161*10^-5
Plot[0 == (1/(1 - E*x)^2 + (1.161*10^-5)*E/(1 + x*E))*x, {x, 0, 15}]

NSolve gives three numerical solution for A = 2.709*10^-5 and B = 1.161*10^-5
In[ ]:= NSolve[(2.709*10^-5) == (1/(1 - E*x)^2 + (1.161*10^-5)*E/(1 + x*E))*x, x]

Out[ ]= {{x -> 8743.05}, {x -> -0.367926}, {x -> 0.0000270852}}

The position and number of solutions will depend on the value of A and B. You will have to develop a selection criteria to get the solution you want using some kind of unique characteristic of the solutions, like something less than zero.
In[ ]:= Select[
NSolve[(2.709*10^-5) == (1/(1 - E*x)^2 + (1.161*10^-5)*E/(1 + x*E))*x, x],
(x /. #) < 0 &]

Out[ ]= {{x -> -0.367926}}

Letting A and B remain symbolic, Solve will give you three solutions, one real and two complex.
Solve[A == (1/(1 - E*x)^2 + B*E/(1 + x*E))*x, x]
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract