# 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 FXSF
: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 FXTF
@ 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-1I
:End
@ Now handle fractional part of FX
:fPart abs FXTF
@ 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*BSTF
:FS+sub(NS,(iPart TF)+1,1)FS
:fPart TFTF
: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
:"-"+FSFS```

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
:sign RLSN
@ Remove the sign from the mantissa.
:abs RLMN
@ figure out the exponent.
:int log MNEX
@ If it's more than seven digits, use float, else fixed.
:If abs EX>7
:Then
:MN/(10^EX)MN
:Else
:0EX
:End
@ Convert mantissa to fixed string
:MNFX
:RTOSF
:FSRS
@ If not doing fixed, convert exponent.
:If EX/=0
:Then
:RS+"e"RS
:EXFS
:RTOSF
:RS+FSRS
:End
@ Now put sign on front of RS.
:If SN==-1
:"-"+RSRS```

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
newlist(n)anglesr
getmode("ALL")premode
setmode({"Graph","FUNCTION","Display
For i,1,n
EndFor
anglesr*180/pianglesd
Custom
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)
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
:e1e
:1i
:Loop
:If i=n
:Exit
:d(e,x)+e1*d(e,y)e
:1+ii
: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).