RREF with unknown variables

18 次查看(过去 30 天)
Janne
Janne 2022-11-18
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