Starting Out: Elementary Arithmetic

As a first example of how the Wolfram Language operates, let’s look at elementary arithmetic.

2+2

1234+5678

1234*5678

Compute 1+2+3. »

Add the numbers 1, 2, 3, 4, 5. »

Multiply the numbers 1, 2, 3, 4, 5. »

Compute 5 squared (i.e. 5×5 or 5 raised to the power 2). »

Compute 3 raised to the fourth power. »

Compute 10 raised to the power 12 (a trillion). »

Compute 3 raised to the power 7×8. »

Add parentheses to 4-2*3+4 to make 14. »

Compute twenty-nine thousand multiplied by seventy-three. »

Add all integers from -3 to +3.  »

Compute 24 divided by 3. »

Compute 5 raised to the power 100. »

Subtract 5 squared from 100. »

Multiply 6 by 5 squared, and add 7. »

Compute 3 squared minus 2 cubed.  »

Compute 2 cubed times 3 squared. »

Compute “double the sum of eight and negative eleven”. »

In 2+2, etc. how do I tell the Wolfram Language that I’ve finished my input?

On a computer, press (Key1[shift, return]). On a mobile device, press the  button. See Practicalities of Using the Wolfram Language for more details.

Why is multiplication indicated by *?

Because the * (“star”, typically typed as (Key1[shift, 8])) looks like a multiplication sign. In the Wolfram Language, you can also just put a space between numbers you want to multiply; the Wolfram Language will then automatically insert a × multiplication sign.

What does “raised to the power” (^) mean?

6^3 means 6×6×6 (i.e. 6 multiplied by itself 3 times); 10^5 means 10×10×10×10×10; etc.

How big can numbers get in the Wolfram Language?

As big as you want—so long as they fit in your computer’s memory.

What is the order of operations in the Wolfram Language?

The same as in ordinary math: powers, multiplication, addition. So 4*5^2+7 means (4*(5^2))+7. You can use parentheses just like in math. (In math, people sometimes use [...] as well as (...). In the Wolfram Language [...] means something different.)

When I do division, how do I avoid getting fractions in my answer?

If you put in numbers with decimal points, you’ll get out numbers with decimal points. You can also use N, as we discuss in Section 23.

What are the little spaces between digits in results like 7 006 652?

They’re there to help you read the number when it’s displayed; they’re not part of the number.

How do I enter a big number?

Just type the digits, without putting any commas, spaces or other separators (e.g. 1234123511415223).

What happens if I compute 1/0?

Try it!  You’ll get a symbolic representation of infinity, on which the Wolfram Language can then do further computations.