# &kmplot; Reference

## Function Syntax

Some syntax rules must be complied with:

    		name(var1[, var2])=term [;extensions]

name

  The function name. If the first character is r the parser assumes that you are using polar coordinates. If the first character is x (for instance xfunc) the parser expects a second function with a leading y (here yfunc) to define the function in parametric form.

var1

  The function's variable

var2

  The function group parameter. It must be separated from the function's variable by a comma. You can use the group parameter to, for example, plot a number of graphs from one function. The parameter values can be selected manually or you can choose to have a slider bar that controls one parameter. By changing the value of the slider the value parameter will be changed. The slider can be set to an integer between 0 and 100.

term

  The expression defining the function.

## Predefined Function Names and Constants

All the predefined functions and constants that &kmplot; knows can be shown by selecting Help Predefined Math Functions , which displays this page of &kmplot;'s handbook.

These functions and constants and even all user defined functions can be used to determine the axes settings as well. See .

### Trigonometric Functions

By default, the trigonometric functions work in radians. However, this can be changed via Settings Configure &kmplot;.

sin(x)
arcsin(x)
cosec(x)
arccosec(x)

  The sine, inverse sine, cosecant and inverse cosecant respectively.

cos(x)
arccos(x)
sec(x)
arcsec(x)

  The cosine, inverse cosine, secant and inverse secant respectively.

tan(x)
arctan(x)
cot(x)
arccot(x)

  The tangent, inverse tangent, cotangent and inverse cotangent respectively.

### Hyperbolic Functions

The Hyperbolic Functions.

sinh(x)
arcsinh(x)
cosech(x)
arccosech(x)

  The hyperbolic sine, inverse sine, cosecant and inverse cosecant respectively.

cosh(x)
arccosh(x)
sech(x)
arcsech(x)

  The hyperbolic cosine, inverse cosine, secant and inverse secant respectively.

tanh(x)
arctanh(x)
coth(x)
arccoth(x)

  The hyperbolic tangent, inverse tangent, cotangent and inverse cotangent respectively.

### Other Functions

sqr(x)

  The square x^2 of x.

sqrt(x)

  The square root of x.

sign(x)

  The sign of x. Returns 1 if x is positive, 0 if x is zero, or −1 if x is negative.

H(x)

  The Heaviside Step Function. Returns 1 if x is positive, 0.5 if x is zero, or 0 if x is negative.

exp(x)

  The exponent e^x of x.

ln(x)

  The natural logarithm (inverse exponent) of x.

log(x)

  The logarithm of x to base 10.

abs(x)

  The absolute value of x.

floor(x)

  Rounds x to closest integer less than or equal to x.

ceil(x)

  Rounds x to the closest integer greater than or equal to x.

round(x)

  Rounds x to the closest integer.

gamma(x)

  The gamma function.

factorial(x)

  The factorial of x.

min(x1,x2,...,xn)

  Returns the minimum of the set of numbers {x1,x2,...,xn}.

max(x1,x2,...,xn)

  Returns the maximum of the set of numbers {x1,x2,...,xn}.

mod(x1,x2,...,xn)

  Returns the modulus (Euclidean length) of the set of numbers {x1,x2,...,xn}.

### Predefined Constants

pi
&pgr;

  Constants representing &pgr; (3.14159...).

e

  Constant representing Euler's Number e (2.71828...).

## Extensions

An extension for a function is specified by entering a semicolon, followed by the extension, after the function definition. The extension can be entered by using the &DBus; method parser addFunction. None of the extensions are available for parametric functions but N and D[a,b] work for polar functions too. For example:

    				f(x)=x^2; A1

will show the graph y=x2 with its first derivative. Supported extensions are described below:

N

  The function will be stored but not be drawn. It can be used like any other user-defined or predefined function.

A1

  The graph of the derivative of the function will be drawn additionally with the same color but less line width.

A2

  The graph of the second derivative of the function will be drawn additionally with the same color but less line width.

D[a,b]

  Sets the domain for which the function will be displayed.

P[a{,b...}]

  Give a set of values of a group parameter for which the function should be displayed. For example: `f(x,k)=k*x;P[1,2,3]` will plot the functions f(x)=x, f(x)=2*x and f(x)=3*x. You can also use functions as the arguments to the P option.

Please note that you can do all of these operations by editing the items in the Derivates tab, the Custom plot range section and the Parameters section in the Functions sidebar too.

## Mathematical Syntax

