# Solve can not solve the equation correctly in Reals

Here is the error I found.

r = 3;
Solve[Sqrt[(r^2 Cos[m Pi] - x)^2 + (r^2 Sin[m Pi])^2] == 10 && x > 0 &&
0 <= m <= 2, x, Reals]


{{x -> ConditionalExpression[ 9 Cos[m \[Pi]] + Sqrt[100 - 81 Sin[m \[Pi]]^2], 0 <= m < 1/2 || 1/2 < m < 3/2 || 3/2 < m <= 2]}}

Mathematica says $$m \neq \frac {1} {2}$$ and $$m \neq \frac {3} {2}$$

But I beleieve it can be equal to these 2 numbers.

1. When $$r=3,m= \frac {1} {2}$$,

$$x = \sqrt {19}$$

1. When $$r=3,m= \frac {3} {2}$$,

$$x = \sqrt {19}$$

• If you had used the Weierstrass substitution, you might have less problems. Aug 14 '20 at 22:55
• @J.M. How can I use Weierstrass substitution? Any tips?
– kile
Aug 15 '20 at 0:36

To use the Weierstrass substitution, we temporarily let $$m\pi=2\arctan u$$, which corresponds to restricting $$m$$ to $$-1. Thus,

With[{r = 3},
Simplify[Solve[Sqrt[TrigExpand[(r^2 Cos[2 ArcTan[u]] - x)^2 +
(r^2 Sin[2 ArcTan[u]])^2]] == 10 &&
x > 0, x, Reals] /. u -> Tan[m π/2]]]
{{x -> 1/2 (18 Cos[m π] + Sqrt[238 + 162 Cos[2 m π]])}}


which is equivalent to what Bob got in his answer:

9 Cos[m π] + Sqrt[100 - 81 Sin[m π]^2] == x /. First[%] // Simplify
True


When you experience a problem with a function check out its options.

Clear["Global*"]

r = 3;

sys = Sqrt[(r^2 Cos[m Pi] - x)^2 + (r^2 Sin[m Pi])^2] == 10 && x > 0 &&
0 <= m <= 2;

Solve[sys, x, Reals]


Using the option MaxExtraConditions

Solve[sys, x, Reals, MaxExtraConditions -> All]


Or use Reduce

Reduce[sys, x, Reals]


• Why not {{x -> ConditionalExpression[ 9 Cos[m \[Pi]] + Sqrt[100 - 81 Sin[m \[Pi]]^2]}} instead?
– kile
Aug 14 '20 at 14:07
• -What is sol? Can you specify it? I can't find sol in your answer.
– kile
Aug 14 '20 at 14:57
• @kile - The result is given in the form that the internal algorithms came up with. Presumably for reasons of efficiency, it did not try to find a simpler representation. The simpler form would be {x -> ConditionalExpression[9*Cos[m*Pi] + Sqrt[100 - 81*Sin[m*Pi]^2], 0 <= m <= 2]}` Aug 14 '20 at 15:21