Skip to content

Commit d7bfc0e

Browse files
committed
Merge remote-tracking branch 'origin/master' into dev
2 parents 2bf8385 + 2c84ace commit d7bfc0e

11 files changed

Lines changed: 56 additions & 26 deletions

File tree

doc/en/Topics/Linear_algebra/Matrix_library.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,15 @@ The last three predicates above will all accept an optional argument, `sp`, that
8383

8484
It is sometimes convenient to be able to display an augmented matrix. `matrix.mac` adds some limited support for this.
8585

86-
Perhaps you have a question in which students are asked to solve the matrix equation \(A\underline{\mathbf{x}} = \underline{\mathbf{b}}\) using Gaussian elimination and you wanted to display this problem as an augmented matrix. Then, with matrix `A` and right hand side vector (really a matrix) `b` already defined, you could use `aug(addcol(A,b))` to display
86+
Perhaps you have a question in which students are asked to solve the matrix equation \(A\underline{\mathbf{x}} = \underline{\mathbf{b}}\) using Gaussian elimination and you wanted to display this problem as an augmented matrix. Then, with matrix `A` and right hand side vector (really a matrix) `b` already defined, you could use `aug(A,b)` to display
8787

88-
\[{\left[\begin{array}{cc} 1 & 2 \\ 4 & 5 \end{array}\right|\left.\begin{array}{c} 3 \\ 6 \end{array}\right]}\]
88+
\[\left[\begin{array}{cc} 1 & 2 \\ 4 & 5 \end{array}\right|\left.\begin{array}{c} 3 \\ 6 \end{array}\right]\]
8989

90-
Really what is happening here is that `aug` is converting a matrix with concatenated columns `A` and `b` to an `aug_matrix`, which then displays as a matrix with its final column separated by a vertical bar. `aug_matrix` is an inert function that exists only in this library for display purposes. You can save this to a variable, perhaps `Ab`, but Maxima doesn't know that this is a matrix at all and so matrix operations won't work on it. To turn it back into a matrix, you can use `de_aug(Ab)`.
90+
Really what is happening here is that `aug` is converting a matrix with concatenated columns `A` and `b` to an `aug_matrix`, which then displays as a matrix with its final column separated by a vertical bar. `aug_matrix` is an inert function that exists only in this library for display purposes. You can save this to a variable, perhaps `Ab`, but Maxima doesn't know that this is a matrix at all and so matrix operations won't work on it. To turn it back into a matrix, you can use `de_aug(Ab)`. `de_aug` concatenates the input matrices instead of returning a list, so if you need more control you may prefer to programme your row operations separately and display `aug(A1,b1)`, `aug(A2,b2)` etc. manually.
91+
92+
This can generalise to as many inputs as needed. For instance, `aug(matrix([1,2,3],[4,5,6],[7,8,9]), matrix([1],[1],[1]), ident(3))` will display as
93+
94+
\[\left[\begin{array}{ccc} 1 & 2 & 3 \\ 4 & 5 & 6 \\ 7 & 8 & 9 \end{array}\left|\begin{array}{c} 1 \\ 1 \\ 1 \end{array}\right.\left|\begin{array}{ccc} 1 & 0 & 0 \\ 0 & 1 & 0 \\ 0 & 0 & 1 \end{array}\right.\right]\]
9195

9296
### Systems of equations
9397

doc/en/Topics/Proof/Proof_styles.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ We support the following CSS styles to enable consistent display of mathematical
44

55
Note, the precise style will also depend on the styles in your learning environment. The `class="proof"` styles focus on block structure and layout, e.g. indenting blocks and column layout. Colour and typeface are generally not specified in the proof styles (although a white background is defined). Styles are defined in `styles.css` of the top-level of the STACK plugin.
66

7+
### `<div class="statement">`
8+
9+
This class can be used to present the statement of a Theorem/Lemma/etc.
10+
11+
<div class="statement"><strong>Claim:</strong>\(\displaystyle \sum_{k=1}^n k = \frac{n(n+1)}{2}\)</div>
12+
713
### `<div class="proof">`
814

915
This class is a general high level container.

