Difference between revisions of "MatrixOperations1"

From WeBWorK_wiki
Jump to navigation Jump to search
(add historical tag and give links to newer problems.)
 
(One intermediate revision by one other user not shown)
Line 1: Line 1:
  +
{{historical}}
  +
  +
<p style="font-size: 120%;font-weight:bold">This problem has been replaced with [https://openwebwork.github.io/pg-docs/sample-problems/LinearAlgebra/MatrixOperations.html a newer version of this problem]</p>
  +
 
<h2>Matrix Operations</h2>
 
<h2>Matrix Operations</h2>
   
Line 6: Line 10:
 
</p>
 
</p>
 
* File location in OPL: [https://github.com/openwebwork/webwork-open-problem-library/blob/master/OpenProblemLibrary/FortLewis/Authoring/Templates/LinAlg/MatrixOperations1.pg FortLewis/Authoring/Templates/LinAlg/MatrixOperations1.pg]
 
* File location in OPL: [https://github.com/openwebwork/webwork-open-problem-library/blob/master/OpenProblemLibrary/FortLewis/Authoring/Templates/LinAlg/MatrixOperations1.pg FortLewis/Authoring/Templates/LinAlg/MatrixOperations1.pg]
  +
* PGML location in OPL: [https://github.com/openwebwork/webwork-open-problem-library/blob/master/OpenProblemLibrary/FortLewis/Authoring/Templates/LinAlg/MatrixOperations1_PGML.pg FortLewis/Authoring/Templates/LinAlg/MatrixOperations1_PGML.pg]
 
* More problems like this in the OPL: [https://github.com/openwebwork/webwork-open-problem-library/blob/master/OpenProblemLibrary/Hope/Multi1/02-01-Matrix-operations/ Hope/Multi1/02-01-Matrix-operations/]
 
* More problems like this in the OPL: [https://github.com/openwebwork/webwork-open-problem-library/blob/master/OpenProblemLibrary/Hope/Multi1/02-01-Matrix-operations/ Hope/Multi1/02-01-Matrix-operations/]
   

Latest revision as of 05:24, 18 July 2023

This article has been retained as a historical document. It is not up-to-date and the formatting may be lacking. Use the information herein with caution.

This problem has been replaced with a newer version of this problem

Matrix Operations

Click to enlarge

This PG code shows how to assess whether a student knows whether two matrices can be multiplied and, when the matrix product exists, what the dimensions of a matrix product are.


Templates by Subject Area

PG problem file Explanation

Problem tagging data

Problem tagging:

DOCUMENT();
loadMacros(
"PGstandard.pl",
"MathObjects.pl",
"parserPopUp.pl",
"AnswerFormatHelp.pl",
"PGcourse.pl",
);
$showPartialCorrectAnswers = 0;
TEXT(beginproblem()); 

Initialization: We use parserPopUp.pl for the multiple choice part of the question. Use $showPartialCorrectAnswers = 0; to withhold feedback (we will use an all-or-nothing answer grader).

Context('Matrix');

$A = Matrix([
[non_zero_random(-5,5,1),non_zero_random(-5,5,1)],
[non_zero_random(-5,5,1),non_zero_random(-5,5,1)],
]);

$B = Matrix([
[non_zero_random(-5,5,1),non_zero_random(-5,5,1),non_zero_random(-5,5,1)],
[non_zero_random(-5,5,1),non_zero_random(-5,5,1),non_zero_random(-5,5,1)],
]);

$popup = PopUp(['Choose','True','False'],'False');

Setup: Create two 2 by 3 matrices and a true/false popup.

Context()->texStrings;
BEGIN_TEXT
Let 
\[ A = $A,\]
\[ B = $B.\]
If possible, compute the following.  
If an answer does not exist, enter ${BBOLD}DNE${EBOLD}.
$BR
$BR
\( AB = \)
\{ ans_box(3,30).$SPACE.AnswerFormatHelp('matrices') \}
$BR
$BR
\( BA = \)
\{ ans_box(3,30).$SPACE.AnswerFormatHelp('matrices') \}
$BR
$BR
\{ $popup->menu \} True or False: For any two matrices 
\( A \) and \( B \), both of the products \( AB \) and \( BA \) 
are always defined.
END_TEXT
Context()->normalStrings;

Main Text: Use ans_box(rows,cols) so that students must find the matrix product dimensions themselves, if the matrix product exists.

install_problem_grader(~~&std_problem_grader);

ANS( ($A * $B)->cmp() );
ANS( Compute('DNE')->cmp() );
ANS( $popup->cmp );

COMMENT('MathObject version.');

ENDDOCUMENT();

Answer Evaluation: Use the standard problem grader, which awards full credit only when all answers are correct and zero credit otherwise. Although it would have been better coding practice to construct the matrix product $A * $B in the Setup section, we did it in the answer section just to show you that it was possible to break "the rules". Standard matrix operations such as +, -, * can be used whenever the matrix operation makes sense.

Templates by Subject Area