Average Error: 35.7 → 27.6
Time: 17.1s
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 1.859438286531938988588308347971178591251:\\ \;\;\;\;\mathsf{log1p}\left(\mathsf{log1p}\left(\mathsf{expm1}\left(\mathsf{expm1}\left(\frac{\tan \left(\frac{x}{2 \cdot y}\right)}{\sin \left(\frac{x}{2 \cdot y}\right)}\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 1.859438286531938988588308347971178591251:\\
\;\;\;\;\mathsf{log1p}\left(\mathsf{log1p}\left(\mathsf{expm1}\left(\mathsf{expm1}\left(\frac{\tan \left(\frac{x}{2 \cdot y}\right)}{\sin \left(\frac{x}{2 \cdot y}\right)}\right)\right)\right)\right)\\

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

\end{array}
double f(double x, double y) {
        double r478102 = x;
        double r478103 = y;
        double r478104 = 2.0;
        double r478105 = r478103 * r478104;
        double r478106 = r478102 / r478105;
        double r478107 = tan(r478106);
        double r478108 = sin(r478106);
        double r478109 = r478107 / r478108;
        return r478109;
}

double f(double x, double y) {
        double r478110 = x;
        double r478111 = 2.0;
        double r478112 = y;
        double r478113 = r478111 * r478112;
        double r478114 = r478110 / r478113;
        double r478115 = tan(r478114);
        double r478116 = sin(r478114);
        double r478117 = r478115 / r478116;
        double r478118 = 1.859438286531939;
        bool r478119 = r478117 <= r478118;
        double r478120 = expm1(r478117);
        double r478121 = expm1(r478120);
        double r478122 = log1p(r478121);
        double r478123 = log1p(r478122);
        double r478124 = 1.0;
        double r478125 = r478119 ? r478123 : r478124;
        return r478125;
}

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
Target28.8
Herbie27.6
\[\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)))) < 1.859438286531939

    1. Initial program 24.3

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

      \[\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. Simplified24.4

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

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

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

    if 1.859438286531939 < (/ (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.1

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

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

Reproduce

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