445,870 Members | 1,212 Online
Need help? Post your question and get tips & solutions from a community of 445,870 IT Pros & Developers. It's quick & easy.

# Math Troubles

 P: n/a Hi, Maybe I'm missing something: MessageBox.Show("a = " + a + ", b = " + c + ", c = " + c); //message 1 double top = (Math.Pow(a, 2) + Math.Pow(b, 2) - Math.Pow(c, 2)); double bottom = (2.0 * a * b); MessageBox.Show("top = " + top + ", bottom = " + bottom); //message 2 return Math.Acos(top / bottom); Message 1 displays, "a = 15, b = 18.027..., c = 10". Message 2 displays, "top = 450, bottom = 540.832...". Which is all correct. The method itself returns 0.588, which leads me to believe that Math.Acos is the wrong way to go about finding the answer. On a TI-83 calculator, the functionality I'm looking for is marked as cos^-1 (inverse cosine), which is right above the cos button. The angle in question should be calculated as roughly 33.7 degrees. What's wrong with the math? Thanks. Nov 17 '05 #1
4 Replies

 P: n/a It is standard practice to use radians instead of degrees. .NET makes no exception. 0.588 radians converted to degrees is 33.7. The same is true of logarithms regarding the base. Base e is used instead of base 10. Brian Typpo wrote: Hi, Maybe I'm missing something: MessageBox.Show("a = " + a + ", b = " + c + ", c = " + c); //message 1 double top = (Math.Pow(a, 2) + Math.Pow(b, 2) - Math.Pow(c, 2)); double bottom = (2.0 * a * b); MessageBox.Show("top = " + top + ", bottom = " + bottom); //message 2 return Math.Acos(top / bottom); Message 1 displays, "a = 15, b = 18.027..., c = 10". Message 2 displays, "top = 450, bottom = 540.832...". Which is all correct. The method itself returns 0.588, which leads me to believe that Math.Acos is the wrong way to go about finding the answer. On a TI-83 calculator, the functionality I'm looking for is marked as cos^-1 (inverse cosine), which is right above the cos button. The angle in question should be calculated as roughly 33.7 degrees. What's wrong with the math? Thanks. Nov 17 '05 #2

 P: n/a Thanks. Correct returned value should be: return ((Math.Acos(top / bottom)) * (180.0 / Math.PI)); Brian Gideon wrote: It is standard practice to use radians instead of degrees. .NET makes no exception. 0.588 radians converted to degrees is 33.7. The same is true of logarithms regarding the base. Base e is used instead of base 10. Brian Nov 17 '05 #3

 P: n/a "Typpo" wrote in message news:ur**************@tk2msftngp13.phx.gbl... Hi, Which is all correct. The method itself returns 0.588, which leads me to believe that Math.Acos is the wrong way to go about finding the answer. On a TI-83 calculator, the functionality I'm looking for is marked as cos^-1 (inverse cosine), which is right above the cos button. The angle in question should be calculated as roughly 33.7 degrees. What's wrong with the math? Hi, As Brian stated, the result is in radians and not degrees. Multiply your result by 180/ Math.PI and you will get 33.7 degrees Bill Nov 17 '05 #4

 P: n/a "Typpo" wrote in message news:ur**************@tk2msftngp13.phx.gbl... Which is all correct. The method itself returns 0.588, which leads me to believe that Math.Acos is the wrong way to go about finding the answer. On a TI-83 calculator, the functionality I'm looking for is marked as cos^-1 (inverse cosine), which is right above the cos button. The angle in question should be calculated as roughly 33.7 degrees. What's wrong with the math? 33.7 degrees = 0.588 radian. Nov 17 '05 #5

### This discussion thread is closed

Replies have been disabled for this discussion.