4
$\begingroup$

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[2]:=  Solve[-1 - 2 x - x^2 + 2 x^3 + x^4 == 0]
Out[2]:= {x -> 1/2 (-1 - I Sqrt[-5 + 4 Sqrt[2]])}, {x -> 
1/2 (-1 + I Sqrt[-5 + 4 Sqrt[2]])}, {x -> 
1/2 (-1 - Sqrt[5 + 4 Sqrt[2]])}, {x -> 
1/2 (-1 + Sqrt[5 + 4 Sqrt[2]])}}

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

$\endgroup$
4
  • 6
    $\begingroup$ Maybe ToRadicals $\endgroup$ – Apple Dec 2 '14 at 10:36
  • $\begingroup$ Sorry, I did't notice the comment, so deleted the answer. $\endgroup$ – user18792 Dec 2 '14 at 12:56
  • $\begingroup$ Umm... ToRadicals solves the problem conveniently. How should I accept this the answer? $\endgroup$ – SarthakC Dec 5 '14 at 17:34
  • $\begingroup$ 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! $\endgroup$ – 2012rcampion Apr 1 '15 at 14:40
4
$\begingroup$

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[33])^(1/3) - (-17 + 3 Sqrt[33])^(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.:

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

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[33])^(1/3) - (-17 + 3 Sqrt[33])^(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[33])^(1/3) - (-17 + 3 Sqrt[33])^(1/3)) + x]

$\endgroup$
1
  • $\begingroup$ 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] $\endgroup$ – Jack LaVigne Jul 31 '15 at 13:14

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.