Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2004
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2004

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

Search the Archive

Re: Lists

  • To: mathgroup at smc.vnet.net
  • Subject: [mg46987] Re: Lists
  • From: astanoff at yahoo.fr (astanoff)
  • Date: Thu, 18 Mar 2004 04:38:03 -0500 (EST)
  • References: <c3bgbb$7pl$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Clément wrote:

> Hello MathGroup,

> I'm french so i don't speak english very well...

> I have resolved an equation. So i have a list of solutions.
> But how can i extract only the reel solutions of this list ?

> thanks

--
Clément,

Zis is ze way I do :

In[1]:=
realSolutions[sol_]:=#[[1]]&/@Select[{#,#//N}&/@sol,FreeQ[#[[2]],Complex]&];

Example (InputForms inserted for readability) :

In[2]:=sol=Solve[x^3-x+1 == 0];

In[3]:=sol//InputForm

Out[3]//InputForm=
{{x -> -(2/(3*(9 - Sqrt[69])))^(1/3) - ((9 - Sqrt[69])/2)^(1/3)/3^(2/3)}, 
 {x -> ((1 + I*Sqrt[3])*((9 - Sqrt[69])/2)^(1/3))/(2*3^(2/3)) + 
    (1 - I*Sqrt[3])/(2^(2/3)*(3*(9 - Sqrt[69]))^(1/3))}, 
 {x -> ((1 - I*Sqrt[3])*((9 - Sqrt[69])/2)^(1/3))/(2*3^(2/3)) + 
    (1 + I*Sqrt[3])/(2^(2/3)*(3*(9 - Sqrt[69]))^(1/3))}}

In[4]:=realSolutions[sol]//InputForm
Out[4]//InputForm=
{{x -> -(2/(3*(9 - Sqrt[69])))^(1/3) - ((9 - Sqrt[69])/2)^(1/3)/3^(2/3)}}

--
0% de pub! Que du bonheur et des vrais adhérents !
Vous aussi inscrivez-vous sans plus tarder!!
Message posté à partir de http://www.gyptis.org, BBS actif depuis 1995.




  • Prev by Date: Re: DSolve problem solving an elemental DE in Math 5.0.1
  • Next by Date: Re: doing things on a procedural way and doing them on a functional way
  • Previous by thread: Lists
  • Next by thread: Re: Lists