Average Error: 36.1 → 28.4
Time: 8.1s
Precision: binary64
\[\frac{\tan \left(\frac{x}{y \cdot 2}\right)}{\sin \left(\frac{x}{y \cdot 2}\right)} \]
\[\begin{array}{l} \mathbf{if}\;y \cdot 2 \leq -6.3806695735061406 \cdot 10^{-83}:\\ \;\;\;\;\frac{1}{\log \left(e^{\cos \left(0.5 \cdot \frac{x}{y}\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}\;y \cdot 2 \leq -6.3806695735061406 \cdot 10^{-83}:\\
\;\;\;\;\frac{1}{\log \left(e^{\cos \left(0.5 \cdot \frac{x}{y}\right)}\right)}\\

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


\end{array}
(FPCore (x y)
 :precision binary64
 (/ (tan (/ x (* y 2.0))) (sin (/ x (* y 2.0)))))
(FPCore (x y)
 :precision binary64
 (if (<= (* y 2.0) -6.3806695735061406e-83)
   (/ 1.0 (log (exp (cos (* 0.5 (/ x y))))))
   1.0))
double code(double x, double y) {
	return tan(x / (y * 2.0)) / sin(x / (y * 2.0));
}
double code(double x, double y) {
	double tmp;
	if ((y * 2.0) <= -6.3806695735061406e-83) {
		tmp = 1.0 / log(exp(cos(0.5 * (x / y))));
	} else {
		tmp = 1.0;
	}
	return tmp;
}

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.3
Herbie28.4
\[\begin{array}{l} \mathbf{if}\;y < -1.2303690911306994 \cdot 10^{+114}:\\ \;\;\;\;1\\ \mathbf{elif}\;y < -9.102852406811914 \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 (*.f64 y 2) < -6.3806695735061406e-83

    1. Initial program 29.3

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

      \[\leadsto \frac{\color{blue}{\frac{\sin \left(0.5 \cdot \frac{x}{y}\right)}{\cos \left(0.5 \cdot \frac{x}{y}\right)}}}{\sin \left(\frac{x}{y \cdot 2}\right)} \]
    3. Applied add-log-exp_binary6429.4

      \[\leadsto \frac{\frac{\sin \left(0.5 \cdot \frac{x}{y}\right)}{\color{blue}{\log \left(e^{\cos \left(0.5 \cdot \frac{x}{y}\right)}\right)}}}{\sin \left(\frac{x}{y \cdot 2}\right)} \]
    4. Taylor expanded in x around inf 17.3

      \[\leadsto \color{blue}{\frac{1}{\log \left(e^{\cos \left(0.5 \cdot \frac{x}{y}\right)}\right)}} \]

    if -6.3806695735061406e-83 < (*.f64 y 2)

    1. Initial program 39.2

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \cdot 2 \leq -6.3806695735061406 \cdot 10^{-83}:\\ \;\;\;\;\frac{1}{\log \left(e^{\cos \left(0.5 \cdot \frac{x}{y}\right)}\right)}\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]

Reproduce

herbie shell --seed 2021220 
(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.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)))))