From 06b4a5b105f5aebe66b987194fc9b5c207fae5ff Mon Sep 17 00:00:00 2001 From: Weiqun Zhang Date: Mon, 24 Feb 2025 18:41:06 -0800 Subject: [PATCH] Make Parser CI less sensitive to roundoff errors (#4321) Replace `1-cos(x)` with `2*sin(x/2)**2` to reduce roundoff errors for small x's. --- Tests/Parser/main.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Tests/Parser/main.cpp b/Tests/Parser/main.cpp index df82ba2f3f0..aafd8da8a09 100644 --- a/Tests/Parser/main.cpp +++ b/Tests/Parser/main.cpp @@ -318,14 +318,14 @@ int main (int argc, char* argv[]) {-149.e-6}, {1.e-6}, 1000, 1.e-12, 1.e-15); - nerror += test1("if(z Real { Real lramp=8.e-3, pi=3.14, dens=1.e23; if (z < lramp) { - //return 0.5*(1-std::cos(pi*z/lramp))*dens; - return 0.5*dens-0.5*dens*std::cos(pi*z/lramp); + auto x = std::sin(pi/2*z/lramp); + return x*x*dens; } else { return dens; }