# Expressions

Expressions (or SGExpressions) are a feature of the SimGear library and provide a nice way of implementing complex math formulas using XML syntax. They are supported in many systems within the FlightGear code.

 Caution  Expressions do not check if your math creates floating point exceptions (like division by zero conditions, taking the square root of a negative number, etc.). This can cause undefined behavior and may result in NaNs or even Cascading NaNs.

## Usage

Expressions are supported in

## Sample Expressions

This is a sample expression for `c = sqrt(a*a + b^2)`. Children/arguments are parsed in the order they appear in in the file (or the order in which they are set via property methods).

```<expression>
<sqrt>
<sum>
<product>
<property>/value/a</property>
<property>/value/a</property>
</product>
<pow>
<property>/value/b</property>
<value>2</value>
</pow>
</sum>
</sqrt>
</expression>```

## Supported elements

```<abs> <!-- also: fabs -->
<acos>
<asin>
<atan>
<atan2>
<ceil>
<clip>
<cos>
<cosh>
<difference> <!-- also: dif -->
<div>
<exp>
<floor>
<log>
<log10>
<max>
<min>
<mod>
<pow>
<product> <!-- also: prod -->
<property> <!-- Unlike elsewhere, 'prop' does not work in expressions. -->
<sin>
<sinh>
<sqr>
<sqrt>
<sum>
<table>
<tan>
<tanh>
<value>```

## Hints and tips

### Rounding

While there is no element for rounding, this workaround can be used for that:

```<expression>
<floor>
<sum>
<property>your/property/here</property>
<value>0.5</value>
</sum>
</floor>
</expression>```