Average Error: 35.4 → 27.4
Time: 5.2s
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.100251565530924:\\ \;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{1}{\frac{\sin \left(\frac{x}{y \cdot 2}\right)}{\tan \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 1.100251565530924:\\
\;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{1}{\frac{\sin \left(\frac{x}{y \cdot 2}\right)}{\tan \left(\frac{x}{y \cdot 2}\right)}}\right)\right)\\

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

\end{array}
double f(double x, double y) {
        double r664778 = x;
        double r664779 = y;
        double r664780 = 2.0;
        double r664781 = r664779 * r664780;
        double r664782 = r664778 / r664781;
        double r664783 = tan(r664782);
        double r664784 = sin(r664782);
        double r664785 = r664783 / r664784;
        return r664785;
}

double f(double x, double y) {
        double r664786 = x;
        double r664787 = y;
        double r664788 = 2.0;
        double r664789 = r664787 * r664788;
        double r664790 = r664786 / r664789;
        double r664791 = tan(r664790);
        double r664792 = sin(r664790);
        double r664793 = r664791 / r664792;
        double r664794 = 1.100251565530924;
        bool r664795 = r664793 <= r664794;
        double r664796 = 1.0;
        double r664797 = r664792 / r664791;
        double r664798 = r664796 / r664797;
        double r664799 = expm1(r664798);
        double r664800 = log1p(r664799);
        double r664801 = 1.0;
        double r664802 = r664795 ? r664800 : r664801;
        return r664802;
}

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.4
Target28.6
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)))) < 1.100251565530924

    1. Initial program 20.4

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

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

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

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

    1. Initial program 60.6

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

      \[\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 1.100251565530924:\\ \;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{1}{\frac{\sin \left(\frac{x}{y \cdot 2}\right)}{\tan \left(\frac{x}{y \cdot 2}\right)}}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array}\]

Reproduce

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