samplequestions/stacklibrary/HELM/Course_quiz_13_2-definite-integrals/top/Default-for-13-2/13-2-2-2-T-Definite-integral-switch-limits.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
</name>
77
<questiontext format="html">
88
<text><![CDATA[<p class="HELM_exercise">Exercise</p>
9-
<p>Find the definite integral of {@exp1@} from {@b1@} to {@b2@}, that is, find \(\displaystyle \int_{@b1@}^{@b2@} ({@exp@}) \, \mathrm{d}x\).</p>
9+
<p>Find the definite integral of {@exp1@} from {@b1@} to {@b2@}, that is, find \(\displaystyle \int_{@b1@}^{@b2@} ({@exp1@}) \, \mathrm{d}x\).</p>
1010
<p>First find the indefinite integral:</p>
1111
<p>\(\displaystyle \int ({@exp1@}) \, \mathrm{d}x = \) [[input:ans1]] [[validation:ans1]] [[feedback:prt1]]</p>
1212
<p>Now insert the limits of integration, the upper limit first, and hence evaluate the integral:</p>

samplequestions/stacklibrary/HELM/Course_quiz_2_6-the-circle/top/Default-for-2-6/2-6-1-6-Find-eq-of-circles.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
</li>
2323
2424
<li>
25-
<p>\( C({@x3@}, {@y4@}), \, R= {@r4@} :\) [[input:ans4]] [[validation:ans4]] [[feedback:prt4]]</p>
25+
<p>\( C({@x4@}, {@y4@}), \, R= {@r4@} :\) [[input:ans4]] [[validation:ans4]] [[feedback:prt4]]</p>
2626
</li>
2727
2828
</ol>]]></text>

samplequestions/stacklibrary/HELM/Course_quiz_2_6-the-circle/top/Default-for-2-6/2-6-1-7-Write-eq-of-cirlce.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
<text>ordergreat (x,y);
4848
ta1: x^2+y^2 = 2^2;
4949
ta2: (x-1)^2+y^2=1^2;
50-
ta3: (x-3)^3+(y-3)^2=3^2;
50+
ta3: (x-3)^2+(y-3)^2=3^2;
5151
ta4: (x+1)^2+(y+1)^2=1^2;</text>
5252
</questionvariables>
5353
<specificfeedback format="html">

samplequestions/stacklibrary/Introductory-Mathematics/Week-01---Quadratic-functions-and-their-graphs/1-2-10-(Complete-the-square-ax^2+bx+c).xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<text><![CDATA[<p>Write {@quad@} in completed square form:</p><p>[[input:ans1]] [[validation:ans1]]</p>]]></text>
99
</questiontext>
1010
<generalfeedback format="html">
11-
<text><![CDATA[<p>We first need to take out the&nbsp;\(x^2\) coefficient as a factor from the&nbsp;\(x^2\) and \(x\) terms:</p><p>\[{@quad@}={@(a*(ev(x^2+b/a*x,simp))+c),simp=false@} \]</p><p>Now working inside the bracket, we complete the square {@(simp:true,x^2+(b/a)*x)@} using the bracket {@(x+b/(2*a))^2@} and compensating by subtracting \(\left({@b/(2*a)@}\right)^2\):</p><p>\[ \begin{align*} {@quad@} &amp;={@(a*(ev(x^2+b/a*x,simp))+c),simp=false@} \\ &amp;={@(a*(ev((x+b/(2*a))^2,simp)-(ev(b/(2*a),simp))^2)+c),simp=false@} \\ &amp;= {@a*ev((x+b/(2*a))^2,simp) -(make_multsgn("cross"),a*(ev(b/(2*a),simp))^2)+c,simp=false@} \\ &amp;= {@(make_multsgn("blank"),ta1)@} \end{align*} \]</p>]]></text>
11+
<text><![CDATA[<p>We first need to take out the&nbsp;\(x^2\) coefficient as a factor from the&nbsp;\(x^2\) and \(x\) terms:</p><p>\[{@quad@}={@(a*(ev(x^2+b/a*x,simp))+c),simp=false@} \]</p><p>Now working inside the bracket, we complete the square {@(simp:true,x^2+(b/a)*x)@} using the bracket {@(x+b/(2*a))^2@} and compensating by subtracting \(\left({@b/(2*a)@}\right)^2\):</p><p>\[ \begin{align*} {@quad@} &amp;={@(a*(ev(x^2+b/a*x,simp))+c),simp=false@} \\ &amp;={@(a*(ev((x+b/(2*a))^2,simp)-(ev(b/(2*a),simp))^2)+c),simp=false@} \\ &amp;= {@a*ev((x+b/(2*a))^2,simp) -(make_multsgn("cross"),a*(ev(b/(2*a),simp))^2)+c,simp=false@} \\ &amp;= {@(make_multsgn("none"),ta1)@} \end{align*} \]</p>]]></text>
1212
</generalfeedback>
1313
<defaultgrade>1</defaultgrade>
1414
<penalty>0.1</penalty>

