Simplification tips in Mathematica

This is both a note to myself and advice for the interested reader.

Be clever about your assumptions.

Note that you can use global assumptions with $Assumptions. Generally, setting

$Assumptions = {Element[_, Reals]}

will help a great deal with simplifications. Otherwise, Mathematica will work with the assumption that your variables COULD be complex, which will make all equations ugly.

Then, for every bound you know, you can add it with:

$Assumptions = Join[$Assumptions, {Sin[theta] >= 1}]

etc. However, in my experience the more assumptions you have, the longer it will take to simplify. So sometimes you might want to use local assumptions.

Simplify early

The earlier you simplify, the exponentially less effort mathematica will have to spend later. You could add a // FullSimplify at the end of every line, if you’d like. You can also add FullSimplify to the inside parts of an equation to help prevent it branching out too much.

Use transformations

  • Use some hand-coded variable transformations, to, e.g., spherical coordinates if you are dealing with unit vectors. This can help significantly with trig simplifications

Other tricks

  • Try series expansion. Does it look like any common series (e.g., sine?).
  • Apparently using Collect with Simplify can find some expressions which otherwise can’t be found.
  • Sometimes, evaluating an expression for a set of variables can give you some intuition. Is some part of your equation always 1? Then just replace it.
  • Plot your equation as a function of a few parameters. Does the plot look pretty simple? Try fitting functions to it (seriously). This is a bit of an art. Also, you could try using genetic programming here if you’d like - try DEAP.

Leave a comment