Practicing Mathematica Basics

Shift + Enter

For Mathematica to execute a command that you type in, you must press Shift + Enter, not just Enter.  Place your cursor at the end of the line below, and press Shift + Enter to perform the calculation.

4032/7

Numerical Approximation

Now try calculating 4032/20 by pressing Shift + Enter.

4032/20

Since 20 does not divide 4032 evenly, Mathematica reduces the fraction, but does not give a decimal approximation.  To get a decimal approximation, we need to use another command:

N[4032/20]

Parentheses

As you probably know from using graphing calculators, appropriate use of parenthesis is important for telling the computer which operations you want to be performed first.  Suppose I want to calculate ((5+(Sqrt[2]))/3).  Correct the following command, and then use the N command to obtain a numerical approximation.

5+Sqrt[2]/3

Built-in Functions and Constants

All built-in functions in Mathematica, like the N command and the Sqrt command in the examples above, start with a capital letter.  All built-in constants like ℼ and e also need to be capitalized; otherwise Mathematica will treat them like variables.  Correct the following command to find a numerical approximation for (π/12).

N[pi/12]

As you may have noticed, all functions in Mathematica use square brackets for inputs.  Correct the following command to find the exact value of sin((π/12)).

sin(pi/12)

The absolute value command is Abs.  Correct the following command to find the a numerical approximation of (Sqrt[|7-(4^3)|]).

Sqrt(Abs(7-4^3))

Lists and Ranges

Mathematica uses curly braces to denote lists and ranges.  For example, curly braces denote the x-range in the Plot command.  To plot sin(x) from [-π, π], use the following command:

Plot[Sin[x], {x, -Pi, Pi}]

To plot two functions at once, you will need to give the Plot command a list of functions.  Use curly braces to denote the list of functions to plot.

Plot[{Sin[x], Cos[x]}, {x, -Pi, Pi}]

Help Resources

The Basic Math Assistant (under Palettes on the main menu) allows you to run Mathematica code without typing in the commands yourself.  It is more like punching keys on a calculator.

You can enter a command in free-form input by typing an equals sign, followed by whatever you want Mathematica to try to do.  An orange equals sign will show up, and then Mathematica will send your query to WolframAlpha.  You need to have an internet connection for this to work.

Under the Help menu, select Documentation Center, and type in your question to the search bar.  The help documentation explains how to use all of Mathematica’s built-in functions and has lots of helpful examples.