Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Andrzejek on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

arccosine function? 1

Status
Not open for further replies.

jlnewbie

Technical User
Aug 9, 2000
69
I'm needing an Arccosine function. I don't see anything access to do this. Thank You



JLopez
Lopez31@ATC-Enviro.com
Environmental Services @ Your Service
 
This formula came from the help topic "Derived Math Functions" in Access 2000. All I did was wrap it in a function declaration.
Code:
Public Function Arccos(X as Double) As Double
    Arccos = Atn(-X / Sqr(-X * X + 1)) + 2 * Atn(1)
End Function

Rick Sprague
Want the best answers? See faq181-2886
To write a program from scratch, first create the universe. - Paraphrased from Albert Einstein
 
Jlopez

You should note that the derived math functions often contain discontinuities. In this case, values of +1 or -1 for X will give you a "Div 0" error. You might slightly modify RickSpr's solution with

Code:
Public Function Arccos(X As Double) As Double
    If X = 1 Then
        Arccos = 0
    ElseIf X = -1 Then
        Arccos = -(4 * Atn(1))
    Else
        Arccos = Atn(-X / Sqr(-X * X + 1)) + 2 * Atn(1)
    End If
End Function
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top