Numerical calculations

The simplest way to work with Mathematica is to use it as a super calculator, capable of performing exact and approximate numerical calculation to any degree of precision required by the user.

Calculations on integers

Calculations on integer and rational numbers are always exact and complete, unlike what happens in common pocket calculators that, with rational numbers or with very large integers, inevitably show a limited number of digits.

Operators on integers
Prime[n]computes the n-th prime numberPrime[10]
PrimeQ[n]checks if n is a prime numberPrimeQ[1234567]
Divisors[n]gives the list of the divisors of nDivisors[1234567]
FactorInteger[n]gives the list of the prime factors of the integer n, together with their exponentsFactorInteger[1234567]
Quotient[m,n]calculates how many times n is contained in mQuotient[100,7]
Mod[m,n]gives the remainder on division of m by nMod[100,7]
GCD[i,j,k,m,n,...]gives the Greatest Common Divisor of the integers within the listGCD[30,120,45]
LCM[i,j,k,m,n,...]gives the Least Common Multiple of the integers within the listLCM[30,120,45]
Factorial[n]computes the factorial of n; n! is the sameFactorial[10]; 10!
Factorial2[n]computes the double factorial of n; n!! is the sameFactorial2[10]; 10!!
Binomial[n,k]calculates the binomial coefficient (nk)Binomial[10,4]
Fibonacci[n]computes the n-th Fibonacci numberFibonacci[50]
BaseForm[n,b]shows the numbers n given in base bBaseForm[1024,2]


The factorial of 100: 100!



The Greatest Common Divisor of 123456,234567,345678: GCD[123456,234567,345678]



The operator Table allows us to generate lists of objects.

Table requires at least two arguments: a function of one or more variables and one or more lists whose first element is a variable that can be followed or by the last value assumable (the first is the default 1) or by the first and last values assumed. In this way, the variable (for example n which in this case is a simple counter) is incremented by one unit at each step.


The first 20 prime numbers: Table[Prime[n],{n,1,20}]



The outcome of the operator Table can be modulated by the operator MatrixForm that formats the output on multiple lines in columns.

Example: the Pythagorean table.


Example: the Pascal's triangle.



In this last example, we used the function If that requires three arguments: a condition, the value if the condition is true, the value if the condition is false.

WolframAlpha: If


Calculations on rational numbers

In general, when we perform operations on whole numbers and fractions, we obtain fractions reduced to lowest terms.

Numerator and Denominator give the numerator or the denominator of a fraction.


WolframAlpha: Sum of fractions

WolframAlpha: Numerator

WolframAlpha: Denominator

11 terms of an arithmetic progression with first term 1/2 and common difference 1/3. WolframAlpha: Arithmetic progression

11 terms of a geometric progression with first term 1/2 and common ratio 1/3. WolframAlpha: Geometric progression


Calculations on real and complex numbers and functions of real or complex variable.

Even in calculations on real and complex numbers Mathematica tries to provide, if possible, mathematically exact results.

For example, if we write


we get




The most common constant
Pithe greek piPi/2; Sin[2Pi/3]
Ethe Euler's numberE^x; Log[Sqrt[E]]
GoldenRatiothe number Eqn001.gif1/GoldenRatio
Degreea sexagesimal degree in radiansSin[60 Degree]
Ithe imaginary unit(1+I)^2; Abs[3+4I]


The most common functions
Abs[z]absolute valueAbs[3+4I]
Sqrt[z]square rootSqrt[2]; Sqrt[1+I]
Exp[z]natural exponential function (also E^z)Exp[2]; E^2
Log[z]natural logarithmLog[E^2]
Log[b,z]logarithm to the base bLog[2,8]
Sin[z]circular sineSin[Pi/6]
Cos[z]circular cosineCos[Pi/6]
Tan[z]circular tangentTan[Pi/4]
ArcSin[z]circular arcsineArcSin[1/2]
ArcCos[z]circular arccosineArcCos[1/2]
ArcTan[z]circular arctangentArcTan[Sqrt[3]]
Sinh[z]hyperbolic sineSinh[1]
Cosh[z]hyperbolic cosineCosh[1]
Tanh[z]hyperbolic tangentTanh[1]
ArcSinh[z]hyperbolic arcsineArcSinh[1]
ArcCosh[z]hyperbolic arccosineArcCosh[1/2]
ArcTanh[z]hyperbolic arctangentArcTanh[2]





The arguments of the trigonometric functions are always in radians.

If we want the argument in degrees we must multiplicate the argument by the constant Degree.


Other examples.

WolframAlpha: Sin(rad)

WolframAlpha: Sin(deg)

WolframAlpha: ArcTan