appScience software

disclaimer

fc31024

Creating functions

Functions are a way of representing sets of mathematical operations. There are many standard functions available but you can also create your own, export them to a file or import previously saved functions.

To define a function type its name with one or more parameters separated by commas followed by the expression to be evaluated. You can choose any name for your function but it has to be unique (that is, there is no other function with the same name). Function definitions should be confined to a single line (no line breaks within the function).

Here are two examples of functions:

mySine(x)=sin(x*pi/180)

multifunc(this,that,those)=pow(this,that)-those*mySine(that)+3/2

Functions can use constants but they cannot access parameters defined outside the function. In this sense, functions are self-contained. If you want to use a parameter in the function you need to pass it through the parameter list, as in this, that and those of the example above.

Once a function is defined it can be used. In single line mode, formula calculator will ask if you want to keep the function. In multi-line mode your function is automatically appended to the end of the user-functions list. It remains there while the function appears in the math text input.

To keep the function, press the Functions button, then User and then the name of your function. You have the option of giving it a description and selecting the keep for next time box. If you have multiple calculators open, the function is copied to all calculators. If a function already exists, formula calculator asks if you want to overwrite it.

To delete the function, just uncheck the keep for next time box and make sure it doesn't appear in the math input text. Alternatively, click the small x button. If the function is still used in the math input text, then running the calculator will place the function name in the functions list again.

To close the popover balloon, click another function name or click in the math input text field.

Formula calculator allows you to export your functions to a file and read them in again later. This is useful if you wish to share the functions you have created. The exported files have the usrmth extension.

To export your functions, select Export...> User functions from the File menu. Note that you must have checked the keep for next time box (see To keep the function above) and make sure the function definition is deleted from the math input text, otherwise formula calculator will not recognise it as a user function to save.

To import your functions, select Import...> User functions from the File menu. If a function name already exists you have the option of overwriting it with the imported function. The functions are imported to all open calculators.