Reference sqrt()

sqrt()

Calculates the square root of a number.

A number's square root can be multiplied by itself to produce the original number. For example, sqrt(9) returns 3 because 3 × 3 = 9. sqrt() always returns a positive value. sqrt() doesn't work with negative arguments such as sqrt(-9).

sqrt() can also be used in shaders with p5.strands. The following example uses sqrt() to create a smooth ease-out curve on color and size.

Examples

Syntax

sqrt(n)

Parameters

n
Number: non-negative number to square root.

Returns

Number: square root of number.

Related References