Re: List of solution

• To: mathgroup at smc.vnet.net
• Subject: [mg47023] Re: List of solution
• From: "Dana DeLouis" <delouis at bellsouth.net>
• Date: Sat, 20 Mar 2004 03:50:35 -0500 (EST)
• Sender: owner-wri-mathgroup at wolfram.com

```Hello.  Here is a little function that I use.   I use RealsOnly vs the
built in package RealOnly.

RealsOnly[v_List] := Drop[v, Union[First /@ Position[(#1[[All,2]] & ) /@
v, _Complex, Infinity]]]

Generate some data?

sol = NSolve[{(x + y)^4 + (x + y)^2 == 3, 4*x - 2*y == 4}];

When doing it this way, some Complex numbers appear to fall thru the
crack.

Select[sol, FreeQ[#1, I] & ]

{{x -> 0.28620267541797006, y -> -1.4275946491640596},
{x -> 1.0471306579153632, y -> 0.09426131583072653},
{x -> 0.6666666666666666 - 0.5058299711839932*I,
y -> -0.6666666666666666 - 1.0116599423679864*I}}

However, by scanning all positions for Complex Numbers, it seems to work
ok.

RealsOnly[sol]
{{x -> 0.28620267541797006, y -> -1.4275946491640596},
{x -> 1.0471306579153632, y -> 0.09426131583072653}}

HTH.
--
Dana DeLouis
Windows XP
Mathematica 5.0 for Windows
delouis at bellsouth.net

= = = = = = = = = = = = = = = = =
"Clément" <rusheraquatic at ifrance.com> wrote in message
news:c3bgf6\$7qh\$1 at smc.vnet.net...
> Hello MathGroup,
>
> I have resolved an equation. So i have a list of solution like :
> {{x->0,
> y->0}{x->1, y->0}{x->i, y->1+2i}}
> I want to remove the complex solutions of this list.
> How can i do ?
>
> Thanks

```

• Prev by Date: Re: Why does Mathematica 5.0 fail where Mathematica 4.1 works ?
• Next by Date: RE: Re: List of solution
• Previous by thread: Re: List of solution
• Next by thread: RE: Re: List of solution