can anyone help me to calculate Arccos(X) ? with some formula ? I'm trying to do it in some environment (SAP WEBI) with limited math formulas. ( have only cos , sin , tan.. ).
Asked
Active
Viewed 2,828 times
3
-
Ok, from your other comment I see you don't have `atan` - what accuracy do you need? If you don't need it exactly, you can prebuild a table of cosines and look-up nearest value to get the inverse. Otherwise you might be stuck with an integral or infinite series [as described here](http://en.wikipedia.org/wiki/Inverse_trigonometric_functions). – Roger Rowland Dec 08 '13 at 13:41
-
I need to calculate the distance between to points ( latitude/longtitude) , I've found this formula : (ACOS(COS(RADIANS(90-X1)) *COS(RADIANS(90-X2)) +SIN(RADIANS(90-X1)) *SIN(RADIANS(90-X2)) *COS(RADIANS(Y1-Y2))) *6371)*1000 but I can't calculate ACOS in my system (WEBI). do you have any suggest? thank you. Mor – Mor Dec 08 '13 at 13:47
-
[This answer](http://stackoverflow.com/a/27943/2065121) is related and has an alternative but still needs at least `atan` :-( – Roger Rowland Dec 08 '13 at 13:50
-
It might be better to [ask this question on Math](http://math.stackexchange.com/) instead. – Roger Rowland Dec 08 '13 at 14:03
3 Answers
2
You can try using Newton's method:
function acos(a) {
delta = 1e-5
// a lousy first approximation
x = pi*(1-a)/2
last = x
x += (cos x-a)/sin x
while ( abs(x-last) > delta ) {
last = x
x += (cos x-a)/sin x
}
return x
}

Teepeemm
- 4,331
- 5
- 35
- 58
0
From https://en.wikipedia.org/wiki/Inverse_trigonometric_functions :
# for -1 < x <= +1 :
acos(x) == 2*atan( sqrt(1-x*x)/(1+x) )

David Cary
- 5,250
- 6
- 53
- 66
-1
In WEBI there isn't way to calculate ACOS so there is 2 solutions:
1) create a new custom function in c++ and import it to WEBI
2) create a universe and use ACOS there.
Mor

Mor
- 229
- 2
- 6
- 14