Average Error: 35.6 → 28.0
Time: 46.4s
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}{2 \cdot y}\right)}{\sin \left(\frac{x}{2 \cdot y}\right)} \le 2.070947091712344256819733345764689147472:\\ \;\;\;\;\mathsf{log1p}\left(\log \left(e^{\mathsf{expm1}\left(\frac{\tan \left(\frac{x}{2 \cdot y}\right)}{\sin \left(\frac{x}{2 \cdot y}\right)}\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}{2 \cdot y}\right)}{\sin \left(\frac{x}{2 \cdot y}\right)} \le 2.070947091712344256819733345764689147472:\\
\;\;\;\;\mathsf{log1p}\left(\log \left(e^{\mathsf{expm1}\left(\frac{\tan \left(\frac{x}{2 \cdot y}\right)}{\sin \left(\frac{x}{2 \cdot y}\right)}\right)}\right)\right)\\

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

\end{array}
double f(double x, double y) {
        double r24182933 = x;
        double r24182934 = y;
        double r24182935 = 2.0;
        double r24182936 = r24182934 * r24182935;
        double r24182937 = r24182933 / r24182936;
        double r24182938 = tan(r24182937);
        double r24182939 = sin(r24182937);
        double r24182940 = r24182938 / r24182939;
        return r24182940;
}

double f(double x, double y) {
        double r24182941 = x;
        double r24182942 = 2.0;
        double r24182943 = y;
        double r24182944 = r24182942 * r24182943;
        double r24182945 = r24182941 / r24182944;
        double r24182946 = tan(r24182945);
        double r24182947 = sin(r24182945);
        double r24182948 = r24182946 / r24182947;
        double r24182949 = 2.0709470917123443;
        bool r24182950 = r24182948 <= r24182949;
        double r24182951 = expm1(r24182948);
        double r24182952 = exp(r24182951);
        double r24182953 = log(r24182952);
        double r24182954 = log1p(r24182953);
        double r24182955 = 1.0;
        double r24182956 = r24182950 ? r24182954 : r24182955;
        return r24182956;
}

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.6
Target29.2
Herbie28.0
\[\begin{array}{l} \mathbf{if}\;y \lt -1.230369091130699363447511617672816900781 \cdot 10^{114}:\\ \;\;\;\;1\\ \mathbf{elif}\;y \lt -9.102852406811913849731222630299032206502 \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)))) < 2.0709470917123443

    1. Initial program 24.7

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

      \[\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-log-exp24.7

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

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

    1. Initial program 62.2

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

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

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

Reproduce

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

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

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