friendly / matlib

Matrix Functions for Teaching and Learning Linear Algebra and Multivariate Statistics
http://friendly.github.io/matlib/
65 stars 16 forks source link

symbolicMatrix developement #54

Closed friendly closed 2 months ago

friendly commented 2 months ago

This issue continues the conversation in #51, which no longer reflects it's current meaning.

friendly commented 2 months ago

From the discussion in #51, there was the idea to rename symbolicMatrix -> latexMatrix. Thoughts, now that we've progressed so far?

john-d-fox commented 2 months ago

That too is on my todo list. I was planning to get to it after merging the stuff in dev/Arith.R into /R, but I'm still working on Arith.R.

If you want to do it now uniformly in /R, the vignettes, etc. (but not in dev/Arith.R), please go head.

John

On 2024-08-12 3:42 p.m., Michael Friendly wrote:

Caution: External email.

From the discussion in #51 <https://github.com/friendly/matlib/ issues/51>, there was the idea to rename |symbolicMatrix| -> | latexMatrix|. Thoughts, now that we've progressed so far?

— Reply to this email directly, view it on GitHub <https://github.com/ friendly/matlib/issues/54#issuecomment-2284777613>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/ ADLSAQWUVIVUIEIGS3O77B3ZREFYZAVCNFSM6AAAAABMK555ICVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDEOBUG43TONRRGM>. You are receiving this because you are subscribed to this thread.Message ID: @.***>

friendly commented 2 months ago

Just about to take off.... I won't touch anything; will wait for the dust to settle.

john-d-fox commented 2 months ago

I just added a solve.symbolicMatrix() method to dev/Arith.R that finds the inverse via cofactors. Things do get unwieldy quickly, but the method is general. There are some examples at the end of the file, including:

B \begin{pmatrix} a & b \ c & d \ \end{pmatrix}

solve(B) \begin{pmatrix} d/(a \cdot d - b \cdot c) & (-b)/(a \cdot d - b \cdot c) \ (-c)/(a \cdot d - b \cdot c) & a/(a \cdot d - b \cdot c) \ \end{pmatrix}

Eqn(solve(B, simplify=TRUE))

\begin{equation} \frac{1}{(a \cdot d - b \cdot c)} \begin{pmatrix} d & -b \ -c & a \ \end{pmatrix} \end{equation}

example from

https://www.vedantu.com/maths/inverse-of-a-matrix-using-minors-cofactors-and-adjugate

X <- symbolicMatrix(matrix(c(3,2,0,1,1,1,2,-2,1), 3, 3)) X \begin{pmatrix} 3 & 1 & 2 \ 2 & 1 & -2 \ 0 & 1 & 1 \

\end{pmatrix}

MASS::fractions(as.numeric(solve(X))) [,1] [,2] [,3] [1,] 3/11 1/11 -4/11 [2,] -2/11 3/11 10/11 [3,] 2/11 -3/11 1/11

MASS::fractions(solve(as.numeric(X))) # check [,1] [,2] [,3] [1,] 3/11 1/11 -4/11 [2,] -2/11 3/11 10/11 [3,] 2/11 -3/11 1/11

John

On 2024-08-12 4:43 p.m., Michael Friendly wrote:

Caution: External email.

Just about to take off.... I won't touch anything; will wait for the dust to settle.

— Reply to this email directly, view it on GitHub <https://github.com/ friendly/matlib/issues/54#issuecomment-2284872383>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/ ADLSAQROJ6CA7JQQRZXAZXTZREM7BAVCNFSM6AAAAABMK555ICVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDEOBUHA3TEMZYGM>. You are receiving this because you commented.Message ID: <friendly/ @.***>