       • To: mathgroup at smc.vnet.net
• Subject: [mg91739] Re: question about Solve
• From: Jean-Marc Gulliet <jeanmarc.gulliet at gmail.com>
• Date: Sun, 7 Sep 2008 05:33:37 -0400 (EDT)
• Organization: The Open University, Milton Keynes, UK
• References: <g9r4cf\$cj3\$1@smc.vnet.net>

```Jaccard Florian wrote:

> I don't understand the following behaviour of Solve.
>
> Consider the following system :
>
> Solve[{x*y==(a+2*b)/(c+2*d),1/Sqrt==Sqrt[(e*y)/(z*f*g*h)],2*Pi*i==0.9/(z*f)},{x,y,z}]
>
> Everything fine, I obtain :
>
> {{z -> 0.1432394487827058/(f*i),
>     x -> (1.419827298426263*^-9*(9.83403688*^9*a +
>               1.966807376*^10*b)*e*i)/((c + 2.*d)*g*h),
>     y -> (0.0716197243913529*g*h)/(e*i)}}
>
> But if I ask for the answer of almost the same (only a 4 in the denominator
> of the second equation), Solve isn't abble anymore to manage without using
> inverse functions... why?
>
> Solve[{x*y == (a + 2*b)/(c + 2*d),
>  1/Sqrt == Sqrt[(e*y)/(4*z*f*g*h)],
>     2*Pi*i == 0.9/(z*f)}, {x, y, z}]
>
> Worse:
>
> If I have numerical values for a, b, c, d, e, f, g, h, i:
> a = 65/10^6;
> b = 1/10^3;
> c = 1.9;
> d = 0.19;
> e = 1/(2.5/10^3);
> v = 18;
> w = 8;
> g = (2*v)/((c + 2*d)*w);
> i = 3000;
> h = 0.2;
>
> Then Solve isn't able anymore! Mathematica thinks there is no solution. But
> there is one. I have to use Reduce or give the numerical values as rules
> after the Solve to find them.
>
> In:= Solve[{x*y == (a + 2*b)/(c + 2*d),
>  1/Sqrt == Sqrt[(e*y)/(z*f*g*h)],
>     2*Pi*i == 0.9/(z*f)}, {x, y, z}]
>
> Out= {}

. Though Solve[] and Reduce[] have many things in common they use
different sets of algorithms.

. Solve[] does not check the domain of definition of the equations or of
the solution.

. Reduce[] does it systematically (for instance, your system is not
defined for f == 0).

. Solve[] and Reduce[] are designed to work on symbolic expressions,
yielding infinite precision solutions. So you better use exact coefficients.

. Since your system is not defined for f == 0 (among other things), when
solving numerically (say, by providing machine-number-precision
coefficients) you might face round off errors and numerical instability.

. Also, a *warning/informational* message is just that. An *error*
message is a different beast and usually does not yield a result.

The examples below illustrate several ways to get the correct and exact
solutions (and to check their validity) as well as well as how to get
numerical results from them.

In:= eqs = Rationalize[{x*y == (a + 2*b)/(c + 2*d),
1/Sqrt == Sqrt[(e*y)/(z*f*g*h)], 2*Pi*i == 0.9/(z*f)}, 0]
sol = Solve[eqs, {x, y, z}]
eqs /. sol // Simplify
sol // N
eqs /. % // Simplify
sol = Reduce[eqs, {x, y, z}]
eqs /. ToRules[sol] // Simplify

Out=
a + 2 b     1              e y                 9
{x y == -------, ------- == Sqrt[-------], 2 i Pi == ------}
c + 2 d  Sqrt         f g h z             10 f z

Out=
9           40 (a e i Pi + 2 b e i Pi)         9 g h
{{z -> ---------, x -> --------------------------, y -> ---------}}
20 f i Pi            9 (c + 2 d) g h             40 e i Pi

Out= {{True, True, True}}

Out=
0.143239       4.44444 (3.14159 a e i + 6.28319 b e i)
{{z -> --------, x -> ---------------------------------------,
f i                      (c + 2. d) g h

0.0716197 g h
y -> -------------}}
e i

Out= {{True, True, True}}

Out= (c + 2 d) g h != 0 && e i != 0 && f != 0 &&

40 (a e i Pi + 2 b e i Pi)           9 g h               9
x == -------------------------- && y == --------- && z == ---------
9 (c + 2 d) g h               40 e i Pi         20 f i Pi

Out= {True, True, True}

In:= eqs = Rationalize[{x*y == (a + 2*b)/(c + 2*d),
1/Sqrt == Sqrt[(e*y)/(4*z*f*g*h)], 2*Pi*i == 0.9/(z*f)}, 0]
sol = Solve[eqs, {x, y, z}]
eqs /. sol // Simplify
sol // N
eqs /. % // Simplify
sol = Reduce[eqs, {x, y, z}]
eqs /. ToRules[sol] // Simplify

Out=
a + 2 b     1       1        e y                 9
{x y == -------, ------- == - Sqrt[-------], 2 i Pi == ------}
c + 2 d  Sqrt    2      f g h z             10 f z

During evaluation of In:= Solve::ifun: Inverse functions are being
used by Solve, so some solutions may \
not be found; use Reduce for complete solution information. >>

Out=
9           10 (a e i Pi + 2 b e i Pi)         9 g h
{{z -> ---------, x -> --------------------------, y -> ---------}}
20 f i Pi            9 (c + 2 d) g h             10 e i Pi

Out= {{True, True, True}}

Out=
0.143239       1.11111 (3.14159 a e i + 6.28319 b e i)
{{z -> --------, x -> ---------------------------------------,
f i                      (c + 2. d) g h

0.286479 g h
y -> ------------}}
e i

Out= {{True, True, True}}

Out= (c + 2 d) g h != 0 && e i != 0 && f != 0 &&

10 (a e i Pi + 2 b e i Pi)           9 g h               9
x == -------------------------- && y == --------- && z == ---------
9 (c + 2 d) g h               10 e i Pi         20 f i Pi

Out= {True, True, True}

In:= Block[{a = 65/10^6, b = 1/10^3, c = 1.9, d = 0.19, e =
1/(2.5/10^3), v = 18,
w = 8, g = (2*v)/((c + 2*d)*w), i = 3000, h = 0.2},
eqs = Rationalize[{x*y == (a + 2*b)/(c + 2*d),
1/Sqrt == Sqrt[(e*y)/(4*z*f*g*h)], 2*Pi*i == 0.9/(z*f)}, 0];
sol = Solve[eqs, {x, y, z}]]
eqs /. sol // Simplify
sol // N
eqs /. % // Simplify
sol = Reduce[eqs, {x, y, z}]
eqs /. ToRules[sol] // Simplify

Out=
148083731502947733735566537720000 Pi           3
{{x -> ------------------------------------, z -> ----------,
48405093832682679258144806707           20000 f Pi

6664487519298027
y -> --------------------------}}
22511157842962219240000 Pi

Out= {{True, True, True}}

Out=
0.0000477465                 -8
{{x -> 9610.95, z -> ------------, y -> 9.42365 10  }}
f

Out= {{True, True, True}}

Out=
148083731502947733735566537720000 Pi
f != 0 && x == ------------------------------------ &&
48405093832682679258144806707

6664487519298027                  3
y == -------------------------- && z == ----------
22511157842962219240000 Pi         20000 f Pi

Out= {True, True, True}

In:= \$Version

Out= 6.0 for Mac OS X x86 (64-bit) (May 21, 2008)

Regards,
-- Jean-Marc

```

• Prev by Date: Re: How can I create a two-axis graph in Mathematica v6
• Next by Date: Re: force variable to be real