0
$\begingroup$

Consider the following system of linear equations with parameters a and b

$2 x_1 - x_2 = a$

$-6 x_1 + 3 x_2 = b$

When $a = -1/3$ and $b = 1$ the system has the following solution

$x_1 = -1/6$ and $x_2 = 0$

There are infinitely many other values of $a$ and $b$ that also result in solutions.

However, when I evaluate

G = {{2, -1}, {-6, 3}};
LinearSolve[G, {a, b}]

I get the message

LinearSolve: Linear equation encountered that has no solution.

I would interpret this to mean that the above system has no solutions for any values of a and b. This interpretation is clearly incorrect.

So when LinearSolve tells us that the above system has no solutions, what is it actually saying?

$\endgroup$
2
  • 2
    $\begingroup$ Note that $G$ is singular, so the solution, if exists, is not unique. $\endgroup$ Apr 27, 2018 at 23:31
  • 1
    $\begingroup$ When I am told that, I usually go off and sulk for a couple of days. $\endgroup$ Apr 28, 2018 at 18:51

2 Answers 2

6
$\begingroup$

This particular function is telling you that your linear system is singular: the determinant of $G$ is zero. The general system only has solutions when $b=-3a$, and then it has infinitely many solutions. You can interpret the message "no solution" as "no generic solution," as is typical in Mathematica.

$\endgroup$
2
  • $\begingroup$ what is the meaning of "generic solution"? $\endgroup$ Apr 27, 2018 at 23:36
  • 3
    $\begingroup$ "Generic" here meaning valid for unconstrained {a, b}; or more generally for a dense subset of {a, b}. $\endgroup$
    – ulvi
    Apr 27, 2018 at 23:56
4
$\begingroup$

There is no solution for general {a,b}. Under "Properties and Relations", the documentation for LinearSolve suggests using LeastSquares to get a solution, minimizing the error, for a singular system like this.

LeastSquares[G, {a, b}]
(* {a/25 - (3 b)/25, -(a/50) + (3 b)/50} *)
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.