I am working with the linear system $$ \left\{ \begin{aligned} x_1 + x_2 + x_3 &= 1 \\ 2x_1 + x_2 + x_3 &= 3 \\ 3x_1 + x_2 + x_3 &= 2 \end{aligned} \right. $$ (Taken from David Towers: A guide to Linear Algebra (1988), p.53)
Applying the Rouché–Capelli theorem one sees that the system is inconsistent. Using Matlab for the calculations
A = [1 1 1; 2 1 1; 3 1 1];
C = [1, 3, 2]';
mat_augm = [A C]; % augmented matrix
rank(mat_augm)
ans =
3
rank(A)
ans =
2
(Any two of the planes intersect in a straight line, but such that all three do not intersect; that is, no point lies on all of the planes.)
I want to visualise linear systems like above. I can do it with Matlab (see script and figure below) but for the time being my code depends upon the very form of the equations and my manual work. Is there a more systematic way to do such things? (Do not bother with Matlab. I am interested in the math.)
clc, clear, clf
set(0,'defaultTextInterpreter','latex');
% visualisation des plans
% premier plan red
x1 = 0.5:0.1:2.5; x2 = -1:0.1:0;
[X Y] = meshgrid(x1,x2);
Z = 1-X-Y;
H1 = surf(X,Y,Z);
set(H1,'facecolor', 'r','FaceAlpha',0.3, 'EdgeColor' ,'none')
hold on
% deuxième plan blue
x1 = -1:0.1:2; x2 = -1:0.1:0;
[X Y] = meshgrid(x1,x2);
Z = 3-2*X-Y;
H2 = surf(X,Y,Z);
set(H2,'facecolor', 'b','FaceAlpha',0.3, 'EdgeColor','none')
%troisième plan green
x1 = 0.5:-0.1:-1; x2 = -1:0.1:0;
[X Y] = meshgrid(x1,x2);
Z =2-3*X-Y;
H3 = surf(X,Y,Z);
set(H3,'facecolor', 'g','FaceAlpha',0.3, 'EdgeColor' ,'none')
% lines of intersections
% line of intersection of first two planes
% calculate intersection in plane z = 0
A1 = [ 1 1; 1/(3/2) 1/3];
B1 = [ 1; 1];
X1 = A1\B1;
P1 = [ X1; 0];
% calculate intersection in plane y = 0
A2 = [ 1 1; 1/(3/2) 1/3];
B2 = [ 1; 1];
X2 = A2\B2;
P2 = [X2(1); 0; X2(2)];
P1P2 = [P1, P2];
line(P1P2(1,:), P1P2(2,:), P1P2(3,:), 'Color',...
'black', 'linewidth',1.5); view(3)
% line of interesection of first and third plane
% calculate intersection in plane z = 0.5
A1 = [ 1 1; 1/(2/3) 1/2 ];
B1 = [ 0.5; 3/4];
X1 = A1\B1;
P1 = [ X1; 0.5];
% calculate intersection in plane y = -1
A2 = [ 1 1; 1/(2/3) 1/2];
B2 = [ 2; 3/2 ];
X2 = A2\B2;
P2 = [X2(1); -1; X2(2)];
P1P2 = [P1, P2];
line(P1P2(1,:), P1P2(2,:), P1P2(3,:), 'Color','black',...
'linewidth',1.5); view(3)
% line of interesection of second and third plane
% calculate intersection in plane z = 6
A1 = [ 1/(3/2) 1/3; 1/(2/3) 1/2];
B1 = [ -1; -2 ];
X1 = A1\B1;
P1 = [ X1; 6 ];
% calculate intersection in plane y = 0
A2 = [1/(3/2) 1/3; 1/(2/3) 1/2];
B2 = [ 1; 1 ];
X2 = A2\B2;
P2 = [X2(1); 0; X2(2)];
P1P2 = [P1, P2];
line(P1P2(1,:), P1P2(2,:), P1P2(3,:), 'Color',...
'black', 'linewidth',1.5); view(3)
% plot settings and labeling
axis square, grid on, grid minor, box on
xlabel('$x_1$'), ylabel('$x_2$'), zlabel('$x_3$')
set(gca,'FontSize',16)
xlim([-3 2]), ylim([-1 0])
zlim([-1 6])
set(gca, 'Xdir', 'reverse', 'YDir', 'reverse')
title('1st plane (red), 2nd plane (blue), 3rd plane (green)')
title({'$x_1+x_2+x_3=1$ (red)',...
'$2x_1+x_2+x_3=3$ (blue)',...
'$3x_1+x_2+x_3=2$ (green)'})
hold off
set(0,'defaultTextInterpreter','none');
