RREF with unknown variables

조회 수: 17 (최근 30일)
Janne
Janne 2022년 11월 18일
편집: John D'Errico 2024년 4월 28일
Hi
Suppose I have an augmented matrix with unknown variables and I want to reduce it to its reduced row echelon form. How to do this in Matlab ?
Example matrix:
[1, 2, 3, a;
4, 5, 6, b;
7, 8, 9, c;]
Thanks for advance!
  댓글 수: 1
Janne
Janne 2022년 11월 18일
Hey
Thanks for the answer. I was not specific enough. So the issue was I couldnt assign variables (assigned by 'syms') to the "excel sheet" where I was assigning elements to it.
--Janne

댓글을 달려면 로그인하십시오.

답변 (1개)

John D'Errico
John D'Errico 2022년 11월 18일
WTP? Why not try it?
syms a b c
rref([1, 2, 3, a;
4, 5, 6, b;
7, 8, 9, c])
ans = 
  댓글 수: 2
Eshgin
Eshgin 2024년 4월 28일
The issue is that MATLAB divides the entries into a, b, and c. This is not allowed since they can be zero.
John D'Errico
John D'Errico 2024년 4월 28일
편집: John D'Errico 2024년 4월 28일
I would disagree with that statement. You can divide anything INTO any of the variables a,b, or c, regardless of whether they might be zero or not. I'll do the RREF ops by hand to show what happens. I'll use a sequence of pre-multiplies by transformation matrices to do the ops in a simple fashion.
syms a b c
A = [1, 2, 3;
4, 5, 6;
7, 8, 9];
A0 = [A,[a;b;c]]
A0 = 
1 - Reduce column 1, pivoting around element (1,1). You now have:
A1 = [1 0 0;-4 1 0;-7 0 1]*A0
A1 = 
2 - Next, work on column 2, pivoting around element (2,2).
A2 = [1 2/sym(3) 0;0 -1/sym(3) 0;0 2 -1]*A1
A2 = 
That a, b, or c could be zero is not yet an issue. In fact, any or all of them could take on any value, and we never divided by any of a,b, or c. However, we might decide to stop at this point, since the (3,3) pivot is zero, and the non-zero status of the (3,4) element is uncertain. This tells us that A had rank 2. I'd not have an issue had rref stopped at that point, OR if you claimed it should have done so, but performing the last step does not disconcert me at all.
It clearly tells us that the general vector [a;b;c] does not live in the column space of A, UNLESS of course, the variables {a,b,c} are related in this way:
-a + 2*b - c == 0
(The one thing rref does not tell us. Sigh.) So any one of those variables COULD be zero. Only in the circumstance that [a;b;c] is a multiple of the vector [-1 2 -1] is there any issue. That vector happens to define the null space of A.
null(sym(A))
ans = 
Anyway, HAD you claimed that the RREF should have stopped at this point, due to the potential for a divide by zero, in the event that -a+2*b-c==0 and we could not then reduce column 4, I might be willing to agree. Solve would also effectively tell us that, for example, if I did this:
solve(A*[a;b;c] == [0;0;0],ReturnConditions = true)
ans = struct with fields:
a: z b: -2*z c: z parameters: z conditions: symtrue
And there, we see a solution exists when the vector [a;b;c] is a multiple of [1;-2;1], and thus falls in the nullspace of A.
In the end, rref told you all of this, if you chose to think about what it said. That requires understanding the linear algebra, and WHAT it was telling you.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Linear Least Squares에 대해 자세히 알아보기

제품


릴리스

R2022a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by