P: n/a

Hi,
Maybe I'm missing something:
<begin code>
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);
</end code>
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 TI83 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.  
Share this Question
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:
<begin code> 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); </end code>
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 TI83 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.  
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  
P: n/a

"Typpo" <ot********@optonline.net> 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 TI83 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  
P: n/a

"Typpo" <ot********@optonline.net> 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 TI83 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.   This discussion thread is closed Replies have been disabled for this discussion.   Question stats  viewed: 3380
 replies: 4
 date asked: Nov 17 '05
