# Visualize all three cases
fig, axes = plt.subplots(1, 3, figsize=(15, 5))
# Case (a): Unique solution
ax = axes[0]
ax.fill_between([-1, 6], [-1, -1], [7, 7], color='lightblue', alpha=0.2,
label='Column space = ENTIRE plane')
# Draw vectors
ax.arrow(0, 0, A_a[0,0], A_a[1,0], head_width=0.15, head_length=0.15,
fc='blue', ec='blue', linewidth=2, label='a₁ = [1,3]')
ax.arrow(0, 0, A_a[0,1], A_a[1,1], head_width=0.15, head_length=0.15,
fc='green', ec='green', linewidth=2, label='a₂ = [2,4]')
ax.arrow(0, 0, b_a[0], b_a[1], head_width=0.2, head_length=0.2,
fc='red', ec='red', linewidth=3, label='b = [5,6]')
ax.set_title('Unique Solution')
ax.legend(fontsize=8)
ax.grid(True, alpha=0.3)
ax.set_xlim(-1, 6)
ax.set_ylim(-1, 7)
# Case (b): No solution
ax = axes[1]
t = np.linspace(-2, 5, 100)
span_x, span_y = t * A_b[0,0], t * A_b[1,0]
ax.plot(span_x, span_y, 'lightblue', linewidth=6, alpha=0.6,
label='Column space (1D line)')
ax.arrow(0, 0, A_b[0,0], A_b[1,0], head_width=0.15, head_length=0.15,
fc='blue', ec='blue', linewidth=2, label='a₁ = [1,2]')
ax.arrow(0, 0, A_b[0,1], A_b[1,1], head_width=0.15, head_length=0.15,
fc='green', ec='green', linewidth=2, label='a₂ = [2,4] = 2×a₁')
ax.arrow(0, 0, b_b[0], b_b[1], head_width=0.2, head_length=0.2,
fc='red', ec='red', linewidth=3, label='b = [5,6] (off line)')
ax.set_title('No Solution')
ax.legend(fontsize=8)
ax.grid(True, alpha=0.3)
ax.set_xlim(-1, 6)
ax.set_ylim(-1, 7)
# Case (c): Infinitely many solutions
ax = axes[2]
t = np.linspace(-1, 4, 100)
span_x, span_y = t * A_c[0,0], t * A_c[1,0]
ax.plot(span_x, span_y, 'lightblue', linewidth=6, alpha=0.6,
label='Column space (1D line)')
ax.arrow(0, 0, A_c[0,0], A_c[1,0], head_width=0.15, head_length=0.15,
fc='blue', ec='blue', linewidth=2, label='a₁ = [1,2]')
ax.arrow(0, 0, A_c[0,1], A_c[1,1], head_width=0.15, head_length=0.15,
fc='green', ec='green', linewidth=2, label='a₂ = [2,4] = 2×a₁')
ax.arrow(0, 0, b_c[0], b_c[1], head_width=0.2, head_length=0.2,
fc='red', ec='red', linewidth=3, label='b = [3,6] (on line)')
ax.set_title('Infinite Solutions')
ax.legend(fontsize=8)
ax.grid(True, alpha=0.3)
ax.set_xlim(-1, 6)
ax.set_ylim(-1, 7)
plt.tight_layout()
plt.show()
print("Key insight: Solution depends on whether target vector b lies in the column space")