Quiz topics

Math 213 - Math with Mathematica
September 24, 2009

In this file we review the topics that you will need to know for the quiz on October 8, 2009.
It is especially important to understand what and how many data types (number, list, list of lists, True/False expression, etc.) each function requires as an input and gives as an output.

The quiz will consist of a list of questions to answer by either writing a few sentences or to write commands to solve.

First, some general Mathematica questions you should know the answers to:

How do you stop a calculation that is going forever?
How do you insert comments into your files?
How do you undefine a variable?
How do you learn more about a function?
How do you determine the numerical value of some expression, like Sqrt[10]+Log[2]?
How do you make it so that when you evaluate a cell, no output is generated?
What are the differences between (), [], and {}?

Lists

Commands you need to know:

Range, RotateLeft, RotateRight, First, Last, Rest, Drop, Table, TableForm.

Sample questions:

How would you create the list {1,4,7,10,13,16,19}?
Determine another way to find the first element of a list without using the First command.
What command(s) would you use to find the second entry of a list?  How about the last entry of a list?
What do the functions RotateLeft and RotateRight do?  What data structure is the input of each function, and what is the output?
Why is there an error message given when the following command is evaluated? First[First[{1, 2, 3, 4}]]
What do you expect when you evaluate Table[2^k,{k,1,10}]?
When would you use the TableForm function?

Variables and Functions

What you need to know:

You need know how to define a variable (=), define a function using either := or Function, know how to use Module when defining a complex function, and understand nesting of functions and the commands Nest and NestList.

Sample questions:

What will the output be when you enter the following command? Q[x_] := 4 x + 3
Define a function that finds the fifth entry of a list. 
Define the same function using the Function command.
What is the difference between Nest and Nestlist?
Why do you have to use the Module command when writing the following function?  And why are there semicolons in the function?

Survive[n_]:= Module[{b=1}, 
While[2b≤n,b=2b]; 
2(n-b)+1;]

Ifs and Loops

What you need to know:

You need to know the structure of the If statement, how to incorporate Q commands, how to use !=, ==, !, &&, and ||, and how to write a While loop that does what you want.  You will need to be able to use the Mod command as well.

Sample questions:

Use a function that incorporates an If statement that does the following: It prints out ``Yes'' if the input is a multiple of 2, prints out ``Maybe'' if the input is one more than a multiple of 2.
What will each of the following statements evaluate to if vv=4?  What about vv={10}?  What about vv=12?  Explain why.

If[vv==4&&vv==10,100,1000]
If[vv==4||vv==10,100,1000]
If[!vv==10,100,1000]

How will the following statement evaluate, and why?

xx=2;
While[MemberQ[Range[10],xx],xx=xx-1]
xx

Write a while loop that cycles through the first 100 prime numbers and prints out the prime number if it is one less than a multiple of four.

Plotting

What you need to know:

How to plot a list, how to plot a function, how to incorporate two plots together.
You do not need to know how to use the Fit command.

Sample questions:

Plot the following data and function on the same axes where the x-axis goes from -1 to 12 and the y-axis goes from -10 to 100:

TBL=Table[{x,(x+Log[1/x])^2},{x,1,10}];
FCN=x^2;

Say something about how far apart the data points are from the function value.  A plot incorporating the difference between the TBL points and the FCN function may help your discussion.

Which of the following expressions will evaluate correctly, and why?
ListPlot[Table[{n, survivor[n]}, {n, 4, 100}]]
ListPlot[Table[{n, First[survivor[n]]}, (n, 4, 100)]]
ListPlot[Table[{n, First[survivor[n]]}, {n, 4, 100}]] 
ListPlot[Table[{n, First[survivor[n]]}, {n, 4, 100}]//TableForm]

Manipulate

What you need to know:

How to write a simple Manipulate command.

Sample questions:

Write a Manipulate command which plots the functions with integer powers starting with y=x, y=x^2, y=x^3, up through y=x^10.