code
16px-Pencil

In programming languages mathematical functions compute values of "functions" as defined in the science of mathematics. While functions in programming languages are subroutines that return values given certain parameters, functions in mathematics are defined as relations between elements in a definition set Df, and elements in a value set Dv, such that

f: x --> y, where x belongs to Df and y to Dv,

for each x there must be exactly one y, and this y must be the same whenever f is called. This can also be expressed in the more recognizable

f(x) = y,

a pattern that programming languages have borrowed since the old days of the FORTRAN programming language. In most programming languages there is no requirement that f shall produce the same return value (same as the value y from the value set Dv) irrespectively of when the function is called, but instead the "function" may remember a state, and produce another value next time it is called.

Mathematical functions of programming languages adhere to the mathematical same-return-value-each-time rule of mathematical functions. The most often used ones produce one floating point return value from one or sometimes two floating point arguments. The most common mathematical functions regard square roots, logarithms, exponentials and trigonometry.

In general

In general programming languages use to provide a minimal set of mathematical functions that are fit for the most mathematical purposes, although now and then with some shortcomings as regards to number precision.

For some mathematically oriented programming languages, there are also complex versions, computing from complex value numbers and returning complex value return values.

sign and division functions

Sign and division functions use to take floating point values and return floating point values. There are often similar functions ranging over integer values, that are inbuilt in the programming language itself.

The following use to be available:

logarithms and exponentials

Logarithms and exponentials take floating point values and return floating point values.

The common set of functions for powers and exponentials use to be

Constant:

trigonometry

Trigonometric functions take floating point values and return floating point values.

Normally the following functions are represented in most programming languages:

And their constant pi:

Specific programming languages

ActionScript

ActionScript has about the same mathematical functions as Java has.

C

Main article: Mathematical functions in C

C mathematical functions are included by perusing the math.h heading:

#include <math.h>

In the linking process one links in the library libm.so, such as by the call

cc -o program program.c -lm

By all C standards, the library libm.so resides in the global C library, so that no -L option is ever needed to link it in. For the need of a static math library linked in, the compilation should instead be

cc -o program program.c /usr/lib/libm.a

or instead of /usr/lib/, wherever your operating system store the C libraries.

Groovy

Many math functions can be called directly as a method of particular objects.

Number classes

Collections

Java

Python

Functions

Constants

note: there are more functions than what is listed at the link below

See also