# timhunt/moodle-qtype_stack forked from maths/moodle-qtype_stack

1 parent 68579f6 commit f74dfb95b8ac4c2365ba6cec44159763ba3236bd sangwinc committed Jun 27, 2012
4 doc/en/Authoring/Sample_questions.md
 @@ -20,6 +20,10 @@ A rectangle has length 6cm greater than its width. If it has an area of 27cm\$^2\$ This is a multi-part question which illustrates _follow-through marking_. Get the first part wrong, but the second part correct based on the first part to see the feedback. +### `test_3_matrix.xml` ### + +This question creates two random matrices and asks students to multiply them together. See the notes on [matrices](../CAS/Matrix.md). + ### `railways.xml` ### In a railway journey of 90km an increase of 5 kilometers per hour in the speed decreases the time taken by 15 minutes.
11 doc/en/CAS/Matrix.md
 @@ -39,6 +39,17 @@ The above equation is then generated by the CASText \[ @A@+@B@=@C@=@D@.\] +A similar procedure is needed for showing working when multiplying matrices. Here we need to loop over the matrices, but there must be a more elegant way to do this. + + A:ev(rand(matrix([5,5],[5,5]))+matrix([2,2],[2,2]),simp); + B:ev(rand(matrix([5,5],[5,5]))+matrix([2,2],[2,2]),simp); + BT:transpose(B); + C:zeromatrix (first(matrix_size(A)), second(matrix_size(A))); + S:for a:1 thru first(matrix_size(A)) do for b:1 thru second(matrix_size(A)) do C[ev(a,simp),ev(b,simp)]:apply("+",zip_with("*",A[ev(a,simp)],BT[ev(b,simp)])); + D:ev(C,simp); + +Notice we need to simplify the arguments before we take indices of expressions. This is one problem with `simp:false`. + ## Vectors ## If you are trying to use the vector notation such as \(3i+4j\) you will probably want to redefine \(i\) to be an abstract symbol, not a complex number.
0 samplequestions/CR-Diff-01_basic.xml → samplequestions/CR_Diff-01_basic.xml
File renamed without changes.
212 samplequestions/test_3_matrix.xml
 @@ -0,0 +1,212 @@ + + + + + + test_3_matrix + + + Calculate \[ @A@.@B@\]

+

[[input:ans1]] [[validation:ans1]]

]]>
+
+ + To multiply matrices \$A\$ and \$B\$ we need to remember that the \$(i,j)\$th entry is the scalar product of the \$i\$th row of \$A\$ with the \$j\$th column of \$B\$.

+

\[ @A@.@B@ = @C@ = @D@.\]

]]>
+
+ 1.0000000 + 0.1000000 + 0 + + + + + [[feedback:prt1]]

]]>
+
+ + \$@A@.@B@=@TA@\$ + + 0 + 0 + + Correct answer, well done.

]]>
+

]]>
+

]]>
+
+ dot + 1 + i + + + ans1 + matrix + TA + 3 + 1 + 0 + + + 1 + 1 + 1 + 1 + 1 + + + prt1 + 1.0000000 + 1 + + + + + 0 + AlgEquiv + ans1 + TA + + 1 + = + 1.0000000 + + -1 + 1-0-T + + + + = + 0.0000000 + + 1 + 1-0-F + + + + + + 1 + AlgEquiv + ans1 + TB + + 1 + = + 0.0000000 + + -1 + 1-1-T + + Remember, you don't multiply matrices by multiplying the corresponding entries! A quite different process is needed.

]]>
+
+ = + 0.0000000 + + 2 + 1-1-F + + + +
+ + 2 + AlgEquiv + ans1 + A+B + + 1 + = + 0.0000000 + + -1 + 1-3-T + + Please multiply the matrices. It looks like you have added them instead!

]]>
+
+ = + 0.0000000 + + -1 + 1-3-F + + + +
+
+ + 1 + + ans1 + TA + + + prt1 + 1.0000000 + 0.0000000 + 1-0-T + + + + 2 + + ans1 + TB + + + prt1 + 0.0000000 + 0.1000000 + 1-1-T + + + + 3 + + ans1 + A+B + + + prt1 + 0.0000000 + 0.1000000 + 1-3-T + + + + 4 + + ans1 + 1 + + + prt1 + + + NULL + + + + 5 + + ans1 + A + + + prt1 + 0.0000000 + 0.1000000 + 1-3-F + + +
+ +
6 stack/cas/casstring.class.php