Average Error: 35.4 → 27.5
Time: 17.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}{2 \cdot y}\right)}{\sin \left(\frac{x}{2 \cdot y}\right)} \le 2.69286171955532038779779213655274361372:\\ \;\;\;\;\frac{\mathsf{log1p}\left(\mathsf{expm1}\left(\tan \left(\frac{x}{2 \cdot y}\right)\right)\right)}{\sin \left(\frac{x}{2 \cdot y}\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.69286171955532038779779213655274361372:\\
\;\;\;\;\frac{\mathsf{log1p}\left(\mathsf{expm1}\left(\tan \left(\frac{x}{2 \cdot y}\right)\right)\right)}{\sin \left(\frac{x}{2 \cdot y}\right)}\\

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

\end{array}
double f(double x, double y) {
        double r28194064 = x;
        double r28194065 = y;
        double r28194066 = 2.0;
        double r28194067 = r28194065 * r28194066;
        double r28194068 = r28194064 / r28194067;
        double r28194069 = tan(r28194068);
        double r28194070 = sin(r28194068);
        double r28194071 = r28194069 / r28194070;
        return r28194071;
}

double f(double x, double y) {
        double r28194072 = x;
        double r28194073 = 2.0;
        double r28194074 = y;
        double r28194075 = r28194073 * r28194074;
        double r28194076 = r28194072 / r28194075;
        double r28194077 = tan(r28194076);
        double r28194078 = sin(r28194076);
        double r28194079 = r28194077 / r28194078;
        double r28194080 = 2.6928617195553204;
        bool r28194081 = r28194079 <= r28194080;
        double r28194082 = expm1(r28194077);
        double r28194083 = log1p(r28194082);
        double r28194084 = r28194083 / r28194078;
        double r28194085 = 1.0;
        double r28194086 = r28194081 ? r28194084 : r28194085;
        return r28194086;
}

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.4
Target28.9
Herbie27.5
\[\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.6928617195553204

    1. Initial program 24.9

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

      \[\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.6928617195553204 < (/ (tan (/ x (* y 2.0))) (sin (/ x (* y 2.0))))

    1. Initial program 62.7

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

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

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

Reproduce

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