# Function Dialog

This dialog box is used to add a function curve to the active plot or to edit an already existing function curve. In the latter case it is embedded into the Plot details dialog

The plotted function is built with the common operators *, +, /, -, and ^ (for multiplication, addition, division, subtraction and exponentiation, respectively). A complete set of intrinsic functions are available and these are listed in the muParser section of the chapter on Mathematical Expressions and Scripting.

The first item is the Curve type and is used to select the form of the generator function. The simplest and most common function definition is the classical cartesian coordinate definition, y=f(x). This is the default option and is simply named Function.

Figure 5-13. The Add Function... dialog box: Cartesian Coordinates. The Comment input box can be used to enter a text that will be displayed in the plot legend instead of the default function name. Just below, there is a text pane provided for entering the function definition.

On the left side of this text pane there are three buttons. By pressing the first one, displaying the capital greek letter sigma Σ, a menu pops-up listing all built-in mathematical functions provided by QtiPlot. Pressing one of the actions from this menu copies the displayed function into the edit box at the position of the text cursor.

Clicking on the button displaying a pencil icon opens a menu which lists recently used functions. By pressing one of the menu items, the selected function is inserted into the edit text box at the current position of the cursor.

Clicking the Clear button removes the contents of the function definition text box.

The next two parameters are used to select the X-range to be used for the plot. The third parameter sets the number of data points to be computed in the selected X-range.

If the function expression contains terms that are recognizable as constants, e.g.: f(x) = a*x + b, QtiPlot detects them and displays a two column table on the right side of the dialog which contains input spin boxes that simplify the process of setting appropriate values for the detected constants.

Figure 5-14. The Add Function... Dialog Box: Automatic Detection of Constants. A function can also be defined using a parametric definition by selecting Parametric plot as the Curve type. That is, given some variable, m, the (x,y) data points are computed using functions of that variable, x=f(m) and y=g(m).

The first parameter is the name of the parametric variable (here m). It is followed by the definitions of the two functions, the range of the parametric variable, and the number of data points.

Figure 5-15. The Add Function... dialog box: Parametric Coordinates. Finally, a polar definition of the function may be used by selecting Polar plot as the Curve type. Given some variable t, then the radius (R) and angle (Theta) are computed using two functions of that variable, R=f(t) and Theta=g(t), in a manner similar to the parametric function case. The (x,y) data points are then computed as x=R*cos(Theta) and y=R*sin(Theta).

The first parameter is the name of the parametric variable (here t). It is followed by the definition of the two functions, the range of the parametric variable, and the number of data points. Note that the angle is in radians. pi is an internally defined constant which can be used in any mathematical expression. For example, you can use 3*pi to define the parameter range.

Figure 5-16. The Add Function... dialog box: Polar Coordinates. 