# Mathematica 12 hangs up with specific powers p at Solve[{5 ==z-(Abs[-q]+Abs[q]), 3==z-(Abs[3^p-q]+Abs[3^p + q])}, {z, q}]. What should I do?

I try the code

p = 7/22
Solve[{5 == z - (Abs[-q] + Abs[q]),
3 == z - (Abs[3^p - q] + Abs[3^p + q])}, {z, q}]


when p=7/18 or 7/20 or 7/21 the program evaluates quickly, when p is 7/16, 7/19 or 7/22 and a lot of the other values it starts an infinte loop running. Do you have the same problem on your Windows 10? Of course I can use Wolfram Alpha any time instead but what is Mathematica for then?

• Do not use the bugs tag unless other users have confirmed that what you have is a bug. – J. M.'s ennui Feb 15 at 3:10
• Cannot confirm that behavior in 12.2 on Windows 10 Pro. For p=7/16 MMA produces {{z -> 3 + 2 3^(7/16), q -> -\[Sqrt](1 - 2 3^(7/16) + 3^(7/8))}, {z -> 3 + 2 3^(7/16), q -> \[Sqrt](1 - 2 3^(7/16) + 3^(7/8))}} in few minutes. – user64494 Feb 15 at 6:34
• However, for p = 9/32; MMA is running without any response for ages. – user64494 Feb 15 at 6:55
• The above case crashed my comp in several dozen minutes. – user64494 Feb 15 at 7:42

Mathematica 12.2 on windows 10.

it hangs when domain is Complexes which is the default. This could be either a bug or a feature, I do not know.

But for a workaround meanwhile, you could use Reals. Compared to Maple, and it gives correct result.

p = 7/22;
eqs = {5 == z - (Abs[-q] + Abs[q]), 3 == z - (Abs[3^p - q] + Abs[3^p + q])};
Solve[eqs, {z, q}, Reals] // InputForm


N[%, 30]
{{z -> 5.83688221082530144500590077762, q -> 0.418441105412650722502950388812},
{z -> 5.83688221082530144500590077762, q -> -0.418441105412650722502950388812}}


Maple:

restart;
p:=7/22;
[solve({5 = z - (abs(-q) + abs(q)), 3 = z - (abs(3^p - q) + abs(3^p + q))}, {z, q})];


gives

sol := [{q = 3^(7/22) - 1, z = 3 + 2*3^(7/22)},
{q = -3^(7/22) + 1, z = 3 + 2*3^(7/22)}]

Digits:=30;
evalf(sol)

[{q = 0.41844110541265072250295038881, z = 5.83688221082530144500590077762},
{q = -0.41844110541265072250295038881, z = 5.83688221082530144500590077762}]


So answer by Mathematica is correct for p:=7/22, it just hangs for some reason when domain is complex.

• That system implies z\[Element]Reals. However, q may be a complex number. Therefore, Solve[eqs, {z, q}, Reals] is not equivalent to Solve[eqs, {z, q}]. – user64494 Feb 15 at 7:59
Clear["Global*"]

eqns = {5 == z - (Abs[-q] + Abs[q]),
3 == z - (Abs[3^p - q] + Abs[3^p + q])};


Restricting the domain to Reals,

sol = Solve[eqns, {q, z}, Reals]


If the condition in the ConditionalExpression is not satisfied the result is Undefined.

For the case of p == 7/22,

Select[sol /. p -> 7/22, FreeQ[#, Undefined] &]

(* {{q -> 1 - 3^(7/22), z -> 5 + 2 (-1 + 3^(7/22))}, {q -> -1 + 3^(7/22),
z -> 5 + 2 (-1 + 3^(7/22))}} *)

% // N

(* {{q -> -0.418441, z -> 5.83688}, {q -> 0.418441, z -> 5.83688}} *)

• The next step Solve[eqns, {z, q}] performs {{z -> 3 + Sqrt[(-(1/2) + 3^p)^2] + Sqrt[(1/2 + 3^p)^2], q -> -(1/2)}, {z -> 3 + Sqrt[(-(1/2) + 3^p)^2] + Sqrt[(1/2 + 3^p)^2], q -> 1/2}, {z -> 4 + Sqrt[(-1 + 2 3^p)^2], q -> 1 - 3^p}, {z -> 4 + Sqrt[(-1 + 2 3^p)^2], q -> -1 + 3^p}, {z -> 4 + Sqrt[(1 + 2 3^p)^2], q -> -1 - 3^p}, {z -> 4 + Sqrt[(1 + 2 3^p)^2], q -> 1 + 3^p}}` in a moment. – user64494 Feb 15 at 6:49