Solve | solve an equation |

OldSolve | old version of Solve |

SuchThat | special purpose solver |

Eliminate | substitute and simplify |

PSolve | solve a polynomial equation |

MatrixSolve | solve a system of equations |

Solve -- solve an equation

Solve(eq, var) |

** var** -- variable to solve for

The current implementation is far from perfect. In particular, the user should keep the following points in mind:

cannot solve all equations. If it is given a equation it can not solve, it raises an error via`Solve`. Unfortunately, this is not displayed by the inline pretty-printer; call`Check`to change this. If an equation cannot be solved analytically, you may want to call`PrettyPrinter'Set`to get a numerical solution.`Newton`- Systems of equations are not handled yet. For linear systems,
- The periodicity of the trigonometric functions
- It is assumed that all denominators are nonzero. Hence, a solution reported by
- In general, it is wise not to have blind trust in the results returned by

In> quadratic := x^2+x; Out> x^2+x; In> Solve(quadratic, x); Out> {x==0,x==(-1)}; In> quadratic Where %; Out> {0,0}; |

If one tries to solve the equation $\exp \left( x\right) = \sin x$, one finds that
** Solve** can not do this.

In> PrettyPrinter'Set("DefaultPrint"); Out> True; In> Solve(Exp(x) == Sin(x), x); Error: Solve'Fails: cannot solve equation Exp(x)-Sin(x) for x Out> {}; |

The equation $\cos x = \frac{1}{2} $ has an infinite number of solutions,
namely $x = \left( 2 k + \frac{1}{3} \right) \pi $ and $x = \left( 2 k - \frac{1}{3} \right) \pi $ for any
integer $k$. However, ** Solve** only reports the solutions with $k = 0$.

In> Solve(Cos(x) == 1/2, x); Out> {x==Pi/3,x== -Pi/3}; |

For the equation $\frac{x}{\sin x} = 0$, a spurious solution at $x = 0$ is returned. However, the fraction is undefined at that point.

In> Solve(x / Sin(x) == 0, x); Out> {x==0}; |

At first sight, the equation $\sqrt{x} = a$ seems to have the solution $x = a ^{2}$. However, this is not true for eg. $a = - 1$.

In> PrettyPrinter'Set("DefaultPrint"); Out> True; In> Solve(Sqrt(x) == a, x); Error: Solve'Fails: cannot solve equation Sqrt(x)-a for x Out> {}; In> Solve(Sqrt(x) == 2, x); Out> {x==4}; In> Solve(Sqrt(x) == -1, x); Out> {}; |

OldSolve -- old version of

OldSolve(eq, var) OldSolve(eqlist, varlist) |

** var** -- single variable

** eqlist** -- list of identity equations

** varlist** -- list of variables

This command tries to solve one or more equations. Use the first form to solve a single equation and the second one for systems of equations.

The first calling sequence solves the equation "eq" for the variable
"var". Use the ** ==** operator to form the equation.
The value of "var" which satisfies the equation, is returned. Note
that only one solution is found and returned.

To solve a system of equations, the second form should be used. It solves the system of equations contained in the list "eqlist" for the variables appearing in the list "varlist". A list of results is returned, and each result is a list containing the values of the variables in "varlist". Again, at most a single solution is returned.

The task of solving a single equation is simply delegated to ** SuchThat**. Multiple equations are solved recursively:
firstly, an equation is sought in which one of the variables occurs
exactly once; then this equation is solved with

In> OldSolve(a+x*y==z,x) Out> (z-a)/y; In> OldSolve({a*x+y==0,x+z==0},{x,y}) Out> {{-z,z*a}}; |

This means that "x = (z-a)/y" is a solution of the first equation and that "x = -z", "y = z*a" is a solution of the systems of equations in the second command.

An example which ** OldSolve** cannot solve:

In> OldSolve({x^2-x == y^2-y,x^2-x == y^3+y},{x,y}); Out> {}; |

SuchThat -- special purpose solver

SuchThat(expr, var) |

** var** -- variable (or subexpression) to solve for

Basically, only expressions in which "var" occurs only once are
handled; in fact, ** SuchThat** may even give wrong
results if the variables occurs more than once. This is a consequence
of the implementation, which repeatedly applies the inverse of the top
function until the variable "var" is reached.

In> SuchThat(a+b*x, x) Out> (-a)/b; In> SuchThat(Cos(a)+Cos(b)^2, Cos(b)) Out> Cos(a)^(1/2); In> A:=Expand(a*x+b*x+c, x) Out> (a+b)*x+c; In> SuchThat(A, x) Out> (-c)/(a+b); |

Eliminate -- substitute and simplify

Eliminate(var, value, expr) |

** value** -- new value of "var"

** expr** -- expression in which the substitution should take place

In> Subst(Cos(b), c) (Sin(a)+Cos(b)^2/c) Out> Sin(a)+c^2/c; In> Eliminate(Cos(b), c, Sin(a)+Cos(b)^2/c) Out> Sin(a)+c; |

PSolve -- solve a polynomial equation

PSolve(poly, var) |

** var** -- a variable

In> PSolve(b*x+a,x) Out> -a/b; In> PSolve(c*x^2+b*x+a,x) Out> {(Sqrt(b^2-4*c*a)-b)/(2*c),(-(b+ Sqrt(b^2-4*c*a)))/(2*c)}; |

MatrixSolve -- solve a system of equations

MatrixSolve(A,b) |

** b** -- row vector

In> A:={{2,4,-2,-2},{1,2,4,-3},{-3,-3,8,-2},{-1,1,6,-3}}; Out> {{2,4,-2,-2},{1,2,4,-3},{-3,-3,8,-2},{-1,1,6,-3}}; In> b:={-4,5,7,7}; Out> {-4,5,7,7}; In> MatrixSolve(A,b); Out> {1,2,3,4}; |