Average Error: 35.8 → 27.9
Time: 10.9s
Precision: 64
\[\frac{\tan \left(\frac{x}{y \cdot 2}\right)}{\sin \left(\frac{x}{y \cdot 2}\right)}\]
\[\begin{array}{l} \mathbf{if}\;\frac{\tan \left(\frac{x}{y \cdot 2}\right)}{\sin \left(\frac{x}{y \cdot 2}\right)} \le 1.0997944018617001:\\ \;\;\;\;\mathsf{log1p}\left(\sqrt[3]{{\left(\mathsf{expm1}\left(\frac{1}{\cos \left(\frac{x}{y \cdot 2}\right)}\right)\right)}^{3}}\right)\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array}\]
\frac{\tan \left(\frac{x}{y \cdot 2}\right)}{\sin \left(\frac{x}{y \cdot 2}\right)}
\begin{array}{l}
\mathbf{if}\;\frac{\tan \left(\frac{x}{y \cdot 2}\right)}{\sin \left(\frac{x}{y \cdot 2}\right)} \le 1.0997944018617001:\\
\;\;\;\;\mathsf{log1p}\left(\sqrt[3]{{\left(\mathsf{expm1}\left(\frac{1}{\cos \left(\frac{x}{y \cdot 2}\right)}\right)\right)}^{3}}\right)\\

\mathbf{else}:\\
\;\;\;\;1\\

\end{array}
double f(double x, double y) {
        double r666588 = x;
        double r666589 = y;
        double r666590 = 2.0;
        double r666591 = r666589 * r666590;
        double r666592 = r666588 / r666591;
        double r666593 = tan(r666592);
        double r666594 = sin(r666592);
        double r666595 = r666593 / r666594;
        return r666595;
}

double f(double x, double y) {
        double r666596 = x;
        double r666597 = y;
        double r666598 = 2.0;
        double r666599 = r666597 * r666598;
        double r666600 = r666596 / r666599;
        double r666601 = tan(r666600);
        double r666602 = sin(r666600);
        double r666603 = r666601 / r666602;
        double r666604 = 1.0997944018617;
        bool r666605 = r666603 <= r666604;
        double r666606 = 1.0;
        double r666607 = cos(r666600);
        double r666608 = r666606 / r666607;
        double r666609 = expm1(r666608);
        double r666610 = 3.0;
        double r666611 = pow(r666609, r666610);
        double r666612 = cbrt(r666611);
        double r666613 = log1p(r666612);
        double r666614 = 1.0;
        double r666615 = r666605 ? r666613 : r666614;
        return r666615;
}

Error

Bits error versus x

Bits error versus y

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original35.8
Target29.0
Herbie27.9
\[\begin{array}{l} \mathbf{if}\;y \lt -1.23036909113069936 \cdot 10^{114}:\\ \;\;\;\;1\\ \mathbf{elif}\;y \lt -9.1028524068119138 \cdot 10^{-222}:\\ \;\;\;\;\frac{\sin \left(\frac{x}{y \cdot 2}\right)}{\sin \left(\frac{x}{y \cdot 2}\right) \cdot \log \left(e^{\cos \left(\frac{x}{y \cdot 2}\right)}\right)}\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array}\]

Derivation

  1. Split input into 2 regimes
  2. if (/ (tan (/ x (* y 2.0))) (sin (/ x (* y 2.0)))) < 1.0997944018617

    1. Initial program 21.3

      \[\frac{\tan \left(\frac{x}{y \cdot 2}\right)}{\sin \left(\frac{x}{y \cdot 2}\right)}\]
    2. Using strategy rm
    3. Applied tan-quot21.3

      \[\leadsto \frac{\color{blue}{\frac{\sin \left(\frac{x}{y \cdot 2}\right)}{\cos \left(\frac{x}{y \cdot 2}\right)}}}{\sin \left(\frac{x}{y \cdot 2}\right)}\]
    4. Using strategy rm
    5. Applied log1p-expm1-u21.4

      \[\leadsto \color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{\frac{\sin \left(\frac{x}{y \cdot 2}\right)}{\cos \left(\frac{x}{y \cdot 2}\right)}}{\sin \left(\frac{x}{y \cdot 2}\right)}\right)\right)}\]
    6. Simplified21.4

      \[\leadsto \mathsf{log1p}\left(\color{blue}{\mathsf{expm1}\left(\frac{1}{\cos \left(\frac{x}{y \cdot 2}\right)}\right)}\right)\]
    7. Using strategy rm
    8. Applied add-cbrt-cube21.4

      \[\leadsto \mathsf{log1p}\left(\color{blue}{\sqrt[3]{\left(\mathsf{expm1}\left(\frac{1}{\cos \left(\frac{x}{y \cdot 2}\right)}\right) \cdot \mathsf{expm1}\left(\frac{1}{\cos \left(\frac{x}{y \cdot 2}\right)}\right)\right) \cdot \mathsf{expm1}\left(\frac{1}{\cos \left(\frac{x}{y \cdot 2}\right)}\right)}}\right)\]
    9. Simplified21.4

      \[\leadsto \mathsf{log1p}\left(\sqrt[3]{\color{blue}{{\left(\mathsf{expm1}\left(\frac{1}{\cos \left(\frac{x}{y \cdot 2}\right)}\right)\right)}^{3}}}\right)\]

    if 1.0997944018617 < (/ (tan (/ x (* y 2.0))) (sin (/ x (* y 2.0))))

    1. Initial program 60.9

      \[\frac{\tan \left(\frac{x}{y \cdot 2}\right)}{\sin \left(\frac{x}{y \cdot 2}\right)}\]
    2. Taylor expanded around 0 39.1

      \[\leadsto \color{blue}{1}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification27.9

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{\tan \left(\frac{x}{y \cdot 2}\right)}{\sin \left(\frac{x}{y \cdot 2}\right)} \le 1.0997944018617001:\\ \;\;\;\;\mathsf{log1p}\left(\sqrt[3]{{\left(\mathsf{expm1}\left(\frac{1}{\cos \left(\frac{x}{y \cdot 2}\right)}\right)\right)}^{3}}\right)\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array}\]

Reproduce

herbie shell --seed 2020045 +o rules:numerics
(FPCore (x y)
  :name "Diagrams.TwoD.Layout.CirclePacking:approxRadius from diagrams-contrib-1.3.0.5"
  :precision binary64

  :herbie-target
  (if (< y -1.2303690911306994e+114) 1 (if (< y -9.102852406811914e-222) (/ (sin (/ x (* y 2))) (* (sin (/ x (* y 2))) (log (exp (cos (/ x (* y 2))))))) 1))

  (/ (tan (/ x (* y 2))) (sin (/ x (* y 2)))))