473,385 Members | 1,309 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

inverse of cosine

How do I get the inverse of a cosine, that is, cos(a) = x, I have x and I need to know a? I don't
need the hyperbolic inverse, unless I can use it to get the cosine inverse.

Greetings,
Mario
Nov 17 '05 #1
5 6722
How do I get the inverse of a cosine, that is, cos(a) = x, I have x and I need to know a?


a = acos(x)

Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Nov 17 '05 #2
The confusing part is that acos(x) = a returns in the range [0,pi]. But a is in [0,2*pi]! Is acos really the
inverse of cos? The circle has 360 degrees - not 180.

Greetings,
Mario
Nov 17 '05 #3
Mario wrote:
The confusing part is that acos(x) = a returns in the range [0,pi].
But a is in [0,2*pi]! Is acos really the inverse of cos? The circle
has 360 degrees - not 180.


No, it's not really the inverse, since there really isn't an inverse of cos
(or any of the trigonometric transcendentals) over an unbounded range of
theta. acos returns an angle in the 1st or 2nd quadrant that satisfies the
relationship cos(acos(x)) == x. (Of course, being floating point, it may
not be exactly equal). If your angle is in the 3rd or 4th quadrants, you
need to make the necessary adjustment yourself. For instance, if you know
both the sine and the cosine of the original angle, you can use
atan2(sin_theta,cos_theta) to recover an angle in the full circle.

-cd
Nov 17 '05 #4
Makes no sense. acos takes input in the full output range of cos(a) [-1,1]. How can acos take the full range, satisfy your equality (subject to floating point errors) and only be a "partial" two-quadrant solution? Can an angle be negative? No. Why would acos return angles in the 3rd and 4th quadrant? a in cos(a) is always positive. So [0,pi] makes sense to be the
range of the inverse?

Greetings,
Mario
Nov 17 '05 #5
Mario wrote:
Makes no sense. acos takes input in the full output range of cos(a)
[-1,1]. How can acos take the full range, satisfy your equality
(subject to floating point errors) and only be a "partial"
two-quadrant solution?
Because cos varies from 1 to -1 in quadrants 1 and 2, and from -1 to 1 in
quadrants 3 and 4.
Can an angle be negative?
Yes, absolutely.
No. Why would acos
return angles in the 3rd and 4th quadrant? a in cos(a) is always
positive. So [0,pi] makes sense to be the range of the inverse?


Think about it more. In the full circle there are two angles with any given
value of cos (except for 1 and -1 which only occur at 0 and pi) therefore
cos in the mathematical sense is not inversible.

Think about a cosine wave along the y-axis. What's Y as a function of X?
Clearly there is no such function since there are an infinite number of Y's
for any given X.

So, there's no complete inverse for cos (or sin), but any interval of pi
radians defines the entire function (in fact, an interval of pi/2 radians
defines the entire relationship due to symmetry). The designers of acos
could just as well have picked -pi/2 .. pi/2 as the interval rather than 0
... pi.

In fact, if you look at hardware implementations of sin/cos, it's typical
that they only implement the first-quadrant and rely on software to compute
the other quadrants using symmetry.

-cd
Nov 17 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: David C. Fox | last post by:
Is there a function which takes a list of tuples and returns a list of lists made up of the first element of each tuple, the second element of each tuple, etc.? In other words, the the inverse...
1
by: Andy | last post by:
I have drawn an icon. I used the the inverse color on the color window in order to get transparency. However, now the inverse color has stopped working by some reason. Why is this? I press and...
6
by: vishnu mahendra | last post by:
hello to all, can any one please give me an algorithm to find inverse of a matrix of order n rows and m columns. thank you in advance, vishnu.
9
by: Water Cooler v2 | last post by:
What is the inverse of the sine function? I've been pulling my hair and I have no clue nor memory of how to go about solving this little expression: sine-1 (read sine inverse) of (1-(x/y)) An...
1
by: Adam | last post by:
Visual basic 6.0 doesn't appear to have Arc Sin or Arc Cosine built in, I'm working on a program that calculated trigonometry and I need to figure out how to substitute something for Arc Cosine or...
3
by: Smokey Grindle | last post by:
How can you "inverse" a color in GDI+? Say the color I have is blue, the inverse of that is yellow... how would you go about doing this? is there a simpler way then taking the RGB values and...
4
by: Jonathan Fine | last post by:
Hello As part of the MathTran project I found myself wanting to maintain a bijection between long names and short names. http://www.open.ac.uk/mathtran In other words, I wanted to have two...
3
by: illusion.admins | last post by:
Has anyone had experience with or implemented a Discrete Cosine Transform in C#? Found code for FFT which I have taken advantage of and modified for my use but can not find a thing for DCT. Any...
10
by: ratcharit | last post by:
Currently using cosine function in math.h Currently I get: 1 = cos(1e^-7) Is there another way for cos to return value of high accuracy say: 0.999999 = cos(1e^-7)
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.