Mathematica 9 is now available
Services & Resources / Wolfram Forums / MathGroup Archive
-----

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: [mg113635] Re: Finding only the real roots
  • From: Alexei Boulbitch <alexei.boulbitch at iee.lu>
  • Date: Fri, 5 Nov 2010 05:13:29 -0500 (EST)

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 Mathematica, 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.boulbitch 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: Printout Fontsize Mystery
  • Next by Date: issue with LinearSolve[] when using SparseArray when size close
  • Previous by thread: Finding only the real roots
  • Next by thread: Embed extra info?