To create a Math Expression node, **Right-click** in the graph and select **Add Math Expression...** from the context menu.

The Math Expression node acts like a collapsed graph. It is a single node that you can **Double-click** to open the sub-graph that makes up its functionality.
Initially, the name/expression is blank. Whenever you rename the node, then the new expression is parsed and a new sub-graph is generated.

To rename the node and update the sub-graph, **Right-click** on the node and select **Rename**.

For example, you could rename the Math Expression node with the following expression:

<code class="language-cpp">(1+x)*sin(myVar)-2.4/rand()</code>

This would update the Math Expression node to have two float inputs, **X** and **MyVar**, and one float output.

If you **Double-click** the node with this expression, you would see the below sub-graph:

The sub-graph is created by following the below rules:

- Alphabetic names (tokens beginning with a letter) should be turned into either variables, input pins on the Math Expression node, or function calls. From the example above:
**x**,**sin**,**myVar**, and**rand**.- If an alphabetic name matches an existing variable in the Blueprint, then it will become a variable get node (i.e. if the Blueprint already had a
**myVar**variable). - If an alphabetic name is followed by an open parenthesis, like
**sin(**and**rand(**, then it will be turned into a function node. - If the previous two states are not met, then the alphabetic name is turned into a float input on the Math Expression node.
- The name will also be used as an input if it matches the name of an existing pin on the node.

- If an alphabetic name matches an existing variable in the Blueprint, then it will become a variable get node (i.e. if the Blueprint already had a
- Numerical constants are always turned into pin inputs. They never create a node themselves, but instead are used to fill out input fields on other nodes.
- Mathematical operators (like +, *, -) are turned into function nodes.
- Like in mathematics, expressions inside of parentheses will take precedence, and be evaluated first.

Variable naming is fairly flexible, but it is important to remember the following points:

Variables can have numbers in them, but they cannot start with a number.

Variables cannot have the same name as a hidden Blueprint variable.

Be sure that you are working with the correct type of variable. For example,

**boolVar+1.5**is not a valid expression.

Operations follow the below order of operations (highest priority first):

Parentheses

Factorials

Exponents

Multiplication and division

Addition and subtraction

Blueprint pure functions that are in a coded function library should all be available. These include:

Trig functions (sin/cos/tan, asin, acos, etc.):

`sin(x)`

Clamping functions (min, max, clamp, etc.):

`clamp(y,0,20)`

Rounding functions (floor, fceil, round, etc.):

`round(z)`

Exponential functions (square, power, sqrt, loge, e/exp, etc.)

Certain functions have multiple names that are commonly used. To account for that, there are several aliases that map to the same function/node. Some examples are:

Power aliases: power, pow

Trig arc functions (asin/arcsin, acos/arccos, etc.)

Since you are typing in functions rather than connecting pins, make sure to enter the correct number and type of parameters. The Math Expression node will display an error if there is a mismatch.

There are some basic structures that we use quite often in math as well: vectors, transforms, etc. You can make and operate on these types in the expression easily.

The vector keyword spawns a MakeVector node:

`vector(x,y,z)`

The rotator keyword spawns a MakeRotator node:

`rotator(x,y,z)`

The transform keyword spawns a MakeTransform node:

`transform(vec(x,y,z), rot(p,y,r), vec(6,5,4))`

Just like there are aliases for certain functions, there are vector and rotator aliases.

Vector aliases

`vector, vec, vect`

Rotator aliases

`rotator, rot`