Computer Microscopes
in
Two and Three Dimensions

by
K. D.  Stroyan
University of Iowa

copyright 1997 by Academic Press, Inc. - All rights reserved.

Notebook Overview

This NoteBook is a Mathematica  version of the microscope interpretation of Landau's small oh form of the linear approximation given by the first derivative in one or two independent variables.  Algebraically the error is  e  in the formula

f(x + dx) = f(x) + f '(x) dx + ϵ dx

or

f[x+dx,y+dy] - f[x,y] = ∂(f/∂)x[x, y]· dx + ∂(f/∂)y[x, y]· dy + ϵ · |dX|

dX = (dx,dy), or

f[x+dx,y+dy] - f[x,y] = ∂(f/∂)x[x, y]· dx + ∂(f/∂)y[x, y]· dy + ϵ ·(Sqrt[(dx^2) + (dy^2)])

Geometrically, the error  ϵ  is what you see as the difference between the graph and its tangent approximation when you look at the graph under a microscope of magnification  1/dx  in one variable, or in the vector case, magnification 1/ |dX|.

In either case, the function is smooth if  ϵ  is small when  dx  or  |dX|  is small.  Under an ideal microscope of enormous power  1/|dX|  the error term  ϵ  would be tiny.  This means that you would not see the error  ϵ, so that the graph would appear to be linear.  In other words, the graph of a smooth function is "locally linear."  This is the main approximation of differential calculus.

Also see the NoteBook Zoom3D

The Zoom3D NoteBook automatically zooms into a point showing the tangent and a reference box.  This microscope program is closer to the way you would plot the tangent plane by hand.

References to the Text

Section 19.1

In section 19.1 we study the definition of the derivative with respect to a two dimensional vector independent variables.  The 3-D parts of this NoteBook present both explicit graphs and contour graphs with their magnifications.

Step-by-step Computation

3 D Microscopic view of  the explicit graph  z = f[x,y]

The Graph of f[x, y]

SetOptions[Plot3D, BoxRatios -> {1, 1, 1}, 
      BoxRatios -> Automatic, 
      AxesLabel -> {"dx", "dy", "dz"}, 
      Axes -> Automatic, PlotPoints -> 30, ClipFill -> None, 
      ViewPoint -> {5, 3, 1}];

Clear[x, y, f]; f[x_, y_] := Cos[(x^2)]/(1 + (y^2)) - (1/2) x Sin[3 y]; x = 1.0; y = 0.0; z = f[x, y]; scale = 2; Plot3D[
      f[x + dx, y + dy] - z, {dx, -scale, scale}, {dy, -scale, 
        scale}, BoxRatios -> Automatic, 
      PlotRange -> {-scale, scale}];

scale = 1; Plot3D[
      f[x + dx, y + dy] - z, {dx, -scale, scale}, {dy, -scale, 
        scale}, BoxRatios -> Automatic, 
      PlotRange -> {-scale, scale}];

scale = (1/4); Plot3D[
      f[x + dx, y + dy] - z, {dx, -scale, scale}, {dy, -scale, 
        scale}, BoxRatios -> Automatic, 
      PlotRange -> {-scale, scale}];

The Total Differential

The derivative of an expression  "expr" with respect to a "variable" is denoted

D[ expr , variable ]

in Mathematica.  We add Evaluate to make the partial derivative functions act like functions.  (Note that  x  and  y  were fixed above, so we use xx  and  yy.)  Also see the NoteBook PartialD.

\(Clear[dx, dy, dz, xx, yy]; 


    fX[xx_, yy_]\  := \ Evaluate[D[f[xx, yy], xx]]; 

    fY[xx_, yy_]\  := \ Evaluate[D[f[xx, yy], yy]]; 


    dz[dx_, dy_] := fX[x, y]\ dx + fY[x, y]\ dy; 

    \(Print["The total differential at (x,y) = ", {x, y}]; \)\)Print["dz = ", dz[dx, dy]]; Plot3D[dz[dx, dy], {dx, -scale, scale}, {dy, -scale, scale}, 
      BoxRatios -> Automatic, PlotRange -> {-scale, scale}];

Symbolic Differential

Clear[x, y]; Print["The general symbolic differential"]; Print["dz = ", dz[dx, dy]];

3 D Microscopic view of  implicit graphs   f[x,y] = const

Contour Plot of f[x, y]

Clear[x, y, f]; f[x_, y_] := Cos[(x^2)]/(1 + (y^2)) - (1/2) x Sin[3 y]; x = 1.0; y = 0.0; z = f[x, y]; scale = 2; ContourPlot[
      f[x + dx, y + dy] - z, {dx, -scale, scale}, {dy, -scale, 
        scale}];

scale = (1/2); ContourPlot[
      f[x + dx, y + dy] - z, {dx, -scale, scale}, {dy, -scale, 
        scale}];

scale = (1/16); ContourPlot[
      f[x + dx, y + dy] - z, {dx, -scale, scale}, {dy, -scale, 
        scale}];

Differential

\(Clear[dx, dy, dz, xx, yy]; 


    fX[xx_, yy_]\  := \ Evaluate[D[f[xx, yy], xx]]; 

    fY[xx_, yy_]\  := \ Evaluate[D[f[xx, yy], yy]]; 


    dz[dx_, dy_] := fX[x, y]\ dx + fY[x, y]\ dy; 

    \(Print["The total differential at (x,y) = ", {x, y}]; \)\)Print["dz = ", dz[dx, dy]]; ContourPlot[
      dz[dx, dy], {dx, -scale, scale}, {dy, -scale, scale}];

Symbolic Differential

