2

Consider the following input:

Solve[a x^2 + b x + c == 0, x]
%/.{a->0}

The solution produced by Mathematica in the first line is the result of the standard quadratic formula: $$x=\frac{-b-\sqrt{b^2-4 a c}}{2 a}.$$

Because this formula is undefined at $a=0$, the second line outputs errors, "Infinite expression 1/0 encountered", followed by the output {{x->ComplexInfinity},{x->ComplexInfinity}}.

But if $a=0$ and $b\neq 0$ the original equation has a well-defined solution, $x=-c/b$.

Given that Mathematica is normally incredibly rigorous about its output, why is it that, conceptually, asking it to "solve this equation and evaluate the solution at zero" produces nonsense? Or, in other words, why don't we get an output that evaluates to the correct solution for $(a,b,c,x)\in\mathbb{R}^4$?

Ubiquitous
  • 863
  • 2
  • 7
  • 15

2 Answers2

4

You can also use the Option MaxExtraConditions

Solve[a  x^2 + b  x + c == 0, x, MaxExtraConditions -> All ]

During evaluation of Solve::fdimc: When parameter values satisfy the condition a==0&&b==0&&c==0, the solution set contains a full-dimensional component; use Reduce for complete solution information. (* {{x -> ConditionalExpression[-(c/b), a == 0 && b != 0]}, {x -> ConditionalExpression[(-b - Sqrt[b^2 - 4 a c])/(2 a), a != 0]}, {x -> ConditionalExpression[(-b + Sqrt[b^2 - 4 a c])/(2 a), a != 0]}} *)

chuy
  • 11,205
  • 28
  • 48
3

Use Reduce which is more cautious than Solve regarding all possible conditions.

Reduce[a x^2 + b x + c == 0, x]
% /. a -> 0

   (a != 0 && (x == (-b - Sqrt[b^2 - 4 a c])/(2 a) || 
     x == (-b + Sqrt[b^2 - 4 a c])/(2 a))) || (a == 0 && b != 0 && 
   x == -(c/b)) || (c == 0 && b == 0 && a == 0)

(b != 0 && x == -(c/b)) || (c == 0 && b == 0)

enter image description here

You can read about it in documentation of Solve in section "Possible Issues" and in documentation of Reduce in section "Properties & Relations".

azerbajdzan
  • 15,863
  • 1
  • 16
  • 48