octave-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Octave-bug-tracker] [bug #49091] MinGW std::acosh less accurate than Li


From: Markus Mützel
Subject: [Octave-bug-tracker] [bug #49091] MinGW std::acosh less accurate than Linux versions
Date: Wed, 3 Aug 2022 03:51:17 -0400 (EDT)

Follow-up Comment #15, bug #49091 (project octave):

I'm not sure what is happening for acosh(-10i) in Octave.

Test program:

#include <math.h>
#include <stdio.h>
#include <complex.h>

#include <iostream>
#include <cmath>
#include <complex>

int main()
{
  double x = 0;
  double y = 10;

  printf("x = %.16e\n", x);
  printf("y = %.16e\n", y);

  __complex__ double z;
  __real__ z = x;
  __imag__ z = y;

  // CRT
  __complex__ double ret = cacosh (z);
  printf("    cacosh(x+1i*y) = %.16f + %.16fi\n", __real__ ret, __imag__
ret);

  __imag__ z = -y;
  ret = cacosh (z);
  printf("    cacosh(x-1i*y) = %.16f + %.16fi\n", __real__ ret, __imag__
ret);

  // libstdc++
  std::complex<double> zcpp (x, y);
  std::complex<double> retcpp = std::acosh (zcpp);
  std::cout.precision(17);
  std::cout << "std::acosh(x+1i*y) = " << retcpp.real () << " + " <<
retcpp.imag () << "i" << std::endl;

  zcpp.imag (-y);
  retcpp = std::acosh (zcpp);
  std::cout << "std::acosh(x-1i*y) = " << retcpp.real () << " + " <<
retcpp.imag () << "i" << std::endl;

  return 0;
}


For MinGW, I see the following output:

Markus@Markus-PC MINGW64 ~
$ g++ test-acosh.cc -o test-acosh.exe

Markus@Markus-PC MINGW64 ~
$ ./test-acosh.exe
x = 0.0000000000000000e+00
y = 1.0000000000000000e+01
    cacosh(x+1i*y) = 2.9982229502979698 + 1.5707963267948966i
    cacosh(x-1i*y) = 2.9982229502979698 + -1.5707963267948966i
std::acosh(x+1i*y) = 2.9982229502979698 + 1.5707963267948966i
std::acosh(x-1i*y) = 2.9982229502979698 + -1.5707963267948966i


However, Octave still calculates the following:

$ octave --eval "format long; acosh(10i), acosh(-10i)"
ans =  2.998222950297970 + 1.570796326794897i
ans =  2.998222950297976 - 1.570796326794897i


Why does the simple C++ program calculate "good" values (using CRT or C++
functions)? But Octave still calculates "odd" values?


    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?49091>

_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]