I have a question about Simplify: When I do a simplification the returned result is not as simple as I want. When I ask for the Norm of an complex expression, Mathematica just returns Norm[expr].

I don't know how to make it simpler, is this the final form that Mathematica can give?

Simplify[Conjugate[h^4 k^2 + 2 I h^2 k m V + (-1 + E^(2 I k l)) m^2 V^2], 
  {k, V, m, h, l} ∈ Reals]

When evaluating the above code, Mathematica just returns Conjugate[...], but what I need is a form without Conjugate in the front, just replace $i$ to $-i$ as usual math calculation.

  • 3
    $\begingroup$ You've seen ComplexExpand[]? $\endgroup$ – J. M.'s torpor May 12 '13 at 16:05
  • $\begingroup$ Next time I will try this with complex functions $\endgroup$ – an offer can't refuse May 13 '13 at 17:34
       Conjugate[(-1 + E^(2 I k l)) m^2 V^2 + 2 I k m V \[HBar]^2 + 
              k^2 \[HBar]^4], {k, V, m, \[HBar], l} \[Element] Reals]]

is probably as simple as it's going to get

E^(-2 I k l) m^2 V^2 + (-I m V + k \[HBar]^2)^2

There are a range of functions for dealing with complex numbers and equations: FullSimplify, Simplify, TrigToExp and it's brother ExpToTrig, and of course the ever popular ComplexExpand, which does such a nice job here. It's worth exploring the help files for these commands because they often give slightly different forms that might be useful in various situations.

As per Kuba's comment... it looks like the assumptions about the particular values being in the reals is not needed in this case... likely this is because ComplexExpand already makes these assumptions.

  • $\begingroup$ Thank you, your comment is helpful! $\endgroup$ – an offer can't refuse May 13 '13 at 17:06
  • $\begingroup$ Is {k, V, m, \[HBar], l} \[Element] Reals needed? $\endgroup$ – Kuba Jan 19 '18 at 6:44

Simplify uses as few assumptions as possible when simplifying an expression. This means that it doesn't presume that anything is real, or positive for example. At first this may seem perverse, but in fact it saves you from making incorrect assumptions a lot of the time.

Simplify is however very adaptable and allows you to not only include your own assumptions as to the variable types you are using, but also what simple actually means.

The simplest type of assumption you might want to make is that an elements is in the reals, or that something is within some range.

Simplify[somefunction[x,y], {x \[Element] Reals, y>0}]

In order to make your own definition of what simple means you can introduce a ComplexityFunction argument into Simplify. For instance, you can define simple to mean that you want to have the fewest possible characters in the expression:

f[e_] := StringLength[ToString[InputForm[e]]]
Simplify[Abs[x], x < 0, ComplexityFunction -> f]

The above is taken directly from the documentation for ComplexityFunction but I think it's a good example. The second argument in the above is the assumption.

There are, as @bill s has noted, some ready built commands like ComplexExpand which are useful in conjunction with the Simplify command.

Another useful tip for using Simplify is to note that you can adjust the time for which Mathematica will search down a particular transformation path. Setting the option TimeConstraint->10 will mean that after 10 seconds, it will give up with a particular transformation and try something else. Sometimes you will find that Mathematica makes a large improvement in the simplification of an expression in the first few seconds and then spends a long time making smaller improvements, so the TimeConstraint command can be used to define for yourself how long it is spending doing this. The default for this is 300 seconds and of course you can increase this as well if you need to.

You are able also to define your own transformation which Simplify will apply to your expression. For instance, you can ask it to use Reduce, or ComplexExpand. Look up TransformationFunctions in the documentation for this.

  • $\begingroup$ Your comment has such a large scope and I need to digest it with further study in mathematica. Thank you very much! $\endgroup$ – an offer can't refuse May 13 '13 at 17:20

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