13.19: Possible Solutions to a Linear System

Fundamentals of MATLAB Programming · LibreTexts

0%

Contents

    Text

    Size
    100%
    Theme
    Typeface
    Line length
    Spacing

    Read aloud

    How

    Speed: 1×
    Light up
    Highlight

    Symbols: Mulberry Symbols, © 2018–2026 Steve Lee, CC BY-SA 4.0 (licence, the set), the site's own copies.

    From LibreTexts, under CC BY-NC-SA, as the source states it; its equations are written in TeX, which the PDF shows typeset. This page at LibreTexts.

    13.19: Possible Solutions to a Linear System

    A system of linear equations may have one solution, infinitely many solutions, or no solution.

    • One solution: the equations are independent and intersect at one point.
    • Infinitely many solutions: at least one equation is dependent on the others.
    • No solution: the equations are inconsistent and cannot all be true at the same time.

    When A is square, there are as many equations as unknowns. A unique solution may exist, but it is not guaranteed. The equations must also be independent.

    A Graphical View of the Three Cases

    For a system with two unknowns, each linear equation represents a line. Solving the system means finding the point or points that satisfy both equations at the same time. Graphically, that means looking at how the two lines are related.

    Graphical situation

    Number of solutions

    Meaning

    The lines intersect at one point.

    One unique solution

    There is exactly one ordered pair that satisfies both equations.

    The lines are parallel and never meet.

    No solution

    There is no ordered pair that satisfies both equations.

    The two equations describe the same line.

    Infinitely many solutions

    Every point on that line satisfies both equations.

    Graphical View of Three Cases.png

    This graphical idea is very useful for understanding the answer, even when the actual system is larger than two equations. In higher dimensions, the geometry is harder to draw, but the same basic idea remains: the equations may meet in one solution, fail to meet at all, or overlap in a way that gives infinitely many solutions.

    Using MATLAB to Recognize the Type of Solution

    When the coefficient matrix A is square, the determinant gives a quick first test. If det(A) is not zero, then A is invertible and the system Ax = b has a unique solution. If det(A) is zero, then A is singular. In that case, the system does not have a unique solution; it may have no solution or infinitely many solutions.

    To distinguish between those two cases, we can compare the rank of A with the rank of the augmented matrix [A b]. The augmented matrix is created by placing the constant vector b next to the coefficient matrix A.

    Condition

    Type of solution

    rank(A) = rank([A b]) = number of unknowns

    Unique solution

    rank(A) = rank([A b]) but less than the number of unknowns

    Infinitely many solutions

    rank(A) is not equal to rank([A b])

    No solution

    The rank tells us how much independent information is contained in the equations. If the equations provide enough independent information for all unknowns, the solution is unique. If the equations are consistent but do not provide enough independent information, there are infinitely many solutions. If the equations contradict each other, there is no solution.

    Example \(\PageIndex{1}\)

    A System with a unique Solutions

    \(x + y = 5\)
    \(2*x - y = 1\)

    A = [1 1; 2 -1];
    b = [5; 1];
    
    detA = det(A)
    x = A \ b
    Solution
    detA = -3
    
    x =
    
       2
       3

    Because det(A) is not zero, the system has a unique solution. MATLAB returns one value for x and one value for y.

    Example \(\PageIndex{2}\)

    Example: A System with no solution

    \(x + y = 4\)
    \(2*x + 2*y = 10\)

    A = [1 1; 2 2];
    b = [4; 10];
    
    detA = det(A)
    rankA = rank(A)
    rankAug = rank([A b])
    Solution
    detA = 0
    rankA = 1
    rankAug = 2

    Here rank(A) and rank([A b]) are different, so the system is inconsistent. That means there is no solution. If you try to solve this using the backslash operator, MATLAB may return a warning or a least-squares approximation, but that does not mean the original system has an exact solution.

    Example \(\PageIndex{3}\)

    A System with infinitely many solutions

    \(x + y = 4\)
    \(2*x + 2*y = 10\)

    A = [1 1; 2 2];
    b = [4; 8];
    
    detA = det(A)
    aug = [A b];
    rankA = rank(A)
    rankAug = rank(aug)
    Solution
    detA = 0
    rankA = 1
    rankAug = 1
    

    Here rank(A) and rank([A b]) are equal, but the rank is less than the number of unknowns. This means the equations are consistent, but they do not provide enough independent information to produce one unique answer.

    What the Backslash Operator Does in These Cases

    For a well-behaved square system with a unique solution, A\b gives the solution directly. This is the case you will use most often in introductory engineering problems.

    If the system does not have a unique solution, MATLAB still tries to be helpful, but you must interpret the result carefully. For singular or inconsistent systems, MATLAB may show a warning, return one possible solution, or return a least-squares solution depending on the shape and properties of A. This is why it is important to understand the difference between a unique solution, no solution, and infinitely many solutions.

    For beginner work, use this practical approach:

    • Set up A and b carefully.
    • Check det(A) if A is square.
    • Use rank(A) and rank([A b]) if det(A) is zero or if MATLAB gives a singular matrix warning.
    • Use x = A\b when the system has a unique solution.
    • Check your answer by calculating A*x and comparing it with b.

    This page titled 13.19: Possible Solutions to a Linear System was last modified on Tue, 30 Jun 2026 02:12:00 GMT and is shared under a CC BY-NC-SA license and was authored, remixed, and/or curated by Zara Noroozi.