Average Error: 35.8 → 27.9
Time: 8.5s
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 r668596 = x;
        double r668597 = y;
        double r668598 = 2.0;
        double r668599 = r668597 * r668598;
        double r668600 = r668596 / r668599;
        double r668601 = tan(r668600);
        double r668602 = sin(r668600);
        double r668603 = r668601 / r668602;
        return r668603;
}

double f(double x, double y) {
        double r668604 = x;
        double r668605 = y;
        double r668606 = 2.0;
        double r668607 = r668605 * r668606;
        double r668608 = r668604 / r668607;
        double r668609 = tan(r668608);
        double r668610 = sin(r668608);
        double r668611 = r668609 / r668610;
        double r668612 = 1.0997944018617;
        bool r668613 = r668611 <= r668612;
        double r668614 = 1.0;
        double r668615 = cos(r668608);
        double r668616 = r668614 / r668615;
        double r668617 = expm1(r668616);
        double r668618 = 3.0;
        double r668619 = pow(r668617, r668618);
        double r668620 = cbrt(r668619);
        double r668621 = log1p(r668620);
        double r668622 = 1.0;
        double r668623 = r668613 ? r668621 : r668622;
        return r668623;
}

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)))))