samplequestions/stacklibrary/Introductory-Mathematics/Week-01---Quadratic-functions-and-their-graphs/1-2-11-(Solve-by-completing-the-square-ax^2+bx+c).xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<p>[[input:ans2]] [[validation:ans2]][[feedback:prt2]]</p>]]></text>
1212
</questiontext>
1313
<generalfeedback format="html">
14-
<text><![CDATA[<p>We first need to take out the&nbsp;\(x^2\) coefficient as a factor from the&nbsp;\(x^2\) and \(x\) terms:</p><p>\[{@quad@}={@(a*(ev(x^2+b/a*x,simp))+c),simp=false@} \]</p><p>Now working inside the bracket, we complete the square {@(simp:true,x^2+(b/a)*x)@} using the bracket {@(x+b/(2*a))^2@} and compensating by subtracting \(\left({@b/(2*a)@}\right)^2\):</p><p>\[ \begin{align*} {@quad@} &amp;={@(a*(ev(x^2+b/a*x,simp))+c),simp=false@} \\ &amp;={@(a*(ev((x+b/(2*a))^2,simp)-(ev(b/(2*a),simp))^2)+c),simp=false@} \\ &amp;= {@a*ev((x+b/(2*a))^2,simp) -(make_multsgn("cross"),a*(ev(b/(2*a),simp))^2)+c,simp=false@} \\ &amp;= {@(make_multsgn("blank"),ta1)@} \end{align*} \]</p>]]></text>
14+
<text><![CDATA[<p>We first need to take out the&nbsp;\(x^2\) coefficient as a factor from the&nbsp;\(x^2\) and \(x\) terms:</p><p>\[{@quad@}={@(a*(ev(x^2+b/a*x,simp))+c),simp=false@} \]</p><p>Now working inside the bracket, we complete the square {@(simp:true,x^2+(b/a)*x)@} using the bracket {@(x+b/(2*a))^2@} and compensating by subtracting \(\left({@b/(2*a)@}\right)^2\):</p><p>\[ \begin{align*} {@quad@} &amp;={@(a*(ev(x^2+b/a*x,simp))+c),simp=false@} \\ &amp;={@(a*(ev((x+b/(2*a))^2,simp)-(ev(b/(2*a),simp))^2)+c),simp=false@} \\ &amp;= {@a*ev((x+b/(2*a))^2,simp) -(make_multsgn("cross"),a*(ev(b/(2*a),simp))^2)+c,simp=false@} \\ &amp;= {@(make_multsgn("none"),ta1)@} \end{align*} \]</p>]]></text>
1515
</generalfeedback>
1616
<defaultgrade>1</defaultgrade>
1717
<penalty>0.1</penalty>

stack/maxima/contrib/matrix.mac

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -28,39 +28,43 @@ stack_linear_algebra_declare(true)$
2828
/*******************************************************************************/
2929
/* A convenience function for displaying a matrix as an augmented matrix */
3030
/*******************************************************************************/
31-
texput(aug_matrix, lambda([ex], block([M,ll,rr,m,n,A,b,simp],
32-
simp:true,
33-
M: apply(matrix,args(ex)),
34-
ll: lmxchar,
35-
if is(ll="[") then rr: "]"
36-
else if is(ll="(") then rr: ")"
37-
else if is(ll="") then (ll: ".", rr: ".")
38-
else if is(ll="{") then (ll: "\\{", rr: "\\}")
39-
else if is(ll="|") then rr: "|",
40-
[m, n]: matrix_size(M),
41-
A: submatrix(M,n),
42-
b: col(M,n),
43-
sconcat("\\left",ll,block([lmxchar],lmxchar:"",tex1(A)),"\\right|\\left.",block([lmxchar],lmxchar:"",tex1(b)),"\\right",rr)
44-
)));
31+
texput(aug_matrix, lambda([ex],
32+
block([exl:args(ex),ii,ss,ll:lmxchar,rr,lmxchar],
33+
if is(ll="[") then rr: "]"
34+
else if is(ll="(") then rr: ")"
35+
else if is(ll="") then (ll: ".", rr: ".")
36+
else if is(ll="{") then (ll: "\\{", rr: "\\}")
37+
else if is(ll="|") then rr: "|",
38+
lmxchar: "",
39+
ss: ["\\left",ll,tex1(exl[1])],
40+
for ii: 2 thru length(exl) do block(
41+
ii: ev(ii,simp),
42+
ss: append(ss, ["\\left|",tex1(exl[ii]),"\\right."])
43+
),
44+
ss: append(ss, ["\\right",rr]),
45+
return(simplode(ss))
46+
)
47+
));
4548

4649
/**
4750
* Converts a matrix to an aug_matrix
4851
* aug_matrix is an inert function that is used for displaying a matrix as an augmented matrix
4952
* To convert back, use de_aug
5053
*
51-
* @param[matrix] M The matrix you would like to display as an augmented matrix
54+
* @param[matrix] M The matrix or matrices you would like to display as an augmented matrix
5255
* @return[aug_matrix] An augmented matrix
5356
*/
54-
aug(M):= apply(aug_matrix,args(M));
57+
aug([M]):= if is(length(M)=1) then apply(aug_matrix,[submatrix(first(M),second(matrix_size(first(M)))),col(first(M),second(matrix_size(first(M))))]) else apply(aug_matrix,M);
5558

