> For the complete documentation index, see [llms.txt](https://calctree.gitbook.io/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://calctree.gitbook.io/docs/calculations/creating-calculations/maths-equations.md).

# Maths equations

CalcTree supports regular math formulas as a calculation option — powered by [Math.js](https://mathjs.org/), the underlying math engine used in the platform.&#x20;

You can create and edit Math formulas anywhere inside a page.&#x20;

## Create a math formula

Click anywhere on a page document and follow the following steps to create a formula using regular math expression:

<table><thead><tr><th width="116.07611083984375" align="center"> </th><th width="178.2471923828125"> Type:</th><th>What happens next:</th></tr></thead><tbody><tr><td align="center">1. </td><td><code>Length</code> then <code>=</code></td><td><p><img src="/files/aeS7WHYaNZqv6jo8J6GO" alt=""><br></p><p>You've assigned <code>Length</code> as the name for the math variable. </p></td></tr><tr><td align="center">2.</td><td><code>2 + 2</code> then <code>=</code></td><td><p><br><img src="/files/m3iFHYNSHTkvhSAVKGKD" alt=""></p><p>You've defined the math formula as <code>2 + 2</code>, exited the math editor mode, and received a representation of the math formula and the current value of the variable.</p></td></tr></tbody></table>

{% hint style="success" %}
The element you've just created on the page document, acts as an inline source editor for the math node and also as a parametric element that represents the math node and the variable it defines. Learn more about parametric document elements here: [Broken mention](broken://pages/1kxb9icwIEW54Y0pBCCk)
{% endhint %}

While editing a math formula, a drop-down list of recommendations will appear for you to select from. The suggestions include:

* **Variable names**
* **Physical units**
* **Math functions**

For example, by typing `w` in the formula editor below, an available variable name, two available physical units and an available math function that starts with `w` are suggested:

<figure><img src="/files/Ap5nnrgeKmlc79boLJGQ" alt=""><figcaption></figcaption></figure>

### Physical units in math formulas

A number and a physical unit comprise a quantity in CalcTree. You can use quantities in math formulas because formulas accept physical units as valid terms. For example, you can multiply `1 kPa` and `1 m^2` to get `1 kN`:&#x20;

<figure><img src="/files/Oh1TlJzX49IhSvgCQgUr" alt=""><figcaption></figcaption></figure>

Note that if you try operations on quantities that are not physically meaningful, you will receive an error. For example adding a length to a time will result in an error, designated by a red background:&#x20;

<figure><img src="/files/oShdjFwYmxuMWDBzih6B" alt=""><figcaption></figcaption></figure>

This unit-awareness acts as a built-in quality control as it checks the operations are done on compatible quantities. This is especially useful when linking parameters from other sources in Math formulas. Read more here: [#chaining-math-formulas-to-other-sources](#chaining-math-formulas-to-other-sources "mention")

### Automatic unit conversion

CalcTree supports automatic unit handling and conversion within formulas. This makes it easy to write calculations involving physical quantities without having to manually convert units each time.

#### How It Works

If you want to convert a quantity to a specific unit, you can use the `to` keyword directly in a formula:

```
= (3 m + 200 cm) to ft
```

This will convert the result to feet:

```
= 16.4 ft
```

You can also use `to` with variables:

```
= total_length to mm
```

## Linking math formulas to other nodes

You can link multiple nodes to create more complex calculations. That means a node picks up a result from another node and does more calculations on it.&#x20;

In order to link a Math formula to other calculations, it needs to refer to another node's variable. That is simply achievable by typing the variable name inside the formula. For example, if you have two variables called `length`, and `width` which are defined by other nodes, you can refer to them in your formula:&#x20;

<figure><img src="/files/kC4mUDBF82MTise3fEp4" alt=""><figcaption></figcaption></figure>

{% hint style="success" %}
In the above example, the variables `length` and `width` could be defined by another node of any type.
{% endhint %}
