Usage: Difference between revisions
No edit summary |
|||
Line 35: | Line 35: | ||
The behaviour of iMath can be changed by setting options. There are three ways of doing this | The behaviour of iMath can be changed by setting options. There are three ways of doing this | ||
# Globally for all documents from the | # Globally for all documents from the Tools - Options - LibreOffice Writer - iMath global defaults dialog | ||
# Specifically for one document from the iMath - Settings | # Specifically for one document from the iMath - Settings | ||
# Specifically for one formula line with the keyword [[OPTIONS]] | # Specifically for one formula line with the keyword [[OPTIONS]] |
Revision as of 19:21, 20 July 2017
How to use iMath
The best way to learn how to use iMath is to look at the iMath-tour.odt document corresponding to your version of iMath in this folder.
Some background on numerics
Number types
There are two very different modes of numeric calculation available in iMath. As long as you use only integers and rational numbers, iMath (or rather, the underlying CLN library) will calculate exact results. As soon as you introduce floating point numbers (just writing 2.0 instead of 2 is enough), iMath will switch to approximate calculations with a precision of 17 digits (this is the default of the underlying GiNaC library). Not only the precision, but also the size of floating point numbers is limited. You can have an exponent of maximum 32 bits length.
To see the difference, enter these two expression (turn on auto-formatting):
2.0^{-10^3} 2^{-10^3}
If you want to benchmark your CPU, you can increase the exponent of -10 ...
When you use VAL() or ITERATE() everything is converted to floats.
For further details, consult GiNaC and CLN.
Automatic evaluation of expressions
GiNaC does some automatic simplifications whenever you create an expression. Here are some examples:
1/15 + 3/8 -> 53/120 2^{-10^3} -> 1/1071508607186267320948... a + a -> 2 a
You can see these simplifications if you turn on auto-formatting. Only simplifications that are mathematically safe are performed. For details, consult the GiNaC documentation.
Some pitfalls
The expression %e^(-710) creates a floating point overflow error (not underflow as might be expected). This is because CLN calculates it as 1 / %e^710.
There is a difference between VAL(%e)^{-10^18} and VAL(%e^{-10^18}). In the first case, the exponent is converted to a float before doing the exponentiation, because the basis is already a float. In the second case, the exponent is an integer and stays integer - but only 32-bit integer exponents are allowed. So you get an error. You can write VAL(%e^{-10^18.0}) instead.
iMath Options
The behaviour of iMath can be changed by setting options. There are three ways of doing this
- Globally for all documents from the Tools - Options - LibreOffice Writer - iMath global defaults dialog
- Specifically for one document from the iMath - Settings
- Specifically for one formula line with the keyword OPTIONS