My First Assignment

Gentle Steps Towards Programming in Mathematica

<my name>
<date>

Introduction

In this notebook we practice how to write text, enter formulas, format the layout and appearance of a notebook, and also perform a few programming examples.

Formula Examples

Formulas can appear within a text, as for example: (1/2) (Sqrt[(x/(sin(x)))]). One can enter these formulas using the built-in palettes or by keyboard shortcuts, as e.g., Esc inf Esc, which prints as the infinity symbol ∞.

Practicing how to enter formulas in text

Here are a few more examples of formulas.

Note: Put each formula into a separate Text Cell starting with a ⇥ and a Filled Square (■). Start entering formulas by typing: Ctrl-9 (that is, hold down the Ctrl-key and the 9-key).

■	(a)	  ∫(x^n) dx

■	(b)	 ∫Exp(a (x^2)) dx

■	(c)	 ∫(E^(a (y^2))) dy

■	(d)	 ∫(Sqrt[a + 
                b cos(c z)]) dz

■	(e)	 cos(((1 + (Sqrt[1 - x]))/(1 - (Sqrt[1 - x]))))

■	(f)	 4 (x^3) + 3 (x^2) + 2 x + 1 = 0

Calculating with Formulas

Solve the integral for formula (a)

Note: Place your Input Cell right after this cell.

∫(x^n) \[DifferentialD]x

Solve the integral for formula (b)

Note: Place your Input Cell right after this cell.

∫Exp[a (x^2)] \[DifferentialD]x

Solve the integral for formula (c)

Note: Place your Input Cell right after this cell.

∫(E^(a (y^2))) \[DifferentialD]y

Solve the integral for formula (d)

Note: Place your Input Cell right after this cell.

∫(Sqrt[a + b Cos[c z]]) \[DifferentialD]z

Compute the partial derivative of formula (e)

Note: Place your Input Cell right after this cell.

D[Cos[((1 + (Sqrt[1 - x]))/(1 - (Sqrt[1 - x])))], x]

Compute the solution of the equation in formula (f). (Hint: use the Solve command.)

Note: Place your Input Cell right after this cell.

Solve[4 (x^3) + 3 (x^2) + 2 x + 1 == 0, x]

Programming Examples

Working with the Table command

Write a command that generates the following outputs

For each line, which represents the desired output, write the Mathematica command that generates the corresponding result right above each output.

Hint: Look at the Help Browser!

Place your Input Cell right after this cell.

Table[x, {x, 1, 10, 2}]

This is the result you should get:

Place your Input Cell right after this cell.

Table[x, {x, -5, 1, 0.5}]

This is the result you should get:

Place your Input Cell right after this cell.

Table[(i^2), {i, 10}]

This is the result you should get:

Place your Input Cell right after this cell.

Table[■, {10}]

This is the result you should get:

Place your Input Cell right after this cell.

TableForm[Table[Binomial[i, j], {i, 0, 8}, {j, 0, i}]]

This is the result you should get:

Place your Input Cell right after this cell.

Table[{i}, {i, 0, 1}]

This is the result you should get:

Place your Input Cell right after this cell.

Table[{i, a}, {i, 0, 1}]

This is the result you should get:

Place your Input Cell right after this cell.

Table[{i, j}, {i, 0, 1}, {j, 0, 1}]

This is the result you should get:

Working with the Plot command

Enter the commands that produce the following graphics.

Hint: Again, have a look at the Help Browser.

Place your Input Cell right after this cell.

t = {Sin[x], Sin[2  x], Sin[3  x], Sin[4 x]}; 
    pp = Plot[Evaluate[t], {x, 0, 2  π}];

This is the result you should get:

Place your Input Cell right after this cell.

Plot[Evaluate[t], {x, 0, 2  π}, Axes -> False, 
        AspectRatio -> Automatic, 
        Background -> RGBColor[0, 1, 1]];

This is the result you should get:

Place your Input Cell right after this cell.

Show[
        pp /. Line[
              l : {_, __}] :> ({Hue[((0.7 First[Plus @@ #(1/2)])/π)], 
                    Line[#1]} &) /@ Partition[l, 2, 1]];

This is the result you should get: