944,149 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Unsolved
  • Views: 2084
  • C++ RSS
Jul 12th, 2005
0

Creating Amplitude in C++.net

Expand Post »
Hi!

I am new to this, and new to the programming. To be honest, it's not easy.

I am having this problem with doing Complex numbers. Basically, I have to write a program to show the Amplitude and Phase of a Complex object. First, because Amplitudes are usually absolute values, how do you write a absolute value equation in C++.net? Also, how do you show the phase?

Also, if anyone out there is a college student, or was a college student, maybe there is a better way to absorb this material. I read the book, but it tends to be too technical to understand. Anyone got any suggestions?
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
paladin4service is offline Offline
5 posts
since Jul 2005
Jul 12th, 2005
0

Re: Creating Amplitude in C++.net

From what I've read on Wikipedia, it looks like you want the magnitude and the argument of a complex number. Suppose the real part is stored in re and the imaginary part is stored in im (both doubles, presumably). Then

C++ Syntax (Toggle Plain Text)
  1. double amplitude = sqrt( re * re + im * im);
  2. double phase = atan2( re, im);

Amplitude is the absolute value in the sense that it is the distance of the complex number from the origin.

What book is this?
Team Colleague
Reputation Points: 1135
Solved Threads: 173
Super Senior Demiposter
Rashakil Fol is offline Offline
2,480 posts
since Jun 2005
Jul 12th, 2005
0

Re: Creating Amplitude in C++.net

If you are coding in c++, The standard library provides a template class for complex numbers.

C++ Syntax (Toggle Plain Text)
  1. #include <complex>
  2.  
  3. ...
  4.  
  5. complex<double> z1( 2.7, 3.4);
  6.  
  7. double phase=arg(z1);
  8. double magnitude=abs(z1);
Reputation Points: 11
Solved Threads: 6
Junior Poster
CrazyDieter is offline Offline
106 posts
since Jul 2005
Jul 12th, 2005
0

Re: Creating Amplitude in C++.net

Amplitude is the absolute value in the sense that it is the distance of the complex number from the origin.

What book is this?[/QUOTE]

The book we are using in class is called Visual C++.net by DEITEL. I think the book is ok, but it is hard to understand, maybe considering that I am not a programmer. Thanks for the assistance!!!
Reputation Points: 10
Solved Threads: 0
Newbie Poster
paladin4service is offline Offline
5 posts
since Jul 2005

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: Errors with membering functions in a class
Next Thread in C++ Forum Timeline: Again please someone check my code





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC