Difference between revisions of "Solve Command"

From GeoGebra Manual
Jump to: navigation, search
(command syntax: changed [ ] into ( ))
(35 intermediate revisions by 10 users not shown)
Line 1: Line 1:
<noinclude>{{Manual Page|version=4.0}}</noinclude>
+
<noinclude>{{Manual Page|version=5.0}}</noinclude>{{command|cas=true|geogebra}}
{{command|CAS}}
+
{{note|Commands '''Solve''' and [[Solutions Command|Solutions]] solve an equation or a system of equations over the real numbers symbolically. To solve equations numerically,  use the [[NSolve Command]]. For solving equations in complex numbers see [[CSolve Command]].}}
;Solve[ <Equation> ]
+
 
:Solves a given equation for the variable x and returns a list of all solutions.
+
The following commands are only available in the [[File:Menu view cas.svg|link=|16px]] [[CAS View]].
:{{example|1=<div><code><nowiki>Solve[x^2 = 4x]</nowiki></code> yields ''{x = 4, x = 0}'', the solutions of ''x<sup>2</sup> = 4x''.</div>}}
+
 
;Solve[ <Equation>, <Variable> ]
+
;Solve( <Equation in x> )
:Solves an equation for a given unknown variable and returns a list of all solution.
+
:Solves a given equation for the main variable and returns a list of all solutions.
:{{example|1=<div><code><nowiki>Solve[x * a^2 = 4a, a]</nowiki></code> yields <math>\{a = \frac{4}{x}\}</math>, the solution of ''x a<sup>2</sup> = 4a''.</div>}}
+
:{{example|1=<code><nowiki>Solve(x^2 = 4x)</nowiki></code> yields ''{x = 4, x = 0}'', the solutions of ''x<sup>2</sup> = 4x''.}}
;Solve[ <List of Equations>, <List of Variables> ]
+
;Solve( <Equation>, <Variable> )
 +
:Solves an equation for a given unknown variable and returns a list of all solutions.
 +
:{{example|1=<code><nowiki>Solve(x * a^2 = 4a, a)</nowiki></code> yields {<math>a = \frac{4}{x}, a = 0</math>}, the solutions of ''xa<sup>2</sup> = 4a''.}}
 +
;Solve( <List of Equations>, <List of Variables> )
 
:Solves a set of equations for a given set of unknown variables and returns a list of all solutions.
 
:Solves a set of equations for a given set of unknown variables and returns a list of all solutions.
 +
:{{examples|1=<div>
 +
:*<code><nowiki>Solve({x = 4 x + y , y + x = 2}, {x, y})</nowiki></code> yields ''<nowiki>( x = -1, y = 3 )</nowiki>'', the sole solution of ''x = 4x + y'' and ''y + x = 2''
 +
:*<code><nowiki>Solve({2a^2 + 5a + 3 = b, a + b = 3}, {a, b})</nowiki></code> yields ''{{a = 0, b = 3}, {a = -3, b = 6}}''.</div>}}
 +
;Solve( <Equation>, <Variable> , <List of assumptions>)
 +
:Solves an equation for a given unknown variable with the list of assumptions and returns a list of all solutions.
 +
:{{examples|1=<div>
 +
:*<code><nowiki>Solve(u *x < a,x, u>0)</nowiki></code> yields ''<nowiki>{x  <  a / u}</nowiki>'', the solution of ''u *x < a'' assuming that ''u>0''
 +
:*<code><nowiki>Solve(u *x < a,x, {u<0, a<0})</nowiki></code> yields ''{x > a / u}''.</div>}}
 +
;Solve( <List of Parametric Equations>, <List of Variables> )
 +
:Solves a set of parametric equations for a given set of unknown variables and returns a list of all solutions.
 
:{{example|1=<div>
 
:{{example|1=<div>
* <code><nowiki>Solve[{x = 4 x + y , y + x = 2}, {x, y}]</nowiki></code> yields ''<nowiki>{{x = -1, y = 3}}</nowiki>'', the sole solution of ''x = 4x + y'' and ''y + x = 2'' and
+
:*<code><nowiki>Solve({(x, y) = (3, 2) + t*(5, 1), (x, y) = (4, 1) + s*(1, -1)}, {x, y, t, s})</nowiki></code> yields ''<nowiki>{{x = 3, y = 2, t = 0, s = -1}}</nowiki>''.</div>}}
* <code><nowiki>Solve[{2a^2 + 5a + 3 = b, a + b = 3}, {a, b}]</nowiki></code> yields ''{{a = 0, b = 3}, {a = -3, b = 6}}''.
+
{{note|1=
</div>}}
+
* The right hand side of equations (in any of the above syntaxes) can be omitted. If the right hand side is missing, it is treated as 0.
{{note|See also [[Solutions Command]].}}
+
* Sometimes you need to do some manipulation to allow the automatic solver to work, for example <code> Solve(TrigExpand(sin(5/4 π + x) - cos(x - 3/4 π) = sqrt(6) * cos(x) - sqrt(2)))</code>.
 +
* For piecewise-defined functions, you will need to use [[NSolve Command|NSolve]]}}

Revision as of 10:06, 12 October 2017


Note: Commands Solve and Solutions solve an equation or a system of equations over the real numbers symbolically. To solve equations numerically, use the NSolve Command. For solving equations in complex numbers see CSolve Command.

The following commands are only available in the Menu view cas.svg CAS View.

Solve( <Equation in x> )
Solves a given equation for the main variable and returns a list of all solutions.
Example: Solve(x^2 = 4x) yields {x = 4, x = 0}, the solutions of x2 = 4x.
Solve( <Equation>, <Variable> )
Solves an equation for a given unknown variable and returns a list of all solutions.
Example: Solve(x * a^2 = 4a, a) yields {a = \frac{4}{x}, a = 0}, the solutions of xa2 = 4a.
Solve( <List of Equations>, <List of Variables> )
Solves a set of equations for a given set of unknown variables and returns a list of all solutions.
Examples:
  • Solve({x = 4 x + y , y + x = 2}, {x, y}) yields ( x = -1, y = 3 ), the sole solution of x = 4x + y and y + x = 2
  • Solve({2a^2 + 5a + 3 = b, a + b = 3}, {a, b}) yields {{a = 0, b = 3}, {a = -3, b = 6}}.
Solve( <Equation>, <Variable> , <List of assumptions>)
Solves an equation for a given unknown variable with the list of assumptions and returns a list of all solutions.
Examples:
  • Solve(u *x < a,x, u>0) yields {x < a / u}, the solution of u *x < a assuming that u>0
  • Solve(u *x < a,x, {u<0, a<0}) yields {x > a / u}.
Solve( <List of Parametric Equations>, <List of Variables> )
Solves a set of parametric equations for a given set of unknown variables and returns a list of all solutions.
Example:
  • Solve({(x, y) = (3, 2) + t*(5, 1), (x, y) = (4, 1) + s*(1, -1)}, {x, y, t, s}) yields {{x = 3, y = 2, t = 0, s = -1}}.
Note:
  • The right hand side of equations (in any of the above syntaxes) can be omitted. If the right hand side is missing, it is treated as 0.
  • Sometimes you need to do some manipulation to allow the automatic solver to work, for example Solve(TrigExpand(sin(5/4 π + x) - cos(x - 3/4 π) = sqrt(6) * cos(x) - sqrt(2))).
  • For piecewise-defined functions, you will need to use NSolve
© 2024 International GeoGebra Institute