Mathematics 161                                  Laboratory 2                             September 10, 1992
	  
Name: _____________________________   Lab Partner: ___________________________
	  
Consulted with:  ____________________________________________________________

© Lafayette College, 1994

Comparing Graphs of Functions

Part 1:  Defining functions

The Basics

To define a function f(x) = <transformation rule> in Mathematica, type

f[x_] := <transformation rule>.

Notice the underline after the x in f[x_]; it indicates that x represents the input to the function.  Omitting the underline results in defining an expression, not a function.  Try h[x] := x^2 and then h[x], h[3], and h[t].  Just like the “built-in” functions we have seen (Sqrt, Solve, Plot), your function should enclose its arguments in brackets, not parentheses.  The colon-equals (:=) is yet another “equals sign” that indicates what follows is a transformation rule.  We use it to define functions.

An example

Define the functions f(x) = sin x and g(x) = cosπx in Mathematica as follows:

f[x_] := Sin[x]
g[x_] := Cos[Pi x]

Notice that the abbreviations for trig functions are capitalized in Mathematica.  Don’t forget the underlines or the square brackets.  Mathematica uses Pi to represent π.

Use these definitions to check the value of these functions for various inputs.  Compare the the inputs given below with a table of trig functions like that on your handout.

Input                        Output                      Trig function evaluated

f[Pi/2]      _______        ____________

f[90.0]      _______        ____________  (the decimal point
                                                                                                                 is important!)
g[1]         _______        ____________

g[t]         _______        ____________

g[g[0] + 1]  _______        ____________

Does Mathematica use radians or degrees to measure angles?

Part 2:  Periodicity

A function f is said to be periodic with period p if f(x + p) = f(x) for any input x in its domain.  The command Plot[g[x], {x, -4, 4}] will graph the function g over the interval (–4, 4).  Use a similar command to generate a graph of f (defined in part 1) over (–4π, 4π).  Based on their graphs, what are the periods of these functions?

Compare the graphs of the functions below.  Recall from last time, you can generate a plot of the graphs of two functions at once using the Plot command:

Plot[{f1[x], f2[x]}, {x, xmin, xmax},
     PlotStyle->{Red, Blue}].

This command plots the graph of function f1 in red and f2 in blue over the x-interval (xmin,xmax).  (Substitute the functions you want to graph for f1[x] and f2[x].)

Give a brief explanation of the relationship between the periods of these pairs of functions.  You cannot graph the last two pairs without assigning a a particular value.  What can be said in general?

Part 3: Shifted Graphs

Plot the graphs of the following pairs of functions together.  How are the periods of these functions related?  How are the graphs of each pair related?  Based on what you find, try to make a general statement, similar to items 4) and 5) in part 2.

My general statement is:

Part 4: Graphs of Product Functions

Consider the graph of the product function p below.  What simpler factors form the product?

Explain briefly (two or three sentences) how the graph of p related to those of its factors. (Recall that Mathematica's name for square root is Sqrt[x].)  Include copies of any graphs that help you explain your answer; plots with graphs of two—or even three—functions may be appropriate.

Part 5:  Graphs of Quotient Functions

Write a short essay describing the function q(x) shown below.  What properties does it have?  How is it related to the functions 1/x and sin x ?  Are there points that are difficult to explain or compare?  Give your answer on a separate sheet of paper.  Attach any printouts which help you to explain your conclusions.