Sqrt()

From TinyMUX
Jump to: navigation, search

Description

FUNCTION: 20px-Function.png sqrt(number)

Returns the square root of number. number may be a floating point number, and a floating point result is returned. number may not be negative.

PennMUSH also offers root(), to take an arbitrary root of a number. On MUX, you can instead use the following formula to find the nth root of x (In plain LaTeX, since this wiki isn't configured to typeset it if it was in a <math> block):

r = e^{\frac{\log x}{n}}

Or, in softcode:

exp(fdiv(log(x), n))


Related Topics: power().

Examples

> say sqrt(2)
You say "1.414214"
> say sqrt(100)
You say "10"
> say sqrt(0)
You say "0"
> say sqrt(-1)
You say "Ind"


(--Soylent 01:55, 3 December 2005 (EST))