Average Error: 14.2 → 0.4
Time: 10.8s
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 -176977675840.162445068359375:\\ \;\;\;\;\mathsf{fma}\left(1, \frac{x}{\sin B \cdot {F}^{2}}, -\mathsf{fma}\left(1, \frac{x \cdot \cos B}{\sin B}, \frac{1}{\sin B}\right)\right)\\ \mathbf{elif}\;F \le 3.894573343315853049470742812722572039792 \cdot 10^{68}:\\ \;\;\;\;\mathsf{fma}\left(\frac{F}{\sin B}, {\left(\mathsf{fma}\left(x, 2, \mathsf{fma}\left(F, F, 2\right)\right)\right)}^{\left(\frac{-\frac{1}{2}}{2}\right)} \cdot {\left(\mathsf{fma}\left(x, 2, \mathsf{fma}\left(F, F, 2\right)\right)\right)}^{\left(\frac{-\frac{1}{2}}{2}\right)}, -\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 -176977675840.162445068359375:\\
\;\;\;\;\mathsf{fma}\left(1, \frac{x}{\sin B \cdot {F}^{2}}, -\mathsf{fma}\left(1, \frac{x \cdot \cos B}{\sin B}, \frac{1}{\sin B}\right)\right)\\

\mathbf{elif}\;F \le 3.894573343315853049470742812722572039792 \cdot 10^{68}:\\
\;\;\;\;\mathsf{fma}\left(\frac{F}{\sin B}, {\left(\mathsf{fma}\left(x, 2, \mathsf{fma}\left(F, F, 2\right)\right)\right)}^{\left(\frac{-\frac{1}{2}}{2}\right)} \cdot {\left(\mathsf{fma}\left(x, 2, \mathsf{fma}\left(F, F, 2\right)\right)\right)}^{\left(\frac{-\frac{1}{2}}{2}\right)}, -\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 r30964 = x;
        double r30965 = 1.0;
        double r30966 = B;
        double r30967 = tan(r30966);
        double r30968 = r30965 / r30967;
        double r30969 = r30964 * r30968;
        double r30970 = -r30969;
        double r30971 = F;
        double r30972 = sin(r30966);
        double r30973 = r30971 / r30972;
        double r30974 = r30971 * r30971;
        double r30975 = 2.0;
        double r30976 = r30974 + r30975;
        double r30977 = r30975 * r30964;
        double r30978 = r30976 + r30977;
        double r30979 = r30965 / r30975;
        double r30980 = -r30979;
        double r30981 = pow(r30978, r30980);
        double r30982 = r30973 * r30981;
        double r30983 = r30970 + r30982;
        return r30983;
}

double f(double F, double B, double x) {
        double r30984 = F;
        double r30985 = -176977675840.16245;
        bool r30986 = r30984 <= r30985;
        double r30987 = 1.0;
        double r30988 = x;
        double r30989 = B;
        double r30990 = sin(r30989);
        double r30991 = 2.0;
        double r30992 = pow(r30984, r30991);
        double r30993 = r30990 * r30992;
        double r30994 = r30988 / r30993;
        double r30995 = cos(r30989);
        double r30996 = r30988 * r30995;
        double r30997 = r30996 / r30990;
        double r30998 = 1.0;
        double r30999 = r30998 / r30990;
        double r31000 = fma(r30987, r30997, r30999);
        double r31001 = -r31000;
        double r31002 = fma(r30987, r30994, r31001);
        double r31003 = 3.894573343315853e+68;
        bool r31004 = r30984 <= r31003;
        double r31005 = r30984 / r30990;
        double r31006 = 2.0;
        double r31007 = fma(r30984, r30984, r31006);
        double r31008 = fma(r30988, r31006, r31007);
        double r31009 = r30987 / r31006;
        double r31010 = -r31009;
        double r31011 = r31010 / r30991;
        double r31012 = pow(r31008, r31011);
        double r31013 = r31012 * r31012;
        double r31014 = r30988 * r30987;
        double r31015 = tan(r30989);
        double r31016 = r31014 / r31015;
        double r31017 = -r31016;
        double r31018 = fma(r31005, r31013, r31017);
        double r31019 = -r30987;
        double r31020 = r30997 + r30994;
        double r31021 = fma(r31019, r31020, r30999);
        double r31022 = r31004 ? r31018 : r31021;
        double r31023 = r30986 ? r31002 : r31022;
        return r31023;
}

Error

Bits error versus F

Bits error versus B

Bits error versus x

Derivation

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

    1. Initial program 26.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. Simplified26.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. Taylor expanded around -inf 0.2

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(1, \frac{x}{\sin B \cdot {F}^{2}}, -\mathsf{fma}\left(1, \frac{x \cdot \cos B}{\sin B}, \frac{1}{\sin B}\right)\right)}\]

    if -176977675840.16245 < F < 3.894573343315853e+68

    1. Initial program 0.6

      \[\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. Simplified0.6

      \[\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/0.5

      \[\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 sqr-pow0.5

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

      \[\leadsto \mathsf{fma}\left(\frac{F}{\sin B}, \color{blue}{{\left(\mathsf{fma}\left(x, 2, \mathsf{fma}\left(F, F, 2\right)\right)\right)}^{\left(\frac{-\frac{1}{2}}{2}\right)}} \cdot {\left(\left(F \cdot F + 2\right) + 2 \cdot x\right)}^{\left(\frac{-\frac{1}{2}}{2}\right)}, -\frac{x \cdot 1}{\tan B}\right)\]
    8. Simplified0.5

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

    if 3.894573343315853e+68 < F

    1. Initial program 30.7

      \[\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. Simplified30.7

      \[\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.4

    \[\leadsto \begin{array}{l} \mathbf{if}\;F \le -176977675840.162445068359375:\\ \;\;\;\;\mathsf{fma}\left(1, \frac{x}{\sin B \cdot {F}^{2}}, -\mathsf{fma}\left(1, \frac{x \cdot \cos B}{\sin B}, \frac{1}{\sin B}\right)\right)\\ \mathbf{elif}\;F \le 3.894573343315853049470742812722572039792 \cdot 10^{68}:\\ \;\;\;\;\mathsf{fma}\left(\frac{F}{\sin B}, {\left(\mathsf{fma}\left(x, 2, \mathsf{fma}\left(F, F, 2\right)\right)\right)}^{\left(\frac{-\frac{1}{2}}{2}\right)} \cdot {\left(\mathsf{fma}\left(x, 2, \mathsf{fma}\left(F, F, 2\right)\right)\right)}^{\left(\frac{-\frac{1}{2}}{2}\right)}, -\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 2019344 +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))))))