> ## Documentation Index
> Fetch the complete documentation index at: https://docs.truemath.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Writing equations

> Write TrueMath activity equations — literals, variables, operators, functions, units in backticks, and how scalar, unit, and table values combine.

An [activity](/concepts/activities) equation is written in TrueMath's expression syntax. This page covers the building blocks and how value types combine when an equation runs. For the full operator list and ordering, see [Operators and precedence](/math/functions/operators-and-precedence); for the built-in functions, see the [Function library](/math/functions/index).

## Literals

* **Numbers** — `42`, `3.14`, `-7.2`. Scientific notation uses `e`: `1.5e-3` is `0.0015`.
* **Numbers with units** — a unit literal wrapped in backticks (see [Units in equations](#units-in-equations)).
* **Tables** — bracketed lists: `[1; 2; 3]`. See [Tables](/math/types/tables).

### Units in equations

A unit used as a literal must be wrapped in **backticks**, so it reads as a unit and not a variable name. Both simple and compound units work:

```
5`m`
30`yr`
400000`USD`
12`m/s`
```

The backticks are required: without them, `m`, `yr`, or `USD` is parsed as a variable name. See [Unit numbers](/math/types/unit-numbers).

This applies only inside equations. In [structured-text input](/concepts/input-formats#values) a value is not an expression, so units are written plainly — `30 yr`, no backticks.

## Variables

A variable name starts with a letter and contains letters, digits, and underscores:
`rate`, `home_price`, `term`. Variable names are case insensitive and will be lowercased automatically. In an equation, a variable refers to one of the [domain's variables](/concepts/variables).

```
payment = -pmt(loan_amount; 0; rate; term)
```

Changing a name here does not rename a variable — a name that doesn't match an existing one creates a *new* variable. To rename, edit the key in the variable's details. See [Key and labels](/authoring/defining-variables#key-and-labels).

## Constants

| Constant | Value        |
| -------- | ------------ |
| `pi`     | π (3.14159…) |
| `true`   | 1            |
| `false`  | 0            |

## Operators

Arithmetic `+ - * / ^`, comparison `== != < > <= >=`, and logical `&& || !`. Group with
parentheses to control evaluation order:

```
(principal + interest) / periods
```

See [Operators and precedence](/math/functions/operators-and-precedence) for the full list and
ordering.

## Functions

Call a function by name with arguments separated by **semicolons**:

```
root(volume; 3)
pmt(loan_amount; 0; rate; term)
```

Function names are case-insensitive (`sqrt`, `SQRT`, and `Sqrt` are equivalent). See the
[Function library](/math/functions/index).

## Assignment

`=` binds the result of an expression to a variable:

```
loan_amount = home_price - down_payment
```

Do not confuse `=` with `==`: `=` assigns a value to a variable, while `==` tests whether two values are equal inside a [condition](/math/functions/conditionals-and-logic). They are not interchangeable. See [Operators and precedence](/math/functions/operators-and-precedence).

<Note>
  The argument separator and the table/row separator are both the semicolon (`;`). Commas are not used in equations.
</Note>

## Combining types

Equations operate on three value types: [scalar numbers](/math/types/scalar-numbers), [unit numbers](/math/types/unit-numbers), and [tables](/math/types/tables). When an operation combines values, TrueMath applies consistent rules — and rejects combinations that are not meaningful.

### Numbers

* **Scalar with scalar** → scalar.
* **Compatible units** → converted to a common unit and combined.
* **Incompatible units** → rejected, because the dimensions differ.
* **Multiplication and division** combine dimensions — a length multiplied by a length is an area; a length divided by a time yields a velocity; a currency divided by an volume yields a cost-per-volume. See [Units](/math/units).

```
2 + 3              # 5
1`m` + 10`cm`      # a length
5`m` + 3`kg`       # error: length and mass are different dimensions
```

### Tables

* **Table with scalar** → the scalar is applied to every cell. `[1; 2; 3] * 2` is
  `[2; 4; 6]`.
* **Table with table** → element-wise, and the tables must have the same shape.
  `[1; 2] + [3; 4]` is `[4; 6]`.
* **Mismatched shapes** → rejected.

Empty cells in a table are treated as having no value and are skipped by aggregating
[functions](/math/functions/statistics).

### What is not coerced

TrueMath does not silently coerce across incompatible dimensions or mismatched table
shapes. These produce an error rather than a wrong answer — keeping with the principle
that "close" is not acceptable. See [Guarantees](/introduction/guarantees).
