Programming Hints #1

Below are some simple programming hints that will be of great help to you throughout this class.

Functions vs. Expressions

Functions are names;  expressions are values.
1.  Sin is a function;  Sin(x) is an expression.
2.  (x^2) is an expression, not a function.
3.  f(x) = (x^2) --  f is a function
Be sure that you understand the difference between a function and an expression.  Mathematica is very picky about this distinction.

Dummy Variables and Plot

Plot[
        f[x], {x, a, 
          b}]  works by substituting constant values between a and b for x.

Plot[
        D[f[x], x], {x, a, b}]  will fail because:

a.  Plot substitutes constant values for x BEFORE computing the derivative of  f.
	b.  D cannot compute the derivative with respect to a constant.
	c.  The solution is to use a dummy variable in place of x in order to compute the derivative before substitutiing values for x

Plot[D[f[t], t] /. t -> x, {x, a, b}]  -- here t is a dummy variable.

d.  Dummy variable appear elsewhere in mathematics -- for example in integration.

(∫_0^1) (x^2) \[DifferentialD]x==1/3 -- here x is a dummy variable,just a placeholder not appearing in the final result.

Clear Function Names in the Same Cell BEFORE the Definition of Each Function

Altering the definition of a function does NOT erase the old definition.
1. To avoid confusion, clear the function name in the same cell as the function definition, just before the definition.
2.  PROGRAM DEFENSIVELY.