How to get the correct asin value

I have a simple question! How can I get the correct value of asin function (Inverse sin)? Consider this:
asin(sin(-3*pi/2))
The answer is pi/2. However, I need the exact value -3*pi/2 to be the result!
I'd like to thank Azzi and Walter for their answers. However. I would clarify some more aspects of the challenge that I'm trying to solve. Suppose that We have Two Signals:
Yi=X.*h_i+N_i;
Yj=conj(X).*h_j+N_j
Now, I'm trying to extract X out of Yi and Yj. I assume that N_i and N_j are White complex Gaussian noise which are uncorrelated with the data. I can't simply add them and subtract them because this would double the noise. I can extract the magnitude of x.^2 by simply:
sqrt(Yi.*Yj)
However. I'm trying to do the following for the phase:
q=Yi./Yj;
w=1./q;
ph=(asin((q-w)/2j))/2;
Which is giving me the wrong answer for X, because of the 2pi difference! Any suggestions.

Answers (2)

Are you requiring that asin(sin(A)) be A for all (real-valued) A ? If so then you cannot do that. sin() is a periodic function, so for any A there exists multiple B not equal to A such that sin(A) = sin(B), and asin() is not going to be able to tell the difference.

3 Comments

Mohammad
Mohammad on 27 Mar 2014
Edited: Mohammad on 27 Mar 2014
Thank you for your clarifications. I totally agree with you. However, I was looking for a trick to solve it! I added some more details to the question!
Try with atan2() and appropriate arguments, instead of asin()
Great solution! You save me!

Sign in to comment.

You can't get -3*pi/2, you have to add k*2*pi, in your case
asin(sin(-3*pi/2))-2*pi

4 Comments

Dear Azzi, Thank you for your answer. However, this doesn't help my case. Suppose that we interested in calculating the output of a, where:
asin(sin(a))
Where a can be pi/2 or -3*pi/2.
By definition, asin(x) takes its values from -pi/2 to pi/2. In your case the result will be pi/2.
The equation
a=sin(y)
has an infinity of solutions
y=asin(a)+2*k*pi
If you have specific conditions that allows to find the appropriate values of k, you have to add them.
Thank you again. However, I have no means of specifying k! I added some more details to the question.

Sign in to comment.

Products

Tags

Asked:

on 27 Mar 2014

Commented:

on 17 Dec 2019

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!