Average Error: 13.3 → 0.2
Time: 11.0s
Precision: 64
\[\left(-x \cdot \frac{1}{\tan B}\right) + \frac{F}{\sin B} \cdot {\left(\left(F \cdot F + 2\right) + 2 \cdot x\right)}^{\left(-\frac{1}{2}\right)}\]
\[\begin{array}{l} \mathbf{if}\;F \le -77609648.144404009:\\ \;\;\;\;\left(1 \cdot \frac{1}{\sin B \cdot {F}^{2}} - \frac{1}{\sin B}\right) + \left(-\frac{x \cdot 1}{\tan B}\right)\\ \mathbf{elif}\;F \le 1.49264129336098431 \cdot 10^{131}:\\ \;\;\;\;\left(F \cdot {\left(\sqrt{\left(F \cdot F + 2\right) + 2 \cdot x}\right)}^{\left(2 \cdot \left(-\frac{1}{2}\right)\right)}\right) \cdot \frac{1}{\sin B} + \left(-\frac{x \cdot 1}{\tan B}\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(-1, \frac{x \cdot \cos B}{\sin B} + \frac{x}{\sin B \cdot {F}^{2}}, \frac{1}{\sin B}\right)\\ \end{array}\]
\left(-x \cdot \frac{1}{\tan B}\right) + \frac{F}{\sin B} \cdot {\left(\left(F \cdot F + 2\right) + 2 \cdot x\right)}^{\left(-\frac{1}{2}\right)}
\begin{array}{l}
\mathbf{if}\;F \le -77609648.144404009:\\
\;\;\;\;\left(1 \cdot \frac{1}{\sin B \cdot {F}^{2}} - \frac{1}{\sin B}\right) + \left(-\frac{x \cdot 1}{\tan B}\right)\\

\mathbf{elif}\;F \le 1.49264129336098431 \cdot 10^{131}:\\
\;\;\;\;\left(F \cdot {\left(\sqrt{\left(F \cdot F + 2\right) + 2 \cdot x}\right)}^{\left(2 \cdot \left(-\frac{1}{2}\right)\right)}\right) \cdot \frac{1}{\sin B} + \left(-\frac{x \cdot 1}{\tan B}\right)\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-1, \frac{x \cdot \cos B}{\sin B} + \frac{x}{\sin B \cdot {F}^{2}}, \frac{1}{\sin B}\right)\\

\end{array}
double f(double F, double B, double x) {
        double r34339 = x;
        double r34340 = 1.0;
        double r34341 = B;
        double r34342 = tan(r34341);
        double r34343 = r34340 / r34342;
        double r34344 = r34339 * r34343;
        double r34345 = -r34344;
        double r34346 = F;
        double r34347 = sin(r34341);
        double r34348 = r34346 / r34347;
        double r34349 = r34346 * r34346;
        double r34350 = 2.0;
        double r34351 = r34349 + r34350;
        double r34352 = r34350 * r34339;
        double r34353 = r34351 + r34352;
        double r34354 = r34340 / r34350;
        double r34355 = -r34354;
        double r34356 = pow(r34353, r34355);
        double r34357 = r34348 * r34356;
        double r34358 = r34345 + r34357;
        return r34358;
}

double f(double F, double B, double x) {
        double r34359 = F;
        double r34360 = -77609648.14440401;
        bool r34361 = r34359 <= r34360;
        double r34362 = 1.0;
        double r34363 = 1.0;
        double r34364 = B;
        double r34365 = sin(r34364);
        double r34366 = 2.0;
        double r34367 = pow(r34359, r34366);
        double r34368 = r34365 * r34367;
        double r34369 = r34363 / r34368;
        double r34370 = r34362 * r34369;
        double r34371 = r34363 / r34365;
        double r34372 = r34370 - r34371;
        double r34373 = x;
        double r34374 = r34373 * r34362;
        double r34375 = tan(r34364);
        double r34376 = r34374 / r34375;
        double r34377 = -r34376;
        double r34378 = r34372 + r34377;
        double r34379 = 1.4926412933609843e+131;
        bool r34380 = r34359 <= r34379;
        double r34381 = r34359 * r34359;
        double r34382 = 2.0;
        double r34383 = r34381 + r34382;
        double r34384 = r34382 * r34373;
        double r34385 = r34383 + r34384;
        double r34386 = sqrt(r34385);
        double r34387 = r34362 / r34382;
        double r34388 = -r34387;
        double r34389 = r34366 * r34388;
        double r34390 = pow(r34386, r34389);
        double r34391 = r34359 * r34390;
        double r34392 = r34391 * r34371;
        double r34393 = r34392 + r34377;
        double r34394 = -r34362;
        double r34395 = cos(r34364);
        double r34396 = r34373 * r34395;
        double r34397 = r34396 / r34365;
        double r34398 = r34373 / r34368;
        double r34399 = r34397 + r34398;
        double r34400 = fma(r34394, r34399, r34371);
        double r34401 = r34380 ? r34393 : r34400;
        double r34402 = r34361 ? r34378 : r34401;
        return r34402;
}

