IND = Indeterminate (The input to the variables probably causes the equation to evaluate to infinity or a division by zero in which case can never be truly displayed as the number is infinitely large).
1/0 = infinity. -1/0 = -infinity.
I think your function works quite well with the exception of entering negative numbers which will always produce a mathematical error as this can only be solved in the imaginary plane.
sqrt(-1)=i or j.
The DBC solution to ric's code is in your other thread.
I have exchanged my function with yours to show a slide rule.
If you align the top slide number 2, over bottom slide number 1, it will give you the 2 times table. Also if you align top slide number 3, over bottom slide number 1, it gives you the 3 times table.
P.s. It may run slowly because of the number of line commands used.
rem ------- Log Scale Slide Rule -------
rem --- Created By Calculus 05/08/04 ---
sync on
sync rate 0
cls
ink rgb(255,255,255),0
scale=600
do
cls
if rightkey()=1 then x=x+2
if leftkey()=1 then x=x-2
rem --- Coarse Graduations top ---
for n=1 to 10
x#=n/1.0
a#=log(x#)
line 20+a#*scale+x,158,20+a#*scale+x,198
set cursor 20+a#*scale+x,135 : print n
next n
rem --- Fine Graduations top ---
for n=1 to 100
x#=n/10.0
a#=log(x#)
line 20+a#*scale+x,198,20+a#*scale+x,178
next n
rem --- Coarse Graduations bottom---
for n=1 to 10
x#=n/1.0
a#=log(x#)
line 20+a#*scale,200,20+a#*scale,240
set cursor 20+a#*scale,250 : print n
next n
rem --- Fine Graduations bottom---
for n=1 to 100
x#=n/10.0
a#=log(x#)
line 20+a#*scale,200,20+a#*scale,220
next n
rem --- Multiplying two numbers ---
a#=3.0
b#=2.0
ans#=log(a#)+log(b#)
set cursor 20,350 : print "3*2 or e^(ln(2)+ln(3)) = ",10.0^ans#
rem --- square root ---
a#=9.0
ans#=log(a#)/2.0
set cursor 20,370 : print "sqrt 9 or e^(ln(9)/2) = ",10.0^ans#
sync
loop
function log(answer#)
base#=10.0
log#=sqrt(answer#/base#)
lnb#=ln(base#)
lga#=base#^log#
repeat
log#=log#-((lga#-answer#)/(lga#*lnb#))
lga#=base#^log#
until abs(lga#-answer#)<=0.001
endfunction log#
function ln(answer#)
e#=2.71828
ln#=sqrt(answer#/e#)
lgn#=e#^ln#
repeat
ln#=ln#-((lgn#-answer#)/lgn#)
lgn#=e#^ln#
until abs(lgn#-answer#)<=0.001
endfunction ln#
Kind Regards
Calculus