[npl] / trunk / NationalProblemLibrary / TCNJ / TCNJ_LengthOrthogonality / problem6.pg Repository: Repository Listing bbplugincoursesdistsnplrochestersystemwww

# View of /trunk/NationalProblemLibrary/TCNJ/TCNJ_LengthOrthogonality/problem6.pg

Mon Jun 5 02:05:20 2006 UTC (6 years, 11 months ago) by jj
File size: 1275 byte(s)
Fixed answer evaluators and did other cleaning.


    1 ## DESCRIPTION
2 ## Linear Algebra
3 ## ENDDESCRIPTION
4
5 ## KEYWORDS('inner product' 'orthogonal' 'angle')
6 ## Tagged by tda2d
7
8 ## DBsubject('Linear Algebra')
9 ## DBchapter('Vector Spaces')
10 ## DBsection('Inner Product')
11 ## Date('')
12 ## Author('')
13 ## Institution('TCNJ')
14 ## TitleText1('')
15 ## EditionText1('')
16 ## AuthorText1('')
17 ## Section1('')
18 ## Problem1('')
19
20 DOCUMENT();        # This should be the first executable line in the problem.
21
23 "PG.pl",
24 "PGbasicmacros.pl",
26 "PGauxiliaryFunctions.pl",
27 "PGmatrixmacros.pl"
28 );
29
30 TEXT(beginproblem());
31 $showPartialCorrectAnswers = 1; 32 33$prod = 0;
34 $norm_x = 0; 35$norm_y = 0;
36
37 foreach $i (0..1) { 38$x[$i] = non_zero_random(-5,5,1); 39$y[$i] = non_zero_random(-5,5,1); 40 if ($y[$i] ==$x[$i]) { 41$y[$i] = 6; 42 } 43$prod += $x[$i] * $y[$i];
44     $norm_x +=$x[$i] *$x[$i]; 45$norm_y += $y[$i] * $y[$i];
46 }
47
48 $norm_x = sqrt($norm_x);
49 $norm_y = sqrt($norm_y);
50
51 $angle = arccos($prod / $norm_x /$norm_y);
52
53 BEGIN_TEXT
54
55 Find the angle $$\alpha$$ between the vectors
56 \{ mbox( display_matrix([[$x[0]], [$x[1]]]), ' and ', display_matrix([[$y[0]], [$y[1]]]), '.' ) \}
57 $BR 58 $$\alpha =$$ \{ans_rule(20)\}. 59 60 END_TEXT 61 62 ANS(num_cmp($angle));
63
64
65 ENDDOCUMENT();       # This should be the last executable line in the problem.
66