Docs / Shapes / Expression

Expression Shape

The Expression shape is the mathematical heart of every Modellus model. It is where you define equations, parameters, differential equations, recurrences, and conditional logic that drive the simulation.

Expression shape on the board with equations visible

Overview

An Expression shape contains one or more mathematical statements written in LaTeX-like syntax using a MathLive math field. Each statement occupies one line. All Expression shapes in a model share a single calculator system — term names must be globally unique across shapes.

Use multiple small Expression shapes grouped by theme (parameters, equations, derived quantities) to keep your model organized and readable.

Toolbar

Expression shape toolbar showing color picker, shortcuts picker, and delete button

The toolbar appears when you select an Expression shape. It provides:

Statement Types

Each line in an Expression shape is parsed as one of these statement types:

Type Syntax Example Description
Parameter name = value g = 9.8 A constant value. No dependency on other terms or the independent variable.
Function name = expression E = ½·m·v² A computed value depending on other terms or the independent variable.
Differential dx/dt = expression dx/dt = v First-order ODE. Requires an initial value in shape properties.
Recurrence x_{n} = expression x_{n} = x_{n-1} + v·Δt Iterative step definition. Subscript determines step offset.
Conditional name = \begin{cases}...\end{cases} v = { 0 & t=0 \\ a·t & otherwise } Piecewise definition. At least two branches required.
Function with argument f(t) = expression h(t) = v₀·t - ½·g·t² Explicit argument notation (cosmetic; behavior same as Function).
Display expression F = ma Visual label only. Not computed by the calculator.

Arithmetic Operators

Operator LaTeX Keystroke Description
Addition++Sum of two expressions
Subtraction--Difference of two expressions
Multiplication\cdot*Explicit multiplication (· symbol)
Implicit multiplication2x2xCoefficient followed by name or parenthesis
Inline division//a/b inline notation
Fraction\frac{a}{b}/ (in numerator position)Display-quality vertical fraction
Power^{n}^Exponentiation
Square root\sqrt{x}\sqrtSquare root
Negation-x-Unary negation

Comparison Operators

Used in conditional (\begin{cases}) branches:

Operator LaTeX Meaning
==Equal to
>>Greater than
<<Less than
\ge or \geqGreater than or equal
\le or \leqLess than or equal
\neqNot equal to

Conditions can be chained (e.g., 0 < x < 1) or combined with \lor (OR) and \land (AND). The \text{otherwise} keyword acts as an else branch.

Built-in Functions

Category Function LaTeX Arguments
TrigonometricSine\sin\left(x\right)1
Cosine\cos\left(x\right)1
Tangent\tan\left(x\right)1
Cotangent\cot\left(x\right)1
Secant\sec\left(x\right)1
Cosecant\csc\left(x\right)1
Inverse TrigArc sine\arcsin\left(x\right)1
Arc cosine\arccos\left(x\right)1
Arc tangent\arctan\left(x\right)1
HyperbolicHyperbolic sine\sinh\left(x\right)1
Hyperbolic cosine\cosh\left(x\right)1
Hyperbolic tangent\tanh\left(x\right)1
LogarithmicNatural log\ln\left(x\right)1
Logarithm base 10\log\left(x\right)1
Two-argumentMaximum\max\left(a, b\right)2
Minimum\min\left(a, b\right)2
Modulo\mod\left(a, b\right)2
UtilitySignsign\left(x\right)1 — returns -1, 0, or 1
Randomrnd\left(x\right)1 — random float in [0, x]
Integer randomirnd\left(x\right)1 — random integer in [0, x]
Integer partint\left(x\right)1 — truncate to integer
Roundround\left(x\right)1 — round to nearest integer
OtherDeterminant\det\left(x\right)1
All function calls use \left( and \right) delimiters. Bare parentheses are not valid in function calls. The math field inserts these automatically.

Constants

NameLaTeXValue
Pi\pi3.14159…
Euler's numbere or \E2.71828…
g is not a built-in constant. Define it as a parameter: g = 9.8.

Special Syntax

Finite Difference (Δ)

SyntaxMeaning
\Delta xx(current) − x(previous). For the independent variable: the step size.
\Delta\left(expr\right)Finite difference applied to a sub-expression.

Subscripts (Step References)

SyntaxMeaning
x_{n-1}Value of x from the previous iteration
x_{n}Current iteration (LHS of recurrence)
x_0Initial value of x (bare digit, no braces)
x_{0}Initial value (braces form)

Units Annotation

Append display-only units after any statement:

v = 10 \quad\textcolor{gray}{\mathrm{m/s}}

Units are cosmetic — the engine does not validate or convert them.

Dotted Names (Child References)

Reference terms from child shapes inside a Referential: body.x, particle.velocity.

Keyboard Shortcuts

The MathLive math field supports these keyboard shortcuts for fast input:

ActionmacOSWindows
Fraction + /Ctrl + /
Superscript (power)^^
Subscript__
Square root + Shift + RCtrl + Shift + R
Greek letterType \ + name (e.g., \alpha)Same
Multiplication dot**
Greater or equalType \geSame
Less or equalType \leSame
Not equalType \neqSame
DeltaType \DeltaSame
PiType \piSame
New line (new statement)EnterEnter
Navigate out of fractionTabTab
Navigate into next placeholderTabTab

Shortcuts Picker

Expression shape selected with toolbar visible

Click the button in the toolbar to open the shortcuts picker. It provides pre-built templates for common expressions including:

Properties Panel

Expression shape properties panel

When an Expression shape is selected, the properties panel shows:

PropertyDescription
Independent variableThe variable of iteration (default: t)
StepThe increment per iteration (Δt)
Start / EndRange of the independent variable
Initial valuesStarting values for differential equations and recurrences
CasesMultiple sets of initial values for parameter studies

Examples

Simple Kinematics

g = 9.8
v₀ = 20
θ = 45
vx = v₀·\cos\left(θ\right)
vy = v₀·\sin\left(θ\right) - g·t
\frac{dx}{dt} = vx
\frac{dy}{dt} = vy

Population Growth (Recurrence)

r = 0.05
P_{n} = P_{n-1}·\left(1 + r\right)

Piecewise Velocity

v = \begin{cases} 0 & t = 0 \\ a·t & 0 < t < 5 \\ a·5 & \text{otherwise} \end{cases}