# pow

Learn how to use the exponentiation (^) operator in Notion formulas.

The power (^) operator (also known as the exponentiation operator) allows you to raise a number to a higher power.

number[base] ^ number[exponent] pow(number[base], number[exponent])

In technical terms, it raises the first operand to the power of the second operand.

In Notion, the ^ operator has a higher operator precedence than the unaryPlus and unaryMinus operators, and has right-to-left associativity.

You can also use the function version, pow().

3 ^ 4 // Output: 81 pow(4,3) // Output: 64 2 ^ 2 ^ 3 // Output: 256 - evaluates as 2 ^ (2 ^ 3)
• $$x^0 = 1$$
• $$(x^a)^b = x^{ab}$$
• $$x^{a^b} = x^{(a^b)}$$ (not all languages respect this, but Notion does)
• $$x^a * y^a = (xy)^a$$
• $$x^a / y^a = (x/y)^a$$
• $$x^a * x^b = x^{a+b}$$
• $$x^a / x^b = x^{a-b}$$

In Notion, the ^ operator has right-to-left associativity, which means that x ^ y ^ z is evaluated as x ^ (y ^ z).

4 ^ 3 ^ 2 == 262,144 4 ^ (3 ^ 2) == 4 ^ 9 == 262,144 (4 ^ 3) ^ 2 == 64 ^ 2 == 4,096 // Here's that last one according to the (x^a)^b == x^(ab) "Power Rule": (4 ^ 3) ^ 2 == 4 ^ (3*2) == 4 ^ 6 = 4,096

Not every programming and scripting language uses right-to-left associativity for serial exponentiation. Here’s a write-up comparing the methods for many popular languages. Even though standard mathematical notation has the “Tower Rule”, where $$x^{a^b} = x^{(a^b)}$$ (aka: “Work top-down”), the computer science community has not come to a strong consensus on whether x^y^z should be interpreted in the same way.

Good to know: Don’t want to memorize these precedence rules? Just use parentheses () to make the order of your operations explicit.

In Notion, the unaryPlus operator converts strings and Booleans to numbers, while the unaryMinus operator inverts the sign of its operand.

When combining these operators with the ^ operator in Notion, it’s useful to understand the following rules:

1. The ^ operator has a higher operator precedence than the unary operators. This is opposite to JavaScript’s operator precedence! (Though in JavaScript this is irrelevant, because the language doesn’t allow for ambiguous unary operator usage in exponentiation).
2. Notion is smart and will allow for unaryPlus type conversion on the exponent, but will wrap the conversion operation in () automatically.
3. Notion will not allow for automatic unaryPlus type conversion on the base number – e.g. +"8"^2 will throw a type mismatch error.
4. If you write a negative exponent into a formula, Notion parses it as a true negative value instead of a unaryMinus (-) operator appended to a number. Your formula will also be re-written to x ^ (-2) so the exponent is explicitly defined as negative.
5. When using unaryMinus on a base number, Notion will parse it as -(x^y), not (-x)^y. Note that this can result in mathematically incorrect answers depending on your use case – see Negative Base Numbers below.
-2 ^ 2 // Output: -4 - Notion parses this as -(2^2) 4 ^ -2 // Re-written to 4 ^ (-2), outputs 0.0625 4 ^ -(2) // Re-written to 4 ^ (-2), outputs 0.0625 4 ^ -(-2) // Re-written to 4 ^ (-(-2)), outputs 16 +"8" ^ 2 // Type mismatch error (+"8") ^ 2 // Output: 64 8 ^ +"-2" // Re-written to 8 ^ (+"-2"), outputs 0.015625 2 ^ +false// Re-written to 2 ^ (+false), outputs 1

If you type -2^4 directly into Notion’s formula box, you’ll get an output of -16. Assuming you’re intending to pass the actual base number -2, this answer is incorrect! The true answer is 16.

Remember that exponentiation is just repeated multiplication of the base number. Therefore:

-2^4 == (-2)(-2)(-2)(-2) == (4)(-2)(-2) == (-8)(-2) == 16

So why does -2^4 return -16 in a Notion formula?

This happens because when you type - directly into a Notion formula, you’re using the unaryMinus operator. If you type -2, you’re not simply typing a negative number into your formula. Rather, you’re creating an expression equivalent to -(2).

This distinction is important because exponentiation (^) has a higher operator precedence in Notion than unaryMinus, as noted above.

This means that typing -2^4 is equivalent to -(2^4)!

If your intention is to express a negative base number, you’ll need to type (-2)^4 instead.

Negative base numbers passed via a property (e.g. prop("num")) will be evaluated correctly, since they’re actually passing a negative value, rather than adding a hard-coded unaryMinus (-) operator to your formula.

-2^4 // Output: -16 - Notion parses this as -(2^4) (-2)^4 // Output 16 - Notion parses this as (-2)^4 prop("num") == -2 prop("num")^4 // Output: 16 - Notion parses this as (-2)^4

Note: This convention does not apply to all programming and scripting languages. For example, in Microsoft Excel, the formula =-2^4 evaluates to 16, as does =A1^4 where the value of A1 is 2.

The table below shows exponentiation at work in a Notion database.

prop("Base") ^ prop("Exponent")

Instead of using hard-coded numbers, I’ve called in each property using the prop() function.