Fortran How do I calculate the complex argument in Fortran?

AI Thread Summary
The discussion centers around programming a mathematical expression in Fortran90, specifically focusing on calculating the argument of a complex number. The user is attempting to implement the equation (T/(T-2*d))^(i*Nu) and is struggling with the 'arg' function. Initial attempts using the ARG function resulted in errors, prompting a search for alternatives. Suggestions include using the ATAN function to calculate the argument based on the real and imaginary components of the complex number. The correct approach involves using the ATAN2 function, which takes the imaginary part as the first argument and the real part as the second, ensuring proper handling of the quadrant of the angle. The discussion emphasizes the need to use IMAG and REAL functions to extract the respective parts of the complex number correctly, with a note on the distinction between single and double precision functions (ATAN2 vs. DATAN2).
miccol999
Messages
7
Reaction score
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
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?
 
atan2(real(A),imag(A)), if that isn't right, reverse the arguments.
 
that didn't work...how do you get arg(z) in fortran?
 
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.
 
Thread 'Is this public key encryption?'
I've tried to intuit public key encryption but never quite managed. But this seems to wrap it up in a bow. This seems to be a very elegant way of transmitting a message publicly that only the sender and receiver can decipher. Is this how PKE works? No, it cant be. In the above case, the requester knows the target's "secret" key - because they have his ID, and therefore knows his birthdate.
I tried a web search "the loss of programming ", and found an article saying that all aspects of writing, developing, and testing software programs will one day all be handled through artificial intelligence. One must wonder then, who is responsible. WHO is responsible for any problems, bugs, deficiencies, or whatever malfunctions which the programs make their users endure? Things may work wrong however the "wrong" happens. AI needs to fix the problems for the users. Any way to...

Similar threads

Replies
12
Views
2K
Replies
6
Views
2K
Replies
5
Views
9K
Replies
19
Views
2K
Replies
16
Views
3K
Replies
2
Views
2K
Back
Top