[npl] / trunk / NationalProblemLibrary / WHFreeman / Rogawski_Calculus_Early_Transcendentals_Second_Edition / 14_Differentiation_in_Several_Variables / 14.5_The_Gradient_and_Directional_Derivatives / 14.5.23.pg Repository: Repository Listing bbplugincoursesdistsnplrochestersystemwww

 1 : aubreyja 2584 ## DBsubject('Calculus') 2 : ## DBchapter('Differentiation in Several Variables') 3 : ## DBsection('The Gradient and Directional Derivatives') 4 : ## KEYWORDS('calculus') 5 : ## TitleText1('Calculus: Early Transcendentals') 6 : ## EditionText1('2') 7 : ## AuthorText1('Rogawski') 8 : ## Section1('14.5') 9 : ## Problem1('23') 10 : ## Author('JustAsk - Vladimir Finkelshtein') 11 : ## Institution('W.H.Freeman') 12 : 13 : DOCUMENT(); 14 : 15 : loadMacros("PG.pl","PGbasicmacros.pl","PGanswermacros.pl"); 16 : loadMacros("Parser.pl"); 17 : loadMacros("freemanMacros.pl"); 18 : loadMacros("PGauxiliaryFunctions.pl"); 19 : loadMacros("PGgraphmacros.pl"); 20 : loadMacros("PGchoicemacros.pl"); 21 : 22 : TEXT(beginproblem()); 23 : 24 : Context()->texStrings; 25 : $x=non_zero_random(-2,2,1); 26 :$y=non_zero_random(-2,2,1); 27 : $xpow=random(1,3,1); 28 :$ypow=random(1,3,1); 29 : $i=non_zero_random(-3,3,1); 30 :$j=non_zero_random(-3,3,1); 31 : $i1=$i; 32 : $j1=$j; 33 : if($i1==1){$i1=''}; 34 : if($i1==-1){$i1='-'}; 35 : if($j1==1){$j1=''}; 36 : if($j1==-1){$j1='-'}; 37 : 38 : $norm2=($i)**2+($j)**2; 39 :$context = Context(); 40 : $context->variables->add(y=>'Real'); 41 : 42 :$f=Formula("x^($xpow)*y^($ypow)")->reduce(); 43 : $fx=Formula("$xpow*x^($xpow-1)*y^($ypow)")->reduce(); 44 : $fy=Formula("$ypow*x^($xpow)*y^($ypow-1)")->reduce(); 45 : $gradx=$fx->eval(x=>$x, y=>$y); 46 : $grady=$fy->eval(x=>$x, y=>$y); 47 : 48 : $dernum=$gradx*$i+$grady*$j; 49 :$der=($gradx*$i+$grady*$j)/sqrt($norm2); 50 : 51 : 52 : BEGIN_TEXT 53 : \{ textbook_ref_exact("Rogawski ET 2e", "14.5","23") \} 54 :$PAR 55 : Calculate the directional derivative of $$f(x,y)=f$$ in the direction of $$\mathbf{v}=i1 \mathbf{i}+j1\mathbf{j}$$ at the point $$P=(x,y)$$. Remember to normalize the direction vector. 56 : $PAR 57 : $$D_uf(x,y)=$$ \{ans_rule()\} 58 :$BR 59 : END_TEXT 60 : 61 : Context()->normalStrings; 62 : ANS($der->cmp); 63 : Context()->texStrings; 64 : 65 : SOLUTION(EV3(<<'END_SOLUTION')); 66 :$PAR 67 : $SOL 68 :$BR 69 : We normalize $$\mathbf{v}$$ to obtain a unit vector $$\mathbf{u}$$ in the direction of $$\mathbf{v}$$: 70 : $\mathbf{u}=\frac{\mathbf{v}}{||\mathbf{v}||}=\frac{1}{\sqrt{norm2}}(i1\mathbf{i} +j1 \mathbf{j})$ 71 : We compute the gradient of $$f(x,y)=f$$ at the point $$P$$: 72 : $\nabla f=\left< \frac{\partial{f}}{\partial{x}}, \frac{\partial{f}}{\partial{y}} \right>=\left<fx,fy\right>\quad \Rightarrow \quad \nabla f(x,y)=\left<gradx, grady\right>$ 73 : The directional derivative in the direction $$\mathbf{v}$$ is thus 74 : $D_uf(x,y)=\nabla f(x,y) \cdot \mathbf{u}=\left< gradx, grady \right> \cdot \frac{1}{\sqrt{norm2}} \left<i, j\right>=\frac{dernum}{\sqrt{norm2}}\approx der$ 75 : \$BR 76 : END_SOLUTION 77 : 78 : ENDDOCUMENT();