Ok... First up, I never really understood what ArcTan does... However, its a function I need for something of interest.
This is a recursive function (a continued fraction) that represents inverse tan (ArcTan).
print "AC 1: " + str$(ArcTan(15.0, 1))
print "AC 2: " + str$(ArcTan(-45.0, 1))
print "AC 3: " + str$(ArcTan(120.0, 1))
print "AC 4: " + str$(ArcTan(0.0, 1))
wait key
end
function ArcTan(z#, level)
v# = 0
if level > 1
`Next levels... Less than 8 means only itterate 8 times. More time = more accurate + slower...
if level < 8
v# = ((level * 2)-3) + (( ((level - 1)^2) * z# * z#) / (ArcTan(z#, level+1)))
else
v# = ((level * 2)-3) + (((level - 1)^2) * z# * z#)
endif
else
`First level
v# = z# / (ArcTan(z#, 2))
endif
endfunction v#
Thats some code I've tried to represent the ArcTan function. I know this will be slow - its more of a means to an end rather than a highly tuned piece of code.
Can anyone see why that wont work? I've run it through my brain a few times and it SHOULD represent the fraction.
One area where I think I MIGHT be going wrong is the last itteration (ie, the one which doesn't call the function again). What happens on the last line of the equation if every line calls itself?
Anyone got any idea's here?
Cheers!