# How to enforce mathematica to analytically evaluate roots?

I am interested in simplifying expressions involving HeavisideTheta. A simple example could be:

HeavisideTheta[1 + x - x^2 + x^3]


The best I can achieve is with

FullSimplify[HeavisideTheta[1 + x - x^2 + x^3]//FunctionExpand]


but that only outputs this:

HeavisideTheta[x - Root[1 + #1 - #1^2 + #1^3 &, 1]]


Now, I know mathematica can solve the given polynomial:

In:=  Solve[-1 - 2 x - x^2 + 2 x^3 + x^4 == 0]
Out:= {x -> 1/2 (-1 - I Sqrt[-5 + 4 Sqrt])}, {x ->
1/2 (-1 + I Sqrt[-5 + 4 Sqrt])}, {x ->
1/2 (-1 - Sqrt[5 + 4 Sqrt])}, {x ->
1/2 (-1 + Sqrt[5 + 4 Sqrt])}}


But how do I make it give me an appropriately simplified expression for the simplified HeavisideTheta?

• Maybe ToRadicals – Apple Dec 2 '14 at 10:36
• Sorry, I did't notice the comment, so deleted the answer. – user18792 Dec 2 '14 at 12:56
• Umm... ToRadicals solves the problem conveniently. How should I accept this the answer? – SarthakC Dec 5 '14 at 17:34
• Two points: 1) Simplify and FullSimplify don't solve equations, even extremely easy ones; 2) The result with all those Sqrts is longer than the original expression, so even if FullSimplify did manage to find that result, it would discard it since it's no simpler than the input! – 2012rcampion Apr 1 '15 at 14:40

As Apple alludes to in a comment, ToRadicals converts Root objects to radicals, when the roots can be expressed in terms of radicals:

ToRadicals[FunctionExpand[
HeavisideTheta[1 + x - x^2 + x^3]]]
(* HeavisideTheta[ 1/3 (-1 + 2/(-17 + 3 Sqrt)^(1/3) - (-17 + 3 Sqrt)^(1/3)) + x] *)


It well known that not all root can be expressed in terms of radicals, so in some cases the Root objects are the best option:

ToRadicals@FunctionExpand[HeavisideTheta[x^5 - 4 x^3 + x - 3]]
(*
HeavisideTheta[x - Root[-3 + #1 - 4 #1^3 + #1^5 &, 1]] -
HeavisideTheta[x - Root[-3 + #1 - 4 #1^3 + #1^5 &, 2]] +
HeavisideTheta[x - Root[-3 + #1 - 4 #1^3 + #1^5 &, 3]]
*)


Refs.:

• Can you elaborate a bit ? Otherwise it is just a copy-paste from the comment of Chenminqi – Sektor Dec 2 '14 at 12:52

Ok, there's got to be a better way, but for the time being you could use the following.

First define a function f (for lack of a better name) that transforms the argument:

f[expr_] := {1, -1}.List @@ Solve[0 == expr][[1, 1]]

f[1 + x - x^2 + x^3]


1/3 (-1 + 2/(-17 + 3 Sqrt)^(1/3) - (-17 + 3 Sqrt)^(1/3)) + x

Then, you commute the function heads, so that f acts on the argument only (@ is understood as function composition):

f /: f@g[x_] := g@f[x]


What you end up with is:

g = HeavisideTheta;

g[1 + x - x^2 + x^3]//f


HeavisideTheta[ 1/3 (-1 + 2/(-17 + 3 Sqrt)^(1/3) - (-17 + 3 Sqrt)^(1/3)) + x]

• I am on Mathematica 10.1.0.0. I directly copied and executed your code. I get the same output for f[1 + x - x^2 + x^3], but having added the second definition using TagSetDelayed, f /: f@g[x_] := g@f[x] I don't get your result. Rather I get HeavisideTheta[1 + x - x^2 + x^3] – Jack LaVigne Jul 31 '15 at 13:14