Reference: Difference between revisions

From iMath
Jump to navigation Jump to search
No edit summary
Line 11: Line 11:
* <code>symbol</code>
* <code>symbol</code>
The name of a mathematical symbol or function, e.g. <code>x</code> or <code>a_n</code>
The name of a mathematical symbol or function, e.g. <code>x</code> or <code>a_n</code>
* <code>unit</code>
The name of a physical unit, either preceded by a percent sign or enclosed in quotation marks, e.g. <code>%meter</code> or <code>"meter"</code>
* <code>expression</code>
* <code>expression</code>
A mathematical expression in Openoffice math format
A mathematical expression in Openoffice math format
* <code>equation</code>
A kind of expression which has the form <code>expression1 = expression2</code>
* <code>expression1 : expression2 : expression3</code>
A vector of expressions where expression1 is the first element, expression2 the second element and the optional expression3 the step. By default the given interval will be subdivided into 20 steps, so for example <code>x = 1:20<code> will give a vector containing the integer numbers from 1 to 20.
* <code>symbol [ number ] or symbol [ number, number ]</code>
Accesses an element of a matrix.
* <code>#label#</code>
A equation label, used to reference a previously defined equation. The label MUST be enclosed in hash signs.
* <code>list = { element; element; ... }</code>
* <code>list = { element; element; ... }</code>
A list of other elements, enclosed in parentheses and separated by semicolons
A list of other elements, enclosed in parentheses and separated by semicolons
* <code>*</code>
If the asterisk is given, then the output of this line is supressed, which is useful for hiding intermediate calculations.
* <code>{ option; option; ... }</code>
The options can be any of those described for the OPTIONS keyword. It is not necessary to specify options (you need to leave away the brackets, too, if you don't).


== Commands ==
== Commands ==

Revision as of 18:28, 23 December 2013

It is recommended to always use the iMath menus to create or modify iFormulas. Nevertheless, sometimes it will be necessary to fine-tune equations by editing them directly.

All iMath commands start with the string %%ii at the beginning of a line, which will be interpreted as a comment by Openoffice. When the document is recalculated, iMath parses the string and generates the formula that is displayed. The generated lines are marked by %%gg at the end of the line. Editing such a line makes no sense because it will be deleted at the next recalculation! Always modify the %%ii lines if you want to tweak an iFormula. Formulas may also have lines without either %%ii or %%gg, these will not be touched by iMath.

There is also a reference section integrated into the Office help. Press F1 and enter "iFormula" into the Index tab of the help.

Elements

The following elements can be part of an iFormula definition string

  • symbol

The name of a mathematical symbol or function, e.g. x or a_n

  • unit

The name of a physical unit, either preceded by a percent sign or enclosed in quotation marks, e.g. %meter or "meter"

  • expression

A mathematical expression in Openoffice math format

  • equation

A kind of expression which has the form expression1 = expression2

  • expression1 : expression2 : expression3

A vector of expressions where expression1 is the first element, expression2 the second element and the optional expression3 the step. By default the given interval will be subdivided into 20 steps, so for example x = 1:20 will give a vector containing the integer numbers from 1 to 20.

  • symbol [ number ] or symbol [ number, number ]

Accesses an element of a matrix.

  • #label#

A equation label, used to reference a previously defined equation. The label MUST be enclosed in hash signs.

  • list = { element; element; ... }

A list of other elements, enclosed in parentheses and separated by semicolons

  • *

If the asterisk is given, then the output of this line is supressed, which is useful for hiding intermediate calculations.

  • { option; option; ... }

The options can be any of those described for the OPTIONS keyword. It is not necessary to specify options (you need to leave away the brackets, too, if you don't).

Commands

After the initial %%ii, the following commands are possible:

  • READFILE { "path/to/file" }

Open the given file and parse the iMath commands in this file. This command can be used to put common formulas in a file to re-use them. At the moment, the path is operation-system dependent, not a Openoffice URL!

  • CLEAREQUATIONS

iMath stores all equations and functions that it encounters. If you want to make a fresh start in your document, use this command

  • FUNCTION { hints, symbol, expression }

Declare a user-defined function. symbol is the name of the function. The expression declares the arguments of the function and can be either a single symbol or a list of symbols. The way that iMath treats this function can be influenced by function hints:

    • none: No function hints (must be used because iMath requires three arguments to the FUNCTION declaration
    • lib: A library function: It will not be affected by CLEAREQUATIONS
    • trig: For trigonometric functions. Tells iMath that this function will get special treatment when printing (e.g. <math>sin^2 x</math> instead of <math>(sin x)^2</math>)
    • expand: The function is to be expanded immediately. Useful for functions that are really abbreviations, e.g. square(x) will be expanded to <math>x^2</math>
    • nobracket: The function does not require brackets around the argument (e.g. sqrt(x) is printed as <math>root x</math>)
    • defdiff: Differentiate the definition of the function, not the function itself