Re: Defining derivatives

• To: mathgroup at smc.vnet.net
• Subject: [mg88073] Re: Defining derivatives
• From: Jean-Marc Gulliet <jeanmarc.gulliet at gmail.com>
• Date: Wed, 23 Apr 2008 06:04:46 -0400 (EDT)
• Organization: The Open University, Milton Keynes, UK
• References: <fu9vnl\$igu\$1@smc.vnet.net> <fueeme\$b6g\$1@smc.vnet.net> <fukepj\$s3d\$1@smc.vnet.net>

```W_Craig Carter wrote:

>>  >      Derivative[1][f1] = f2;
>>  >
>>
>>  What can one _do_ with this construction?
>
>>  Can one then plot or evaluate f1, without further ado?
>
> Fun, amusement, education, research, profit, ego... Here is an example
> that satisfies 4/6.
>
> (*caveat pedants, this is intended as a pedagogical exercise, lifted
> from my course notes, flames ignored*)
>
> GraphFunction[x_, y_] := ((x - y) (x + y))/(1 + (x + y)^2) (*simple
> graph f(x,y) )
>
> \$Assumptions =  {x \[Element] Reals, y \[Element] Reals}; (*give
> simplify a hint *)
>
> CurvatureOfGraph[f_, x_, y_] :=  (*def. of curvature of f(x,y)*)
>  FullSimplify[ (*silly to call simplify each time the function is
> called? not always*)
>   Module[{dfdx = D[f[x, y], x], dfdy = D[f[x, y], y],
>     d2fdx2 = D[f[x, y], {x, 2}], d2fdy2 = D[f[x, y], {y, 2}],
>     d2fdxdy = D[f[x, y], x, y]} ,
>    Return[((1 + dfdx^2) d2fdx2 -
>        2 dfdx dfdy d2fdxdy + (1 + dfdy^2) d2fdy2)/
>      Sqrt[1 + dfdx^2 + dfdy^2]]]]
>
> CurvFunc =  (*mysterious function definition for out particular surface*)
>  Function[{x, y}, Evaluate[CurvatureOfGraph[GraphFunction, x, y]]]
>
>
> (*enigmatic defintions for partials on our surface*)
> dfdx = Function[{x, y}, Evaluate[FullSimplify[D[GraphFunction[x, y], x]]]]
> dfdy = Function[{x, y}, Evaluate[FullSimplify[D[GraphFunction[x, y], y]]]]
>
> angle[x_] := ((Pi/2 + ArcTan[x])/Pi)
>
>
> (*plot of function showing height, curvature, and normals, all in one go*)
>
> plotcurvature =
>  Plot3D[GraphFunction[x, y], {x, -3, 3}, {y, 3, -3},
>   MeshFunctions -> (CurvFunc[#1, #2] &),
>   MeshStyle -> Thick,
>   PlotLabel -> "Curvatures(level sets) and Normals(color variation)",
>   ColorFunction -> (Glow[
>       RGBColor[angle[dfdx[#1, #2]], angle[dfdy[#1, #2]], 0.75]]
> &),ColorFunctionScaling -> False, Lighting -> None]
>
>
> (*I think that's something*)

Hi Grain,

My two cents: I have fixed some typos and added several semi-columns for
otherwise Mathematica is rapidly confused by the interweaving of
comments and input expressions (assuming, of course, that one wants to
cut and past the code in one go). The code below should work and be
nicely formatted when copied into a notebook.

(*caveat pedants,this is intended as a pedagogical exercise,lifted \
from my course notes,flames ignored*)
GraphFunction[x_,
y_] := ((x - y) (x +
y))/(1 + (x +
y)^2);(*simple graph f(x,y)*)\$Assumptions = {x \[Element]
Reals, y \[Element] Reals};
(*give simplify a hint*)

CurvatureOfGraph[f_, x_, y_] :=(*def.of curvature of f(x,y)*)
FullSimplify[(*silly to call simplify each time the function is \
called?not always*)
Module[{dfdx = D[f[x, y], x], dfdy = D[f[x, y], y],
d2fdx2 = D[f[x, y], {x, 2}], d2fdy2 = D[f[x, y], {y, 2}],
d2fdxdy = D[f[x, y], x, y]},
Return[((1 + dfdx^2) d2fdx2 -
2 dfdx dfdy d2fdxdy + (1 + dfdy^2) d2fdy2)/
Sqrt[1 + dfdx^2 + dfdy^2]]]];
CurvFunc =(*mysterious function definition for out particular surface*)
Function[{x, y}, Evaluate[CurvatureOfGraph[GraphFunction, x, y]]];
(*enigmatic defintions for partials on our surface*)dfdx =
Function[{x, y},
Evaluate[FullSimplify[D[GraphFunction[x, y], x]]]]; dfdy =
Function[{x, y}, Evaluate[FullSimplify[D[GraphFunction[x, y], y]]]];
angle[x_] := ((Pi/2 + ArcTan[x])/Pi);
(*plot of function showing height,curvature,and normals,all in one \
go*)plotcurvature =
Plot3D[GraphFunction[x, y], {x, -3, 3}, {y, 3, -3},
MeshFunctions -> (CurvFunc[#1, #2] &), MeshStyle -> Thick,
PlotLabel -> "Curvatures(level sets) and Normals(color variation)",
ColorFunction -> (Glow[
RGBColor[angle[dfdx[#1, #2]], angle[dfdy[#1, #2]], 0.75]] &),
ColorFunctionScaling -> False, Lighting -> None]
(*I think that's something*)

Best regards,
-- Jean-Marc

```

• Prev by Date: Re: Fourier transform in arbitrary dimension?
• Next by Date: Re: Probably memory problem
• Previous by thread: Re: Re: Defining derivatives
• Next by thread: NDSolve and vector functions