-
-
Notifications
You must be signed in to change notification settings - Fork 436
Expand file tree
/
Copy path5-10-MatrixMultiplicationWithVariables.pg
More file actions
97 lines (85 loc) · 2.6 KB
/
5-10-MatrixMultiplicationWithVariables.pg
File metadata and controls
97 lines (85 loc) · 2.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
## DESCRIPTION
## Matrix multiplication problems with variable entries
## ENDDESCRIPTION
## DBsubject(Linear Algebra)
## DBchapter(Matrices)
## DBsection(Matrix Algebra)
## Date(02/02/2018)
## Institution(Bentley University)
## Author(Nathan Carter)
## TitleText1('Introduction to the Mathematics of Computer Graphics')
## AuthorText1('Nathan Carter')
## EditionText1('1')
## Section1('5')
## Problem1('10')
## KEYWORDS('matrices','matrix multiplication')
DOCUMENT();
loadMacros(
"PGstandard.pl",
"MathObjects.pl",
"PGML.pl",
"PGcourse.pl",
"PGessaymacros.pl",
);
Context("Matrix");
Context()->variables->add( u => Real );
Context()->variables->add( v => Real );
Context()->variables->add( w => Real );
Context()->variables->add( a => Real );
Context()->variables->add( b => Real );
Context()->variables->add( c => Real );
Context()->variables->add( d => Real );
Context()->variables->add( e => Real );
$showPartialCorrectAnswers = 1;
$L3 = Matrix( [
[ Formula( list_random( 0, 1, "a", "b", "c" ) ),
Formula( list_random( 0, 1, "a", "b", "c" ) ),
Formula( list_random( 0, 1, "a", "b", "c" ) ) ],
[ Formula( list_random( "a", "b", "c" ) ),
Formula( list_random( "a", "b", "c" ) ),
Formula( list_random( 0, 1, "a", "b", "c" ) ) ],
[ 0, 0, 1 ]
] );
$R3 = Matrix( [
[ Formula( list_random( 0, 1, "d", "e" ) ),
Formula( list_random( 0, 1, "d", "e" ) ),
Formula( list_random( 0, 1, "d", "e" ) ) ],
[ Formula( list_random( "d", "e" ) ),
Formula( list_random( 0, 1 ) ),
Formula( list_random( 0, 1 ) ) ],
[ 0, 0, 1 ]
] );
$L4 = Matrix( [
[ 1, 0, 0, Formula("u") ],
[ 0, 1, 0, Formula("v") ],
[ 0, 0, 1, Formula("w") ],
[ 0, 0, 0, 1 ]
] );
$R4 = Matrix( [
[ Formula("x"), 0, 0, 0 ],
[ 0, Formula("y"), 0, 0 ],
[ 0, 0, Formula("z"), 0 ],
[ 0, 0, 0, 1 ]
] );
if ( random(0,1) == 1 ) {
$tmp = $R4;
$R4 = $L4;
$L4 = $tmp;
}
$v1 = Formula( list_random( "u", "v", "w", "x", "y", "z" ) );
$v2 = Formula( list_random( "u", "v", "w", "x", "y", "z" ) );
$Lv = Matrix( [ [ $v1, 0, 0, $v2 ], [ 0, $v1, 0, $v2 ], [ 0, 0, $v1, $v2 ], [ 0, 0, 0, 1 ] ] );
$Rv = Matrix( [ [ random(1,9) ], [ random(1,9) ], [ random(1,9) ], [ 1 ] ] );
TEXT(beginproblem());
BEGIN_PGML
Compute the results of each matrix multiplication shown below.
[`[$L3][$R3]=`][_____]*{$L3*$R3} [@ helpLink("matrices") @]*
[`[$L4][$R4]=`][_____]*{$L4*$R4} [@ helpLink("matrices") @]*
[`[$Lv][$Rv]=`][_____]*{$Lv*$Rv} [@ helpLink("matrices") @]*
END_PGML
BEGIN_PGML_SOLUTION
[`[$L3][$R3]=[$L3*$R3]`]
[`[$L4][$R4]=[$L4*$R4]`]
[`[$Lv][$Rv]=[$Lv*$Rv]`]
END_PGML_SOLUTION
ENDDOCUMENT();