Texas Instruments TI-89 Tip List page 238

Graphing calculator
Hide thumbs Also See for TI-89:
Table of Contents

Advertisement

In July 2001, David Dannenmiller posted an nsolve() example to the 89/92+ discussion group, where
the constraints were ignored and nsolve() returned a root outside of the solution bounds. It turns out
that David found a particular constraint expression which causes nsolve() to return a solution which is
a root, but is outside of the solution bounds. In particular, the constraint is expressed with a local
variable, and the constraint bound is expressed as a>x instead of x<a, where 'a' is a local variable.
So, if you use solve() or nsolve() in a program or function, and you use local variables in the constraint
expression, be sure to list the independent variable first in the contraint expression, to the left of the
conditional operator:
nsolve(f(x)=0,x)|x<a and x<b
Do this:
nsolve(f(x)=0,x)|a>x and x<b
Don't do this:
As an example, consider this function:
f ( x ) = x 3 − 6x 2 + 11x − 6 + sin ( 3x )
which has these three real roots when f(x)=0:
x1 = 0.71379958487236
x2 = 1.1085563021699
x3 = 2.14042730947
Suppose we use nsolve() in a function to find the third root, x3. The function might look like this:
f()
Func
local a,b
2→a
2.2→b
return nsolve(x^3-6*x^2+11*x-6+sin(3*x)=0,x)|x>a and x<b
EndFunc
This is a contrived example because you would not actually use such a function, to solve a single
function for a single root. A more realistic application would solve a more complicated function with
variable coefficients, and the constraint limits a and b would be found by some estimating method.
As shown, the constraint is |x>a and x<b. This table shows the returned results for various other
constraint expressions
x>a and x<b
a<x and x<b
a<x and b>x
x>a and b>x
Note that if numeric limits are used, instead of local variables, then nsolve() returns the correct results
regardless of the constraint ordering. For example, nsolve() will return the correct root x3 if the
contraint is |2<x and x<2.2.
Constraint
Result
x3
x1
x1
x3
Comment
Wrong!
Wrong!
6 - 80

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

Ti-92+

Table of Contents