This page will look better in a graphical browser that supports web standards, but is accessible to any browser or internet device.

Served by Samwise.

# if/else trinary boolean operator

This document describes the syntax of the if - else boolean operator. (MML).

Prerequisites:

Contents:

## if - else syntax

The if - else boolean operator is used only with equations that specify exact numerical relationships between variables. Arbitrary nesting of if - else operators is allowed.

if - else statements can have one of the following forms:

```      expr2;
expr3;
var, var2, var3;
var = if (expr1) expr2;
var2 = if (expr1) expr2 else expr3;
var3 = if (expr1) expr2 else (if (expr4) expr5 else expr3);
```

where exprX are algebraic expression of variables, with expr1 and expr4 being of the boolean type. See Algebraic Expression Syntax for further information.

## if - else example

```
// if else syntax:
math if_else {
realDomain t;
t.min=0; t.max=2*PI; t.delta=0.1;
real amp = 1;
real phase = 0;
real u(t), v(t), w(t), x(t);
u = amp*sin(t-phase);
v = amp*cos(t-phase);
w = if (t < PI) (u + v) else (u);
x = if(t > PI) (u + v) else ( if (phase > 0) u else u-v );

}
```
(Java plugin required)