Average Error: 35.9 → 27.4
Time: 5.4s
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 3.04266136491719:\\ \;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{\sqrt[3]{\tan \left(\frac{x}{y \cdot 2}\right)} \cdot \sqrt[3]{\tan \left(\frac{x}{y \cdot 2}\right)}}{\sqrt[3]{\sin \left(\frac{x}{y \cdot 2}\right)} \cdot \sqrt[3]{\sin \left(\frac{x}{y \cdot 2}\right)}} \cdot \frac{\sqrt[3]{\tan \left(\frac{x}{y \cdot 2}\right)}}{\sqrt[3]{\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 3.04266136491719:\\
\;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{\sqrt[3]{\tan \left(\frac{x}{y \cdot 2}\right)} \cdot \sqrt[3]{\tan \left(\frac{x}{y \cdot 2}\right)}}{\sqrt[3]{\sin \left(\frac{x}{y \cdot 2}\right)} \cdot \sqrt[3]{\sin \left(\frac{x}{y \cdot 2}\right)}} \cdot \frac{\sqrt[3]{\tan \left(\frac{x}{y \cdot 2}\right)}}{\sqrt[3]{\sin \left(\frac{x}{y \cdot 2}\right)}}\right)\right)\\

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

\end{array}
double f(double x, double y) {
        double r620935 = x;
        double r620936 = y;
        double r620937 = 2.0;
        double r620938 = r620936 * r620937;
        double r620939 = r620935 / r620938;
        double r620940 = tan(r620939);
        double r620941 = sin(r620939);
        double r620942 = r620940 / r620941;
        return r620942;
}

double f(double x, double y) {
        double r620943 = x;
        double r620944 = y;
        double r620945 = 2.0;
        double r620946 = r620944 * r620945;
        double r620947 = r620943 / r620946;
        double r620948 = tan(r620947);
        double r620949 = sin(r620947);
        double r620950 = r620948 / r620949;
        double r620951 = 3.042661364917194;
        bool r620952 = r620950 <= r620951;
        double r620953 = cbrt(r620948);
        double r620954 = r620953 * r620953;
        double r620955 = cbrt(r620949);
        double r620956 = r620955 * r620955;
        double r620957 = r620954 / r620956;
        double r620958 = r620953 / r620955;
        double r620959 = r620957 * r620958;
        double r620960 = expm1(r620959);
        double r620961 = log1p(r620960);
        double r620962 = 1.0;
        double r620963 = r620952 ? r620961 : r620962;
        return r620963;
}

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.9
Target28.7
Herbie27.4
\[\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)))) < 3.042661364917194

    1. Initial program 25.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-u25.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. Using strategy rm
    5. Applied add-cube-cbrt26.1

      \[\leadsto \mathsf{log1p}\left(\mathsf{expm1}\left(\frac{\tan \left(\frac{x}{y \cdot 2}\right)}{\color{blue}{\left(\sqrt[3]{\sin \left(\frac{x}{y \cdot 2}\right)} \cdot \sqrt[3]{\sin \left(\frac{x}{y \cdot 2}\right)}\right) \cdot \sqrt[3]{\sin \left(\frac{x}{y \cdot 2}\right)}}}\right)\right)\]
    6. Applied add-cube-cbrt25.4

      \[\leadsto \mathsf{log1p}\left(\mathsf{expm1}\left(\frac{\color{blue}{\left(\sqrt[3]{\tan \left(\frac{x}{y \cdot 2}\right)} \cdot \sqrt[3]{\tan \left(\frac{x}{y \cdot 2}\right)}\right) \cdot \sqrt[3]{\tan \left(\frac{x}{y \cdot 2}\right)}}}{\left(\sqrt[3]{\sin \left(\frac{x}{y \cdot 2}\right)} \cdot \sqrt[3]{\sin \left(\frac{x}{y \cdot 2}\right)}\right) \cdot \sqrt[3]{\sin \left(\frac{x}{y \cdot 2}\right)}}\right)\right)\]
    7. Applied times-frac25.4

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

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

    1. Initial program 63.0

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

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

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

Reproduce

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