Math

Built-in math functions and other features

Built-in

This library includes typical math functions you see in conventional spreadsheets, like Sqrt(), Abs(), Max(), Min(), Sum(), or Average(). These work the same way.

Functions are unit sensitive

Unlike conventional spreadsheets, Blockpad functions are unit sensitive. For example, Sin(30 deg) = 0.5, Sum(5 ft, 12 in, 1 m) = 9.281 ft, or Sqrt(4 in^2) = 2 in.

Learn more

To learn more about math calculations in Blockpad, check out calculations in the deep dive guide.

Trigonometry

The math library includes standard trig functions. These functions are unit sensitive, but default to radians if no unit is provided.

Sin() Returns the sine of an angle.
Cos() Returns the cosine of an angle.
Tan() Returns the tangent of an angle.
Asin() Returns the arcsine of a ratio as an angle between -pi/2 and pi/2.
Acos() Returns the arccosine of a ratio as an angle between 0 and pi.
Atan() Returns the arctangent of a number as an angle between -pi/2 and pi/2.
Atan2() Returns the arctangent of given (x, y) coordinates as an angle between -pi and pi, not including -pi.
Built-in values

Blockpad includes built-in values. Unlike conventional spreadsheets, they are stored as values, not functions, so there's no need to follow them with parentheses.

pi The value for pi, 3.1415...
e The value for e, 2.718...
i The square root of negative one
Functions for units
Compatible() Tests if two numbers have compatible units (e.g. both are lengths) and returns true or talse.
Magnitude() Returns the magnitude of a number with units.
Unit() Returns the units stored with a number.
UnitConvert() Converts a number to different units. (e.g. UnitConvert(5 m, 1 in))
Note the to keyword is typically preferable (e.g. 5 m to in).
Matrix and vector math functions
CrossProduct() Returns the cross product of two vectors (1 dimensional arrays).
Determinant() Returns the determinant of a matrix.
DotProduct() Returns the cross product of two vectors (1 dimensional arrays).
Identity() Returns an identity matrix with the specified size.
Inverse() Returns the inverse of a matrix or number.
Calculus functions

To use the calculus functions, some knowledge of user-defined functions is necessary. See custom functions in the deep dive for more information.

Derivative() Returns the derivative of a function.
Integral() Returns the definite integral of a function, given start and end points.

Note that the Derivative() function returns a function that you can use for calculations.

Interpolation functions
Interpolate() Classic interpolation - returns a y value given an x value and pairs of x and y (x1, x2, y1, y2).
Interpolate2D() Returns a value given a column lookup value, row lookup value, and an array or table reference.
It is similar to VlookupInterpolate(), but it works in two dimensions.

Also note that VlookupInterpolate() is found in the Lookup library.

Logarithm functions
Log() Returns the logarithm of a number given the base.
Defaults to base 10 if none is specified.
Log10() Returns the base 10 logarithm of a number.
Ln() Returns the natural logarithm of a number (logarithm with base e).
Rounding functions
Round() Returns a value rounded to a specified number of digits.
RoundDown() Returns a value rounded down to a specified number of digits.
RoundUp() Returns a value rounded up to a specified number of digits.
RoundSigFigs() Returns a value rounded to the specified number of significant figures.
Is there a function you'd like to see here?

Please, let us know.