How do I calculate the complex argument in Fortran?

Click For Summary

Discussion Overview

The discussion revolves around calculating the complex argument in Fortran, specifically in the context of programming a mathematical expression involving complex numbers. Participants are seeking solutions for implementing the argument function in Fortran90.

Discussion Character

  • Technical explanation
  • Mathematical reasoning
  • Homework-related

Main Points Raised

  • One participant describes an attempt to compute the argument using the expression ARG(A) but encounters an error.
  • Another participant suggests using ATAN(REAL(AIMAG(A))/REAL(REAL(A))) to calculate the argument, indicating uncertainty about the correct extraction of real and imaginary parts.
  • A different participant proposes using atan2(real(A),imag(A)) as a potential solution, noting that reversing the arguments might be necessary.
  • Another participant provides clarification on using ATAN2 for single precision and DATAN2 for double precision, along with examples of its usage.

Areas of Agreement / Disagreement

Participants express various methods for calculating the argument, but there is no consensus on the best approach or resolution to the initial error encountered. Multiple competing views on how to implement the argument function remain.

Contextual Notes

Some participants mention specific functions for handling real and imaginary parts, but there is uncertainty regarding the correct application of these functions in the context of the problem.

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.
 

Similar threads

  • · Replies 12 ·
Replies
12
Views
2K
  • · Replies 8 ·
Replies
8
Views
2K
  • · Replies 6 ·
Replies
6
Views
2K
  • · Replies 5 ·
Replies
5
Views
9K
  • · Replies 26 ·
Replies
26
Views
4K
  • · Replies 19 ·
Replies
19
Views
3K
  • · Replies 4 ·
Replies
4
Views
4K
  • · Replies 2 ·
Replies
2
Views
1K
  • · Replies 16 ·
Replies
16
Views
3K
  • · Replies 2 ·
Replies
2
Views
2K