2

I am doing some calculations that end up popping out a lot of $-1$s to various fractional powers, and Mathematica doesn't seem to want to set them to $-1$. Is there an easy way to do this?

swygerts
  • 123
  • 3
  • See if you agree with the output of ComplexExpand[(-1)^(1/3), TargetFunctions -> {Re, Im}]. – b.gates.you.know.what Feb 01 '19 at 17:39
  • 11
    If you know you're only interested in the real roots when you're taking roots, you might be interested in using Surd instead of fractional powers. – eyorble Feb 01 '19 at 17:43
  • These solutions both seemed to have work. On a more general note, I have a variable $L$ that I am using. I have other terms that are written in terms of $L$. At some point in my output, Mathematica writes "$\sqrt{L^2} \sqrt{L}$." How can I force them to combine? – swygerts Feb 01 '19 at 18:04
  • Simplify can be given an optional second argument defining things to assume during the simplification process, thus Simplify[Sqrt[L^2]Sqrt[L],L>=0] returns L^(3/2) – Bill Feb 01 '19 at 18:19
  • @Bill so if I make that assumption earlier in my code will it assume that every time, or will I need to write that every time L appears? – swygerts Feb 01 '19 at 18:25
  • @swygerts If you assign $Assumptions = {L >= 0} then it is assumed automatically – MeMyselfI Feb 01 '19 at 18:27
  • 1
    Only some functions in Mathematica check the assumptions only under some conditions. Simplify is one of those. As you might have seen, if you type in some expression there is a default very lightweight quick simplification done to that, like 3+5 being replaced by 8, but that does not invoke all the power of Simplify or make use of all the power of Assumptions. That means Mathematica works much more quickly if you choose when and where you want to have it spend time doing Simplify and using Assumptions – Bill Feb 01 '19 at 19:36
  • There was a special function CubeRoot added in V9 to handle this kind of problem. It accepts only real-valued arguments and returns only the real valued root. – m_goldberg Feb 02 '19 at 04:01
  • 2
    Possible duplicate of this question – m_goldberg Feb 02 '19 at 04:03

2 Answers2

2

First Question: (-1)^(1/3) is not equal to -1
(-1)^n is only equal to -1 for odd, integer values of n.

Second Question:
Try Assuming[L \[Element] Reals, FullSimplify[Sqrt[L^2] Sqrt[L]]]

Rudy Potter
  • 2,553
  • 8
  • 20
2
rule = x_^(1/3) -> CubeRoot[x];

(-1)^(1/3) /. rule
(*-1*)
Bill Watts
  • 8,217
  • 1
  • 11
  • 28