How to | Do Basic Calculations

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

Add two numbers:

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

Subtract a number from another number:

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

Multiply two numbers by using or a space:

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

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

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

Multiply two complex numbers:

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

Divide two numbers:

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

The Wolfram Language follows the ordinary order of operations in algebraic calculations:

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

Compute the fifth power of 3:

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

Compute the square root of 25:

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

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

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

Use N to get numerical results:

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

Adding a decimal to any number forces a numerical result:

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

This shows 40 significant digits:

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

Approximate using N:

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

Get 50 decimal places:

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

Calculate 50 significant digits of :

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

A large collection of common and well-known functions is built into the Wolfram Language.

Evaluate trigonometric functions:

In[1]:=
Click for copyable input
Out[1]=
In[2]:=
Click for copyable input
Out[2]=

Evaluate the natural logarithm of numbers:

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

Find the 125^(th) prime number:

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

Find the sum of the first billion positive integers:

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

Set a value to a variable by using :

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

Display the value of :

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

Use in a calculation:

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

Define a function :

In[4]:=
Click for copyable input

Evaluate the function:

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