Usage: Difference between revisions
(8 intermediate revisions by the same user not shown) | |||
Line 3: | Line 3: | ||
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 [http://sourceforge.net/projects/ooo-imath/files folder]. | 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 [http://sourceforge.net/projects/ooo-imath/files folder]. | ||
Usage with Impress is very similar to usage with Writer. The main difference is that Math objects in an Impress document cannot be anchored in any specific order. Therefore, the recalculation order of the iMath formulas inside each Impress page is defined by the object names. The object names can be set in the context menu (Properties) or in the Navigator. The user is responsible to name the Math objects in such a way that calculation will happen in the desired order. | |||
== 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 [http://www.ginac.de/tutorial/Numbers.html#Numbers GiNaC] and [http://www.ginac.de/CLN/cln.html#Ordinary-number-types 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 [http://www.ginac.de/tutorial/Automatic-evaluation.html#Automatic-evaluation 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. | |||
The | == 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 [[Document settings|iMath - Settings]] | |||
# Specifically for one formula line with the keyword [[OPTIONS]] |
Latest revision as of 19:11, 15 November 2020
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.
Usage with Impress is very similar to usage with Writer. The main difference is that Math objects in an Impress document cannot be anchored in any specific order. Therefore, the recalculation order of the iMath formulas inside each Impress page is defined by the object names. The object names can be set in the context menu (Properties) or in the Navigator. The user is responsible to name the Math objects in such a way that calculation will happen in the desired order.
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