Fit Builder Help

The Fit Builder enables users to define mathematical fit functions to be compared with experimental data. The closeness of a fit is quantified by determining the rms deviation between the fit function and the data points. Typically, a fit is optimized by varying parameters of the function to minimize the rms deviation.

Functions and parameters are defined by entering expressions that are "parsed" (interpreted) by the OSP parser. The values of parameters are constants while those of functions depend on input variables such as x, y, t, etc. The parser recognizes the following elements:

- Numbers in decimal or scientific notation (e.g., 1.0E-3)
- Names of parameters, functions and other input variables
- Constants e and pi
- Arithmetic operators + - * / ^
- Boolean operators = > < <= >= <> & | !
- Parentheses to control order of operation
- Mathematical functions shown in Table 1
- If statements in the form if(conditional statement, expression1, expression2). Expression1 is evaluated if the conditional statement is true and expression2 is evaluated if it is false. For example, if (x < 0, x^2, -x^2) is a valid function expression.

abs(x) | acos(x) | acosh(x) | asin(x) | asinh(x) | atan(x) | atanh(x) | atan2(x,y) | ceil(x) | cos(x)
cosh(x) | exp(x) | frac(x) | floor(x) | int(x) | log(x) | max(x,y) | min(x,y) | mod(x,y) | random(x)
round(x) | sign(x) | sin(x) | sinh(x) | sqr(x) | sqrt(x) | step(x) | tan(x) | tanh(x) |

Table 1 Mathematical functions recognized by the OSP Parser

How to use Fit Builder

The Fit Builder displays fit functions and their associated parameters in tables with Name and Expression columns. The name of the fit is shown in bold font in the function table.

To edit a name or expression, double-click its table cell (gray cells cannot be edited). Names must be unique and can contain no spaces or mathematical symbols. Expressions must be valid mathematical expressions parsable by the OSP parser.

To create a new parameter or function, click the appropriate Add button.

When editing an expression, the names of all available variables are listed in blue immediately below the popup editor field. You can enter variable names and operators using the keyboard and/or mouse. To insert a variable with the mouse, move the mouse over the list until the desired variable turns red, then click.

Parameter expressions can include other parameters. Fit function expressions can include parameters, independent variables (e.g., t or x) and support function names (see below). For example, if the parameters "v0" and "g" are defined and the independent (x-axis) variable is "t", then the entry "v0*t - 0.5*g*t^2" is a valid fit function expression.

If an invalid expression is entered into a cell the cell turns red and an error message is displayed in the status bar. For example, the expression "v0t - 0.5gt^2" is invalid since the multiplication operators (*) have been omitted. Circular references also result in an error condition.

The Fit Builder includes several features designed to help users build, modify and compare functions quickly:

1. Complex expressions can be simplified by defining one or more support functions. For example, suppose you wish to define a sinusoidal function for which the amplitude decreases exponentially. Using a separate function to define the time-dependent amplitude makes the damped oscillation function easier to write and understand.
2. All edits are undoable and redoable making it easy to quickly flip back and forth between two function expressions or parameter values.
3. Single or multiple table rows can be copied or cut to the clipboard for pasting into other fit function tables.