How do I calculate the complex argument in Fortran?

In summary, the conversation is about programming a formula in Fortran90 involving complex numbers and finding the argument of a complex number. The person has tried using the ATAN function but is getting an error message. They are seeking help on how to properly find the argument of a complex number in Fortran90.
  • #1
miccol999
7
0
Hi
I need help with programming the following:

(T/(T-2*d))^(i*Nu)=exp(-i*Nu*ln|T/(T-2*d)| +Nu*arg(T/(T-2*d))

I don't know how to do the arg bit in Fortran90...this is what I've tried so far

A=T/(T-2*DELTA)
B=EXP(-CI*NU*LOG(ABS(A))+NU*ARG(A))

but obviously it threw back an error message at the 'ARG(A)' bit...I've tried searching the web and help directories but still unsure as to what to do, HELP!
 
Technology news on Phys.org
  • #2
I've also tried the following...

A=T/(T-2*DELTA)
ARGA=ATAN(REAL(AIMAG(A))/REAL(REAL(A)))
B=EXP(-CI*NU*LOG(ABS(A))+NU*ARGA)

...since arg(x+iy)=tan^(-1)(y/x). I think I'm not using the right function to find the real and imaginary parts of A, can anyone help at all?
 
  • #3
atan2(real(A),imag(A)), if that isn't right, reverse the arguments.
 
  • #4
that didn't work...how do you get arg(z) in fortran?
 
  • #5
Ten en cuenta que usas ATAN2 si es simple presicion y DATAN2 si es doble presicion

ATAN2(parte imaginaria, parte real)

Parte imaginaria: IMAG (o AIMAG) y DIMAG (Simple y doble presicion)
Parte real: REAL o DREAL

Examples

ATAN2 (2.679676, 1.0) has the value 1.213623.
 

Related to How do I calculate the complex argument in Fortran?

1. What is a Fortran complex argument?

A Fortran complex argument is a data type used in the Fortran programming language to represent complex numbers. It consists of two parts - a real part and an imaginary part, and is written in the form of (a,b) where a is the real part and b is the imaginary part. This data type is commonly used in scientific and engineering applications.

2. How do you declare a complex argument in Fortran?

To declare a complex argument in Fortran, you need to use the COMPLEX keyword followed by the name of the variable and the values for the real and imaginary parts enclosed in parentheses. For example, COMPLEX :: z = (1.5, 2.5) declares a complex argument named z with a real part of 1.5 and an imaginary part of 2.5.

3. How do you perform arithmetic operations on complex arguments in Fortran?

To perform arithmetic operations on complex arguments in Fortran, you can use the standard arithmetic operators such as +, -, *, and /. For example, z1 + z2 will add two complex arguments z1 and z2 together, while z1 * z2 will multiply them. It is important to note that when dividing complex arguments, you need to use the CDIV function instead of the / operator.

4. Can you compare complex arguments in Fortran?

Yes, you can compare complex arguments in Fortran using the standard comparison operators such as ==, /=, <, >, <=, and >=. These operators compare the real parts first and then the imaginary parts if the real parts are equal. For example, (2.5, 1.5) == (2.5, 2.5) will return .FALSE. as the imaginary parts are not equal.

5. How can I convert a complex argument to a real argument in Fortran?

To convert a complex argument to a real argument in Fortran, you can use the REAL function. This function takes a complex argument as an input and returns its real part as a real argument. For example, REAL(z) will return 1.5 for the complex argument z = (1.5, 2.5).

Similar threads

  • Programming and Computer Science
Replies
12
Views
1K
Replies
4
Views
840
  • Programming and Computer Science
Replies
8
Views
1K
  • Programming and Computer Science
Replies
15
Views
1K
  • Special and General Relativity
Replies
1
Views
849
  • Programming and Computer Science
Replies
6
Views
2K
  • Programming and Computer Science
Replies
5
Views
8K
  • Precalculus Mathematics Homework Help
Replies
2
Views
978
  • Calculus and Beyond Homework Help
Replies
23
Views
2K
Replies
13
Views
758
Back
Top