Average Error: 35.7 → 27.8
Time: 16.9s
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 2.168131007224150419432362468796782195568:\\ \;\;\;\;\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)}\\ \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 2.168131007224150419432362468796782195568:\\
\;\;\;\;\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)}\\

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

\end{array}
double f(double x, double y) {
        double r449440 = x;
        double r449441 = y;
        double r449442 = 2.0;
        double r449443 = r449441 * r449442;
        double r449444 = r449440 / r449443;
        double r449445 = tan(r449444);
        double r449446 = sin(r449444);
        double r449447 = r449445 / r449446;
        return r449447;
}

double f(double x, double y) {
        double r449448 = x;
        double r449449 = y;
        double r449450 = 2.0;
        double r449451 = r449449 * r449450;
        double r449452 = r449448 / r449451;
        double r449453 = tan(r449452);
        double r449454 = sin(r449452);
        double r449455 = r449453 / r449454;
        double r449456 = 2.1681310072241504;
        bool r449457 = r449455 <= r449456;
        double r449458 = expm1(r449453);
        double r449459 = log1p(r449458);
        double r449460 = r449459 / r449454;
        double r449461 = 1.0;
        double r449462 = r449457 ? r449460 : r449461;
        return r449462;
}

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.7
Target29.1
Herbie27.8
\[\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.1681310072241504

    1. Initial program 25.0

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

      \[\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)}\]

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

    1. Initial program 62.4

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{\tan \left(\frac{x}{y \cdot 2}\right)}{\sin \left(\frac{x}{y \cdot 2}\right)} \le 2.168131007224150419432362468796782195568:\\ \;\;\;\;\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)}\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array}\]

Reproduce

herbie shell --seed 2019306 +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.23036909113069936e114) 1 (if (< y -9.1028524068119138e-222) (/ (sin (/ x (* y 2))) (* (sin (/ x (* y 2))) (log (exp (cos (/ x (* y 2))))))) 1))

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