Error

Bits error versus F

Bits error versus B

Bits error versus x

Derivation

  1. Split input into 3 regimes
  2. if F < -77609648.14440401

    1. Initial program 24.4

      \[\left(-x \cdot \frac{1}{\tan B}\right) + \frac{F}{\sin B} \cdot {\left(\left(F \cdot F + 2\right) + 2 \cdot x\right)}^{\left(-\frac{1}{2}\right)}\]
    2. Simplified24.4

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{F}{\sin B}, {\left(\left(F \cdot F + 2\right) + 2 \cdot x\right)}^{\left(-\frac{1}{2}\right)}, -x \cdot \frac{1}{\tan B}\right)}\]
    3. Using strategy rm
    4. Applied associate-*r/24.4

      \[\leadsto \mathsf{fma}\left(\frac{F}{\sin B}, {\left(\left(F \cdot F + 2\right) + 2 \cdot x\right)}^{\left(-\frac{1}{2}\right)}, -\color{blue}{\frac{x \cdot 1}{\tan B}}\right)\]
    5. Using strategy rm
    6. Applied add-sqr-sqrt24.4

      \[\leadsto \mathsf{fma}\left(\frac{F}{\sin B}, {\color{blue}{\left(\sqrt{\left(F \cdot F + 2\right) + 2 \cdot x} \cdot \sqrt{\left(F \cdot F + 2\right) + 2 \cdot x}\right)}}^{\left(-\frac{1}{2}\right)}, -\frac{x \cdot 1}{\tan B}\right)\]
    7. Applied unpow-prod-down24.4

      \[\leadsto \mathsf{fma}\left(\frac{F}{\sin B}, \color{blue}{{\left(\sqrt{\left(F \cdot F + 2\right) + 2 \cdot x}\right)}^{\left(-\frac{1}{2}\right)} \cdot {\left(\sqrt{\left(F \cdot F + 2\right) + 2 \cdot x}\right)}^{\left(-\frac{1}{2}\right)}}, -\frac{x \cdot 1}{\tan B}\right)\]
    8. Using strategy rm
    9. Applied fma-udef24.4

      \[\leadsto \color{blue}{\frac{F}{\sin B} \cdot \left({\left(\sqrt{\left(F \cdot F + 2\right) + 2 \cdot x}\right)}^{\left(-\frac{1}{2}\right)} \cdot {\left(\sqrt{\left(F \cdot F + 2\right) + 2 \cdot x}\right)}^{\left(-\frac{1}{2}\right)}\right) + \left(-\frac{x \cdot 1}{\tan B}\right)}\]
    10. Simplified19.4

      \[\leadsto \color{blue}{\frac{F \cdot {\left(\sqrt{\left(F \cdot F + 2\right) + 2 \cdot x}\right)}^{\left(2 \cdot \left(-\frac{1}{2}\right)\right)}}{\sin B}} + \left(-\frac{x \cdot 1}{\tan B}\right)\]
    11. Taylor expanded around -inf 0.1

      \[\leadsto \color{blue}{\left(1 \cdot \frac{1}{\sin B \cdot {F}^{2}} - \frac{1}{\sin B}\right)} + \left(-\frac{x \cdot 1}{\tan B}\right)\]

    if -77609648.14440401 < F < 1.4926412933609843e+131

    1. Initial program 1.2

      \[\left(-x \cdot \frac{1}{\tan B}\right) + \frac{F}{\sin B} \cdot {\left(\left(F \cdot F + 2\right) + 2 \cdot x\right)}^{\left(-\frac{1}{2}\right)}\]
    2. Simplified1.2

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{F}{\sin B}, {\left(\left(F \cdot F + 2\right) + 2 \cdot x\right)}^{\left(-\frac{1}{2}\right)}, -x \cdot \frac{1}{\tan B}\right)}\]
    3. Using strategy rm
    4. Applied associate-*r/1.1

      \[\leadsto \mathsf{fma}\left(\frac{F}{\sin B}, {\left(\left(F \cdot F + 2\right) + 2 \cdot x\right)}^{\left(-\frac{1}{2}\right)}, -\color{blue}{\frac{x \cdot 1}{\tan B}}\right)\]
    5. Using strategy rm
    6. Applied add-sqr-sqrt1.2

      \[\leadsto \mathsf{fma}\left(\frac{F}{\sin B}, {\color{blue}{\left(\sqrt{\left(F \cdot F + 2\right) + 2 \cdot x} \cdot \sqrt{\left(F \cdot F + 2\right) + 2 \cdot x}\right)}}^{\left(-\frac{1}{2}\right)}, -\frac{x \cdot 1}{\tan B}\right)\]
    7. Applied unpow-prod-down1.2

      \[\leadsto \mathsf{fma}\left(\frac{F}{\sin B}, \color{blue}{{\left(\sqrt{\left(F \cdot F + 2\right) + 2 \cdot x}\right)}^{\left(-\frac{1}{2}\right)} \cdot {\left(\sqrt{\left(F \cdot F + 2\right) + 2 \cdot x}\right)}^{\left(-\frac{1}{2}\right)}}, -\frac{x \cdot 1}{\tan B}\right)\]
    8. Using strategy rm
    9. Applied fma-udef1.2

      \[\leadsto \color{blue}{\frac{F}{\sin B} \cdot \left({\left(\sqrt{\left(F \cdot F + 2\right) + 2 \cdot x}\right)}^{\left(-\frac{1}{2}\right)} \cdot {\left(\sqrt{\left(F \cdot F + 2\right) + 2 \cdot x}\right)}^{\left(-\frac{1}{2}\right)}\right) + \left(-\frac{x \cdot 1}{\tan B}\right)}\]
    10. Simplified0.3

      \[\leadsto \color{blue}{\frac{F \cdot {\left(\sqrt{\left(F \cdot F + 2\right) + 2 \cdot x}\right)}^{\left(2 \cdot \left(-\frac{1}{2}\right)\right)}}{\sin B}} + \left(-\frac{x \cdot 1}{\tan B}\right)\]
    11. Using strategy rm
    12. Applied div-inv0.3

      \[\leadsto \color{blue}{\left(F \cdot {\left(\sqrt{\left(F \cdot F + 2\right) + 2 \cdot x}\right)}^{\left(2 \cdot \left(-\frac{1}{2}\right)\right)}\right) \cdot \frac{1}{\sin B}} + \left(-\frac{x \cdot 1}{\tan B}\right)\]

    if 1.4926412933609843e+131 < F

    1. Initial program 36.9

      \[\left(-x \cdot \frac{1}{\tan B}\right) + \frac{F}{\sin B} \cdot {\left(\left(F \cdot F + 2\right) + 2 \cdot x\right)}^{\left(-\frac{1}{2}\right)}\]
    2. Simplified36.9

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{F}{\sin B}, {\left(\left(F \cdot F + 2\right) + 2 \cdot x\right)}^{\left(-\frac{1}{2}\right)}, -x \cdot \frac{1}{\tan B}\right)}\]
    3. Taylor expanded around inf 0.2

      \[\leadsto \color{blue}{\frac{1}{\sin B} - \left(1 \cdot \frac{x \cdot \cos B}{\sin B} + 1 \cdot \frac{x}{\sin B \cdot {F}^{2}}\right)}\]
    4. Simplified0.2

      \[\leadsto \color{blue}{\mathsf{fma}\left(-1, \frac{x \cdot \cos B}{\sin B} + \frac{x}{\sin B \cdot {F}^{2}}, \frac{1}{\sin B}\right)}\]
  3. Recombined 3 regimes into one program.
  4. Final simplification0.2

    \[\leadsto \begin{array}{l} \mathbf{if}\;F \le -77609648.144404009:\\ \;\;\;\;\left(1 \cdot \frac{1}{\sin B \cdot {F}^{2}} - \frac{1}{\sin B}\right) + \left(-\frac{x \cdot 1}{\tan B}\right)\\ \mathbf{elif}\;F \le 1.49264129336098431 \cdot 10^{131}:\\ \;\;\;\;\left(F \cdot {\left(\sqrt{\left(F \cdot F + 2\right) + 2 \cdot x}\right)}^{\left(2 \cdot \left(-\frac{1}{2}\right)\right)}\right) \cdot \frac{1}{\sin B} + \left(-\frac{x \cdot 1}{\tan B}\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(-1, \frac{x \cdot \cos B}{\sin B} + \frac{x}{\sin B \cdot {F}^{2}}, \frac{1}{\sin B}\right)\\ \end{array}\]

Reproduce

herbie shell --seed 2020027 +o rules:numerics
(FPCore (F B x)
  :name "VandenBroeck and Keller, Equation (23)"
  :precision binary64
  (+ (- (* x (/ 1 (tan B)))) (* (/ F (sin B)) (pow (+ (+ (* F F) 2) (* 2 x)) (- (/ 1 2))))))