1
$\begingroup$

Often, when I solve an equation in the reals using reduce, it gives me an answer which contains a non-integer power of -1, which is a complex number. It has happened to me several times and always, I could just get the correct solution by throwing away this power of -1. How is this possible? What is it? How do I prevent this from happening, that is, how do I get the result directly without this?

An example:

Reduce[d > 0 && 
 n > 1 && (Log[n]*(1/eps^2))^2/
 n <= eps d, {n, eps}, Reals] // ToRadicals

gives me

d>0 && n>1 && eps >=((-1)^(2/5) log^(2/5)(n))/(d^(1/5) n^(1/5))

Edit: If I understand correctly, the problem lies in ToRadicals. Specifically, it returns the wrong answer. Is there any way I can solve iequalities like this and get a correct answer?

.

$\endgroup$
  • 1
    $\begingroup$ This Reduce[d > 0 && n > 1 && (Log[n]*(1/eps^2))^2/n <= eps d /. eps -> x^(1/5), {n, x}, Reals] /. x -> eps^5 gives me an inequality eps^5 >= Log[n]^2/(d n) implying no minus. For me the solution you have shown looks like a bug. $\endgroup$ – Alexei Boulbitch Sep 15 at 10:41
  • 1
    $\begingroup$ The command Reduce[d > 0 && n > 1 && (Log[n]*(1/eps^2))^2/n <= eps d, eps, Reals] produces n > 1 && d > 0 && eps >= Root[-Log[n]^2 + d n #1^5 &, 1]. One reads in the documentation to ToRadicals: "If Root objects in expr contain parameters, ToRadicals[expr] may yield a result that is not equal to expr for all values of the parameters]". Hope this sheds a light on the situation, however, don't hesitate to ask for further explanation in need. $\endgroup$ – user64494 Sep 15 at 11:05
  • $\begingroup$ @user64494 thanks very much for the answer. I have expanded the question accordingly. Is there any way to fix/circumvent this? $\endgroup$ – user2316602 Sep 15 at 12:37
  • 1
    $\begingroup$ With Solve and Reduce it often helps to request a solution for all variables. Why is beyond me. But in your case:Reduce[d > 0 && n > 1 && (Log[n]*(1/eps^2))^2/n <= eps d, {n, eps, d}, Reals] gives: n > 1 && eps > 0 && d >= Log[n]^2/(eps^5 n) $\endgroup$ – Daniel Huber Sep 15 at 14:13
  • $\begingroup$ @user2316602: Sorry, don't understand you. What do you mean by "fix this"? $\endgroup$ – user64494 Sep 15 at 15:15
2
$\begingroup$

When ToRadicals tries to convert the Root object in your inequality, it knows nothing about the conditions on your parameters. To rectify this, you can make use of the undocumented Assumptions option of ToRadicals:

ineq = Reduce[d>0 && n>1 && (Log[n]*(1/eps^2))^2/n <= eps d, {n, eps}, Reals];

ToRadicals[ineq, Assumptions -> d>0 && n>1]

d > 0 && n > 1 && eps >= Log[n]^(2/5)/(d^(1/5) n^(1/5))

| improve this answer | |
$\endgroup$
  • $\begingroup$ Thank you very much! Do I understand correctly that the problem was that ToRadicals did not know that I want a real solution and it only gave me one of the multiple complex ones? Also, where does one learn about undocumented features? $\endgroup$ – user2316602 Sep 15 at 17:15
1
$\begingroup$

Mind these are inequalities and not solutions!

If the right-hand side is in the Complexes and the left-hand side is Reals the inequality does never hold. Both sides are not comparable. And in the example, the roots of -1 are on the unit circle around 0.

The problem comes in with the application of ToRadicals on the result of Reduce. The result of Reduce is an inequality over the reals. It is meant to be solved for example graphical in plotting the inequality.

ToRadicals does know nothing about the constraints and does not even care about them too. It evaluates the chain of logical AND as a list and evaluates only the terms of the chain that can be treated by the methods of ToRadicals.

The advantage of ToRadicals is that is deals with parameters. Your needs comes from the attributes of Root. It does not automatically express terms in radicals.

A better approach is

Reduce[(Log[n]^2)/n <= eps^5 d, {d, n, eps}, Reals]

The output is then

(d == 0 && 
   n == 1) || (d > 
    0 && ((n == 1 && eps >= 0) || (n > 1 && 
       eps >= Root[Log[n]^2/(d n) - #1^5 &, 1]) || (0 < n < 1 && 
       eps >= Root[Log[n]^2/(d n) - #1^5 &, 1]))) || (d < 
    0 && ((n == 1 && eps <= 0) || (n > 1 && 
       eps <= Root[Log[n]^2/(d n) - #1^5 &, 1]) || (0 < n < 1 && 
       eps <= Root[Log[n]^2/(d n) - #1^5 &, 1])))

This shows much more solutions. It does again not automatically express all terms in radicals as desired.

Reduce[(Log[n]^2)/n <= eps^5 d, {eps, d, n}, Reals]

gives

(eps == 0 && 
   n == 1) || (eps > 
    0 && ((d >= 0 && 
       n == 1) || (d >= 4/(
        E^2 eps^5) && (n > 1 || 
         E^(-2 ProductLog[Sqrt[d eps^5]/2]) <= n < 1)) || (0 < d < 4/(
        E^2 eps^5) && (n >= 
          E^(-2 ProductLog[-1, -(1/2) Sqrt[d eps^5]]) || 
         1 < n <= E^(-2 ProductLog[-(1/2) Sqrt[d eps^5]]) || 
         E^(-2 ProductLog[Sqrt[d eps^5]/2]) <= n < 1)))) || (eps < 
    0 && ((4/(E^2 eps^5) < d < 
        0 && (n >= E^(-2 ProductLog[-1, -(1/2) Sqrt[d eps^5]]) || 
         1 < n <= E^(-2 ProductLog[-(1/2) Sqrt[d eps^5]]) || 
         E^(-2 ProductLog[Sqrt[d eps^5]/2]) <= n < 1)) || (d <= 0 && 
       n == 1) || (d <= 4/(
        E^2 eps^5) && (n > 1 || 
         E^(-2 ProductLog[Sqrt[d eps^5]/2]) <= n < 1))))

So constrain further for more interesting solution representations.

Reduce[eps > 0 && (Log[n]^2)/n < eps^5 d, {eps, d, n}, Reals]

The output is

eps > 0 && ((d > 0 && 
     n == 1) || (d > 4/(
      E^2 eps^5) && (n > 1 || 
       E^(-2 ProductLog[Sqrt[d eps^5]/2]) < n < 1)) || (0 < d <= 4/(
      E^2 eps^5) && (n > E^(-2 ProductLog[-1, -(1/2) Sqrt[d eps^5]]) ||
        1 < n < E^(-2 ProductLog[-(1/2) Sqrt[d eps^5]]) || 
       E^(-2 ProductLog[Sqrt[d eps^5]/2]) < n < 1)))

Reduce[eps > 0 && n ∈ Integers && 
  n > 1 && (Log[n]^2)/n < eps^5 d, {eps, d, n}, Reals]

has

Element[n, Integers] && eps > 0 && ((d > 4/(E^2*eps^5) && n >= 2) || 

(Inequality[0, Less, d, LessEqual, 4/(E^2eps^5)] && (n > E^(-2ProductLog[-1, (-(1/2))Sqrt[deps^5]]) || 1 < n < E^(-2*ProductLog[(-(1/2))Sqrt[deps^5]]))))

ProductLog has a small imaginary part still.

Take attention to this order of the parameters:

Reduce[eps > 0 && n ∈ Integers && 
  n > 1 && (Log[n]^2)/n < eps^5 d, {n, eps, d}, Reals]

the results are

Element[n, Integers] && n >= 2 && eps > 0 && d > Log[n]^2/(eps^5*n)

This shows all other possibilities to use Reduce are complicated by the parameter on the first position in the set of parameters. Putting n the first place gives the most tautologic result to the input. But this is easiest to understand.

Keep track of the following process for working with Reduce:

(a) Simplify the equations first for example with Simplify, FullSimplify. (b) Put all parameters in the parameter list in the second argument of Reduce. (c) Enter stepwise all restrictions that match the intents or the question to reduce. (d) Varied the sequence in which the parameters are entered and use Reduce again. (e) Compare these solutions that match the needs best. (f) Use ToRadicals or a Plot whatever show the solutions best. Avoid Roots and ToRadicals like Mathematica does prefer the output with the least Roots.

Table[RegionPlot[
  n < Re[E^(-2 ProductLog[-(1/2) Sqrt[d eps^5]])], {eps, 
   0.3, .95}, {d, 0, 24}], {n, 3, 7}]

RegionPlot

Table[RegionPlot[d > Log[n]^2/(eps^5*n), {eps, 0.1, 4}, {d, 0, 4}, 
  FrameLabel -> {"eps", "d"}, PlotLabel -> n], {n, 1, 151, 50}]

RegionPlot

It is always very interesting how complicated it is to make a Plot of the region as long as this is possible.

Keep in mind if Complexes can not be avoided to make the functions Reals with Re and investigate the ReIm plots. But better than this is work without Complexes. Mathematica can mix Reals and Complexes and this work is always up to the user to clarify for his personal viewpoint.

This can not cover everything. Think about trigonometric. But the community might help.

This example is not the very best for such a discussion. The receipt works here brilliant in making a table over the iterator n and vary in two dimensions the inequality for example graphically and numerically. Make use in the discussion of the monotony of the function depending on n.

It only shows up how senseful it is to input the inequality nice and meaningful then Solve, Reduce and else work towards easier results representations. The Mathematica documentation does show this process. If there are many parameters these function make trouble, pose long runtime. To solve subproblems graphical first can be an improvement and led to better performances and even give better interpretations of the results.

Use all information given to reduce the numbers of free or limited parameters.

| improve this answer | |
$\endgroup$
  • $\begingroup$ The statement "The advantage of ToRadicals is that is deals with parameters" kind of conflicts with the documentation. I'm not sure the rest of the response really addresses the actual question. $\endgroup$ – Daniel Lichtblau Sep 15 at 13:18
  • $\begingroup$ This not really my opinion. It is from the documentation: [reference.wolfram.com/language/ref/ToRadicals.html?view=all] section possible issues: "ToRadicals converts Root objects containing parameters:" and then "The result may not be equal to the Root object for some values of the parameter:" $\endgroup$ – Steffen Jaeschke Sep 15 at 15:00
  • 1
    $\begingroup$ You are misinterpreting the documentation. Root objects also deal with parameters, so there is no relative advantage there. $\endgroup$ – Daniel Lichtblau Sep 15 at 17:19
  • $\begingroup$ My intend with the answer war to advice that to avoid using Root a priori avoids independ of parameters involved to be guided through the Complexes by Mathematica methodology. That takes into account Root can deal with parameters but only symbolical. The Root objects are not removed by the use of ToRadicals. And there is advice in the documentation for Eigensystem on that too. $\endgroup$ – Steffen Jaeschke Sep 20 at 17:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.