473,516 Members | 2,771 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Math Troubles

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 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 3670
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 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
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

"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 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

"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 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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
2282
by: Jussi Mononen | last post by:
Hi, I'm having problems to successfully execute the test scripts on a Compaq host ( OSF1 tr51bdev V5.1 2650 alpha ). Almost all tests end up with the following error message "PARI: *** Invalid arguments to divll. at test_eng/Testout.pm line 30. ...propagated at t/polyser.t line 9. t/polyser.....dubious
0
1948
by: lmckaha | last post by:
Hi, Mysql version: 3.23.49 Solaris version: 2.7 gcc compiler version: 2.95.2 Python : 2.2.2 I'm evaluating the C and C++ API to decide which one to bye but I have many troubles.
1
2705
by: limelight | last post by:
I have discovered a math error in the .NET framework's Log function. It returns incorrect results for varying powers of 2 that depend on whether the program is run from within the IDE or from the command line. The amount by which the calculation is off is very small; even though the double data type holds the errant value, it seems to round...
17
3590
by: cwdjrxyz | last post by:
Javascript has a very small math function list. However there is no reason that this list can not be extended greatly. Speed is not an issue, unless you nest complicated calculations several levels deep. In that case you need much more ram than a PC has to store functions calculated in loops so that you do not have to recalculate every time...
0
1482
by: Michal | last post by:
I have troubles with instaling .Net Framework 2.0 (Beta 2 - 2.0.50215). The main instalation went just fine, troubles begin with my attemt to run aspnet_regiss.exe -i. Asp.Net is instaled into IIS as it should be, sites are working just fine. The only problem is thet this instalation did not create the AspNet_WebAdmin folder in...
11
7327
by: Sambo | last post by:
I have the following module: ------------------------------- import math def ac_add_a_ph( amp1, ph1, amp2, ph2 ): amp3 = 0.0 ph3 = 0.0 ac1 = ( 0, 0j ) ac2 = ( 0, 0j )
15
4655
by: lbrtchx | last post by:
I am trying to write up a page with Math formulas (statistical ones) ~ http://www.geocities.com/tekmonk2005/OnLineStats02.html ~ The thing is that I am not able to make it look OK using HTML. I would like to somehow mark up parenthesis using the character entities for vertical bars and solid front and back slashes, but ~ <td...
0
1430
by: JohnIdol | last post by:
VC++6 to VC++2003 - linking troubles -------------------------------------------------------------------------------- Hi All, I successfully ported an application from VC++6 to VS2003. Solved compiling issues but now I am sticking with serious Linking troubles. I got a bunch of:
1
1647
by: Pegasus | last post by:
Good morning, I'm Filippo Battaglia. We're porting Apache STDCXX under Nanodesktop. We are trying to make nd compatible also with C++ and not only with C. Unfortunately, we're finding different technical troubles in the compilation. So, can anyone of the developers tell with me ? So, I can solve the troubles step by step and I can obtain...
0
7276
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7182
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7408
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7581
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7142
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
1
5110
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
4773
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3259
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1624
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.