&kmplot; uses a common way of expressing mathematical functions, so you should have no trouble working it out. The operators &kmplot; understands are, in order of decreasing precedence:

^

  The caret symbol performs exponentiation. &eg;, `2^4` returns 16.

*
/

  The asterisk and slash symbols perform multiplication and division . &eg;, `3*4/2` returns 6.

+
−

  The plus and minus symbols perform addition and subtraction. &eg;, `1+3−2` returns 2.

<
>
≤
≥

  Comparison operators. They return 1 if the expression is true, otherwise they return 0. &eg;, `1 ≤ 2` returns 1.

√

  The square root of a number. &eg;, `√4` returns 2.

|x|

  The absolute value of x. &eg;, `|−4|` returns 4.

±

  Each plus-minus sign gives two sets of plots: one in which the plus is taken, and one in which the minus is taken.&eg;. `y = ±sqrt(1−x^2)` will draw a circle. These, therefore, cannot be used in constants.

Note the precedence, which means that if parentheses are not used, exponentiation is performed before multiplication/division, which is performed before addition/subtraction. So `1+2*4^2` returns 33, and not, say 144. To override this, use parentheses. To use the above example, `((1+2)*4)^2` will return 144.

## Plotting Area

By default, explicitly given functions are plotted for the whole of the visible part of the horizontal axis. You can specify an other range in the edit-dialog for the function. If the plotting area contains the resulting point it is connected to the last drawn point by a line.

Parametric and polar functions have a default plotting range of 0 to 2&pgr;. This plotting range can also be changed in the Functions sidebar.

## Crosshair Cursor

While the mouse cursor is over the plotting area the cursor changes to a crosshair. The current coordinates can be seen at the intersections with the coordinate axes and also in the status bar at the bottom of the main window.

You can trace a function's values more precisely by clicking onto or next to a graph. The selected function is shown in the status bar in the right column. The crosshair then will be caught and be colored in the same color as the graph. If the graph has the same color as the background color, the crosshair will have the inverted color of the background. When moving the mouse or pressing the keys Left or Right the crosshair will follow the function and you see the current horizontal and vertical value. If the crosshair is close to vertical axis, the root-value is shown in the statusbar. You can switch function with the Up and Down keys. A second click anywhere in the window or pressing any non-navigating key will leave this trace mode.

For more advanced tracing, open up the configuration dialog, and select Draw tangent and normal when tracing from the General Settings page. This option will draw the tangent, normal and oscillating circle of the plot currently being traced.

## Coordinate System Configuration

To open this dialog select View Coordinate System... from the menubar.

Screenshot of the Coordinate System dialog
Screenshot of the Coordinate System dialog

### Axes Configuration

Horizontal axis Range

  Sets the range for the horizontal axis scale. Note that you can use the predefined functions and constants (see ) as the extremes of the range (&eg;, set Min: to `2*pi`). You can even use functions you have defined to set the extremes of the axis range. For example, if you have defined a function `f(x) = x^2`, you could set Min: to `f(3)`, which would make the lower end of the range equal to 9.

Vertical axis Range

  Sets the range for the vertical axis. See Horizontal axis Range above.

Horizontal axis Grid Spacing

  This controls the spacing between grid lines in the horizontal direction. If Automatic is selected, then &kmplot; will try to find a grid line spacing of about two centimeters that is also numerically nice. If Custom is selected, then you can enter the horizontal grid spacing. This value will be used regardless of the zoom. For example, if a value of 0.5 is entered, and the x range is 0 to 8, then 16 grid lines will be shown.

Vertical axis Grid Spacing

  This controls the spacing between grid lines in the vertical direction. See Horizontal axis Grid Spacing above.

## Constants Configuration

To open this dialog select Edit Constants... from the menubar.

Screenshot of the Constants dialog
Screenshot of the Constants dialog

Constants can be used as part of an expression anywhere inside of &kmplot;. Each constant must have a name and a value. Some names are invalid, however, such as existing function names or existing constants.

There are two options that control the scope of a constant:

Document

  If you select the Document checkbox, then the Constant will be saved along with the current diagram when you save it to file. However, unless you have also selected the Global option, the constant will not be available between instances of &kmplot;.

Global

  If you select the Global checkbox, then the Constant's name and value will be written to &kde; settings (where it can also be used by &kcalc;). The constant will not be lost when &kmplot; is closed, and will be available again for use when &kmplot; is started again.