Average Error: 35.9 → 27.4
Time: 5.0s
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 3.04266136491719:\\ \;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{\sqrt[3]{\tan \left(\frac{x}{y \cdot 2}\right)} \cdot \sqrt[3]{\tan \left(\frac{x}{y \cdot 2}\right)}}{\sqrt[3]{\sin \left(\frac{x}{y \cdot 2}\right)} \cdot \sqrt[3]{\sin \left(\frac{x}{y \cdot 2}\right)}} \cdot \frac{\sqrt[3]{\tan \left(\frac{x}{y \cdot 2}\right)}}{\sqrt[3]{\sin \left(\frac{x}{y \cdot 2}\right)}}\right)\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 3.04266136491719:\\
\;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{\sqrt[3]{\tan \left(\frac{x}{y \cdot 2}\right)} \cdot \sqrt[3]{\tan \left(\frac{x}{y \cdot 2}\right)}}{\sqrt[3]{\sin \left(\frac{x}{y \cdot 2}\right)} \cdot \sqrt[3]{\sin \left(\frac{x}{y \cdot 2}\right)}} \cdot \frac{\sqrt[3]{\tan \left(\frac{x}{y \cdot 2}\right)}}{\sqrt[3]{\sin \left(\frac{x}{y \cdot 2}\right)}}\right)\right)\\

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

\end{array}
double f(double x, double y) {
        double r694781 = x;
        double r694782 = y;
        double r694783 = 2.0;
        double r694784 = r694782 * r694783;
        double r694785 = r694781 / r694784;
        double r694786 = tan(r694785);
        double r694787 = sin(r694785);
        double r694788 = r694786 / r694787;
        return r694788;
}

double f(double x, double y) {
        double r694789 = x;
        double r694790 = y;
        double r694791 = 2.0;
        double r694792 = r694790 * r694791;
        double r694793 = r694789 / r694792;
        double r694794 = tan(r694793);
        double r694795 = sin(r694793);
        double r694796 = r694794 / r694795;
        double r694797 = 3.042661364917194;
        bool r694798 = r694796 <= r694797;
        double r694799 = cbrt(r694794);
        double r694800 = r694799 * r694799;
        double r694801 = cbrt(r694795);
        double r694802 = r694801 * r694801;
        double r694803 = r694800 / r694802;
        double r694804 = r694799 / r694801;
        double r694805 = r694803 * r694804;
        double r694806 = expm1(r694805);
        double r694807 = log1p(r694806);
        double r694808 = 1.0;
        double r694809 = r694798 ? r694807 : r694808;
        return r694809;
}

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.9
Target28.7
Herbie27.4
\[\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)))) < 3.042661364917194

    1. Initial program 25.4

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

      \[\leadsto \color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{\tan \left(\frac{x}{y \cdot 2}\right)}{\sin \left(\frac{x}{y \cdot 2}\right)}\right)\right)}\]
    4. Using strategy rm
    5. Applied add-cube-cbrt26.1

      \[\leadsto \mathsf{log1p}\left(\mathsf{expm1}\left(\frac{\tan \left(\frac{x}{y \cdot 2}\right)}{\color{blue}{\left(\sqrt[3]{\sin \left(\frac{x}{y \cdot 2}\right)} \cdot \sqrt[3]{\sin \left(\frac{x}{y \cdot 2}\right)}\right) \cdot \sqrt[3]{\sin \left(\frac{x}{y \cdot 2}\right)}}}\right)\right)\]
    6. Applied add-cube-cbrt25.4

      \[\leadsto \mathsf{log1p}\left(\mathsf{expm1}\left(\frac{\color{blue}{\left(\sqrt[3]{\tan \left(\frac{x}{y \cdot 2}\right)} \cdot \sqrt[3]{\tan \left(\frac{x}{y \cdot 2}\right)}\right) \cdot \sqrt[3]{\tan \left(\frac{x}{y \cdot 2}\right)}}}{\left(\sqrt[3]{\sin \left(\frac{x}{y \cdot 2}\right)} \cdot \sqrt[3]{\sin \left(\frac{x}{y \cdot 2}\right)}\right) \cdot \sqrt[3]{\sin \left(\frac{x}{y \cdot 2}\right)}}\right)\right)\]
    7. Applied times-frac25.4

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

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

    1. Initial program 63.0

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

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

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

Reproduce

herbie shell --seed 2020060 +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)))))