friendly / matlib

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

showEqn (simplify=TRUE) error #45

Closed rjrovetti closed 1 year ago

rjrovetti commented 1 year ago

Coefficient is incorrect in some cases when simplify=TRUE

Reproducible case: M = matrix(c(-10,2,3,4), ncol=2) b = c(1,2) showEqn(M,b) showEqn(M,b, simplify=TRUE)

friendly commented 1 year ago

John Fox contributed a fix to this, presently on a testing branch

philchalmers commented 1 year ago

Looks good now.

library(matlib)
M = matrix(c(-10,2,3,4), ncol=2)
b = c(1,2)
showEqn(M,b)
#> -10*x1 + 3*x2  =  1 
#>   2*x1 + 4*x2  =  2
showEqn(M,b, simplify=TRUE)
#> -10*x1 + 3*x2  =  1 
#>   2*x1 + 4*x2  =  2

Created on 2022-12-06 with reprex v2.0.2