# sqrt

Learn how to use the sqrt function in Notion formulas.
The sqrt() function returns the square root of its argument. sqrt() accepts only numbers.
1
sqrt(number)

## Example Formulas

1
sqrt(16) // Output: 4
2
3
sqrt(100) // Output: 10
4
5
sqrt(73-3^2) // Output: 8

## Example Database

This example database uses the Pythagorean Theorem to solve for the missing side of any right triangle. Two of the three side lengths must be provided; the Calculator property will solve for the missing one.

### "Calculator" Property Formula

1
// Compressed
2
if(empty(prop("Hypotenuse")) and empty(prop("Side 1")) or empty(prop("Hypotenuse")) and empty(prop("Side 2")) or empty(prop("Side 1")) and empty(prop("Side 2")), "Not enough information!", if(empty(prop("Hypotenuse")), "Hypotenuse: " + format(round(sqrt(prop("Side 1") ^ 2 + prop("Side 2") ^ 2) * 100) / 100), if(empty(prop("Side 1")), "Side 1: " + format(round(sqrt(prop("Hypotenuse") ^ 2 - prop("Side 2") ^ 2) * 100) / 100), "Side 2: " + format(round(sqrt(prop("Hypotenuse") ^ 2 - prop("Side 1") ^ 2) * 100) / 100))))
3
4
// Expanded
5
if(
6
empty(
7
prop("Hypotenuse")
8
) and empty(
9
prop("Side 1")
10
) or empty(
11
prop("Hypotenuse")
12
) and empty(
13
prop("Side 2")
14
) or empty(
15
prop("Side 1")
16
) and empty(
17
prop("Side 2")
18
),
19
"Not enough information!",
20
if(
21
empty(
22
prop("Hypotenuse")
23
),
24
"Hypotenuse: " +
25
format(
26
round(
27
sqrt(
28
prop("Side 1")^2 + prop("Side 2")^2
29
) * 100
30
) / 100
31
),
32
if(
33
empty(
34
prop("Side 1")
35
),
36
"Side 1: " +
37
format(
38
round(
39
sqrt(
40
prop("Hypotenuse")^2 -
41
prop("Side 2")^2
42
) * 100
43
) / 100
44
),
45
"Side 2: " +
46
format(
47
round(
48
sqrt(
49
prop("Hypotenuse")^2 -
50
prop("Side 1")^2
51
) * 100
52
) / 100
53
)
54
)
55
)
56
)
I'll start this explanation off by saying that you can create a much simpler Pythagorean Theorem calculator that solves for the Hypotenuse only with: sqrt(prop("Side 1") ^ 2 + prop("Side 2") ^ 2).
The example above goes a few steps further. It rounds its answer to two decimal places using the round function (see that function's page for tips on how to round to specific decimal places).
It also solves for any missing side of a right triangle, so long as the other sides have been provided.
The formula first checks to make sure there's enough information to make a calculation. We use the empty function for this, and we must do so several times since we're checking to see if any two of the three number properties are empty.
Good to know: The or operator has lower operator precedence than the and operator, so this part of the formula executes as (empty(prop("Hypotenuse")) and empty(prop("Side 1"))) or (empty(prop("Hypotenuse")) and empty(prop("Side 2"))).
In other words, all of the and clauses are executed before the first or clause.
After this error-checking stage, the formula uses a nested if-statement to determine the correct calculation to perform.
If the hypotenuse is missing, we use the following formula to solve for it, where Side 1 and Side 2 are
$a$
and
$b$
respectively:
$\sqrt{a^2+b^2}$
If one of the sides is missing, we instead use this formula, where
$c$
is the hypotenuse, and
$b$
is the non-missing side:
$\sqrt{c^2-b^2}$