Closed Thread
Results 1 to 4 of 4

Thread: SQL Inverse Trig Functions

  1. #1
    Join Date
    Mar 2008
    Posts
    7,145
    Rep Power
    86

    SQL Inverse Trig Functions

    I was looking more into functions in SQL and found the trig functions. Something just doesn't seem right though. I don't get how the inverse functions work?

    If I use the cosine function, it takes an argument representing an angle in radians.

    So:

    Code:
    SELECT COS(5.5);
    Is the cosine of an angle which is 5.5 radians. Thus the resulting value is:

    0.70866977429126
    Now, if I was to apply ACOS to 0.70866977429126 then the resulting value should be 5.5?

    So what we should have is:

    Code:
    SELECT ACOS(COS(5.5));
    The resulting value should be:

    5.5
    Then why is it
    0.783185307179586
    ? I'm sure I'm missing something. Any thoughts as to what I am missing here?

  2. CODECALL Circuit advertisement
    Join Date
    Always
    Posts
    Many

     
  3. #2
    Join Date
    Jul 2006
    Posts
    16,491
    Blog Entries
    75
    Rep Power
    143

    Re: SQL Inverse Trig Functions

    COS is a many to one function. The result is that it doesn't have an inverse that is guaranteed to result in the original value entered.

    ACOS returns a value between 0 and PI.
    Programming is a branch of mathematics.
    My CodeCall Blog | My Personal Blog

  4. #3
    Join Date
    Mar 2008
    Posts
    7,145
    Rep Power
    86

    Re: SQL Inverse Trig Functions

    So then is that the same as SIN and ASIN because those create weird results also.

    Code:
    SELECT ASIN(SIN(3.5));
    returns -0.358407346410207.

    When I do:

    Code:
    SELECT ATAN(TAN(3.5));
    The result is 0.358407346410207. Then what are these functions doing? Where are these weird numbers coming from?

    When I do this:

    Code:
    SELECT DEGREES(ASIN(SIN(RADIANS(3.5))));
    I get the original value of 3.5. I don't actually know what a radian is. Does that mean I can't have 3.5 radians? Which is why I am getting weird results?

  5. #4
    Join Date
    Jul 2006
    Posts
    16,491
    Blog Entries
    75
    Rep Power
    143

    Re: SQL Inverse Trig Functions

    In advanced math and ALL programming languages, trig is done in radians. A circle has 2*PI radians (360 degrees). 90 degrees is PI/2 radians. If you are thinking in degrees, you will get severely scrambled.
    Programming is a branch of mathematics.
    My CodeCall Blog | My Personal Blog

Closed Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. How to properly use trig functions in C++
    By Daftatt in forum C and C++
    Replies: 2
    Last Post: 05-22-2011, 07:14 PM
  2. Replies: 4
    Last Post: 02-06-2011, 01:37 PM
  3. SQL Functions - SQL Encryption Functions
    By chili5 in forum Tutorials
    Replies: 8
    Last Post: 09-04-2009, 09:40 AM
  4. SQL Functions - Math Functions
    By chili5 in forum Tutorials
    Replies: 6
    Last Post: 09-02-2009, 02:11 PM
  5. Functions help
    By ahmed in forum C and C++
    Replies: 7
    Last Post: 11-23-2008, 12:46 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts