Hey guys, I'm Scorpion and I'm taking my first steps in calculator programming!
So I wrote a little program to use in my numerical methods class that uses the bisection method of finding the root of a non-linear equation. It's my first foray in programming on my calculator and I need some help. I wrote this program using what this wiki had, the calculator's reference manual and my matlab programming knowledge, which is basically my only programming experience.
I wrote this little program and for some reason it locks up right after I press enter. Having nowhere else to turn to, I hoped you guys could make some sense of it and help me a little bit (or a lot!).
Thanks in advance!
My code:
define LibPub bissec(a,b,c,d)=Prgm
local e,g,h,i
e:=ceiling(((ln((b-a)/c))/(ln2))-1)
if e>d then
g:=d
else
g:=e
endif
h:=newmat(g,7)
h[1,2]:=a
h[1,3]:=b
for i,1,g
h[i,1]:=i
h[i,4]:=(h[i,2]+h[i,3])/2
while i<g
if f(h[i,2])>0 then
h[i,5]:=1
elseif f(h[i,2])<0 then
h[i,5]:=-1
else
h[i,5]:=0
endif
if f(h[i,4])>0 then
h[i,6]:=1
elseif f(h[i,4])<0 then
h[i,6]:=-1
else
h[i,6]:=0
endif
if h[i,5]*h[i,6]<0 then
h[i+1,2]:=h[i,2]
h[i+1,3]:=h[i,4]
h[i,7]:=-1
else
h[i+1,2]:=h[i,4]
h[i+1,3]:=h[i,3]
h[i,7]:=1
endif
endwhile
endfor
disp h
endprgm