How to | Do Basic Calculations

Mathematica serves as a convenient and extensible environment for doing basic math. In addition to performing advanced calculations, Mathematica can also be used as a powerful calculator with arbitrary precision.

Add two numbers:

In[219]:=
Click for copyable input
Out[219]=

Subtract a number from another number:

In[220]:=
Click for copyable input
Out[220]=

Multiply two numbers by using or a space:

In[221]:=
Click for copyable input
Out[221]=

Spaces between numbers, variables, or function values are interpreted as multiplication. Mathematica automatically shows a space between numbers with a multiplication symbol:

In[222]:=
Click for copyable input
Out[222]=

Multiply two complex numbers:

In[223]:=
Click for copyable input
Out[223]=

Divide two numbers:

In[224]:=
Click for copyable input
Out[224]=

Mathematica follows the ordinary order of operations in algebraic calculations:

In[225]:=
Click for copyable input
Out[225]=

Compute the fifth power of 3:

In[226]:=
Click for copyable input
Out[226]=

Compute the square root of 25:

In[227]:=
Click for copyable input
Out[227]=
    

Mathematica displays the results of calculations using integers, rational numbers, or variables in exact form:

In[228]:=
Click for copyable input
Out[228]=

Use N to get numerical results:

In[229]:=
Click for copyable input
Out[229]=

Adding a decimal to any number forces a numerical result:

In[230]:=
Click for copyable input
Out[230]=

This shows 40 significant digits:

In[231]:=
Click for copyable input
Out[231]=
    

Approximate using N:

In[232]:=
Click for copyable input
Out[232]=

Get 50 decimal places:

In[233]:=
Click for copyable input
Out[233]=

Calculate 50 significant digits of :

In[234]:=
Click for copyable input
Out[234]=
    

A large collection of common and well-known functions is built into Mathematica.

Evaluate trigonometric functions:

In[235]:=
Click for copyable input
Out[235]=
In[236]:=
Click for copyable input
Out[236]=

Evaluate the natural logarithm of numbers:

In[237]:=
Click for copyable input
Out[237]=

Find the 125^(th) prime number:

In[238]:=
Click for copyable input
Out[238]=

Find the sum of the first billion positive integers:

In[239]:=
Click for copyable input
Out[239]=
    

Set a value to a variable by using :

In[240]:=
Click for copyable input
Out[240]=

Display the value of :

In[241]:=
Click for copyable input
Out[241]=

Use in a calculation:

In[242]:=
Click for copyable input
Out[242]=

Define a function :

In[243]:=
Click for copyable input

Evaluate the function:

In[244]:=
Click for copyable input
Out[244]=
New to Mathematica? Find your learning path »
Have a question? Ask support »