MathGroup Archive 2004

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

Search the Archive

Re: Lists


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