# Expressions

Several nodes in the Composer allow for writing mathematical expressions. This page outlines the allowed expressions.

Note: spaces are ignored in expressions, so they can be placed whereever.

### Constants

pi = 3.14159265358979323846

i = 0+1i

e = exp(1)

### Arithmetic operator precedence

operators with lower precedence are calculated before those with higher precedence

1: ^

2: unary +, unary -

3: *, /

4: +, -

### Basic functions

• pow(a,b) = $a^b$
• sqrt(a) = $\sqrt{a}$
• abs(a) = $|a|$
• exp(a) = $e^a$
• exp2(a) = $2^a$
• log(a) = $\log (a)$
• log2(a) = $\log_2(a)$
• log10(a) = $\log_{10}(a)$

• sin(a)
• cos(a)
• tan(a)
• asin(a) = $\sin^{-1}(a)$
• acos(a) = $\cos^{-1}(a)$
• atan(a) = $\tan^{-1}(a)$
• sinh(a)
• cosh(a)
• tanh(a)
• asinh(a) = $\sinh^{-1}(a)$
• acosh(a) = $\cosh^{-1}(a)$
• atanh(a) = $\tanh^{-1}(a)$

### functions for nodes taking x as input

• gauss(a,b,c) = $a \cdot \exp \left( -\frac{1}{2 b^2} (x-c)^2 \right)$ (only for states, not potentials)
• step(a) = $0$ for $x<a$, $1$ for $x>a$
• box(a,b) = $0$ for $x<a$ & $x>b$, $1$ for $a<x<b$
• well(a,b) = -box(a,b)
• finite(a,b) = $1$ for $x<a$ & $x>b$, $0$ for $a<x<b$
• infinite(a,b) = $\infty$ for $x<a$ & $x>b$, $0$ for $a<x<b$

Numerical simulations tend to dislike hard bounds. Below are soft versions of the above steps and boxes. Higher hardness (h) gets close to completely hard steps.

• sstep(a,h) = $\frac{1}{1+exp(-h*(x-a))}$
• sbox(a,b,h) = sstep(a,h)-sstep(b,h)
• swell(a,b,h) = -sbox(a,b,h)