Skip to content

Commit dbcb4c3

Browse files
authored
Merge pull request #1065 from gajennings/main
Fix bug 4773
2 parents ec8b99b + cee2af7 commit dbcb4c3

File tree

1 file changed

+24
-23
lines changed
  • OpenProblemLibrary/WHFreeman/Holt_linear_algebra/Chaps_1-4

1 file changed

+24
-23
lines changed

OpenProblemLibrary/WHFreeman/Holt_linear_algebra/Chaps_1-4/3.5.36.pg

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
## Author(Darwyn Cook)
1111
## Level(2)
1212
## MO(1)
13+
## Static(1)
1314
## TitleText1('Linear Algebra with Applications')
1415
## AuthorText1('Holt')
1516
## EditionText1('1')
@@ -23,9 +24,9 @@ DOCUMENT();
2324
loadMacros(
2425
"PGstandard.pl",
2526
"MathObjects.pl",
26-
"freemanMacros.pl",
27-
"PGmatrixmacros.pl",
27+
"parserPopUp.pl",
2828
"parserMultiAnswer.pl",
29+
"PGmatrixmacros.pl",
2930
"PGcourse.pl"
3031
);
3132

@@ -40,30 +41,26 @@ $showPartialCorrectAnswers = 1;
4041
# Setup
4142
#
4243
#
43-
Context("Numeric");
44+
Context("Matrix");
4445
Context()->variables->are(a=>"Real",b=>"Real");
4546

47+
$tf = PopUp(['???','True','False'],'True');
48+
49+
$A = Matrix([[Formula("a"),Formula("1-b")],[Formula("1-a"),Formula("b")]]);
50+
4651
$multians = MultiAnswer(Formula("(1-b)/(2-a-b)"),Formula("(1-a)/(2-a-b)"))->with(
47-
singleResult => 0,
52+
singleResult => 1,
4853
checker => sub {
4954
my ( $correct, $student, $self ) = @_;
5055
my ( $stu1,$stu2 ) = @{$student};
5156
my ( $correct1, $correct2 ) = @{$correct};
52-
if (($stu1 == 1) && ($stu2 == 1)){
53-
$self->setMessage(1,'The answer is true, you need to find a vector.');
54-
return [0,0];
55-
}
56-
elsif ($stu1 + $stu2 != 1){
57-
$self->setMessage(1,'Your vector is not a state vector.');
58-
return [0,0];
57+
if ($stu1 + $stu2 != 1){
58+
Value::Error('Your vector is not a state vector.');
5959
}
60-
elsif (Formula("a*$stu1+b*$stu2") != $stu1){
61-
return [0,0];
62-
}
63-
elsif (Formula("(1-a)*$stu1+(1-b)*$stu2") != $stu2){
64-
return [1,0];
65-
}
66-
else {return [1,1]};
60+
if ( (Formula("a*$stu1+(1-b)*$stu2") != $stu1) or
61+
(Formula("(1-a)*$stu1+b*$stu2") != $stu2) )
62+
{Value->Error("Your vector is not a steady-state vector for \(A\)");}
63+
else {return 1};
6764
}
6865
);
6966

@@ -75,12 +72,14 @@ $multians = MultiAnswer(Formula("(1-b)/(2-a-b)"),Formula("(1-a)/(2-a-b)"))->with
7572

7673
Context()->texStrings;
7774
BEGIN_TEXT
78-
\{ textbook_ref_exact("Holt Linear Algebra", "3.5","36") \}
79-
$BR
80-
True or False: Every 2 × 2 stochastic matrix has at least one steady-state
81-
vector.
75+
Every 2x2 stochastic matrix \(A\) has the form
76+
\[A = $A\] $BR
77+
where \(0\leq a\leq 1\) and \(0\leq b \leq 1\).
78+
$PAR
79+
1) \{$tf->menu()\} True or False: Every 2×2 stochastic matrix has at least one steady-state vector.$PAR
80+
81+
2) If \(A\) has a steady-state vector enter it here. If it has is no steady-state matrix enter the zero vector.
8282
$BR
83-
\{mbox("Note: Every 2 x 2 stochastic matrix has the form A = ", display_matrix([["\({\rm a}\)","\({\rm 1-b}\)"],["\({\rm 1-a}\)","\({\rm b}\)"]]))\} where \(0 \leq {\rm a} \leq 1\) and \(0 \leq {\rm b} \leq 1\). If there is a steady-state vector for this matrix enter it below, otherwise enter all 1's for the vector.
8483
\{display_matrix([[$multians->ans_rule],[$multians->ans_rule]])\}
8584
END_TEXT
8685
Context()->normalStrings;
@@ -91,6 +90,8 @@ Context()->normalStrings;
9190
#
9291
#
9392

93+
94+
ANS($tf->cmp);
9495
ANS($multians->cmp());
9596

9697
ENDDOCUMENT();

0 commit comments

Comments
 (0)