[npl] / trunk / NationalProblemLibrary / Union / setMVderivatives / an14_6_5.pg Repository: Repository Listing bbplugincoursesdistsnplrochestersystemwww

# View of /trunk/NationalProblemLibrary/Union/setMVderivatives/an14_6_5.pg

Thu Jan 1 00:02:58 2009 UTC (4 years, 4 months ago) by dpvc
File size: 2233 byte(s)
```Update to current Union versions (using MathObjects)
```

```    1 ## DESCRIPTION
2 ##   Calculate Gradient and Directional Derivative
3 ## ENDDESCRIPTION
4
6 ## Tagged by nhamblet
7
8 ## DBsubject('Calculus')
9 ## DBchapter('Partial Derivatives')
10 ## DBsection('Directional Derivatives and the Gradient Vector')
11 ## Date('8/23/07')
12 ## Author('')
13 ## Institution('Union College')
14 ## TitleText1('Calculus')
15 ## EditionText1('7')
16 ## AuthorText1('Anton')
17 ## Section1('14.6')
18 ## Problem1('5')
19 ## TitleText2('Calculus: Early Transcendentals')
20 ## EditionText2('1')
21 ## AuthorText2('Rogawski')
22 ## Section2('14.5')
23 ## Problem2('21 22 23 24 25 26 27 28 29 30')
24
25 DOCUMENT();        # This should be the first executable line in the problem.
26
28   "PGstandard.pl",
29   "PGunion.pl",
30   "MathObjects.pl",
31   "parserVectorUtils.pl",
32   "PGchoicemacros.pl",
33   "PGcourse.pl",
34 );
35
36
37 TEXT(beginproblem);
38
39 ##############################################
40 #  Setup
41
42 Context("Vector");
43
44 #
45 #  The function
46 #
47 \$nx = random(2,5,1);
48 \$ny = random(2,5,1);
49 \$nz = random(2,5,1);
50 \$m = \$nx*\$ny*\$nz;
51
52 \$f = Formula("(x^\$nx y^\$ny z^\$nz)/(\$nx*\$ny*\$nz)");
53
54 #
55 #  The point
56 #
57 (\$x,\$y,\$z) = (non_zero_random(-3,3,1),
58               non_zero_random(-3,3,1),
59               non_zero_random(-3,3,1));
60
61 #
62 #  The vector
63 #
64 \$U = Vector((2*non_zero_random(-1,1,1),
65              2*non_zero_random(-1,1,1),
66              non_zero_random(-1,1,1))[shuffle(3)]);
67
68 #
69 #  The derivatives
70 #
71 \$fx = Formula("x^(\$nx-1) y^\$ny z^\$nz/(\$ny*\$nz)");
72 \$fy = Formula("x^\$nx y^(\$ny-1) z^\$nz/(\$nx*\$nz)");
73 \$fz = Formula("x^\$nx y^\$ny z^(\$nz-1)/(\$nx*\$ny)");
74
75 #
76 #  Directional derivative
77 #
78
80 \$Duf = \$gradf->eval(x=>\$x,y=>\$y,z=>\$z) . unit(\$U);
81
82 ##############################################
83 #  Main text
84
85 \$u = BoldMath('u');
86
87 Context()->texStrings;
88 BEGIN_TEXT
89
90 Let \(f(x,y,z) = \$DISPLAY \$f\).
91 \$PAR
92
93 Then \(\$GRAD\!f\) = \{ans_rule(60)\}, and \(D_{\$u} f(\$x,\$y,\$z)\)
94 in the direction of \(\$U\) is \{ans_rule(40)\}.
95
96 END_TEXT
97 Context()->normalStrings;
98
99 ##################################################