clear all;
clc;
%Question 4: The two equations to be solved are x+2y=3 and 2x+4y=11
%we can convert these in a form AW=U
A = [[1 2]; [2 4]];
B = [[1 2 3]; [2 4 11]];
U = [3;11];
%We need to check that inv(A) exists. Else if det(A) =0, it won't exist, and hence we can't find a unique solution.
disp('The determinant value is'); disp(det(A));
%Here the det(A) = 0; Hence we might have more than one solution or no solution.
% Hence the rank of a A is 1. Let the augmented matrix be 1 2 3
% B= 2 4 11 Hence it's rank is 2.
if(det(A) == 0 && rank(A) ~= rank(B)) disp('We have no solution for the given system of linear equations');
else if(det(A)==0) disp('We have infinitely many solutions for the given system of equations');
end
end
% Another approach is to use plots.
% We can plot two functions y1 = f(x) = (3-x)/2 and y2 = g(x) = (11-2x)/4;
x = -10:10;
y1 = (3-x)/2;
y2 = (11-2*x)/4;
plot(y1,x,y2,x);
grid on;
% Here the two lines are parallel to each other. Hence no solution exists.