1 Mathematica Basics

The following commands are typed into this notebook so that you can evaluate them as you read the corresponding explanation about them in our textbook for the course titled "CalcLabs with Mathematica,"  Sixth Edition (for Version 6.0), by Selwyn Hollis.  To evalulate any one of the expressions, place the cursor in the expression (or mark the corresponding bracket at the far right) and press the right Enter key.  (Instead of pressing the right Enter key, you can press the left Enter key and one of the two  Shift  keys at the same time.)   By itself, the left  Enter key is merely used as one would employ a carrage return for a typewriter to place the cursor on the next line.

At this point, the main thing to learn during this first sesssion in the laboratory is how to type each of the input items (in the textbook's form or in some equivalent form used here).

The Documentation Center can be explored later.

1.1  Getting Started

Basic Calculations    (page 4)

217 5713

321*5.479

2x

3(2+3)2

a=17/13+211/93;
b=23 a; c = (a+b)/51

3/17+1/5

%^2

25!
	%/(3! 22!)
%*.1^3 .9^22

To understand what the % signs stand for in the preceding evaluation, we consider the following.

25!
	a =%; a/(3!*22!)
b=%; c= %*.1^3*.9^22; {a,b,c}

So the % sign in each instance stands for the most recently  evaluated expression.

Parentheses, Brackets, and Braces   (page 5)

x(x+2)^2

Cos[π/3]        (* π can be obtained by clicking that symbol in the BasicInput Palette---e.g., if this palette is not displayed, successively click on:   Palettes,   BasicMathInput  
 --------------------  or as: Escape  p  Esc  --------------------  *)

The preceding comment within  the  (*   *) combination can be written more 
neatly as text such as this  by successively clicking on  "Text"   (rather that "Input" or etc.)    in the upper left portion of the menue for this page.  Or, by typing the sentence, then marking the right bracket, and then successively clicking on  "Text " in the mentioned menu item.  
Actualy,   π   is obtained from a palette's representation for  Pi.   The text size can also be enlarged (by going to  "Format", "Size."

Cos[Pi/3]

{1,2,3,4}

{Sin[π],  Sin[Pi]}

{0,0, Sin(π), Sin(Pi)}

[x+y(1-y)]^2                           (* Copied to illustrate an error.*)

(1,2)                                               (* Copied to illustrate an error.*)

Sin(π)                                            (* Copied to illustrate an error.*)

{ Sin[π], Sin[Pi] }

Symbolic vs. Numerical Computation          (typed as a subsection)

123/(Sqrt[768])          (* typed as  123,  then (Sqrt[\[Placeholder]]) from the InputPalette, 
		           then fill in the square with 768 *)

One should not think that the Palettes are ever absolutely necessary.  They are merely a convenience in various situation.  For example, in a course dealing with matrices, the input palette for a 2 × 2 matrix  can be extended  (with   Contrtol+Enter   and  Control+Comma)  to a palette for matrices of larger numbers of rows and columns (if necessary) into which the components can then be conveniently typed with the aid of the TAB  key.

{123/(Sqrt[768]), 123/Sqrt[768]}

N[{ 123/(Sqrt[768]), 123/Sqrt[768]}]

{123./(Sqrt[768]), 123./Sqrt[768]}    (*  The palettes do not always make the typing easier.  I would prefer to simply type Sqrt[768] rather than use the palette here.*)

Sin[2]

Cos[(π/12)]

{Cos[(π/12)],   Cos[Pi/12]}

Log[2]

{Log[2],  N[Log[2]],  Log[2]//N,  N[ Log[2],15]}

Names and Capitalization; Basic Functions     (page 7)

To obtain the following input statement, we type   Sin[  , then click (□/□) from the BasicMathInput Palette,  then click  π  from the BasicMathInput palette (while the cursor is in the upper square of (□/□), then put the clursor in the lower  square (e.g., either by pressing the  TAB  key or by using the left mouse button), then type  ].

Sin[(π/3)]

Personally, I would prefer to simply type  Sin[Pi/3].

{Sin[(π/3)], Sin[Pi/3]}

{Cos[(π/3)], Cos[Pi/3]}

{Log[2],  N[ Log[2] ],    E^Log[2],   N[ E ],  N[ E, 25 ]}

Names and Capitalization; Basic Functions    (page 7)

{ Sin[(π/3)],  Sin[Pi/3], N[ Sin[Pi/3] ],  N[ Sin[Pi/3], 30 ] }

PrimeQ[22801763489]

In the preceding   Q   stands for question; and the preceding question is: "Is 22801763489  a prime number?"
	The answer  True  means  "Yes, 22801763489 is a prime number."

Solve[ x^2+x-12==0, x]

Equations are written with two equality signs to distinguish them from the use of  =  in assignments  as the previous assignment    a = 17/13+2ll/93  on page 4.   
When asssignments are no longer needed, they should be cleared.

{a= 17/13+211/93, Clear[a], a, area = 4.42*7.98, Clear[area], area}

FullForm[x+7]

FullForm[x==x^2]

{ Sin[(π/12)], Sin[Pi/12], ArcTan[1], ArcCos[1/2], Log[E]}

Algebraic Manipulalltion     (page 9)

Expand[ (x+5)^3 (2x-1)^2]

Factor[ x^3 + 2x^2-5x-6 ]

{ Together[ x +(2/((x^2)+1))],  Together[ x + (2/(x^2+1))]}

{ Apart[ (x/((x^2)+3x+2))],  Apart[x/(x^2+3x+2)]}

x(3-x)-5(x^2)+(x-1)(2x+3)

Simplify[ x(3-x)-5(x^2)+(x-1)(2x+3)]

Expand[ x(3-x)-5(x^2)+(x-1)(2x+3) ]

Factor[ x(3-x)-5(x^2)+(x-1)(2x+3) ]

FullSimplify[ x(3-x)-5(x^2)+(x-1)(2x+3) ]

Plotting Graphs: An Introduction to Options

Plot[ Sin[ π x(3-x)], {x,0,3} ];

Here, a space is definitely needed between  π and  x. 
Due to the parentheses, a space is not needed between  x  and  (3-x)
 I would prefer to type

Plot[ Sin[ Pi*x(3-x)],{x,0,3}]

so that a mistake would not occur if the space were to be lost.

Plot[ Sin[ Pi*x(3-x)], {x,0,3}, Ticks->None, AxesLabel->{x,y}]

Plot[ Sin[x^2]/(1+x^2), {x,0,10}]

Plot[ Sin[x^2]/(1+x^2), {x,0,10}, PlotRange->All]

Plot[ Sqrt[(1-x^2)], {x,-1,1}, AspectRatio->Automatic]

Plot[ { (Sqrt[1-x^2]) , -(Sqrt[1-x^2]) }, {x,-1,1},AspectRatio->Automatic]

Plot[ {x*Exp[-x/2]*Cos[Pi*x], x*Exp[-x/2]*Sin[Pi*x]}, {x,0,12}]

In the expression

{ E,  (E^2), N[E,15], N[(E^2),8], Exp[1],Exp[2], N[ Exp[1], 9], N[Exp[2],7] }

the  e  is obtained from the BasicMathInput  Palette as the second character in the row   π  e  i  ∞  ° .  
note the evaluation of

{ I, (I^2), (I^3), (I^4), I, I^2, I^3, I^4,  (E^(π I)) , Exp[ Pi*I] }

Plot[ { (x^(1/3)), x, (x^3)}, {x,0,2}, PlotRange->{0,1.6},
PlotStyle->{{Dashing[{.02}]},{},{Thickness[.007], GrayLevel[.7]}}];

Variables    (page   10)

piSixths=N[Pi/6]

Clear[piSixths]; piSixths

radius :=  (Sqrt[10./π])

radius

graph := Plot[ x (Sqrt[1-(x^2)]),{x,-1,1}]

graph

graph = Plot[ x (Sqrt[1-(x^2)]),{x,-1,1}]

Tips and Shortcuts

This is too specialized for most of us to be concerned about.   
Simply, use a suitable palette or learn the full command..

Exercises on page 13.
Look at  Exercises   1,  2,  3,  4,  5,  and 6.

In Problem 4,  the value of the integrand at x = 0 does not seem to give difficulty in the following evalualtion.

Plot[ Sin[x^3]/x^3, {x,0,1},PlotRange->All,AspectRatio->Automatic]

However, if we define

f[x_] = Sin[x^3]/x^3

without restriction and then ask for

f[0]

Mathematica points out that  f[0]  is not defined.  Since we have

Limit[ Sin[x^3]/x^3, x->0]

the intended function  f   on the interval  [0, 1]  can be defined as follows.

Clear[f]
f[x_] := Sin[x^3]/x^3 /;  (x > 0)&&(x<=1)
f[x_] := 1  /;  x==0
(*  Or, simply  f[0] = 1  *)

{f[0], f[.2], f[.5], f[.9], f[1.],f[13.], f[-7.]}

The preceding is a better example (than ones given later) where delayed evaluation 
                                             (       i.e.,    :=   rather than    =     )
of the function is needed.  Namely, for any x, MATHEMATICA must first check to see whether the condition x is both greater than zero and either less than or equal to 1 before it can evaluate f[x] as  Sin[x^3/x^3].

Plot[ f[x], {x,0,1},PlotRange->All,AspectRatio->Automatic]

Clear[f]

1.2 Functions   (page 14)

Defining Functions

f[x_] := x^3 - 2*x

f[3]

Plot[ f[x],{x,-2,2}]

g[x_,y_,z_] := x+y+z

g[1,2,3]

In the preceding definitions, the delayed evaluation is not needed because the definitions have meaning without conditions later being imposed on them.   So the definitions could have used   =  (Set) in place of   :=  (SetDelayed).

Clear[f,g]; f[x_] := (∂_x) ((x+1)Cos[x])

The symbol  (∂_□) □  is the sixth entry in the BasicMathInput palette.  When this symbol is clicked with the left mouse button, it appears in your notebook where the cursor was located and the cursor now is in the lower left square.  Simply type   x  and then move the cursor to the other square (either by pressing the TAB key or by using the mouse) and then type the remaining expression.  	HOWEVER, THE PALETTE IS NOT NEEDED.  YOU COULD SIMPLY TYPE     f{x_} := D[(x+1)*Cos[x], x]

f[2]

However, the following does what one wants.

Clear[f,g]; 
f[x_] = (∂_x) ((x+1)Cos[x]);  
g[x_] = D[ (x + 1)*Cos[x], x];

{f[2],  g[2]}

It is important to use SetDelayed  (i.e.   :=  ) in those cases where the expression in the right-hand member depends on conditions to be satisfied as for the Piecewise-defined functions of pages 17--19  or depends on other expressions to be defined later.

plotSin[k_] := Plot[ Sin[k*x], {x,0, 2Pi}]

plotSin[2]

In the following input statement, the arrow appears in the  BasicMathInput  pallett.  It may also be entered as a hyphen  -  followed by a greater-than sign  >  (see the period key)  giving  ->

plotSin[k_] = Plot[ Sin[k*x], {x, 0, 2Pi}, PlotRange->All]

plotSin[2]

Applying Fuctions with @ and //

Clear[f]; f[x_] := x(x-1)

f[3]

The textbook has a misprint for the evaluation of the following input.

f@3

3//f

{ f[3], f@3, 3//f }

{  2x+x(5x+1)//Simplify,   2x+x(5x+1)//Factor }

{ (Sqrt[585])/33,  Sqrt[585]/33, N[ Sqrt[585]/33 ], Sqrt[585]/33 //N ,N[Sqrt[585]/33,43]}

Piecewise-defined Functions

The use of   /;  for conditional statements makes it easier to write and understand the subject here.

f[x_] :=  x  /;  x <= 1;

f[x_] := x-2  /;  x > 1;

Plot[ f[x], {x,-1,3}]

The preceding is a situation where delayed evaluation is necessary.  Namely, 
to know whether f[x] is x, Mathematica must decide if x satisfies the condition x <= 1.

Clear[f]; 
f[x_] := 1 /;      x<= -1;
f[x_] := -x /;   -1 < x <= 1;
f[x_] := -1 /;    x > 1;
Plot[f[x],{x,-3,3}]

Clear[f];
f[x_] = Piecewise[{{1,x≤-1},{-x,-1<x≤1},{-1,1<x}}]

GraphicsRow[
			{Plot[Abs[x], {x,-1,1}], Plot[Floor[x], {x,-2,3}],
			  Plot[Mod[x,1],{x,0,3}]} ]

GraphicsRow[{
			Plot[Abs[Cos[x]-.5],{x,0,4*Pi}],
			Plot[Abs[Abs[x]-1],{x,-3,3}]}]

GraphicsRow[{
			Plot[(-1)^Floor[x], {x,-2,3}],
				Plot[Sin[(Pi*Floor[6x]/6)],{x,0,2}] }]

GraphicsRow[ {
			Plot[Sin[Pi*Mod[x,1]/2],{x,0,3}],
			Plot[Abs[Mod[x,2]-1],{x,-4,4}]}]

Exercises on page 19.

Do Problems 1, 2, 3, 4, and 5.

1.3 Equations      (page 21)

{2*17 - 34==0,  3==4, x^2-4==0, 2x+x-2==3x+5-7, x^2-4==(x+2)(x-2)}

Solve[ 6x^3-23x^2+25x-6==0,x]

Solve[x^4-2x^3-x^2+6x-6==0, x]

Solve[Sqrt[x-1]+x==4+Sqrt[x+4],x]

Solve[2Sin[2x]==Cos[x]^2-1,x]

Solve[{x^2-y==1,-x+y==1},{x,y}]

Solve[x^5-10x^2+5x+1==0,x]

NSolve[x^5-10x^2+5x+1==0,x]

{ I^2,   I ^2    (* from BasicMathInput Palette *), I - I   }

(*  "Escape  i  Escape"  merely gives the greek letter  ι  (iota)   *)

Solve[x^3-10x^2+5x+1==0,x]

NSolve[x^3-10x^2+5x+1==0,x]

Plot[x^2-Cos[x], {x,-5,5}]

Plot[{x^2, Cos[x]}, {x,0,1}]

FindRoot[x^2==Cos[x],{x,.75}]

Exercises on page 23.

Look at Problems 1, 2, 3, 4, 5, 7, 8, 9.

1.4  Lists

Listable Functions

Cos[ {0, Pi/4, Pi/2,3*Pi/4,Pi} ]

{ Cos[0],Cos[Pi/4], Cos[Pi/2], Cos[3*Pi/4], Cos[Pi] }

Sqrt[ {1, 4, 9, 16, 25} ]

{1,2,3,4,5,6,7,8,9}^2

Sqrt[ {{{2,3}, {4,5}}, {{6,7},{8,9}}}]

1/{1,2,3,4,5}

{1,2,3}+{4,5,6}

{1,2,3}*{4,5,6}

2^{0,1,2,3,4,5,6,7,8,9,10}

Cos[ {0,Pi/4, Pi/2, 3Pi/4,Pi}]

{ Pi, π (*  from  Basic MathInput Palette  *),  π   (*  as "Excape p Escape" *), Pi - π}

Cos[ { Pi, π (*  from  Basic MathInput Palette  *),  π   (*  as "Excape p Escape" *), Pi - π} ]

The Parts of a List

alist = {2,x,y,{a,b}}

Length[alist]

alist[[3]]

alist[[4]]

{  alist[[4]][[2]],  alist[[4,2]]  }

alist[[{1,3}]]

alist[[1;;3]]

First[alist]

Last[alist]

Creating Lists  (page  26--Here the Table command is the most useful.)

Range

Range[10]

Range[4.5,15.1]

Range[0,1,1/10]

Table

Table[k^2, {k,10}]

Table[k^2,{k,1,10}]

Table[k^2,{k,4,13}]

Table[ Sin[k*Pi*x],{k,1,4}]

Table[Table[i-j,{i,1,4}],{j,1,4}]

%//MatrixForm

h[i_,j_] = i-j;
Table[ h[i,j], {j,1,4},{i,1,4}] //MatrixForm

NestList   (page 27,   Mostly for specialized reference later.)

Clear[f,g,h]; 
f[x_] = 2x-1;
NestList[f,3,9]

NestList[f,1,9]

NestList[f,2,12]

Manipulating Lists  (page 27,  Mostly for specialized reference later.)

Flatten

Flatten[ { {1,2,3}, {a,b},{c},{6,7,6,5}}]

Flatten[{{1,2,3},{4,5}}]

Flatten[{{x,y},{3},{4,q}}]

Append and Prepend

Append[{1,2,3,4},13]

Prepend[{1,3,5,7},13]

Append[{1,2},3]

Prepend[{1,2},0]

Union and Join

Union[{1,4,2, a, c},{c,4,d,13},{4,a,b,d,13},{1,2,d}]

Join[{1,4,2, a, c},{c,4,d,13},{4,a,b,d,13},{1,2,d}]

a=4324/1209; b=99452/1209; c= 34592/20553;

Union[{a,2},{v,8},{h,s}]

Join[{a,2},{v,8},{h,s}]

Map and Apply    (page 27, not for immediate use)

points = Table[{2*i, 5-i},{i,1,8}]

addpairs[{x_,y_}] := x+y

Map[addpairs, points]

Map[ Flatten, {{3,{5,6}}, {a,{b,c}}}]

list1= {3,{5,6}};
list2 =  {a,{b,c}};

{Flatten[list1], Flatten[list2]}

So Map applies the operation Flatten to each of the two component lists of the original list.

Both  Map  and  Apply are rather specialized commands that can be looked up if a need arises.

Apply

vol[r_,h_] := Pi*r^2*h

measurements := {3.47,5.12}

Of course, we have

vol[3.47,5.12]

So, while this can be ignored for our uses, we continue here with page 28??Plus.

measurements[[1]]      (*the first part of measurements *)
measurements[[2]]      (*the second part of measurements *)

vol[measurements[[1]],measurements[[2]]]

Apply[vol, measurements]

The following is more interesting.

list3 = {2,5,8,12,13};
Apply[ Plus, list3]
Apply[Times, list3]
Clear[vol, measurements, list1,list2, list3,  addpairs, f,g,h]

??Plus

?Flat

?Apply

Flatten[{ {2,3},{2,1,3},{1,1,1}}]

Exercises   (page 28)

---------------------------------------------------------------------------

A Solution for Exercise 1 on page 28.

?Prime

Table[{n,Prime[n]}, {n,1,100}]//TableForm

--------------------------------------------------------------------

A Solution for Exercise 2 on page 28.

f[x_] := Sin[x]/x   /;  x=!=0        (*defined so long as s is not equal to 0  *)
{f[Pi/4], f[0]}

Table[f[.1*t], {t,1,10}]

list1 = Range[.1,1,.1]

Map[f, list1]

-----------------------------------------------------------------------------------------------------------------------------------------
A Solution for Exercise 3 on page 28.

(a)

Table[2*k-1,{k,1,50}]

(b)

Range[1,99,2]

h[x_] = x+2;
NestList[h,1,49]

------------------------------------------------------------------------------

A Solutlion for Exercise 4 on page 28.

(a)

Table[2^n,{n,0,20}]

(b)

list1 = Range[0,20,1]

2^list1

Clear[h]
h[x_] = 2*x;
NestList[h,1,20]

-------------------------------------------------------------------------------

A Solution for Exercise 5 on page 28.

Clear[f]
f[x_] = Sin[x];
Table[{t*Pi/12,f[t*Pi/12]}, {t,0,12}]

Clear[f,h,list1]
h[x_] = {x,Sin[x]};
list1 = Range[0, Pi,Pi/12];
Map[h,list1]

----------------------------------------------------------------------------

A Solution for Exercise 7 on page 28.

(a)

Clear[f,h,list1]
f[x_] = x^5-2x^2-3x+3;
Plot[f[x],{x,-3,3}];

guesses = {-1.23,.78,1.39}

(b)

getZero[guess_] := FindRoot[f[x], {x, guess}]
Map[ getZero, guesses]

1.5 Rules

soln = Solve[{x^2+x+y^2==2,2x-y==1}, {x,y}]

{x,y} /. soln

{x,y} /. Solve[{x^2+x+y^2==2,2x-y==1}, {x,y}]

Sqrt[x^2-x+1] /. x->3

x+y  /. y->x

x*y+y*z+x*z /. {x->a,y->b+c,z->5}

Exercise 1 of page 30. (Look at this only if you have time.  There are more important concerns.)

sinAdd := Sin[x_+y_]->Sin[x]*Cos[y]+Cos[x]*Sin[y]

Sin[3x+5y] /. sinAdd

Sin[t-ϕ] /. sinAdd

Sin[a+b+c] //. sinAdd

cosAdd = Cos[x_+y_] -> Cos[x]*Cos[y] - Sin[x]*Sin[y];

Cos[3x+5y] /. cosAdd

Cos[t-ϕ] /. cosAdd

Cos[a+b+c] //. cosAdd

Cos[a+b+c]//.{ cosAdd,sinAdd}

sinMult = Sin[n_Integer*x]-> Sin[(n-1)x+x] /.sinAdd;

{Sin[2x],Sin[3x]} //. sinMult

cosMult = Cos[n_Integer*x_]->Cos[(n-1)x + x] /.cosAdd;

{Cos[2x], Cos[3x]} //. cosMult

Sin[2x+y] //. {sinAdd,cosAdd,sinMult,cosMult}  //Expand
%//Simplify

trigExpand[expr_] := expr //. {sinAdd,cosAdd,sinMult,cosMult};

?trigExpand

?TrigExpand

Cos[x+2y]+ Sin[3x-y] //  trigExpand  
%//Simplify

or

trigExpand[ Cos[x+2y]+ Sin[3x-y] ]
Simplify[%]

Table[  {Sin[k*x], Sin[k*x]//trigExpand}, {k,1,5}]// TableForm

Table[  {Cos[k*x], Cos[k*x]//trigExpand}, {k,1,5}]// TableForm

Exercise 2 of page 30.

Clear[f,list1]
f[x_]  =+ x^5-4x^4+12x^2-9x+1

list1 = x /. NSolve[f[x]==0,x]

Apply[Plus, list1]

?Total

Total[list1]

Total[x /. NSolve[  x^5+3x^4+12x^2-9x+1 ==0, x ] ]

Total[  x /. NSolve[  x^5+1x^4+12x^2-9x+1 ==0, x ] ]

In terms of  a monic nth degree polylnomial  
    (X^n) + (Subscript[b, 1])(X^(n-1)) + (Subscript[b, 2]) (X^(n-2))+ ... + (Subscript[b, n])  =  (X- (Subscript[r, 1]))(X-(Subscript[r, 2]))... (X-(Subscript[r, n]))
we equate the coefficient of (X^(n-1)) in both members to obtain  (Subscript[b, 1]) = -(Subscript[r, 1])-(Subscript[r, 2]) - ...- (Subscript[r, n]).  
So the sum of the roots is equal to the negative of the coefficient of  (X^(n-1)).
and for n = 5  this is the negative of the coefficient of (X^4).

Apply[ Times, x /. NSolve[  x^5-4x^4+12x^2-9x+1 ==0, x ] ]

The preceding argument shows that:  by equating the coefficients of  (X^0) ,  we obtain 
                                       (-(Subscript[r, 1]))(-(Subscript[r, 2])) ... (-(Subscript[r, n])) =   (Subscript[b, n])
so that  (((-1))^n) times the product of the roots equals the constant term.  Thus, for n = 5, 
the product of the roots of a fifth degree monic polynomial equals the negative of the constant term 
(as the preceding computation suggests).
-------------------------------------------------------------------------------------------------------------------------------

Graphics Objects and Show  (of page 31)

graph1 = Plot[Sin[x]*Cos[10x], {x,0,2*Pi}]

graph2 = Plot[{Sin[x], -Sin[x]}, {x,0,2*Pi}]

Show[graph1, graph2];

Graphics Primatives (of page 32)

In particular,  Point, Line, Cirle, Disk, Rectangle, Polygon, and Text .

zigzag := Line[{{1,2},{1,1},{3,2},{2,2},{1,0},{3,1},{2,1},{2,0}}]

Graphics[zigzag]

shapes = {Rectangle[{-2,1},{0,2}], Circle[{1,1},1], Disk[{0,0}, .7], Text["rectangle", {-1.5,.8}], Text["disk", {-1,0}], Text["circle",{1.5,1.5}]};

Show[Graphics[shapes], AspectRatio->Automatic]

Graphics Directives

redRect={Red, Opacity[.67], Rectangle[{-1,1},{1,2}]};
thickCircle = {Thickness[.02], Opacity[.4], Green, Circle[{1,1},1]};
purpleDisk = {Purple, Opacity[.4], Disk[{0,1},.7]};
colorShapes = Graphics[{redRect, thickCircle, grayDisk}];
Graphics[{redRect, thickCircle, purpleDisk}]

Plot[x^2, {x,-1,1}, PlotStyle->{Thick, White},
	AxesStyle->Green, Background->GrayLevel[.5]]

Suppressing and Combining Graphics     (beginning on page 34)

curve = Plot[x^2, {x, -1.4, 1.4}, DisplayFunction->Identity];

circ = Graphics[ Circle[{0,.5},.5]];

Show[curve, circ,  AspectRatio->Automatic]

Graphics Array  (beginning on page 34)

segment = Graphics[Line[{{0,0}, {2,2}}]];
circ = Graphics[ Circle[{0,0},.5]];
parabola = Plot[x^2, {x,-1,1}, Axes->None];
rect = Graphics[{Gray, Rectangle[{0,0}, {1,1}]}];

GraphicsRow[{segment, circ, parabola,rect}]

GraphicsGrid[{{segment,circ},{parabola,rect}}]

Exercises    (Page 36.)
1.

GraphicsRow[Table[Graphics[{Thickness[t], Orange, Circle[]}],{t,.02,.1,.02}]]

GraphicsRow[Table[ Graphics[{PointSize[t], Point[{0,0}]}], {t,.1,1.1,.25}]]

GraphicsRow[ Table[ Graphics[{col, Disk[]}],{col, {Red, Blue, Green, Purple}}]]

?NestList

GraphicsRow[ Table[ Graphics[ {col, Disk[]}], {col, NestList[Lighter, Red, 3]}]]

GraphicsRow[ Table[ Graphics[{RGBColor[h, 0, 1-h], Disk[]}], {h, 0, 1,.1}]]

Graphics[ Table[ {Hue[RandomReal[]], Disk[{Cos[t], Sin[t]}, .25]}, {t,Pi/6,2Pi, Pi/6}]]

Animate and Manipulate      (beginning on page 36)

Table[ Plot[Sin[x - phi], {x,0,6Pi}, PlotRange->{ {0,6Pi}, {-1.1,1.1}}, AspectRatio->.2, Ticks->{Range[6] Pi, None}], {phi,0,2Pi}]

Animate[ Plot[Sin[x - phi], {x,0,6Pi}, PlotRange->{ {0,6Pi}, {-1.1,1.1}}, AspectRatio->.2, Ticks->{Range[6] Pi, None}], {phi,0,2Pi}]

When each of the following three Input items are evaluated, place the curser of the mouse on the manipulate rectangle, press the left mouse button down, and move the mouse horizontally (and the rectangle back and forth).

Manipulate[ Plot[Sin[x - phi], {x,0,6Pi}, PlotRange->{ {0,6Pi}, {-1.1,1.1}}, AspectRatio->.2, Ticks->{Range[6] Pi, None}], {phi,0,2Pi}]

Manipulate[ Expand[ (a + b)^n ], {n,1,20,1}]

Manipulate[ Expand[ (a + b)^n],{n,1,15,1}, ControlType->SetterBar]

Manipulate[ x^y, {x, 1, 15, 1, ControlType->SetterBar}, {y,1,15,1, ControlType->SetterBar}]

Exercises    (page 38)

1.

Manipulate[ Plot[ Sin[a*t] + Sin[b*t], {t,0,5}, PlotRange->{-2, 2}, PlotPoints->40], {a,50,100}, {{b,100}, 50, 100}]

Play[ Sin[ (950 +10t)t] + Sin[1000t], {t,0,5}]

Play[ {Sin[ (950 +10t)t],  Sin[1000t]}, {t,0,5}]

2.

r := RandomReal[];
Show[ Graphics[Line[{{r,r}, {r,r}}]], PlotRange->{{0,1}, {0,1}}]

Graphics[ Table[ Line[{{r,r}, {r,r}}], {40}], PlotRange->{{0,1}, {0,1}}]

Graphics[ Table[ {RGBColor[r,r,r], Opacity[ E^(-1.5r)], Thickness[.01+.02r], Line[{{r,r}, {r,r}}]}, {40}], PlotRange->{{0,1}, {0,1}}]

GraphicsRow[ Table[ Graphics[ Table[ {RGBColor[r,r,r], Thickness[ .003 + .01r], Line[{{r,r},{r,r}}]}, {40}]], {5}]]

Animate[ Graphics[k; Table[ 
    {RGBColor[r,r,r], Opacity[.9E^(-2r)], Thickness[ .01 + .02r], 
   Polygon[{{r,r}, {r,r}, {r,r}}]},  {30}], 
             PlotRange-> {{0,1}, {0,1}}, Background->Black], {k,1,20}]

Animate[ Graphics[k; Table[ 
    {RGBColor[r,r,r], Opacity[.9E^(-2r)], Thickness[ .01 + .02r], 
   Polygon[{{r,r}, {r,r}, {r,r}}]},  {30}], 
             PlotRange-> {{0,1}, {0,1}}, Background->Black], {k,1,20}]

In the last three lines of page 38, the author may have intended to write something like: 
     Repeat the preceding animation by replacing the Polygon[{{r, r},{r, r}, {r, r}}] primitive with the corresponding primitives listed there for line, circle, and disk.

Animate[ Graphics[k; Table[ 
    {RGBColor[r,r,r], Opacity[.9E^(-2r)], Thickness[ .01 + .02r], 
   Line[{{r,r}, {r,r}}]},  {30}], 
             PlotRange-> {{0,1}, {0,1}}, Background->Black], {k,1,20}]

Animate[ Graphics[k; Table[ 
    {RGBColor[r,r,r], Opacity[.9E^(-2r)], Thickness[ .01 + .02r], 
   Circle[.25{1+2r,1+2r}, 7r/5]},  {30}], 
             PlotRange-> {{0,1}, {0,1}}, Background->Black], {k,1,20}]

Animate[ Graphics[k; Table[ 
    {RGBColor[r,r,r], Opacity[.9E^(-2r)], Thickness[ .01 + .02r], 
   Disk[{r,r}, .5r]},  {30}], 
             PlotRange-> {{0,1}, {0,1}}, Background->Black], {k,1,20}]