954,483 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Creating Amplitude in C++.net

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?

paladin4service
Newbie Poster
5 posts since Jul 2005
Reputation Points: 10
Solved Threads: 0
 

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

double amplitude = sqrt( re * re + im * im);
    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?

Rashakil Fol
Super Senior Demiposter
Team Colleague
2,658 posts since Jun 2005
Reputation Points: 1,135
Solved Threads: 177
 

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

#include <complex>

...

complex<double> z1( 2.7, 3.4);

double phase=arg(z1);
double magnitude=abs(z1);
CrazyDieter
Junior Poster
108 posts since Jul 2005
Reputation Points: 11
Solved Threads: 6
 

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

paladin4service
Newbie Poster
5 posts since Jul 2005
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You