Miscellaneous

Crash due to 'while loop' and "show me another"?

Re: Crash due to 'while loop' and "show me another"?

by Stacey Rodman -
Number of replies: 0

Full code:

DOCUMENT();
loadMacros(
  "PGstandard.pl",
  "PGchoicemacros.pl",
  "PGcourse.pl",
  "MathObjects.pl",
 );
 
Context('Vector');

$a = random(-5,5,1);
$b = random(-5,5,1);
while ($a == $b) { $b = random(-5,5,1); }  # make sure curl is not = 0
$c = random(-5,5,1);
$d = random(-5,5,1);
$e = random(-5,5,1);
$f = random(-5,5,1);

$f1 = nicestring([$a,  $d],[ 'y', 'z']);
$f2 = nicestring([$b,  $e],[ 'x', 'z']);
$f3 = nicestring([$c,  $f],[ 'x', 'y']);

$curl = Vector( $f-$e, $d-$c, $b-$a );

$p1 = non_zero_random(-5,5,1);
$p2 = random(-5,5,1);
$p3 = random(-5,5,1);

$v1 = random(-5,5,1);
$v2 = random(-5,5,1);
$v3 = non_zero_random(-5,5,1);

$vector = Vector($v1, $v2, $v3);

$rotation = $curl.$vector/norm($vector);
Context('Numeric');
##
TEXT(beginproblem());

BEGIN_TEXT  
Consider the vector field 
\( \vec{F}(x,y,z) = \langle $f1, $f2, $f3 \rangle \).
$BR
Find the divergence and curl of \(\vec{F} \).  Use <  >  for vectors. 
$BR
$BR
\( \textrm{div}(\vec{F}) = \) \{ans_rule(20)\}.
$BR
\( \textrm{curl}(\vec{F}) = \) \{ans_rule(20)\}.
$BR
$BR
What is the "right-hand" rotation of \(\vec{F}\) at the point \( ($p1,$p2,$p3 ) \)  around the vector \( \langle $v1, $v2, $v3 \rangle \)
$BR
$BR
\(\textrm{rotation} = \) \{ans_rule(20)\}.

END_TEXT

ANS(num_cmp(0));
ANS($curl->cmp());
ANS($rotation->cmp());

ENDDOCUMENT();