Skip to content

<cmath>: Invalid output for incomplete elliptic integral of the second kind with k = 1 #3076

@fsb4000

Description

@fsb4000

Describe the bug
The elliptic integral of second kind std::ellint_2 produces wrong result for k=1 and angles less than -pi/2 or larger than pi/2

https://godbolt.org/z/Mq9v36TWh

Command-line test case

C:\Temp>type main.cpp
#include <type_traits>
#include <iostream>
#include <cmath>

int main() {
    double res = std::ellint_2(1, 6.2831853071795862);
    std::cout << res << std::endl;
}

C:\Temp>cl /EHsc /W4 /WX /std:c++17 .\main.cpp
Microsoft (R) C/C++ Optimizing Compiler Version 19.34.31721 for x64
Copyright (C) Microsoft Corporation.  All rights reserved.

main.cpp
Microsoft (R) Incremental Linker Version 14.34.31721.0
Copyright (C) Microsoft Corporation.  All rights reserved.

/out:main.exe
main.obj

C:\Temp>.\main.exe
-2.44929e-16

Expected behavior
4

STL version

Microsoft Visual Studio Community 2022 Preview
Version 17.4.0 Preview 1.0

Additional context
DevCom-10133797 .
Also the issue is fixed in boost: boostorg/math#321
So probably just updating boost-math submodule will fix the issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingfixedSomething works now, yay!

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions