Average Error: 35.9 → 28.0
Time: 16.5s
Precision: binary64
Cost: 20424
\[\frac{\tan \left(\frac{x}{y \cdot 2}\right)}{\sin \left(\frac{x}{y \cdot 2}\right)} \]
\[\begin{array}{l} t_0 := \frac{x}{y \cdot 2}\\ \mathbf{if}\;t_0 \leq -1 \cdot 10^{+33}:\\ \;\;\;\;1\\ \mathbf{elif}\;t_0 \leq 5 \cdot 10^{+88}:\\ \;\;\;\;\frac{1}{\cos \left({\left(y \cdot \frac{1}{x \cdot 0.5}\right)}^{-1}\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\cos \left(\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{0.5}{\frac{y}{x}}\right)\right)\right)}\\ \end{array} \]
(FPCore (x y)
 :precision binary64
 (/ (tan (/ x (* y 2.0))) (sin (/ x (* y 2.0)))))
(FPCore (x y)
 :precision binary64
 (let* ((t_0 (/ x (* y 2.0))))
   (if (<= t_0 -1e+33)
     1.0
     (if (<= t_0 5e+88)
       (/ 1.0 (cos (pow (* y (/ 1.0 (* x 0.5))) -1.0)))
       (/ 1.0 (cos (expm1 (log1p (/ 0.5 (/ y x))))))))))
double code(double x, double y) {
	return tan((x / (y * 2.0))) / sin((x / (y * 2.0)));
}
double code(double x, double y) {
	double t_0 = x / (y * 2.0);
	double tmp;
	if (t_0 <= -1e+33) {
		tmp = 1.0;
	} else if (t_0 <= 5e+88) {
		tmp = 1.0 / cos(pow((y * (1.0 / (x * 0.5))), -1.0));
	} else {
		tmp = 1.0 / cos(expm1(log1p((0.5 / (y / x)))));
	}
	return tmp;
}
public static double code(double x, double y) {
	return Math.tan((x / (y * 2.0))) / Math.sin((x / (y * 2.0)));
}
public static double code(double x, double y) {
	double t_0 = x / (y * 2.0);
	double tmp;
	if (t_0 <= -1e+33) {
		tmp = 1.0;
	} else if (t_0 <= 5e+88) {
		tmp = 1.0 / Math.cos(Math.pow((y * (1.0 / (x * 0.5))), -1.0));
	} else {
		tmp = 1.0 / Math.cos(Math.expm1(Math.log1p((0.5 / (y / x)))));
	}
	return tmp;
}
def code(x, y):
	return math.tan((x / (y * 2.0))) / math.sin((x / (y * 2.0)))
def code(x, y):
	t_0 = x / (y * 2.0)
	tmp = 0
	if t_0 <= -1e+33:
		tmp = 1.0
	elif t_0 <= 5e+88:
		tmp = 1.0 / math.cos(math.pow((y * (1.0 / (x * 0.5))), -1.0))
	else:
		tmp = 1.0 / math.cos(math.expm1(math.log1p((0.5 / (y / x)))))
	return tmp
function code(x, y)
	return Float64(tan(Float64(x / Float64(y * 2.0))) / sin(Float64(x / Float64(y * 2.0))))
end
function code(x, y)
	t_0 = Float64(x / Float64(y * 2.0))
	tmp = 0.0
	if (t_0 <= -1e+33)
		tmp = 1.0;
	elseif (t_0 <= 5e+88)
		tmp = Float64(1.0 / cos((Float64(y * Float64(1.0 / Float64(x * 0.5))) ^ -1.0)));
	else
		tmp = Float64(1.0 / cos(expm1(log1p(Float64(0.5 / Float64(y / x))))));
	end
	return tmp
