Programs

These programs were written by frequent visitors to TI's discussion groups to provide for a frequently requested feature that the calculators do not have.


Number to string by Sam Jordan

For the TI-8x

"/=" is the NOT EQUAL test operator. The hyphens in the last two lines of the programs are the negative sign, not the minus sign. When keying this in, do NOT include the lines that begin with "@". These were written for the TI-85/86, but the conversion to TI-83 family format is minimal. The main changes would be to switch to single letter variable names, use Str variables for the strings, and use = instead of = = for comparisons.

RTOSF - Real to string (fixed)
Converts the input real FX to the output string SF in base BS.
BS (the output base) can be from 2 to 16.

Inputs:
FX - the real number to be converted
BS - the base for the conversion (2 - 16)

Output:
FS - a string of ascii digits.

PROGRAM:RTOSF
@ initialize the conversion string NS
:"0123456789ABCDEF"->NS
@ Figure out the sign and save in SF
@ If it's zero, just return "0" in FS.
:sign FX->SF
:If SF==0
:Then
:"0"->FS
:Return
:End
@ Non-zero, initialize FS to blank.
:" "->FS
@ Figure out how many digits in front of decimal point.
:int((ln abs FX)/ln BS)->I
@ Set TF to the part in front of decimal point.
:iPart abs FX->TF
@ Convert TF to a string in the proper base.
:Repeat I<0
:int (TF/(BS^I))->T
:TF-(T*(BS^I))->TF
:FS+sub(NS,T+1,1)->FS
:I-1->I
:End
@ Now handle fractional part of FX
:fPart abs FX->TF
@ If TF is NOT EQUAL to zero then add the decimal point.
:If TF/=0
:FS+"."->FS
@ Now add digits until it's time to quit.
:While TF/=0 and (lngth FS)<18
:TF*BS->TF
:FS+sub(NS,(iPart TF)+1,1)->FS
:fPart TF->TF
:End
@ Remove that initial blank we intialized FS with.
:sub(FS,2,(lngth FS)-1)->FS
@ Add the sign to the front of FS.
:If SF==-1
:"-"+FS->FS

RTOSE: A program to convert a real to a "float string".
This program uses the above "RTOSF" program.

Input:
RL - Real number to be converted.
BS - Base for output representation.

Output:
RS - Real string.

PROGRAM:RTOSE
@ If the input is zero, just return it.
:If RL==0
:Then
:"0"->RS
:Return
:End
@ Save the sign in SN
:sign RL->SN
@ Remove the sign from the mantissa.
:abs RL->MN
@ figure out the exponent.
:int log MN->EX
@ If it's more than seven digits, use float, else fixed.
:If abs EX>7
:Then
:MN/(10^EX)->MN
:Else
:0->EX
:End
@ Convert mantissa to fixed string
:MN->FX
:RTOSF
:FS->RS
@ If not doing fixed, convert exponent.
:If EX/=0
:Then
:RS+"e"->RS
:EX->FS
:RTOSF
:RS+FS->RS
:End
@ Now put sign on front of RS.
:If SN==-1
:"-"+RS->RS

Back to the FAQ


Nth roots by Scott Campbell

For the TI-89 family

This takes ALL the work out of finding and displaying nth roots.

CustmOn and CustmOff are 89 Flash family commands only, omit them on the 92.

nroot(z,n)
Prgm
Local i,rad
newlist(n)->anglesr
getmode("ALL")->premode
setmode({"Graph","FUNCTION","Display
Digits","FLOAT","Angle","RADIAN","Exact/Approx","AUTO"})
cZeros(x^n-z,x)->answer
abs(answer)[1]->length
angle(z)->rad
If rad<0
rad+2*pi->rad
rad/n->rad
For i,1,n
2*pi*(i-1)/n+rad->anglesr[i]
EndFor
anglesr*180/pi->anglesd
Custom
Title "answer"
Title "length"
Title "anglesR"
Title "anglesD"
Title ">Polar"
Title "restore()"
EndCustm
CustmOn
EndPrgm

This next program must be in the same directory as nroot:

restore()
Prgm
ClrHome
setMode(premode)
Delvar answer,length,anglesr,anglesd,premode
CustmOff
EndPrgm

Back to the FAQ


Implicit Differentiation by Don Phillips

For the TI-89 family

Here's a function that can calculate implicit derivatives of any degree. It's basically a variation on the routine from SoftWarehouse, it accepts expressions as well as equations.

:impdifn(u,x,y,n)
:Func
:Local e,e1,i
:If part(u,0)="="
:left(u)-right(u)->u
:-d(u,x)/(d(u,y))->e1
:e1->e
:1->i
:Loop
:If i=n
:Exit
:d(e,x)+e1*d(e,y)->e
:1+i->i
:EndLoop
:factor(e)
:EndFunc

Where 'd' is the differential operator.

'u' may be either an expression or an equation. 'x' is the independent variable and 'y' the dependent variable. 'n' is the degree of differentiation. An example is to enter
impdif(x^4+y^4=1,x,y,2).

The answer given is:
(-3*x^2*(x^4+y^4))/y^7

Since we know that x^4+y^4 =1, the answer can be simplified to -3*x^2/y^7.

Back to the FAQ

Visit counter provided by Site Meter. visitors since 8/1/2001