The  Map  command

Math 213 - Math with Mathematica
Christopher Hanusa

Overview

In this tutorial, we learn how to use the Map command
We will visit a few useful resources along the way, which are useful for more than just learning about functions.

Key Command: Map

An extremely important command is the Map command.  What Map[function,list] does is to take the function and evaluates the function at each entry of the list individually and returns the results in a list. For example, if you want to know the values of Sin[x] for multiples of Pi/6, you can Map the Sin function onto the desired list.

piList=Range[0,2Pi,Pi/6]

Map[Sin,piList]

More generically, if your list is {e1,e2,e3} and your function is fcn, then Map will return a list with f evaluated at each entry:

Map[fcn,{e1,e2,e3}]

Ask for help to see the syntax:

?Map

The shorthand for Map is /@ (slash-at).

fcn/@{e1,e2,e3}

Wolfram’s “Elementary Introduction”

A tutorial that goes at a leisurely and in-depth pace is Wolfram’s new “An elementary introduction to the Wolfram Language”.  Read through the section on “Ways to Apply Functions” here: http://www.wolfram.com/language/elementary-introduction/25-ways-to-apply-functions.html

Concept Check

1. Explain the difference in the outputs between Framed @ {x,y,z} and Framed /@ {x,y,z}.

2. Complete Exercise 25.2 from that webpage.

3. Complete Exercise 25.9 from that webpage.

Hint 1. (Open to see.)

Use the command Characters.

Hint 2. (Open to see.)

You may be running into issues if the input to Characters is not a String.

Hint 3. (Open to see.)

4. Use the function Prime, Map, and Range commands to generate a list of the 100th, 200th, ... 1000th prime numbers.

5. Use a Table command to create a list of 10 to 100 points that lie in the range [0,100]x[0,100].  Then use the Map command to Apply the function Disk to them.  Lastly, Wrap this whole list in a Graphics command, and you will see your points displayed.