- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

The intrinsic function ACOSH with complex argument was added to Fortran in Fortran 2008. Since this function is multi-valued for complex arguments, a convention is needed for what the return value should be. The F2008 (13.7.5) and F2018 (16.9.5) standards state:

__5 Result Value. The result has a value equal to a processor-dependent approximation to the inverse hyperbolic cosine function of X. If the result is complex the imaginary part is expressed in radians and lies in the range 0 ≤ AIMAG (ACOSH (X)) ≤ π__

In contrast, the Intel Fortran Development Reference Guide says:

__If the result is complex, the real part is non-negative, and the imaginary part is expressed in radians and lies in the range -pi <= AIMAG (ACOSH (x)) <= pi.__

The following program outputs a result with the imaginary part negative:

```
program xacosh
implicit none
complex :: z = (-0.01, -0.01)
print 10, 'z', z, 'acosh(z)', acosh(z)
10 format(1x,A,T10,'( ',ES11.3,' , ',ES11.3,' )')
end
```

The result:

```
S:\LANG\ftn95>acosh
z ( -1.000E-02 , -1.000E-02 )
acosh(z)( 1.000E-02 , -1.581E+00 )
```

Please clarify if the deviations ( w.r.t. (a) sign of the real part and (b) range of the imaginary part) from the standard are deliberately intended, and any reasons for the choices, if available. Thank you in advance.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

```
D:\Projects>nagfor -o t.exe t.f90
NAG Fortran Compiler Release 7.1(Hanzomon) Build 7114
[NAG Fortran Compiler normal termination]
D:\Projects>t.exe
z ( -1.000E-02 , -1.000E-02 )
acosh(z)( 1.000E-02 , -1.581E+00 )
```

It's an error in the F2018 standard, corrected by interpretation request F18/0001. The corrected text says, "If the result is complex the real part is nonnegative, and the imaginary part is expressed in radians and lies in the range −π ≤ AIMAG (ACOSH (X)) ≤ π"

Link Copied

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

This is really fascinating, the https://www.geeksforgeeks.org/acosh-function-for-complex-number-in-c/ site seems to agree with your Intel observations. They provide a couple of quick samples.

Running their sample but with the -0.000 I get -pi.

-1.58 is just 335 degrees in the -PI to PI system.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

This is an interesting one. gfortran 12.0.1 is in agreement in values with ifort/ifx. I will ask advice from someone more familiar with this function, and the F08 Standard. I don't have the NAG compiler myself but I'll ask someone to try it with NAG.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

```
D:\Projects>nagfor -o t.exe t.f90
NAG Fortran Compiler Release 7.1(Hanzomon) Build 7114
[NAG Fortran Compiler normal termination]
D:\Projects>t.exe
z ( -1.000E-02 , -1.000E-02 )
acosh(z)( 1.000E-02 , -1.581E+00 )
```

It's an error in the F2018 standard, corrected by interpretation request F18/0001. The corrected text says, "If the result is complex the real part is nonnegative, and the imaginary part is expressed in radians and lies in the range −π ≤ AIMAG (ACOSH (X)) ≤ π"

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

The portion "the imaginary part is expressed in radians" strikes me as odd, since the imaginary part (with the __ i __removed) does not represent an angle -- it is just a real number.

If one wishes to think about the Argand Diagram, the real part is the x-coordinate and the imaginary part is the y-coordinate. It is only after the point (x, y), where z = x + i y, is plotted and a line drawn to it from the origin that we may speak of angles.

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page