Skip to content

Commit 8806d67

Browse files
authored
Merge pull request #1274 from dlglin/updateTCNJLinInd
Convert problem to PGML and add solution
2 parents febba71 + e765891 commit 8806d67

File tree

1 file changed

+33
-44
lines changed
  • OpenProblemLibrary/TCNJ/TCNJ_LinearIndependence

1 file changed

+33
-44
lines changed

OpenProblemLibrary/TCNJ/TCNJ_LinearIndependence/problem3.pg

Lines changed: 33 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -14,64 +14,53 @@
1414
## EditionText1('1')
1515
## Section1('2.3')
1616
## Problem1('')
17-
DOCUMENT(); # This should be the first executable line in the problem.
17+
DOCUMENT(); # This should be the first executable line in the problem.
1818

19-
loadMacros(
20-
"PGstandard.pl",
21-
"PGchoicemacros.pl",
22-
"PGgraphmacros.pl",
23-
"PGmatrixmacros.pl",
24-
"PGcourse.pl"
25-
);
19+
loadMacros("PGstandard.pl", "PGML.pl", "PGcourse.pl");
2620

27-
TEXT(beginproblem());
2821
$showPartialCorrectAnswers = 1;
2922

30-
$a = non_zero_random(1,8,1);
31-
$b = non_zero_random(1,8,1);
32-
if($a<$b){
33-
$c=$b;
34-
$b=$a;
35-
$a=$c;
23+
$a = non_zero_random(1, 8, 1);
24+
$b = non_zero_random(1, 8, 1);
25+
if ($a < $b) {
26+
$c = $b;
27+
$b = $a;
28+
$a = $c;
3629
} else {
37-
if ($a == $b) { $a=$b+1; }}
38-
30+
if ($a == $b) { $a = $b + 1; }
31+
}
3932

4033
## $a is now the larger value
4134
## $a and -$b will be the roots of the equation.
4235

43-
$c= $a -$b;
44-
$d= $a * $b;
36+
$c = $a - $b;
37+
$d = $a * $b;
4538

39+
Context("Numeric")->variables->are('k' => 'Real');
40+
Context()->noreduce('(-x)-y');
41+
$f = Formula("$c*k+$d")->reduce();
42+
$g = Formula("k^2-$c*k-$d")->reduce();
43+
$ans1 = List(-$b, $a);
4644

47-
if( $a == $b+1){
48-
BEGIN_TEXT
49-
$BR
45+
BEGIN_PGML
46+
If [`k`] is a real number, then the vectors [`\begin{bmatrix}1\\ k\end{bmatrix},\begin{bmatrix}k\\[$f]\end{bmatrix}`]
47+
are linearly independent precisely when [`k \ne`][_]{$ans1}{5}
5048

51-
If \(k\) is a real number, then
52-
the
53-
vectors \( (1, k), (k, k+ $d) \) are linearly independent precisely when
49+
If there is more than one value, enter a list separated by commas.
50+
END_PGML
5451

55-
\( k \ne a, b \), $BR
56-
where \(a= \)\{ans_rule(10)\}, \(b = \) \{ans_rule(10)\}, and
57-
\( a<b \).
58-
END_TEXT
59-
}else{
60-
BEGIN_TEXT
61-
$BR
52+
BEGIN_PGML_SOLUTION
53+
The vectors will be linearly independent provided that if [`a\begin{bmatrix}1\\ k\end{bmatrix}+b\begin{bmatrix}k\\[$f]\end{bmatrix}=\begin{bmatrix} 0\\0\end{bmatrix}`], then [`a=0`] and [`b=0`].
6254

63-
If \(k\) is a real number, then the
64-
vectors \( (1, k), (k, $c k+ $d) \) are linearly independent precisely when
65-
66-
\( k \ne a, b \), $BR
67-
where \(a= \)\{ans_rule(5)\}, \(b = \) \{ans_rule(5)\}, and
68-
\( a<b \).
69-
END_TEXT
70-
}
55+
This is equivalent to checking that the system of equations given by [`\begin{bmatrix}1 & k\\k & [$f]\end{bmatrix}\begin{bmatrix}a\\ b\end{bmatrix}=\begin{bmatrix}0\\0\end{bmatrix}`] has a unique solution.
7156

57+
One way to do this is to check that the determinant of the coefficient matrix is nonzero:
7258

59+
[`\begin{array}{rcl}\begin{vmatrix}1 & k\\k & [$f]\end{vmatrix}\ne 0 & \Rightarrow & ([$f])-k^2\ne 0\\
60+
& \Rightarrow & [$g]\ne 0\\
61+
& \Rightarrow & (k+[$b])(k-[$a])\ne 0\\
62+
& \Rightarrow & k\ne-[$b],[$a]
63+
\end{array}`]
64+
END_PGML_SOLUTION
7365

74-
$k=2;
75-
ANS(num_cmp(-$b));
76-
ANS(num_cmp($a));
77-
ENDDOCUMENT(); # This should be the last executable line in the problem.
66+
ENDDOCUMENT(); # This should be the last executable line in the problem.

0 commit comments

Comments
 (0)