Clear[x, y]; Print["The general symbolic differential"]; Print["dz = ", dz[dx, dy]];

Combined Computations

To predict the view in an ideal infintiesimal microscope by hand we:

1)  Compute  the partial derivatives  fX[x,y] and fY[x,y]  from  z = f[x,y]  by rules.

2)  Verify that  f[x,y]  and  fX[x,y]  and  fY[x,y]  are valid formulas in a rectangle about the fixed value of  (x,y).

3)  Fix  (x,y)  in the differential  dz = fX[x,y] dx + fY[x,y] dy  = m dx + n dy, for specific numbers  m  and  n.

4)  Plot the linear equation

dz = m dx + n dy   in (dx,dy)-coordinates.

This can be done with Mathematica as follows:

Explicit Tangents

Clear[x, y, dx, dy, f, fX, fY]; \(f[x_, y_] := 3\ Exp[\(-\(x\^2\/3\)\) - y\^2\/5]; 


    fX[x_, y_]\  := \ Evaluate[D[f[x, y], x]]; 

    fY[x_, y_]\  := \ Evaluate[D[f[x, y], y]]; 


    dz[dx_, dy_] := fX[x, y]\ dx + fY[x, y]\ dy; 

    \(Print["The function  z = f[x,y] = ", f[x, y]]; \)\)Print["has symbolic total differential"]; Print["dz = ", dz[dx, dy]]; x = 1.0; y = -1.0; z = f[x, y]; Print["At (x,y,f[x,y]) =", {x, y, z}, " the differential"]; 
    Print["dz = ", dz[dx, dy]]; scale = 0.5; tangent = 
      Plot3D[dz[dx, dy], {dx, -scale, scale}, {dy, -scale, scale}, 
        BoxRatios -> Automatic, PlotRange -> {-scale, scale}, 
        AxesLabel -> {"dx", "dy", "dz"}, 
        ViewPoint -> {5, 3, 1}, PlotPoints -> 8, 
        Ticks -> None, ClipFill -> None];

Now compare this to a plot of the nonlinear function:

Print["The explicit graph near (x,y,z) = (", x, ",", y, 
      ",", z, ")"]; surface = 
      Plot3D[f[x + dx, y + dy] - z, {dx, -scale, scale}, {dy, -scale, 
          scale}, BoxRatios -> Automatic, 
        PlotRange -> {-scale, scale}, 
        AxesLabel -> {"dx", "dy", "dz"}, 
        ViewPoint -> {5, 3, 1}, PlotPoints -> 30, 
        ClipFill -> None];

Both together:

Show[surface, tangent, 
      Graphics3D[{PointSize[0.02], Point[{0, 0, 0}]}], 
      DisplayFunction -> $DisplayFunction];

Contour Tangents

Clear[x, y, dx, dy, f, fX, fY]; \(f[x_, y_] := 3\ Exp[\(-\(x\^2\/3\)\) - y\^2\/5]; 


    fX[x_, y_]\  := \ Evaluate[D[f[x, y], x]]; 

    fY[x_, y_]\  := \ Evaluate[D[f[x, y], y]]; 


    dz[dx_, dy_] := fX[x, y]\ dx + fY[x, y]\ dy; 

    \(Print["The function  z = f[x,y] = ", f[x, y]]; \)\)Print["has symbolic total differential"]; Print["dz = ", dz[dx, dy]]; x = 1.0; y = -1.0; z = f[x, y]; Print["At (x,y,f[x,y]) =", {x, y, z}, " the differential"]; 
    Print["dz = ", dz[dx, dy]]; scale = 0.5; tangent = 
      ContourPlot[
        dz[dx, dy], {dx, -scale, scale}, {dy, -scale, scale}, 
        ContourShading -> False];

Now compare this to a plot of the nonlinear function:

Print["The explicit graph near (x,y,z) = (", x, ",", y, 
      ",", z, ")"]; surface = 
      ContourPlot[
        f[x + dx, y + dy] - z, {dx, -scale, scale}, {dy, -scale, 
          scale}];

Both together:

Show[surface, tangent, Graphics[{PointSize[0.02], Point[{0, 0}]}], 
      DisplayFunction -> $DisplayFunction];

Exercises

The Zoom3D NoteBook

These exercises can also be done with the Zoom3D NoteBook.

Exercise 18.2.1

This exercise can be done with this NoteBook or the Zoom3D NoteBook.

Modify the function in this notebook to calculate the differentials and show microscopic views of some of the functions in  Exercise 18.2.1:

a)  z  = x (y^2) + (x^3) y

b)  z = Sin[x]^3 + Cos[y]^4

c)  z = Sin[x*y]*Cos[x*y]

d)  z = (Sqrt[1 - (x^2) - (y^2)]) Cos[2 π x y]

e)  z = (Sqrt[(x^2) + Sin[(y^2)]])

f) z = (1/(Sqrt[(x^2) + (y^2)]))

g)  z = (2 (x^2) + 3 (y^2)) Exp[-((x^2) + (y^2))]
	or  z = (2 (x^2) + 3 (y^2)) (e^(-((x^2) + (y^2))))

h)  z = 2 x y Exp[-(((x^2)/2) + ((y^2)/8))]

    or z = 2 x y (e^(-(((x^2)/2) + ((y^2)/8))))

i)  z = ArcTan[(x^2) (y^3)]

j)  z = Log[(x^2) + (y^4)]

Simply copy, paste and edit as needed.  Be careful to plot your functions over interesting domains of the independent variables.

Which (x,y)-points have both partials equal to zero?

NOTE:

We especially recommend that you magnify

z = (Sqrt[(x^2) + Sin (y^2)]) at (x,y)=(0,0)

and explain what you see.