So close yet so far! I've read a number of posts here about tips and strategies for simplifying expressions. I hope this case still offers guidance to others.

I have an expression that (just!) fits in on the screen (after a marathon of black magic to from 12Mb of length). It is made up of 78 terms that of complex exponentials. Here is a simplified (illustrative) version, with 4 terms, of the code I am running:

  2 E^(I (b + (3 + 2 N) v - 2 \[Phi])))/((Sqrt[a] E^(I b) - E^(
     I v))^3 (Sqrt[a] E^(I b) + E^(I v))) - (
  2 a^4 E^(I (5 b + (3 + 2 N) v - 2 \[Phi])))/((-Sqrt[a] E^(I b) + E^(
     I v))^4 (a - E^(2 I v))^2 (Sqrt[a] - E^(I (b + v)))^4) - (
  2 a^3 E^(I (b + (5 + 2 N) v - 2 \[Phi])))/((-Sqrt[a] E^(I b) + E^(
     I v))^4 (a - E^(2 I v))^2 (Sqrt[a] - E^(I (b + v)))^4) - (
  26 a^3 E^(
   I (3 b + (5 + 2 N) v - 2 \[Phi])))/((-Sqrt[a] E^(I b) + E^(
     I v))^4 (a - E^(2 I v))^2 (Sqrt[a] - E^(I (b + v)))^4), 
 Assumptions -> {N \[Element] PositiveIntegers && N > 1, 0 < a < 1, 
   b > 0, v > 0, 0 <= \[Phi] < 2*Pi}]

I know my final function must only have Real components (i.e. should be trigonometric). I also just have intuition to believe that it can be simplified further as I do have limiting cases that are much more manageable.

I tried naively running FullSimplify but it crashed: my 32GB RAM was not enough!

Of course I have tried Simplifying it (it returned back the same thing instantly). This clearly requires more hand-curation. The question is how to go about that?

