Homework # 4:  Dummy Variables and Clearing Function Definitions

Below are a few simple exercises that will help you understand some of the problems you may have encountered while working on Module 4.  Be sure you understand the solutions to these exercises because these problems will come up again later in this course.

You may use the Documentation Center to assist you with these problems, but you should not copy your answers verbatim from the Documentation Center.  After you understand the solution in the Documentation Center, you should present the solution in your own words.  Try to avoid jargon and special notation;  use standard English and classical Mathematical notation.  Also you should not copy examples from the Documentation Center;  rather you should provide your own examples to ensure that you understand the concepts.

Please format your solutions appropriately.  Use text format, not input format, when you are typing text.  Write coherent sentences and paragraphs;  part of your grade will depend on how clearly you present your ideas.

You must work on these exercises by yourself, not in pairs;  if you get stuck and cannot find the solution in the Documentation Center, you may consult the labbie or the instructor during their office hours.

Dummy Variables

Calculus sometimes uses dummy variables as placeholders.  These variables are called dummy variables because they disappear after the expression is evaluated.  The use of dummy variables is especially common in integration.  Consider the following examples:

(∫_0^t)(x^2)dx,
(∫_0^t)Cos[x]dx.

Notice that x is a dummy variable;  when you evaluate the integral by hand x disappears and only t remains.  Some students would like to write

(∫_0^t)(t^2)dt,
(∫_0^t)Cos[t]dt.

But this notation would confuse the distinction between the variable of integration (x) and the interval of integration [0,t].  Mathematicians are painfully precise;  they try at all costs to avoid any ambiguity.  Avoiding ambiguous notation is particularly important when programming, since computers have no understanding of the context with which to interpret the notation.

Problems

Explain why each of the following programs fails to work in Mathematica (try them out), and explain how to fix them by using a dummy variable.  Give examples to show that your fix actually corrects the problem.  (In the second problem, you are not permitted to change D[f[x],x] to f'[x].)

IntPlot[f_]:=Plot[(∫_0^x)f[x]\[DifferentialD]x,{x,0,1}]

DiffPlot[f_]:=Plot[D[f[x],x],{x,0,1}]

Clear

If your function is not operating correctly, it may be because you have failed to clear the function definition.

Problems

1.  Explain why it is good programming practice to clear the definition of each function you define immediately before you define the function but in the same cell as the function definition.

2.  Explain why it is not sufficient simply to delete the old function definition when you are redefining a function to remove a bug.