MathGroup Archive 2010

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Finding only the real roots

  • To: mathgroup at smc.vnet.net
  • Subject: [mg114352] Re: Finding only the real roots
  • From: Equilib <petterbe at gmail.com>
  • Date: Thu, 2 Dec 2010 05:37:23 -0500 (EST)
  • References: <ib0lbs$gku$1@smc.vnet.net>

Hi Alexi,
Thanks a lot for your answer - it works great! (for some strange
reason I didn't see your reply until now).

A short follow -up.
Since the solution will for some specifications (c and g) will not be
real numbers, I cannot plot it.
Is there some elegant way to only get the real numbers so that it is
possible to plot the output?

I tried using Reduce[Manipulate[ Solve[1/2 + c + g (1 - p) + Sqrt[c +
p*g - 1] == 0, p], {c, 0, 1}, {g, 0, 1}], p, Reals] and some similar
commands, but that did not  work

Best,
Petter


On 5 Nov, 11:13, Alexei Boulbitch <alexei.boulbi... at iee.lu> wrote:
> Hi, Peter,
>
> All your questions have simple answers, but first your should write down =
correct Mathematica expressions.
>
> NSolve, rather than Nsolve, Sqrt, rather than root and [] at Sqrt, rather=
 than () at root.
>
> You will hardly move further without learning few basic things about Math=
ematica, so do it.
>
> In particular,
> NSolve[1/2 + c + g (1 - p) + Sqrt[c + p*g - 1] == 0, p]
>
> {{p ->  (0.125 (-1. (-8. - 8. c - 8. g) g -
>        11.3137 Sqrt[-0.125 g^2 + 1. c g^2 + 0.5 g^3]))/g^2}, {p -=
>  (
>     0.125 (-1. (-8. - 8. c - 8. g) g +
>        11.3137 Sqrt[-0.125 g^2 + 1. c g^2 + 0.5 g^3]))/g^2}}
>
> but I would do
>
> Solve[1/2 + c + g (1 - p) + Sqrt[c + p*g - 1] == 0, p]
>
> {{p ->  (2 g + 2 c g + 2 g^2 - Sqrt[-g^2 + 8 c g^2 + 4 g^3])/(
>     2 g^2)}, {p ->  (
>     2 g + 2 c g + 2 g^2 + Sqrt[-g^2 + 8 c g^2 + 4 g^3])/(2 g^2)}}
>
> instead. Also Manipulate works. Try this for instance:
>
> Manipulate[
>   Solve[1/2 + c + g (1 - p) + Sqrt[c + p*g - 1] == 0, p], {c, 0,
>    1}, {g, 0, 1}]
>
> Have fun, Alexei
>
> Hi all,
> I'm trying to numerically evaluate a function using NSolve, for
> example
> Nsolve[1/2+c+g(1-p)+root(c+p*g-1)==0,p] where my two variables g and =
c
> are both in the interval [0,1]. But, since the root is not always
> positive I do not get a solution to NSolve. The idea was therefore to
> first define the positive roots and then to do NSolve.
>
> My questions are therefore;
> 1) Is this the best approach, or are there more direct ways?
> 2) What should I do to only get the real roots?
> 3) If I first solve the root, and then use NSolve, will I still be
> able to use functions such as Manipulate on the NSolve solution?
>
> Best,Petter
>
> --
> Alexei Boulbitch, Dr. habil.
> Senior Scientist
> Material Development
>
> IEE S.A.
> ZAE Weiergewan
> 11, rue Edmond Reuter
> L-5326 CONTERN
> Luxembourg
>
> Tel: +352 2454 2566
> Fax: +352 2454 3566
> Mobile: +49 (0) 151 52 40 66 44
>
> e-mail: alexei.boulbi... at iee.lu
>
> www.iee.lu
>
> --
>
> This e-mail may contain trade secrets or privileged, undisclosed or
> otherwise confidential information. If you are not the intended
> recipient and have received this e-mail in error, you are hereby
> notified that any review, copying or distribution of it is strictly
> prohibited. Please inform us immediately and destroy the original
> transmittal from your system. Thank you for your co-operation.



  • Prev by Date: Re: Re-virginating Manipulates?
  • Next by Date: Re: Manipulate and ParametricPlot Control?
  • Previous by thread: fyi, Mathematica 8 full listing of symbols and functions
  • Next by thread: Using a Correlation Matrix to reduce risk