[6.40] Write Functions With Multiple Input Argument Types - Texas Instruments TI-89 Tip List

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

Advertisement

parcurve(f,x,y)
Func
©ParCurve(f,x,y) parametrizes curve f(x,y)=0 as x(t),y(t)
©Bhuvanesh Bhatt
expr("solve("&string(f=y-t*x)&" and y-t*x=0,{"&string(x)&","&string(y)&"})")
EndFunc
For example, to find a parametric expression for
x 3 + x 2 − y 2 = 0
use the call
parcurve(x^3+x^2-y^2,x,y)
which returns
x = t 2 − 1 and y = t 2 − 1 $ t or x = 0 and y = 0
The first two equations are the useful parameterizations; the second two are extraneous solutions.
(Credit to Bhuvanesh Bhatt)

[6.40] Write functions with multiple input argument types

Many built-in functions operate on numbers, expressions and lists. For example,
sin(a)
sin(.2)
sin({0,.2})
This is very convenient in that you can use a single function to handle various argument types. You
can accomplish this convenience with your own functions, as shown in this demonstration function:
f1demo(xx)
Func
©Demo program to evaluate function of expression, list or matrix.
©29mar01/dburkett@infinet.com
local f1,xxt,j,k,r,xxr,xxc
©Define the function to evaluate
define f1(x)=func
ln(x)
endfunc
©Get the input argument type
gettype(xx)→xxt
©Evaluate the function
if xxt="NUM" or xxt="EXPR" or xxt="VAR" then
return f1(xx)
elseif xxt="LIST" then
return seq(f1(xx[j]),j,1,dim(xx))
elseif xxt="MAT" then
sin(a)
returns
0.1987
returns
{0, 0.1987}
returns
6 - 72

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

Ti-92+

Table of Contents