In
Problem setLinearAlgebra17DotProductRn/ur_la_17_13.pg
with initial seed 773, one gets the following error. Other seeds work
fine and the code looks fine so I'm really confused. The error seems to
be coming from a sqrt error in line 31 of the code. I initially thought
the sqrts later in the problem were causing the error but even when
inserted code to insure that those numbers $norm_x, $norm_y were
positive, the problem still didn't work as the error was coming
earlier. But there's no square root earlier!
I'm baffled.
-Tom Software Error
WeBWorK has encountered a software error while attempting to process this problem. It is likely that there is an error in the problem itself. If you are a student, contact your professor to have the error corrected. If you are a professor, please consut the error output below for more informaiton. Error messages
Can't take sqrt of -4.44089e-16 at (eval 1491073) line 31. Error context
Problem1 ERROR caught by Translator while processing problem file:setHagedorn/WeirdError.pg * Can't take sqrt of -4.44089e-16 at (eval 1491073) line 31.
*
------Input Read 1 ##DESCRIPTION 2 ##KEYWORDS('linear algebra', 'inner product', 'dot product', 'angle') 3 ## 4 ##ENDDESCRIPTION 5 6 DOCUMENT(); # This should be the first executable line in the problem. 7 8 loadMacros( 9 PG.pl, 10 PGbasicmacros.pl, 11 PGchoicemacros.pl, 12 PGanswermacros.pl, 13 PGgraphmacros.pl, 14 PGnumericalmacros.pl, 15 PGstatisticsmacros.pl, 16 PGauxiliaryFunctions.pl, 17 PGmatrixmacros.pl 18 ); 19 20 TEXT(beginproblem()); 21 $showPartialCorrectAnswers = 1; 22 23 $prod = 0; 24 $norm_x = 0; 25 $norm_y = 0; 26 27 foreach $i (0..1) { 28 $x[$i] = non_zero_random(-5,5,1); 29 $y[$i] = non_zero_random(-5,5,1); 30 if ($y[$i] == $x[$i]) { 31 $y[$i] = 6; 32 } 33 $prod = $prod + $x[$i] * $y[$i]; 34 $norm_x = $norm_x + $x[$i] * $x[$i]; 35 $norm_y = $norm_y + $y[$i] * $y[$i]; 36 37 } 38 39 if($norm_x <0){$norm_x= -$norm_x}; 40 if($norm_y <0){$norm_y= -$norm_y}; 41 42 $norm_x = sqrt($norm_x); 43 $norm_y = sqrt($norm_y); 44 45 $angle = arccos( $prod / $norm_x / $norm_y); 46 47 BEGIN_TEXT 48 49 Find the angle ( alpha ) between the vectors 50 { mbox( display_matrix([[$x[0]], [$x[1]]]), ' and ', display_matrix([[$y[0]], [$y[1]]]), '.' ) } 51 $BR 52 ( alpha = ) {ans_rule(20)}. 53 54 END_TEXT 55 56 ANS(num_cmp($angle)); 57 ANS($norm_x); 58 ANS($norm_y); 59 ANS($x[1]); 60 ANS($x[0]); 61 ANS($y[0]); 62 ANS($y[1]); 63 64 65 ENDDOCUMENT(); # This should be the last executable line in the problem.
--
Edit this problem
This set is visible to students.
<| Post or View Comments |>
|