MathGroup Archive 2007

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

Search the Archive

Re: Extracting solutions from Solve[]

  • To: mathgroup at smc.vnet.net
  • Subject: [mg82581] Re: Extracting solutions from Solve[]
  • From: Jean-Marc Gulliet <jeanmarc.gulliet at gmail.com>
  • Date: Thu, 25 Oct 2007 06:09:08 -0400 (EDT)
  • Organization: The Open University, Milton Keynes, UK
  • References: <ffn0bv$5o0$1@smc.vnet.net>

Isaac Martinez G. wrote:
> Hello group:
> New guy to Mathematica and I am using the Solve function to find all the roots of a non linear set of equations.
> My question is once I have all the solution I am getting rid of all the complex ones and then I need to keep the ones that are within the interval [0,1].
> I have the following nested list after removing complex values:
> {{}, {}, {}, {}, {}, {}, {}, {}, {
>   1., -0.357968, -0.0366376}, {1., -0.357968, -0.0366376}, {}, {}, {}, {}, \
> {0.326026, -0.812319, 0.0112833}, {-0.791102, 
>     0.283189, 0.0113524}, {}, {}, {0.454731, 0.840435, 0.0318799}, {}, {}, \
> {0.999998, 
>     1.8482, 1.63961}, {0.999997, 1.8482, 1.63962}, {0.998429, -2.49158, 
>     3.06313}, {0.999101, -2.49158, 3.06323}}
> 
> I need to take the solution/group that is within [0,1].
> How do you do this??
> Any help is appreciated....no luck so far...

One possible way, using *Cases* and interval arithmetic:

In[1]:= sols = {{}, {}, {}, {}, {}, {}, {}, {}, {1., -0.357968, \
-0.0366376}, {1., -0.357968, -0.0366376}, {}, {}, {}, {}, {0.326026, \
-0.812319, 0.0112833}, {-0.791102, 0.283189,
     0.0113524}, {}, {}, {0.454731, 0.840435,
     0.0318799}, {}, {}, {0.999998, 1.8482, 1.63961}, {0.999997,
     1.8482, 1.63962}, {0.998429, -2.49158,
     3.06313}, {0.999101, -2.49158, 3.06323}};

In[2]:= Cases[sols, {a_, b_, c_} /;
   IntervalMemberQ[Interval[{0, 1}], a] &&
    IntervalMemberQ[Interval[{0, 1}], b] &&
    IntervalMemberQ[Interval[{0, 1}], c]]

Out[2]= {{0.454731, 0.840435, 0.0318799}}

-- 
Jean-Marc


  • Prev by Date: Re: Converting notebooks to use Mathematica Player
  • Next by Date: Re: Converting notebooks to use Mathematica Player
  • Previous by thread: Re: Extracting solutions from Solve[]
  • Next by thread: Why does Sum return 0 on this series?