Using Forth to Find asin(x) or acos(x)Date: 03/16/2004 at 02:47:07 From: Phil Subject: My last math class was a few years ago :-) I am writing a program in Forth. I have available tan, atan, cos, and sin. I have three sides of an oblique triangle. How can I find the angles? I know I can do it if I have asin. Is there another way, or can I define asin in terms of what I have available? Thanks! Date: 03/16/2004 at 08:35:06 From: Doctor Rick Subject: Re: My last math class was a few years ago :-) Hi, Phil. It is possible to find the arcsin or arccos using the arctangent. Consider the right triangle B * /| / | c/ | / |a / | / | *------* A b C The tangent of A is a/b, so atan(a/b) = A The sine of A is a/sqrt(a^2+b^2), so asin(a/c) = A Let's let c = 1, and find b using the Pythagorean theorem: c^2 = a^2 + b^2 b^2 = c^2 - a^2 b = sqrt(c^2 - a^2) b = sqrt(1 - a^2) Now we've got asin(a/c) = asin(a/1) = asin(a) = A = atan(a/b) = atan(a/sqrt(1 - a^2)) Thus: asin(a) = atan(a/sqrt(1 - a^2)) That's the formula for the arcsin. Similarly, acos(b) = atan(sqrt(1 - b^2)/b) When angles can be outside the range 0 to 180 degrees, we need to do a bit more work. For instance, both 45 degrees and 225 degrees have the same tangent, but they have different sines (sqrt(2)/2 and -sqrt(2)/2). We must know what quadrant the angle is in in order to distinguish between the two possible values for the arcsin or arccos. This is not an issue, however, in solving triangles, because the angles are necessarily in the range 0 to 180 degrees. The easiest way to find the angles in an oblique triangle would be to use the law of cosines, which requires the acos, not asin: c^2 = a^2 + b^2 - 2ab*cos(C) C = acos((a^2 + b^2 - c^2)/(2ab)) You might also find it helpful or interesting to read this thread from our archives: Trig Functions in Forth http://mathforum.org/library/drmath/view/62672.html Feel free to write back if you have any further questions. - Doctor Rick, The Math Forum http://mathforum.org/dr.math/ Date: 03/20/2004 at 11:32:22 From: Phil Subject: My last math class was a few years ago :-) The equations worked perfectly! Thank you for your help. |
Search the Dr. Math Library: |
[Privacy Policy] [Terms of Use]
Ask Dr. Math^{TM}
© 1994-2015 The Math Forum
http://mathforum.org/dr.math/