Symbolics.jl icon indicating copy to clipboard operation
Symbolics.jl copied to clipboard

get rref of augment matrix

Open phpsmarter opened this issue 3 years ago • 2 comments

prepare to get rref from expression

  1. write expression
  2. to augment matrix
  3. evaluate rref function to get rref

seems type has problem

let
	using LaTeXStrings,Symbolics,LinearAlgebra,RowEchelon,Latexify
	
	@variables x,y,z,eqs
    eq1=4x+3y+2z~4
	eq2=5x+4y+7z~2
	eq3=6x-4y+5z~5
	eqs=[eq1,eq2,eq3]
    coeffs,b=[(eq).lhs for eq in eqs],[(eq).rhs for eq in eqs]
	matrix=Symbolics.jacobian(coeffs,[x,y,z])
	augment_matrix=hcat(matrix,b)
	# reduce_matrix=rref(augment_matrix)   ??
	
end

phpsmarter avatar Jul 29 '22 02:07 phpsmarter

Please try:

using LaTeXStrings, Symbolics, LinearAlgebra, RowEchelon, Latexify

@variables x, y, z, eqs
eq1 = 4x + 3y + 2z ~ 4
eq2 = 5x + 4y + 7z ~ 2
eq3 = 6x - 4y + 5z ~ 5
eqs = [eq1, eq2, eq3]
coeffs, b = [(eq).lhs for eq in eqs], [(eq).rhs for eq in eqs]
matrix = Symbolics.jacobian(coeffs, [x, y, z])
augment_matrix = hcat(matrix, b)

augment_matrix = Symbolics.value.(augment_matrix)          # SEE HERE

reduce_matrix=rref(augment_matrix)

Num is a wrapper for Number and SymbolicUtils.Symbolic, etc.

You need to call Symbolics.value to get its internal values.

bowenszhu avatar Jul 29 '22 23:07 bowenszhu

Num is a wrapper for Number and SymbolicUtils.Symbolic, etc.

You need to call Symbolics.value to get its internal values.

Thanks !

phpsmarter avatar Jul 30 '22 00:07 phpsmarter