Mathematica Tips and Tricks

From Physiki
Jump to: navigation, search

Working with Complex Numbers

Mathematica has certain issues with complex numbers that make it difficult to use under certain circumstances, to entirely turn off complex number support you should include the 'RealOnly' package:

<<Miscellaneous`RealOnly`

However, this does not solve all problems with complex numbers since you may need to have Mathematica perform operations with complex numbers but not use them in certain variables. You can achieve this by including the package 'ReIm' and informing mathematica that a certain variable has no imaginary part:

<<Algebra`ReIm`
z /: Im[z] = 0;

Please note that this uses a single equal sign rather than the usual two you are accustomed to in Mathematica. Another option that performs nearly identical functionality is to give the function you're using certain assumptions for solving the variables as reals, for example:

Simplify[difficultExpression,Assumptions -> {Im[x] == 0}]

Please note that the Assumptions tag only works for the functions Integrate, Refine, and Simplify. If you are starting with something else you can take the resulting "difficultExpression" and use it in Simplify in order to use the Assumptions tag.

Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox