Today we are going to see how we can use Wolfram language as a calculator in the Notebook environment.

Doing most arithmetic in Wolfram language is as easy as just typing the expression you want to calculate.

In[]:=

2+3

Out[]=

5

In[]:=

45*3

Out[]=

135

In most cases Wolfram language will hold your results in fractional form

In[]:=

6/7

Out[]=

6

7

But you can always get your result in floating point if you want

In[]:=

N[6/7]

Out[]=

0.857143

If you need constants like Pi they are always available

In[]:=

Pi

Out[]=

π

We can also get the numerical value if we are interested.

In[]:=

N[Pi]

Out[]=

3.14159

Let’s increase the precision to 50 decimal places

In[]:=

N[Pi,50]

Out[]=

3.1415926535897932384626433832795028841971693993751

You could use the Greek π symbol in your own programs by typing the ESC key followed by pi and another ESC key.

π

The area of a Circle is given by

π

2

r

Using rule replacement we can fill in a value for r . The rule replacement starts after the /. symbol on the right. the arrow is made by pressing minus - followed by greater than > on your keyboard.

In[]:=

π/.r3

2

r

Out[]=

9π

Numerically

In[]:=

N[π/.r3]

2

r

Out[]=

28.2743

## Exercises

Exercises

1. Use the notebook environment to do some calculation of your own.

2. Edit the last line of code so that you calculate the area of the circle of radius 5 or any other number you want.