end
code[x_, y_] := N[(N[Tan[N[(x / N[(y * 2.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sin[N[(x / N[(y * 2.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
code[x_, y_] := Block[{t$95$0 = N[(x / N[(y * 2.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -1e+33], 1.0, If[LessEqual[t$95$0, 5e+88], N[(1.0 / N[Cos[N[Power[N[(y * N[(1.0 / N[(x * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], -1.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(1.0 / N[Cos[N[(Exp[N[Log[1 + N[(0.5 / N[(y / x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]] - 1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]
\frac{\tan \left(\frac{x}{y \cdot 2}\right)}{\sin \left(\frac{x}{y \cdot 2}\right)}
\begin{array}{l}
t_0 := \frac{x}{y \cdot 2}\\
\mathbf{if}\;t_0 \leq -1 \cdot 10^{+33}:\\
\;\;\;\;1\\

\mathbf{elif}\;t_0 \leq 5 \cdot 10^{+88}:\\
\;\;\;\;\frac{1}{\cos \left({\left(y \cdot \frac{1}{x \cdot 0.5}\right)}^{-1}\right)}\\

\mathbf{else}:\\
\;\;\;\;\frac{1}{\cos \left(\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{0.5}{\frac{y}{x}}\right)\right)\right)}\\


\end{array}

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original35.9
Target28.9
Herbie28.0
\[\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 3 regimes
  2. if (/.f64 x (*.f64 y 2)) < -9.9999999999999995e32

    1. Initial program 59.0

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

      \[\leadsto \color{blue}{1} \]

    if -9.9999999999999995e32 < (/.f64 x (*.f64 y 2)) < 4.99999999999999997e88

    1. Initial program 19.9

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

      \[\leadsto \color{blue}{\frac{1}{\cos \left(0.5 \cdot \frac{x}{y}\right)}} \]
    3. Simplified7.4

      \[\leadsto \color{blue}{\frac{1}{\cos \left(\frac{0.5}{y} \cdot x\right)}} \]
      Proof
      (/.f64 1 (cos.f64 (*.f64 (/.f64 1/2 y) x))): 0 points increase in error, 0 points decrease in error
      (/.f64 1 (cos.f64 (Rewrite<= associate-/r/_binary64 (/.f64 1/2 (/.f64 y x))))): 12 points increase in error, 19 points decrease in error
      (/.f64 1 (cos.f64 (Rewrite<= associate-/l*_binary64 (/.f64 (*.f64 1/2 x) y)))): 15 points increase in error, 12 points decrease in error
      (/.f64 1 (cos.f64 (Rewrite<= associate-*r/_binary64 (*.f64 1/2 (/.f64 x y))))): 0 points increase in error, 0 points decrease in error
    4. Applied egg-rr7.6

      \[\leadsto \frac{1}{\cos \color{blue}{\left(\frac{\frac{0.5 \cdot x}{{\left(\sqrt[3]{y}\right)}^{2}}}{\sqrt[3]{y}}\right)}} \]
    5. Applied egg-rr7.4

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

    if 4.99999999999999997e88 < (/.f64 x (*.f64 y 2))

    1. Initial program 59.2

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

      \[\leadsto \color{blue}{\frac{1}{\cos \left(0.5 \cdot \frac{x}{y}\right)}} \]
    3. Simplified59.1

      \[\leadsto \color{blue}{\frac{1}{\cos \left(\frac{0.5}{y} \cdot x\right)}} \]
      Proof
      (/.f64 1 (cos.f64 (*.f64 (/.f64 1/2 y) x))): 0 points increase in error, 0 points decrease in error
      (/.f64 1 (cos.f64 (Rewrite<= associate-/r/_binary64 (/.f64 1/2 (/.f64 y x))))): 12 points increase in error, 19 points decrease in error
      (/.f64 1 (cos.f64 (Rewrite<= associate-/l*_binary64 (/.f64 (*.f64 1/2 x) y)))): 15 points increase in error, 12 points decrease in error
      (/.f64 1 (cos.f64 (Rewrite<= associate-*r/_binary64 (*.f64 1/2 (/.f64 x y))))): 0 points increase in error, 0 points decrease in error
    4. Applied egg-rr59.5

      \[\leadsto \frac{1}{\cos \color{blue}{\left(\frac{\frac{0.5 \cdot x}{{\left(\sqrt[3]{y}\right)}^{2}}}{\sqrt[3]{y}}\right)}} \]
    5. Applied egg-rr59.5

      \[\leadsto \frac{1}{\cos \color{blue}{\left(\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{0.5}{\frac{y}{x}}\right)\right)\right)}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification28.0

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{x}{y \cdot 2} \leq -1 \cdot 10^{+33}:\\ \;\;\;\;1\\ \mathbf{elif}\;\frac{x}{y \cdot 2} \leq 5 \cdot 10^{+88}:\\ \;\;\;\;\frac{1}{\cos \left({\left(y \cdot \frac{1}{x \cdot 0.5}\right)}^{-1}\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\cos \left(\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{0.5}{\frac{y}{x}}\right)\right)\right)}\\ \end{array} \]

Alternatives

Alternative 1
Error28.0
Cost20424
\[\begin{array}{l} t_0 := \frac{x}{y \cdot 2}\\ \mathbf{if}\;t_0 \leq -1 \cdot 10^{+33}:\\ \;\;\;\;1\\ \mathbf{elif}\;t_0 \leq 5 \cdot 10^{+88}:\\ \;\;\;\;\frac{1}{\cos \left({\left(y \cdot \frac{1}{x \cdot 0.5}\right)}^{-1}\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\cos \left(e^{\log \left(\frac{0.5}{\frac{y}{x}}\right)}\right)}\\ \end{array} \]
Alternative 2
Error27.5
Cost14216
\[\begin{array}{l} t_0 := \frac{x}{y \cdot 2}\\ \mathbf{if}\;t_0 \leq -1 \cdot 10^{+33}:\\ \;\;\;\;1\\ \mathbf{elif}\;t_0 \leq 5 \cdot 10^{+88}:\\ \;\;\;\;\frac{1}{\cos \left({\left(y \cdot \frac{1}{x \cdot 0.5}\right)}^{-1}\right)}\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
Alternative 3
Error28.6
Cost64
\[1 \]

Error

Reproduce

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