Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Atan()
Message
From
04/03/2002 07:18:29
 
 
To
01/03/2002 10:05:40
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivia
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Re: Atan()
Miscellaneous
Thread ID:
00626890
Message ID:
00627715
Views:
24
This message has been marked as a message which has helped to the initial question of the thread.
Hilmar,

Whilst this is not the solution to your problem, ther are a couple of thing you might consider

(1) faster atan algorithm

(2) Speed of trig functions

(1) with a bit of math you can find that
atan(x) = acos( 1 / sqrt(1 + x ^2) ) && should acos work faster

&& let
a = sin (t)
b = cos(t)

&& now

tan(t) = sin(t) / cos(t)
tan(t) = sqrt(1-b^2) / b

&& hence
acos(b) == atan(sqrt(1-b^2) / b)


&& let
x = sqrt(1-b^2)/b

&&right hand side becomes: atan(x)

&& find left side
x = sqrt(1-b^2)/b
x^2 = (1 - b^2) / b^2
x^2 * b^2 = 1 - b^2
x^2 * b^2 + b^2 = 1
b^2 *(1 + x^2) = 1
b^2 = 1 / (1 + x^2)
b = 1 / sqrt(1 + x^2) && ie 0 <= b <= 1

&& subsitute b (in terms of x) in left hand side, x in right hand side
acos( 1 / sqrt(1 + x^2)) = atan(x)

&& sample set decimals to 18
x = .98
a = atan(x) && 0.775297496812126000
b = acos(1 / sqrt(1 + x^2)) && .775297486612127000
(2) speed of execution
I found on the net that the way calculators calculate is by using the CORDIC algorithm. Found one for sin, cos and asin

Suggest you have a look at them

http://mathforum.org/dr.math/problems/warren.05.16.99.html
http://www.math.tamu.edu/~jmorgan/Right_Angle_March_99/calculator.htm
http://mathforum.org/dr.math/problems/betty5.14.96.html
Gregory
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform