FORTRAN: Differences between "cabs" and "csqrt"

  • Context: Fortran 
  • Thread starter Thread starter Dimis414
  • Start date Start date
  • Tags Tags
    Fortran
Click For Summary
SUMMARY

The discussion centers on the differences between the FORTRAN commands CSQRT and CABS when applied to complex vectors. The command CSQRT(cvect1**2 + cvect2**2 + cvect3**2) produces a complex vector with both real and imaginary parts, while CABS(cvect1 + cvect2 + cvect3) yields only the real part, which is a non-negative value. The discrepancy in the results is attributed to the nature of complex square roots versus absolute values, with CSQRT always returning a complex number with a non-negative real part. A significant distinction arises when the input arguments approach π/2, leading to a notable difference between the outputs of the two commands.

PREREQUISITES
  • Understanding of complex numbers and their operations in FORTRAN
  • Familiarity with FORTRAN intrinsic functions, specifically CSQRT and CABS
  • Knowledge of vector mathematics and complex vector addition
  • Basic grasp of mathematical concepts such as absolute value and square roots
NEXT STEPS
  • Explore the FORTRAN documentation on intrinsic functions, focusing on CSQRT and CABS
  • Investigate the mathematical properties of complex numbers and their square roots
  • Learn about the implications of complex number operations in numerical computing
  • Examine case studies where complex vector operations are critical in scientific computing
USEFUL FOR

Mathematicians, scientists, and software developers working with complex numbers in FORTRAN, particularly those involved in numerical analysis and vector mathematics.

Dimis414
Messages
6
Reaction score
0
Assumung adding 3 complex vectrors (cvect1, cvect2 and cvect3).
What is the difference between using command:
CSQRT(cvect1**2+cvect2**2+cvect3**2)
and command:
CABS(cvect1+cvect2+cvect3)
??
The first one produces a complex vector (real and imaginary part), but the second only the real part has a value (the imaginary is zero).
However, both the real parts are pretty close but not the same. Why is that?
 
Technology news on Phys.org
Dimis414 said:
Assumung adding 3 complex vectrors (cvect1, cvect2 and cvect3).
What is the difference between using command:
CSQRT(cvect1**2+cvect2**2+cvect3**2)
and command:
CABS(cvect1+cvect2+cvect3)
??
The first one produces a complex vector (real and imaginary part), but the second only the real part has a value (the imaginary is zero).
However, both the real parts are pretty close but not the same. Why is that?
It's the difference between the complex square root and the absolute value (or magnitude) of a complex number. The square root of a complex number is also complex. The abs. value of a complex number is a real number..
 
Dimis414 said:
However, both the real parts are pretty close but not the same. Why is that?
That is just a coincidence. The real values can be completely different. The absolute value will always be a non-negative real, but the square root can have a negative real part.

CORRECTION: FORTRAN CSQRT always return a complex number with a non-negative real part.
So to get a real part very different from CABS, the input would need to have argument near π/2. In that case, the real part would be a relatively small positive number.
 
Last edited:

Similar threads

  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 3 ·
Replies
3
Views
5K
  • · Replies 8 ·
Replies
8
Views
3K
  • · Replies 2 ·
Replies
2
Views
4K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 3 ·
Replies
3
Views
14K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 8 ·
Replies
8
Views
5K
  • · Replies 6 ·
Replies
6
Views
2K