5659
/**
5760
* Converts an aug_matrix to a matrix
5861
* aug_matrix is an inert function that is used for displaying a matrix as an augmented matrix
62+
* Note: This always returns a single matrix constructed by concatenating the arguments of the original aug_matrix.
5963
*
6064
* @param[matrix] M The aug_matrix you would like to treat as a regular matrix
6165
* @return[aug_matrix] A matrix
6266
*/
63-
de_aug(M):= apply(matrix,args(M));
67+
de_aug(M):= apply(addcol, args(M));
6468

6569
/*********************************************************************************/
6670
/* Functions to extract parts of matrices */

stack/maxima/contrib/matrix_test.mac

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,15 @@
3030

3131
s_test_case(aug(matrix([1,2,3,1],[4,5,6,1],[7,8,9,1])),aug_matrix([1,2,3,1],[4,5,6,1],[7,8,9,1]));
3232
s_test_case(de_aug(aug_matrix([1,2,3,1],[4,5,6,1],[7,8,9,1])),matrix([1,2,3,1],[4,5,6,1],[7,8,9,1]));
33+
s_test_case(de_aug(aug(ident(4),matrix([1],[2],[3],[4]),ident(4))),matrix([1,0,0,0,1,1,0,0,0],[0,1,0,0,2,0,1,0,0],[0,0,1,0,3,0,0,1,0],[0,0,0,1,4,0,0,0,1]));
34+
35+
lmxchar: "[";
36+
s_test_case(tex1(aug(matrix([1,2,3],[4,5,6],[7,8,9]),matrix([1],[1],[1]))),"\\left[\\begin{array}{ccc} 1 & 2 & 3 \\\\ 4 & 5 & 6 \\\\ 7 & 8 & 9 \\end{array}\\left|\\begin{array}{c} 1 \\\\ 1 \\\\ 1 \\end{array}\\right.\\right]");
37+
s_test_case(tex1(aug(matrix([1,2,3,1],[4,5,6,1],[7,8,9,1]))),"\\left[\\begin{array}{ccc} 1 & 2 & 3 \\\\ 4 & 5 & 6 \\\\ 7 & 8 & 9 \\end{array}\\left|\\begin{array}{c} 1 \\\\ 1 \\\\ 1 \\end{array}\\right.\\right]");
38+
s_test_case(tex1(aug(matrix([1,2,3],[4,5,6],[7,8,9]),matrix([1],[1],[1]),matrix([3,2,1,0],[6,5,4,3],[9,8,7,6]))),"\\left[\\begin{array}{ccc} 1 & 2 & 3 \\\\ 4 & 5 & 6 \\\\ 7 & 8 & 9 \\end{array}\\left|\\begin{array}{c} 1 \\\\ 1 \\\\ 1 \\end{array}\\right.\\left|\\begin{array}{cccc} 3 & 2 & 1 & 0 \\\\ 6 & 5 & 4 & 3 \\\\ 9 & 8 & 7 & 6 \\end{array}\\right.\\right]");
39+
lmxchar: "{";
40+
s_test_case(tex1(aug(matrix([1,2,3],[4,5,6],[7,8,9]),matrix([1],[1],[1]))),"\\left\\{\\begin{array}{ccc} 1 & 2 & 3 \\\\ 4 & 5 & 6 \\\\ 7 & 8 & 9 \\end{array}\\left|\\begin{array}{c} 1 \\\\ 1 \\\\ 1 \\end{array}\\right.\\right\\}");
41+
lmxchar: "[";
3342

3443
s_test_case(triu(matrix([1,2,3],[4,5,6],[7,8,9])),matrix([1,2,3],[0,5,6],[0,0,9]));
3544
s_test_case(triu(matrix([1,2,3],[4,5,6],[7,8,9],[10,11,12])),matrix([1,2,3],[0,5,6],[0,0,9],[0,0,0]));

stack/maxima/contrib/matrixfactorizations.mac

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ get_Jordan_form(M):= block([jordan_info,J,P],
7272
diagonalize(M):= block([P,D],
7373
if not(squarep(M)) then return([]),
7474
[P, D]: get_Jordan_form(M),
75-
if ev(zeromatrixp(M - transpose(M)),simp) then P:ev(transpose(apply('matrix, map(lambda([ex], ex/sqrt(ex.ex)), args(transpose(P))))), simp),
75+
if ev(zeromatrixp(M - transpose(M)),simp) then P:ev(transpose(apply('matrix, map(lambda([ex], ex/sqrt(ex.ex)), gramschmidt(args(transpose(P)))))), simp),
7676
if diagp(D) then return([P,D]) else return([])
7777
);
7878

0 commit comments

Comments
 (0)