[6.46] Solve() And Nsolve() Ignore Constraints With Local Variables - Texas Instruments TI-89 Tip List

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

Advertisement

return
abs((at-(tArea(px,py,bx,by,cx,cy)+tArea(ax,ay,px,py,cx,cy)+tArea(ax,ay,bx,by,px,
py)))/at)≤tol
EndFunc
The function returns true if point (px,py) is within the triangle defined by the points (ax,ay), (bx,by) and
(cx,cy), otherwise it returns false. tol is a small positive number which specifies the tolerance at which
the two areas will be considered equal. If you are using Exact mode, you may set tol = 0. If you are
using the function in Approx mode, with floating point coordinate arguments, set tol to specify the
precision at which you want to consider the two areas equal. This will depend on your application. If,
for example, you want to assume that the point P is in triangle ABC if the two areas are the same to six
significant digits, then set tol = 1E-6. A safe minimum value for tol is 1E-12, since the 89/92+ results
are accurate to about 12 significant digits.
Note that I use a relative tolerance, not an absolute tolerance. This is necessary because the point
coordinates may have a wide range. For example, suppose that the three triangle points are (0,0),
(0,2E20) and (1E20,1E20), and we want to determine if point P = (-1E10,-1E10) is in the triangle. The
area of ABC is 1E40, and the sum of the areas of the three triangles including P is 1.0000000002E40.
The absolute difference between the two areas is 2E30, but the relative difference is 2E-10. If we call
PntTrian() with tol = 1E-12, it will correctly return false in this case.
Disregarding the tolerance, points at the triangle vertices and on the lines joining the vertices are
considered inside the triangle.
As an example, suppose we have a triangle with vertices at (0,0), (7,0) and (4,4). Which of the points
(4,1), (5,3) and (2,2) are within the triangle? We will use exact mode and tol = 0, so the function calls
are
PntTrian(4,1,0,0,7,0,4,4,0)
PntTrian(5,3,0,0,7,0,4,4,0)
PntTrian(2,2,0,0,7,0,4,4,0)
So the first and third points are in the triangle, but the second point is not. Note that the third point is on
a triangle edge.
The idea for this tip was taken from a Design Idea in the August 3, 2000 issue of Electronic Design
News magazine, titled Algorithm tests for point location, by Lawrence Arendt, of the Mannitoba HVDC
Research Centre, Winnipeg, Canada.

[6.46] solve() and nsolve() ignore constraints with local variables

(Applies to AMS 2.05)
Constraint expressions are used with solve() and nsolve() to limit the solution range for the
independent variable. This shortens the solution time, and also narrows the search to the desired root
if the function has more than one. For example, the constraint expression "|x>1 and x<2" in this
example
nsolve(f(x)=0,x)|x>1 and x<2
should return a single solution between x=1 and x=2.
returns true
returns false
returns true
6 - 79

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

Ti-92+

Table of Contents