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

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

Thu Oct 9 05:14:38 2008 UTC (4 years, 7 months ago) by jj
File size: 2236 byte(s)
```Fixed bug 1522, added PGchoicemacros so that shuffle will be defined.
```

```    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('')
12 ## Author('')
13 ## Institution('Union College')
14 ## TitleText1('')
15 ## EditionText1('')
16 ## AuthorText1('')
17 ## Section1('')
18 ## Problem1('')
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   "Parser.pl",
31   "parserVectorUtils.pl",
32   "PGchoicemacros.pl",
33   "PGcourse.pl"
34 );
35
36
37 TEXT(beginproblem());
38 BEGIN_PROBLEM();
39
40 ##############################################
41 #  Setup
42
43 Context("Vector");
44
45 #
46 #  The function
47 #
48 \$nx = random(2,5,1);
49 \$ny = random(2,5,1);
50 \$nz = random(2,5,1);
51 \$m = \$nx*\$ny*\$nz;
52
53 \$f = Formula("(x^\$nx y^\$ny z^\$nz)/(\$nx*\$ny*\$nz)");
54
55 #
56 #  The point
57 #
58 (\$x,\$y,\$z) = (non_zero_random(-3,3,1),
59               non_zero_random(-3,3,1),
60               non_zero_random(-3,3,1));
61
62 #
63 #  The vector
64 #
65 \$U = Vector((2*non_zero_random(-1,1,1),
66              2*non_zero_random(-1,1,1),
67              non_zero_random(-1,1,1))[shuffle(3)]);
68
69 #
70 #  The derivatives
71 #
72 \$fx = Formula("x^(\$nx-1) y^\$ny z^\$nz/(\$ny*\$nz)");
73 \$fy = Formula("x^\$nx y^(\$ny-1) z^\$nz/(\$nx*\$nz)");
74 \$fz = Formula("x^\$nx y^\$ny z^(\$nz-1)/(\$nx*\$ny)");
75
76 #
77 #  Directional derivative
78 #
79
81 \$Duf = \$gradf->eval(x=>\$x,y=>\$y,z=>\$z) . unit(\$U);
82
83 ##############################################
84 #  Main text
85
86 \$u = BoldMath('u');
87
88 Context()->texStrings;
89 BEGIN_TEXT
90
91 Let \(f(x,y,z) = \$DISPLAY \$f\).
92 \$PAR
93
94 Then \(\$GRAD\!f\) = \{ans_rule(60)\}, and \(D_{\$u} f(\$x,\$y,\$z)\)
95 in the direction of \(\$U\) is \{ans_rule(40)\}.
96
97 END_TEXT
98 Context()->normalStrings;
99
100 ##################################################