Saturday, May 9 2009
9:10 am
I will stay with the Stylesheet "Classroom"

Chapter 1 Getting Started
1.8 Using Variables
Variables are defined by means of the equal symbol.

In[1]:=

a = 3

b = 5

a + b

Out[1]=

3

Out[2]=

5

Out[3]=

8

One of the real powers of Mathematica is that it can manipulate abstract expressions. This is sometimes called symbolic computation.
Here is an example using the function Expand:

In[4]:=

Expand[(x + y)^10]

Out[4]=

x^10 + 10 x^9 y + 45 x^8 y^2 + 120 x^7 y^3 + 210 x^6 y^4 + 252 x^5 y^5 + 210 x^4 y^6 + 120 x^3 y^7 + 45 x^2 y^8 + 10 x y^9 + y^10

I would not want to do this by hand.
1.9 Using Comments
This section is not as useful as simply using alt-7 to change to Text (as I am doing at the moment).

1.10 Suppressing Output
Sometimes the result of a calculation can produce a large amount of output.

In[6]:=

3^1000

Out[6]=

13220708194808066368904552597521443659654220327521481676649203682268285973467048995407783138 ... 695516765018940588109060426089671438864102814350385648747165832010614366132173102768902855220001

This output can be suppressed by adding a ; to the end of the expression.

In[10]:=

Clear[a]

a = 3^1000 ;

In[12]:=

a + 1 ;

In[13]:=

a + 1

Out[13]=

13220708194808066368904552597521443659654220327521481676649203682268285973467048995407783138 ... 695516765018940588109060426089671438864102814350385648747165832010614366132173102768902855220002

There is a Quiz at the end of the chapter.
1. Use
Mathematica to compute (1/2 + 1/3)^3 exactly.

In[14]:=

(1/2 + 1/3)^3

Out[14]=

125/216

2. Use Mathematica to compute (1/2 + 1/3)^3 and represent the answer in decimal form.

In[15]:=

(1./2 + 1/3)^3

Out[15]=

0.578704

3. It turns out tha the numbers ^π and π^ are pretty close to each other. Without computing them it is not easy to see which is bigger. Use Mathematica to find out which number is bigger.

In[16]:=

(E^Pi) > (Pi^E)

Out[16]=

True

I can verify this by computing each number to a certain number of decimal places.

In[17]:=

N[E^Pi, 5]

Out[17]=

23.141

In[18]:=

N[Pi^E, 5]

Out[18]=

22.459

4. The volume of a ball of radius r is given by V = 4/3πr^3 and its surface area is given by A = 4πr^2. The radius of the earth is about 4000 miles. Use Mathematica to estimate the volume and surfce area of the earth.

In[23]:=

Clear["Global*"]

In[24]:=

r = 4000

Out[24]=

4000

In[29]:=

v = N[(4/3) Pi r^3, 5]

Out[29]=

2.6808*10^11

In[30]:=

v

Out[30]=

2.6808*10^11

In[32]:=

a = N[4 π r^2, 5]

Out[32]=

2.0106*10^8

This last problem was excellent as it reminded me to leave a space between each symbol for implied multiplication.

In[35]:=

Clear["Global`*"]

In[36]:=

a

Out[36]=

a

In[37]:=

v

Out[37]=

v

5. The volume of any cone is one-third the area of the base times the height, where the height is measured perpendicular to the base. The Great Pyramid at Cheops has a square base about 230 meters on a side and its height is about 147 meters high. Use Mathematica to compute the volume of the pyramid.

In[39]:=

s = 230

h = 147

v = 1/3 s^2 h

Out[39]=

230

Out[40]=

147

Out[41]=

2592100

6. Use the Table function to make a list of the cubes of the first 10 integers.

In[43]:=

cubes = Table[x^3, {x, 1, 10}]

Out[43]=

{1, 8, 27, 64, 125, 216, 343, 512, 729, 1000}

In[44]:=

cubes

Out[44]=

{1, 8, 27, 64, 125, 216, 343, 512, 729, 1000}

7. The sine function is given by Sin. Use the Table function to make a table of sin x for every x from 0 to π/2 in increments of π/20. Have the entries in the table in decimal form.

In[45]:=

Table[Sin[x], {x, 0, π/2, π/20.}]

Out[45]=

{0, 0.156434, 0.309017, 0.45399, 0.587785, 0.707107, 0.809017, 0.891007, 0.951057, 0.987688, 1.}

This is one way of obtaining values of a trigonometric function. But usually I will want to see the corresponding graph.
8. The number e is defined as the limit of (1 + 1/n)^n as n approaches infinity. Use the Table function to list the value of (1 + 1/n)^n for n = 10, 10^2, 10^3, ... 10^6.

In[46]:=

Table[(1. + 1/10^k)^10^k, {k, 1, 6}]

Out[46]=

{2.59374, 2.70481, 2.71692, 2.71815, 2.71827, 2.71828}

9. The function n! which is read as "n factorial" is defined to be the product of all positive integers from 1 to n. Use the Table function to make a list of n! for n = 1 to 20.

In[48]:=

Table[n !, {n, 1, 20}]

Out[48]=

{1, 2, 6, 24, 120, 720, 5040, 40320, 362880, 3628800, 39916800, 479001600, 6227020800, 87178 ... 000, 20922789888000, 355687428096000, 6402373705728000, 121645100408832000, 2432902008176640000}

In[49]:=

0 !

Out[49]=

1

A good morning session. I am making good use of the Basic Math Input Palette.
11:00 am


Created by Mathematica  (May 9, 2009) Valid XHTML 1.1!