Difference between revisions of "NSolve Command"
From GeoGebra Manual
(or other extreme examples) |
m (Text replace - ";(.*)\[(.*)\]" to ";$1($2)") |
||
Line 3: | Line 3: | ||
This command is only available in the [[File:Menu view cas.svg|link=|16px]] [[CAS View]]. | This command is only available in the [[File:Menu view cas.svg|link=|16px]] [[CAS View]]. | ||
− | ;NSolve | + | ;NSolve( <Equation> ) |
:Attempts (numerically) to find a solution for the equation for the main variable. For non-polynomials you should always specify a starting value (see below). | :Attempts (numerically) to find a solution for the equation for the main variable. For non-polynomials you should always specify a starting value (see below). | ||
:{{example|1=<div><code><nowiki>NSolve[x^6 - 2x + 1 = 0]</nowiki></code> yields ''{x = 0.51, x = 1}''.</div>}} | :{{example|1=<div><code><nowiki>NSolve[x^6 - 2x + 1 = 0]</nowiki></code> yields ''{x = 0.51, x = 1}''.</div>}} | ||
− | ;NSolve | + | ;NSolve( <Equation>, <Variable> ) |
:Attempts (numerically) to find a solution of the equation for the given unknown variable. For non-polynomials you should always specify a starting value (see below). | :Attempts (numerically) to find a solution of the equation for the given unknown variable. For non-polynomials you should always specify a starting value (see below). | ||
:{{example|1=<div><code><nowiki>NSolve[a^4 + 34a^3 = 34, a]</nowiki></code> yields '' {a = -34, a = 0.99}''.</div>}} | :{{example|1=<div><code><nowiki>NSolve[a^4 + 34a^3 = 34, a]</nowiki></code> yields '' {a = -34, a = 0.99}''.</div>}} | ||
− | ;NSolve | + | ;NSolve( <Equation>, <Variable = starting value> ) |
:Finds numerically the list of solutions to the given equation for the given unknown variable with its starting value. | :Finds numerically the list of solutions to the given equation for the given unknown variable with its starting value. | ||
:{{examples|1=<div> | :{{examples|1=<div> | ||
:*<code><nowiki>NSolve[cos(x) = x, x = 0]</nowiki></code> yields ''{x = 0.74}'' | :*<code><nowiki>NSolve[cos(x) = x, x = 0]</nowiki></code> yields ''{x = 0.74}'' | ||
:*<code><nowiki>NSolve[a^4 + 34a^3 = 34, a = 3]</nowiki></code> yields ''{a = 0.99}''.</div>}} | :*<code><nowiki>NSolve[a^4 + 34a^3 = 34, a = 3]</nowiki></code> yields ''{a = 0.99}''.</div>}} | ||
− | ;NSolve | + | ;NSolve( <List of Equations>, <List of Variables> ) |
:Attempts (numerically) to find a solution of the set of equations for the given set of unknown variables. | :Attempts (numerically) to find a solution of the set of equations for the given set of unknown variables. | ||
:{{example|1=<div><code><nowiki>NSolve[{pi / x = cos(x - 2y), 2 y - pi = sin(x)}, {x = 3, y = 1.5}]</nowiki></code> yields ''{x = 3.14, y = 1.57}''.</div>}} | :{{example|1=<div><code><nowiki>NSolve[{pi / x = cos(x - 2y), 2 y - pi = sin(x)}, {x = 3, y = 1.5}]</nowiki></code> yields ''{x = 3.14, y = 1.57}''.</div>}} |
Revision as of 17:15, 7 October 2017
CAS Syntax
This command is only available in the CAS View.
- NSolve( <Equation> )
- Attempts (numerically) to find a solution for the equation for the main variable. For non-polynomials you should always specify a starting value (see below).
- Example:
NSolve[x^6 - 2x + 1 = 0]
yields {x = 0.51, x = 1}.
- NSolve( <Equation>, <Variable> )
- Attempts (numerically) to find a solution of the equation for the given unknown variable. For non-polynomials you should always specify a starting value (see below).
- Example:
NSolve[a^4 + 34a^3 = 34, a]
yields {a = -34, a = 0.99}.
- NSolve( <Equation>, <Variable = starting value> )
- Finds numerically the list of solutions to the given equation for the given unknown variable with its starting value.
- Examples:
NSolve[cos(x) = x, x = 0]
yields {x = 0.74}NSolve[a^4 + 34a^3 = 34, a = 3]
yields {a = 0.99}.
- NSolve( <List of Equations>, <List of Variables> )
- Attempts (numerically) to find a solution of the set of equations for the given set of unknown variables.
- Example:
NSolve[{pi / x = cos(x - 2y), 2 y - pi = sin(x)}, {x = 3, y = 1.5}]
yields {x = 3.14, y = 1.57}.
Note:
- If you don't give a starting point like a=3 or {x = 3, y = 1.5} the numerical algorithm may find it hard to find a solution (and giving a starting point doesn't guarantee that a solution will be found)
- The number of decimals depends on the choosen in global rounding.
- NSolve won't work for functions that are asymptotic to the x-axis or other extreme examples. They can often be reformulated though.
- NSolve will work only if the function is continuous!
- See also Solve Command and NSolutions Command.