Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2010

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

Search the Archive

Re: Problems with Mathematica 8.0 Solve

  • To: mathgroup at smc.vnet.net
  • Subject: [mg114233] Re: Problems with Mathematica 8.0 Solve
  • From: Chris Chiasson <chris.chiasson at gmail.com>
  • Date: Sun, 28 Nov 2010 06:53:09 -0500 (EST)
  • References: <icqfv3$m3f$1@smc.vnet.net>

On Nov 27, 2:36 am, Daniel Lichtblau <d... at wolfram.com> wrote:
> ----- Original Message -----
> > From: "leigh pascoe" <le... at evry.inserm.fr>
> > To: mathgr... at smc.vnet.net
> > Sent: Friday, November 26, 2010 4:32:06 AM
> > Subject:  Problems with Mathematica 8.0 Solve
> > Dear Mathgroup,
>
> > Like many of you I have recently installed Mathematica 8.0 and have
> > been
> > exploring its new features. I have encountered the following problem
> > using the Solve Function:
>
> > Firstly in Mathematica 7.0
>
> > I try to solve the following two simultaneous equations
> > In[35]
> > eq1 = (b + d + f)/x - (a + b)/(1 + x) - 2*(c + d + e)/(1 + 2*x + y) -
> > (f + g)/(x + y) == 0
> > eq2 = (e + g)/y - (c + d + e)/(1 + 2*x + y) - (f + g)/(x + y) == =
0
>
> > In[36}
> > Timing[sols = Solve[{eq1, eq2}, {x, y}];]
> > Out[36]
> > {52.437, Null}
>
> > A bit slow but it gives me the result I want. I then Simplify the
> > solutions and evaluate them with a set of vectors of the constants
> > {a,b,c,d,e,f,g}.
>
> > subs = {{a -> 45, b -> 79, c -> 4, d -> 11, e -> 8, f -> 0, g -> 2},
> > {a -> 95, b -> 85, c -> 9, d -> 13, e -> 6, f -> 0, g -> 1},
> > {a -> 18, b -> 45, c -> 0, d -> 1, e -> 2, f -> 0, g -> 0}, {a -> 50,
> > b -> 41, c -> 0, d -> 1, e -> 0, f -> 0, g -> 0},
> > {a -> 17, b -> 61, c -> 1, d -> 9, e -> 14, f -> 0, g -> 1}, {a ->
> > 68, b -> 60, c -> 10, d -> 7, e -> 3, f -> 2, g -> 0},
> > {a -> 42, b -> 90, c -> 5, d -> 29, e -> 49, f -> 6, g -> 17}, {a ->
> > 140, b -> 108, c -> 23, d -> 32, e -> 19, f -> 16, g -> 8}}
>
> > nsols = Simplify[RootReduce[sols /. subs]]
>
> > N[%]
>
> > giving me the answers I want
>
> > {{{y -> -2.18473, x -> 2.02599}, {y -> -0.0457403, x -> -0.53058}, {y
> > ->
> > 2.72299, x -> 1.70867}}, {{y -> -1.05434, x -> 1.00657}, {y ->
> > -0.0244319, x -> -0.536953},
> > {y -> 0.83139, x -> 0.871734}}, {{y -> -2.66667, x -> 2.66667}, {y ->
> > -0.0183209, x -> -0.50458}, {y -> 12.1294, x -> 2.53236}}, {{y ->
> > -0.84,
> > x -> 0.84},
> > {y -> 0., x -> -0.503749}, {y -> 0., x -> 0.833749}}, {{y -> -4.83381,
> > x -> 4.69898}, {y -> -0.100097, x -> -0.530885}, {y -> 12.0561, x ->
> > 3.63746}}, {{y -> -1.05985,
> > x -> 0.917926}, {y -> -0.014617, x -> -0.542283}, {y -> 0.351798, x
> > -> 0.797433}}, {{y -> -4.52487, x -> 3.85637}, {y -> -0.240225, x ->
> > -0.548865}, {y -> 7.61935, x -> 2.24569}},
> > {{y -> -1.46526, x -> 1.07904}, {y -> -0.0612374, x -> -0.561339}, {y
> > ->
> > 0.684794, x -> 0.770645}}}
>
> > In Mathematica 8.0 this process hangs at the Solve command. I was
> > forced
> > to abort the evaluation after more than an hour with no result. The
> > program seems to use only 25% of the available cpu (i.e. 1 of the 4
> > available in the quadcore) and never arrives at a result. I thought
> > that
> > equation solving was much improved in the new version, so what is
> > going on?
>
> > Perhaps there is a much better way to get the results I want. I need
> > to
> > evaluate the solutions to the above equations for large numbers of
> > data
> > vectors. I would appreciate any suggestions. Thanks in advance.
>
> > LP
>
> We are not exactly sure why this worked better in earlier versions (we kn=
ow where it gets into trouble in version 8). First are some suggestions fro=
m Adam Strzebonski, regarding your use of parametrized Solve.
>
> "[...] mention that
> for the (hopefully rare) cases when the new Solve method turns out
> to be slower than the old one we still have the old method available.
>
> In[3]:= Timing[sols = Solve[{eq1, eq2}, {x, y}, Method->"Legacy"];]
> Out[3]= {15.4497, Null}
>
> Another possibility
>
> parallelSolve[args__] :=
>   ParallelTry[#[args] &, {Solve, Solve[##, Method -> "Legacy"] &}]
>
> In[10]:= AbsoluteTiming[sol = parallelSolve[{eq1, eq2}, {x, y}];]
> Out[10]= {30.6728358, Null}
>
> Adam"
>
> Let me point out some other issues. First is that you will not save signi=
ficant time if your goal is to get "nice" results. Specifically, you can so=
lve relatively fast once you plug in those numeric values.
>
> In[5]:= Timing[solns = Map[Solve[(exprs /. #) == 0] &, Take[subs,=
 4]];]
> Out[5]= {0.889, Null}
>
> But the reduction is relatively slow.
>
> In[6]:= Timing[RootReduce[solns];]
> Out[6]= {161.009, Null}
>
> Also in version 8 you can readily suppress the radical solutions and then=
 it will RootReduce quote quickly.
>
> In[6]:= Timing[
>  solns = Map[Solve[(exprs /. #) == 0, Cubics -> False] &,
>     Take[subs, 4]];]
> Out[6]= {0.063, Null}
>
> In[9]:= Timing[RootReduce[solns];]
> Out[9]= {0.032, Null}
>
> If your end goal is the numeric solutions, I generally recommend NSolve.
>
> In[10]:= Timing[Map[NSolve[exprs /. #] &, subs]]
>
> Out[10]= {0.28, {{{y -> -2.18473, x -> 2.02599}, {y -> 2.72299,
>     x -> 1.70867}, {y -> -0.0457403, x -> -0.53058}}, {{y -> -1.05434=
,
>      x -> 1.00657}, {y -> -0.0244319, x -> -0.536953}, {y -> 0.8313=
9,
>     x -> 0.871734}}, {{y -> 12.1294, x -> 2.53236}, {y -> -0.0183209,
>     x -> -0.50458}}, {}, {{y -> 12.0561,
>     x -> 3.63746}, {y -> -4.83381, x -> 4.69898}, {y -> -0.100097,
>     x -> -0.530885}}, {{y -> -1.05985,
>     x -> 0.917926}, {y -> -0.014617, x -> -0.542283}, {y -> 0.351798,
>     x -> 0.797433}}, {{y -> -4.52487, x -> 3.85637}, {y -> 7.61935,
>     x -> 2.24569}, {y -> -0.240225, x -> -0.548865}}, {{y -> -1.46526=
,
>      x -> 1.07904}, {y -> -0.0612374, x -> -0.561339}, {y -> 0.6847=
94,
>      x -> 0.770645}}}}
>
> Daniel Lichtblau
> Wolfram Research

Thanks for posting about the Method->"Legacy" option. I called
technical support a few days ago and asked how to use the old Solve
method, but they never got back to me. Here is an example of an
equation with a few branches where the new default method falls over.

Solve[Max[coefficient Cv, low\[UnderBracket]limit,Min[static\
[UnderBracket]limit, z/(SWL x + y)]] == EBSTNLL/(Mf SWL + WDead), SWL]

Obviously, the Legacy method doesn't provide the conditions under
which the solutions are valid, but at least it does go through, take
each branch, and quickly solve it for the SWL rather than requiring me
to do that manually. Something needs to be done to make the new
default Solver more robust in the face of simple equations like the
one above.

--
http://chris.chiasson.name


  • Prev by Date: Re: Finding local maxima in multidimensional array (efficiently)
  • Next by Date: Re: Matrix Form of Quadratic Equations
  • Previous by thread: Re: Problems with Mathematica 8.0 Solve
  • Next by thread: Re: Problems with Mathematica 8.0 Solve