Average Error: 35.6 → 28.0
Time: 28.3s
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 r28577089 = x;
        double r28577090 = y;
        double r28577091 = 2.0;
        double r28577092 = r28577090 * r28577091;
        double r28577093 = r28577089 / r28577092;
        double r28577094 = tan(r28577093);
        double r28577095 = sin(r28577093);
        double r28577096 = r28577094 / r28577095;
        return r28577096;
}

double f(double x, double y) {
        double r28577097 = x;
        double r28577098 = 2.0;
        double r28577099 = y;
        double r28577100 = r28577098 * r28577099;
        double r28577101 = r28577097 / r28577100;
        double r28577102 = tan(r28577101);
        double r28577103 = sin(r28577101);
        double r28577104 = r28577102 / r28577103;
        double r28577105 = 2.0709470917123443;
        bool r28577106 = r28577104 <= r28577105;
        double r28577107 = expm1(r28577104);
        double r28577108 = exp(r28577107);
        double r28577109 = log(r28577108);
        double r28577110 = log1p(r28577109);
        double r28577111 = 1.0;
        double r28577112 = r28577106 ? r28577110 : r28577111;
        return r28577112;
}

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