As such, there are important questions such as:

  1. Is it better to manipulate (simplify) expressions in terms of exponentials or trig? (Given I know my end result will be trignometric). The reason I have it in exponential form is that the summation I had done initially to get an expression did not seem to complete if I used trig.
  2. Are there more systemised ways to simplify sublists? Is it better to do random sublists and hope for partial cancellation between terms?
  3. Are there ever times where simplifying can be done too early? In my case, if I do TrigReduce[], it can make the expressions grow considerably, even if that does end up resulting in just a trig expression. It really then is unclear if I have something more useful (given that Simplifying is already unreliably slow)
  • 1
    $\begingroup$ Welcome to the Mathematica Stack Exchange. Can you please include code that made it crash? If you have a result, you can include it too. Thanks. $\endgroup$
    – Syed
    Commented Apr 1 at 7:43
  • 3
    $\begingroup$ A minor comment. Avoid using N as a variable, as it is a built-in Mathematica function. $\endgroup$
    – mikado
    Commented Apr 1 at 13:42
  • $\begingroup$ @Syed in principle I'd be happy to include the code, but in reality it's quite long and mundane! The code is FullSimplify[eqm, Assumptions -> {N [Element] PositiveIntegers && N > 1, b > 0, 0 < a < 1, v > 0, Element[[Phi], Reals]}], where "eqm" is made up of lots of terms that look like the one I posted (but have different powers of 'a' and slightly different denominators. Maybe if I made a temporary pastebin for the purposes of this post? $\endgroup$ Commented Apr 2 at 13:25
  • $\begingroup$ A minimal example can attract specific/concrete answers. You have not provided feedback on how/if the general answers you received have helped you thereby making this page not immediately useful for page visitors. $\endgroup$
    – Syed
    Commented Apr 2 at 13:29
  • $\begingroup$ @Syed thanks for that, I've updated it with a few more terms (nothing cherry picked), and made my questions clearer $\endgroup$ Commented Apr 2 at 14:05

2 Answers 2


General thoughts on simplifying very large expressions. Obviously, these are not applicable in all cases.

  • Simplify the parts before assembling the large expression.
  • Identify common subexpressions. See if these can be simplified individually.
  • Try less expensive simplifications (e.g. Refine, Simplify, Factor, rather than FullSimplify)
  • Apply assumptions, where relevant, using Refine to apply them.
  • Try Map[Simplify, expression,{n}] to try simplifying subexpressions at level n, rather than trying to simplify their combined form.
  • Use LeafCount to assess whether you are reducing the size at each step.
  • Substitute numerical values to assess whether your assumptions (e.g. that the expression is real valued) are correct.
  • In general, if simplifications do not succeed rapidly, they are rarely going to be useful.
  • Use ComplexExpand (carefully) where your variables are real, but the expression is complex.
  • See whether a substituting a numerical value (e.g 0 for additive constants, 1 for multiplicative constants) for some of your parameters allows a simplified form to be found. In your example, you might try a->1. If not, you are unlikely to succeed symbolically.

As a trivial example, I show how I might tackle simplifying all the Sinand Cos terms in an expression.

example = 
 Sin[x^2 + 2 x + 1] + Sin[x^3 + 3 x^2 + 3 x + 1] Sin[x^2 + 2 x + 1]
(* Sin[1 + 2 x + x^2] + Sin[1 + 2 x + x^2] Sin[1 + 3 x + 3 x^2 + x^3] *)

Cases[example, _Sin | _Cos, ∞] // Union
(* {Sin[1 + 2 x + x^2], Sin[1 + 3 x + 3 x^2 + x^3]} *)

(* {Sin[(1 + x)^2], Sin[(1 + x)^3]} *)

example /. Thread[%% -> %]
(* Sin[(1 + x)^2] + Sin[(1 + x)^2] Sin[(1 + x)^3] *)

LeafCount /@ {example, %}
(* {34, 20} *)
  • $\begingroup$ Thanks for the reply. I've also updated my question with more concrete questions, btw! I've certainly done much / all of this to lead up to the expression I have now. Could you elaborate a bit more using ComplexExpand wisely please? Given my context of having lots of complex exponentials and that the end result must be real, I wonder if this is the right "inducative bias". Just a FYI, this is a physics problem so I've already solved the simpler case where v=0 and phi=pi/2. I am trying to generalise my result, but it's hard to say whether this additional freedom is going to cost me. $\endgroup$ Commented Apr 2 at 14:11

In the Wolfram Language, FullSimplify is a powerful function used to simplify complex expressions, but it may encounter difficulties in simplifying expressions involving exponential functions (Exp) and complex numbers. Here are some common problems you might encounter and some strategies to address them:

  1. Simplification with Complex Numbers:

    FullSimplify[Exp[I x], x ∈ Reals]

    In this case, you might expect the result to simplify to Cos[x] + I Sin[x]. However, FullSimplify might not always recognize this simplification, especially if the assumption about x being real is not explicitly provided.

    To address this, you can use assumptions or provide additional transformation rules:

    FullSimplify[Exp[I x], x ∈ Reals, TransformationFunctions -> {Automatic, TrigReduce}]
  2. Simplification involving Exponential Functions:

    FullSimplify[Exp[x] Exp[y], x > 0 && y > 0]

    In this case, you might expect the result to simplify to Exp[x + y]. However, FullSimplify may not always perform this simplification automatically.

    One approach is to use transformation rules explicitly:

    FullSimplify[Exp[x] Exp[y], x > 0 && y > 0, TransformationFunctions -> {Automatic, # /. Exp[a_] Exp[b_] :> Exp[a + b] &}]
  3. Handling Complex Conjugates:

    FullSimplify[Conjugate[Exp[I x]], x ∈ Reals]

    You might expect the result to simplify to Exp[-I x], but FullSimplify may not recognize this simplification directly.

    One way to handle this is to use ComplexExpand before simplification:

    FullSimplify[ComplexExpand[Conjugate[Exp[I x]]], x ∈ Reals]
  4. Involving Special Functions: FullSimplify may struggle with simplifications involving special functions like Gamma, Beta, etc., especially when combined with exponentials and complex numbers.

    In such cases, it's helpful to provide specific assumptions and use appropriate transformation functions tailored to your problem domain.

Overall, when dealing with complex expressions involving exponentials and complex numbers in the Wolfram Language, it's essential to carefully set assumptions and use transformation functions to guide FullSimplify to the desired results. Additionally, sometimes a combination of manual simplifications and transformation rules might be necessary to achieve the desired simplification.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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