boostorg / boostorg/multiprecision

exp(pi*i) produces slightly incorrect result

Open
#392 6 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
265
Forks
128
Avg merge
4h 48m
Merged PRs (30d)
2

Description

Basically, exp(pi*i) where i is the imaginary unit should produce -1 but produces a slightly different
result with Boost 1.77.0; however it produces the correct result with Boost 1.74.0. The following program reproduces the issue:
```
#include

using CT = boost::multiprecision::cpp_complex_50;
static const auto pi = boost::math::constants::pi();
static const auto i = CT(0, 1);

int main() {
std::cout << exp(pi*i) << std::endl;
// Output when compiled with Boost 1.74.0 is -1 as expected.
// Output when compiled with Boost 1.77.0 is (-1,4.33483e-51).
// Note: The equivalent program using std::complex when run in compiler
// explorer produces a similar result: (-1,1.22465e-16). Don't know if this
// could be related.
// Note 2: My version of g++ under which this was compiled is 11.2.0.
}
```

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with the standalone reproducer using boost/multiprecision/cpp_complex.hpp and compare its output under Boost 1.74.0 and 1.77.0. Investigate the exp(pi*i) path and determine whether the regression can be addressed; done means the reported discrepancy is resolved and the expected output is confirmed.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.