## DESCRIPTION ## Calculate Gradient and Directional Derivative ## ENDDESCRIPTION ## KEYWORDS('Gradient', 'Directional', 'Derivative') ## Tagged by nhamblet ## DBsubject('Calculus') ## DBchapter('Partial Derivatives') ## DBsection('Directional Derivatives and the Gradient Vector') ## Date('8/23/07') ## Author('') ## Institution('Union College') ## TitleText1('Calculus') ## EditionText1('7') ## AuthorText1('Anton') ## Section1('14.6') ## Problem1('5') ## TitleText2('Calculus: Early Transcendentals') ## EditionText2('1') ## AuthorText2('Rogawski') ## Section2('14.5') ## Problem2('21 22 23 24 25 26 27 28 29 30') DOCUMENT(); # This should be the first executable line in the problem. loadMacros( "PGstandard.pl", "PGunion.pl", "MathObjects.pl", "parserVectorUtils.pl", "PGchoicemacros.pl", "PGcourse.pl", ); TEXT(beginproblem()); ############################################## # Setup Context("Vector"); # # The function # $nx = random(2,5,1); $ny = random(2,5,1); $nz = random(2,5,1); $m = $nx*$ny*$nz; $f = Formula("(x^$nx y^$ny z^$nz)/($nx*$ny*$nz)"); # # The point # ($x,$y,$z) = (non_zero_random(-3,3,1), non_zero_random(-3,3,1), non_zero_random(-3,3,1)); # # The vector # $U = Vector((2*non_zero_random(-1,1,1), 2*non_zero_random(-1,1,1), non_zero_random(-1,1,1))[shuffle(3)]); # # The derivatives # $fx = Formula("x^($nx-1) y^$ny z^$nz/($ny*$nz)"); $fy = Formula("x^$nx y^($ny-1) z^$nz/($nx*$nz)"); $fz = Formula("x^$nx y^$ny z^($nz-1)/($nx*$ny)"); # # Directional derivative # $gradf = Vector($fx,$fy,$fz); $Duf = $gradf->eval(x=>$x,y=>$y,z=>$z) . unit($U); ############################################## # Main text $u = BoldMath('u'); Context()->texStrings; BEGIN_TEXT Let \(f(x,y,z) = $DISPLAY $f\). $PAR Then \($GRAD\!f\) = \{ans_rule(60)\}, and \(D_{$u} f($x,$y,$z)\) in the direction of \($U\) is \{ans_rule(40)\}. END_TEXT Context()->normalStrings; ################################################## # Answers ANS($gradf->cmp); ANS($Duf->cmp); $showPartialCorrectAnswers = 1; ################################################## COMMENT('MathObject version'); ENDDOCUMENT();