Average Error: 36.1 → 28.3
Time: 5.7s
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.380070659087056:\\ \;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{\sin \left(\frac{x}{y \cdot 2}\right)}{\cos \left(\frac{x}{y \cdot 2}\right)}\right)\right)}{\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 1.380070659087056:\\
\;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{\sin \left(\frac{x}{y \cdot 2}\right)}{\cos \left(\frac{x}{y \cdot 2}\right)}\right)\right)}{\sin \left(\frac{x}{y \cdot 2}\right)}\right)\right)\\

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

\end{array}
double f(double x, double y) {
        double r676248 = x;
        double r676249 = y;
        double r676250 = 2.0;
        double r676251 = r676249 * r676250;
        double r676252 = r676248 / r676251;
        double r676253 = tan(r676252);
        double r676254 = sin(r676252);
        double r676255 = r676253 / r676254;
        return r676255;
}

double f(double x, double y) {
        double r676256 = x;
        double r676257 = y;
        double r676258 = 2.0;
        double r676259 = r676257 * r676258;
        double r676260 = r676256 / r676259;
        double r676261 = tan(r676260);
        double r676262 = sin(r676260);
        double r676263 = r676261 / r676262;
        double r676264 = 1.380070659087056;
        bool r676265 = r676263 <= r676264;
        double r676266 = cos(r676260);
        double r676267 = r676262 / r676266;
        double r676268 = expm1(r676267);
        double r676269 = log1p(r676268);
        double r676270 = r676269 / r676262;
        double r676271 = expm1(r676270);
        double r676272 = log1p(r676271);
        double r676273 = 1.0;
        double r676274 = r676265 ? r676272 : r676273;
        return r676274;
}

Error

Bits error versus x

Bits error versus y

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original36.1
Target29.5
Herbie28.3
\[\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.380070659087056

    1. Initial program 23.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-u23.4

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

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

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

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

    1. Initial program 61.3

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

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

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

Reproduce

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