MathGroup Archive 2004

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

Search the Archive

Re: Selecting cubic roots in functional form

  • To: mathgroup at smc.vnet.net
  • Subject: [mg50298] Re: Selecting cubic roots in functional form
  • From: Paul Abbott <paul at physics.uwa.edu.au>
  • Date: Wed, 25 Aug 2004 03:36:12 -0400 (EDT)
  • Organization: The University of Western Australia
  • References: <cggrto$gag$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

In article <cggrto$gag$1 at smc.vnet.net>, suomesta at yahoo.com (Carol Ting) 
wrote:

> I have an equation 
> 
> 2000c*(5c+7q)-4(c+8q)*(12q+5c)^2==0
> 
> and I need to find q as a function of c, where both c and q are
> positive quantities.
> 
> I use InequalitySolve and find that when c<3.11665 the 3rd root gives
> the positive function I need, and when c>3.11665 I should pick the
> first root instead.  So I need to pick different roots in different
> regions of c and combine them into a piecewise continuous function.

But Mathematica can do this for you:

 reduced = Reduce[{2000c*(5c+7q)-4(c+8q)*(12q+5c)^2==0, q > 0, c > 0}, q]

Note that Reduce returns the result in terms of Root objects, which is 
usually more useful than explicit expressions involving radicals.

The following (rather horrible) hack will turn the output of Reduce into 
a Which statement (someone else will think of a better way of doing 
this):

  ReduceToWhich[f_] := Which @@ Flatten[
    f /. And -> List /. Or -> List /. Equal -> (Last[{##}]&)]

so that 

  q[c_] = ReduceToWhich[reduced]

gives the output in the form you need. You can then plot the positive 
root for 0 < c < 100 as

  Plot[q[c], {c, 0, 100}]

> Trouble is, I have a whole series of equations generated by another
> function and it is impossible for me to pick the roots one by one.  Is
> there a way to make Mathematica do this automatically?

Note that this is a FAQ. See the MathGroup archive:

 http://forums.wolfram.com/mathgroup/archive/1994/Mar/msg00040.html
 http://forums.wolfram.com/mathgroup/archive/2000/Mar/msg00414.html
 http://hilbert.math.hr/arhive/mathgroup/2000/03/0422.html
 http://forums.wolfram.com/mathgroup/archive/2004/Mar/msg00285.html

For the equation you give, when c<3.11665 there are three real roots. 
You can use the 1994 posting above to show that the positive root you 
are after is exactly given by

  (1/72) (-23 c - 2 Sqrt[7] Sqrt[c (7 c + 750)] *
    Cos[(1/3) (ArcCos[-((c^2 (343 c + 223875))/
     (7 Sqrt[7] (c (7 c + 750))^(3/2)))] + 2 Pi)])

Now, for c>3.11665 there is only one real root, and it is still given by 
the above expression, as you can confirm by plotting this expression 
over the interval 0 < c < 100 and comparing to the Reduce result.

However, automating this second approach is likely to be problematic 
and, although you might think having explicit expressions is 
advantageous, the results from Reduce are actually more useful in 
general.

Cheers,
Paul

-- 
Paul Abbott                                   Phone: +61 8 9380 2734
School of Physics, M013                         Fax: +61 8 9380 1014
The University of Western Australia      (CRICOS Provider No 00126G)         
35 Stirling Highway
Crawley WA 6009                      mailto:paul at physics.uwa.edu.au 
AUSTRALIA                            http://physics.uwa.edu.au/~paul


  • Prev by Date: Publicon problems converting sample document to LaTeX
  • Next by Date: Re: Comparison of Mathematica on Various Computers
  • Previous by thread: Re: Selecting cubic roots in functional form
  • Next by thread: Random rook's tour of a rectangle