How to convert asin function to atan2 function?
28 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Respected sir,
My question is: I have one equation let say "C = sin D"
That means "D = Sine Inverse of C"
In matlab we used to write "D = asinC".
But I want to write the same thing in terms of atan2 i.e., D in terms of atan2 of C. (The answer should not change)
So, how to write or convert sin function into atan2 function ?
Kindly help me in this regards.
Thanks in advance.
2 comentarios
Jan
el 15 de Dic. de 2022
"Converting" one function into another is not a meaningful procedure. Are you looking for the inverse function of atan2? Then see https://en.wikipedia.org/wiki/Atan2
Torsten
el 15 de Dic. de 2022
C = tan(D)/sqrt(1+tan(D)^2)
But you will need to differ between some case when you solve this equation for tan(D).
Respuestas (2)
John D'Errico
el 15 de Dic. de 2022
Editada: John D'Errico
el 15 de Dic. de 2022
What you are asking does not make complete sense. Actually, relatively little sense at all, really. Sorry, but let me explain in some depth.
atan2 is a TWO argument version of the inverse tangent. The tangent function, and its inverse atan (as opposed to atan2) does work like the sin function, and its inverse asin.
For example, over a limited domain, we have the sin function. Sin is a periodic function, on an interval of length 2*pi. Fir example, here are a few periods of the sin function.
fplot(@sin,[-2*pi,2*pi])
and the asin function maps a number from the interval [-1,1] into an angle, over the interval [pi/2,pi2]. So the range of asin is [-pi/2,pi/2] (as long as we stick to real numbers. It gets more messy if we allow complex numbers.)
fplot(@asin,[-1,1])
As a test, we can see if the sin and asin functions really are functional inverses of each other.
x = linspace(-pi/2,pi/2);
xhat = asin(sin(x));
[min(x - xhat),max(x-xhat)]
We can go the other way too.
y = linspace(-1,1,250);
yhat = sin(asin(y));
[min(y - yhat),max(y-yhat)]
As you can see, to within floating point trash, the two results were always effectively identical, at least in double precision. ain and asin are functional inverses of each other.
As well, we can look at the tangent function.
fplot(@tan,[-2*pi,2*pi])
So the tangent function is actually periodic on a shorter interval than the sin function. tan is periodic on an interval of length pi.
Just like the sin function, we can invert the tan function. This time I'll use an interval that is large for the plot of atan. I shold have written [-inf,inf], but that would make fplot have a heart attack, and the plot would be unviewable anyway. So [-20,20] was good enough.
fplot(@atan,[-20,20])
Next, do the test with tan and atan as we did with the sin function.
x = linspace(-pi/2,pi/2,250);
xhat = atan(tan(x));
[min(x - xhat),max(x-xhat)]
y = linspace(-100,100,10000);
yhat = tan(atan(y));
[min(y - yhat),max(y-yhat)]
So as with the sin function, tan and atan are functional inverses of each other, on that interval. We can go both ways, and they are seen to be inverses, as expected. (Again, always within floating point trash.)
However, atan2 takes TWO arguments. It does not take a single number as an input. But you are asking for atan2 to work just like asin. That cannot happen. atan2 returns just one value, an angle, but it takes TWO arguments.
In fact, atan2 exists to solve a subtly extended problem than does the simpler atan function. atan2 is not in fact the functional inverse of the tan function, as you want to write it, because atan2 requires two arguments.
Can you make atan2 act sort of like the atan function? Sigh. Well, yes, in a sense. We would have the "identity" that
atan(y) == atan2(y,1)
However, atan2 takes two arguments. So used in that sense, you are not using atan2 properly, and if you want a truly functional inverse of the tan function that allows you to reverse the results as you want, you need to use the atan function, NOT the atan2 function.
0 comentarios
GUILLERMO JAQUENOD
el 25 de Sept. de 2023
Editada: GUILLERMO JAQUENOD
el 26 de Sept. de 2023
if C=asin ( D ), then it is also valid C = atan ( D/sqrt ( 1 - D^2)) , not valid for D=1.
Using atan2 (Y,X) the answer should be C=atan2 (D,sqrt(1-D^2)), with the same restriction for D=1
0 comentarios
Ver también
Categorías
Más información sobre Trigonometry en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!