1
$\begingroup$

Example:

Solve[x^2 + a x + 1 == 0, x]

Output: Hold[Solve[x^2 + a x + 1 == 0, x]]

What is the problem? Any child can solve this in its head

$\endgroup$
  • $\begingroup$ For me it works. Have you tried stopping the kernel prior to this? $\endgroup$ – Gladaed Jun 11 '19 at 11:56
  • $\begingroup$ I don't know how but restarting Mathematica solved the problem... Still curious why this happened $\endgroup$ – OD IUM Jun 11 '19 at 11:58
  • $\begingroup$ You must have assigned some value to x that causes the code to loop. Just like what happens when you assign x = x + 1. $\endgroup$ – Sjoerd Smit Jun 11 '19 at 13:04
3
$\begingroup$
Solve[x^2 + a x + 1 == 0, x]

gives the correct answer. Unless x or a are defined. It is pretty much guaranteed to return the correct answer if you Clear the symbols prior to execution or use a Block.

x = 1 
a = 1
Solve[x^2 + a x + 1 == 0, x]

does not work, even if only x is defined. This is actually fairly confusing and might be because the expression does not get properly Hold 'ed. Be Aware!

x = 1 
a = 1
Clear[a,x]
Solve[x^2 + a x + 1 == 0, x]

does

x = 1 
a = 1
Block[{a, x},
 Solve[x^2 + a x + 1 == 0, x]]
{x, a}

does aswell while preserving any potential values of both x and a

| improve this answer | |
$\endgroup$

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