Skip to content
Dave DeLong edited this page Nov 12, 2011 · 3 revisions

In addition to the functions defined by the built-in operators, the following functions are available:

Functions that take > 1 parameter

  • sum() - returns a sum of the passed parameters
  • count() - returns the number of passed parameters
  • min() - returns the minimum of the passed parameters
  • max() - returns the maximum of the passed parameters
  • median() - returns the median of the passed parameters
  • stddev() - returns the standard deviation of the passed parameters
  • average() - returns the average of the passed parameters
  • random() - returns a random integer. Can take 0, 1, or 2 parameters. The first parameter (if given) is the lower bound of the random integer. The second parameter (if given) is the upper bound of the random integer.
  • nthroot() - returns the nth root of a number. For example, nthroot(27,3) returns the cube root of 27, or 3.

Functions that take 1 parameter:

  • sqrt() - returns the square root of the passed parameter

  • log() - returns the base 10 log of the passed parameter

  • ln() - returns the base e log of the passed parameter

  • log2() - returns the base 2 log of the passed parameter

  • exp() - returns e raised to the power of the passed parameter

  • ceil() - returns the passed parameter rounded up

  • floor() - returns the passed parameter rounded down

  • The trigonometric functions:

  • sin(), cos(), tan()

  • Their inverses (asin, acos, atan)

  • Their reciprocals (csc, sec, cotan)

  • The reciprocals of the inverses (acsc, asec, acotan)

  • The hyperbolic variations of all the above functions (sinh, cosh, tanh, asinh, acosh, atanh, csch, sech, cotanh, acsch, asech, acotanh)

  • The versine functions (versin, vercosin, coversin, covercosin, haversin, havercosin, hacoversin, hacovercosin, exsec, excsc, crd)

  • dtor() - converts the passed parameter from degrees to radians

  • rtod() - converts the passed parameter from radians to degrees

Functions that take no parameters ("constant functions"):

  • phi() - returns the value of ϕ (the Golden Ratio). Also recognized as ϕ()
  • pi() - returns the value of π. Also recognized as π()
  • pi_2() - returns the value of π/2
  • pi_4() - returns the value of π/4
  • tau() - returns the value of τ. Also recognized as τ()
  • sqrt2() - returns the value of the square root of 2
  • e() - returns the value of e
  • log2e() - returns the value of the log base 2 of e
  • log10e() - returns the value of the log base 10 of e
  • ln2() - returns the value of the log base e of 2
  • ln10() - returns the value of the log base e of 10

Aliases

Functions can also have aliases. For example, the following are equivalent:

average(1,2,3)
avg(1,2,3)
mean(1,2,3)

You can create your own aliases as well. If "hacoversin" is too long to type for you, feel free to do:

[[DDMathEvaluator sharedMathEvaluator] addAlias:@"hcvs" forFunctionName:@"hacoversin"];