MathGroup Archive 2003

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

Search the Archive

Re: How do I extract a non-imaginary answer from an answer set?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg41911] Re: How do I extract a non-imaginary answer from an answer set?
  • From: wself at msubillings.edu (Will Self)
  • Date: Mon, 9 Jun 2003 05:20:56 -0400 (EDT)
  • References: <bbv513$24o$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

"AngleWyrm" <no_spam_anglewyrm at hotmail.com> wrote in message news:<bbv513$24o$1 at smc.vnet.net>...
> I want to extract the answer(s) that don't have an imaginary componant:
> 
> Solve[ 30 86.7 x^49 == 3/2 86.7 1.23^49, x]
> 
> produces a lot of answers, but only the last one is not imaginary, and is
> the only useful answer for me. Is there a way to extract just this answer,
> instead of a huge list?

1. You can just copy and paste the answer you want.

2. Your input above produces a list of rules.  You just want the last
one, so you could instead use the input

Last[Solve[ 30 86.7 x^49 == 3/2 86.7 1.23^49, x]]

3.  You may not know in advance which of the rules are going to give
real answers.  In that case you could select from the list of rules

Select[Solve[30 86.7 x^49 == 3/2 86.7 1.23^49, x],
     Im[#[[1, 2]]] == 0. &]

and this will give all the real answers if there are others.  Actually
due to possible roundoff error you would be safer to use

Select[Solve[30 86.7 x^49 == 3/2 86.7 1.23^49, x],
     Abs[Im[#[[1, 2]]]] < 10^-15. &]

You can use Chop to get rid of the spurious imaginary parts if there
are any.


  • Prev by Date: Re: Re: Quick "Random[]" question
  • Next by Date: Re: "Sloppy Union"? (Union of a list with *nearly* equal elements)
  • Previous by thread: Re: How do I extract a non-imaginary answer from an answer set?
  • Next by thread: Re: How do I extract a non-imaginary answer from an answer set?