Average Error: 2.6 → 0.3
Time: 9.8s
Precision: binary64
Cost: 20424
\[\frac{x \cdot \frac{\sin y}{y}}{z} \]
\[\begin{array}{l} t_0 := x \cdot \frac{\sin y}{y}\\ t_1 := \frac{t_0}{z}\\ \mathbf{if}\;t_0 \leq -9 \cdot 10^{-273}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t_0 \leq 0:\\ \;\;\;\;x \cdot \frac{\frac{\sin y}{z}}{y}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
(FPCore (x y z) :precision binary64 (/ (* x (/ (sin y) y)) z))
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (* x (/ (sin y) y))) (t_1 (/ t_0 z)))
   (if (<= t_0 -9e-273) t_1 (if (<= t_0 0.0) (* x (/ (/ (sin y) z) y)) t_1))))
double code(double x, double y, double z) {
	return (x * (sin(y) / y)) / z;
}
double code(double x, double y, double z) {
	double t_0 = x * (sin(y) / y);
	double t_1 = t_0 / z;
	double tmp;
	if (t_0 <= -9e-273) {
		tmp = t_1;
	} else if (t_0 <= 0.0) {
		tmp = x * ((sin(y) / z) / y);
	} else {
		tmp = t_1;
	}
	return tmp;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    code = (x * (sin(y) / y)) / z
end function
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = x * (sin(y) / y)
    t_1 = t_0 / z
    if (t_0 <= (-9d-273)) then
        tmp = t_1
    else if (t_0 <= 0.0d0) then
        tmp = x * ((sin(y) / z) / y)
    else
        tmp = t_1
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	return (x * (Math.sin(y) / y)) / z;
}
public static double code(double x, double y, double z) {
	double t_0 = x * (Math.sin(y) / y);
	double t_1 = t_0 / z;
	double tmp;
	if (t_0 <= -9e-273) {
		tmp = t_1;
	} else if (t_0 <= 0.0) {
		tmp = x * ((Math.sin(y) / z) / y);
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(x, y, z):
	return (x * (math.sin(y) / y)) / z
def code(x, y, z):
	t_0 = x * (math.sin(y) / y)
	t_1 = t_0 / z
	tmp = 0
	if t_0 <= -9e-273:
		tmp = t_1
	elif t_0 <= 0.0:
		tmp = x * ((math.sin(y) / z) / y)
	else:
		tmp = t_1
	return tmp
function code(x, y, z)
	return Float64(Float64(x * Float64(sin(y) / y)) / z)
end
function code(x, y, z)
	t_0 = Float64(x * Float64(sin(y) / y))
	t_1 = Float64(t_0 / z)
	tmp = 0.0
	if (t_0 <= -9e-273)
		tmp = t_1;
	elseif (t_0 <= 0.0)
		tmp = Float64(x * Float64(Float64(sin(y) / z) / y));
	else
		tmp = t_1;
	end
	return tmp
end
function tmp = code(x, y, z)
	tmp = (x * (sin(y) / y)) / z;
end
function tmp_2 = code(x, y, z)
	t_0 = x * (sin(y) / y);
	t_1 = t_0 / z;
	tmp = 0.0;
	if (t_0 <= -9e-273)
		tmp = t_1;
	elseif (t_0 <= 0.0)
		tmp = x * ((sin(y) / z) / y);
	else
		tmp = t_1;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := N[(N[(x * N[(N[Sin[y], $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]
code[x_, y_, z_] := Block[{t$95$0 = N[(x * N[(N[Sin[y], $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 / z), $MachinePrecision]}, If[LessEqual[t$95$0, -9e-273], t$95$1, If[LessEqual[t$95$0, 0.0], N[(x * N[(N[(N[Sin[y], $MachinePrecision] / z), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], t$95$1]]]]
\frac{x \cdot \frac{\sin y}{y}}{z}
\begin{array}{l}
t_0 := x \cdot \frac{\sin y}{y}\\
t_1 := \frac{t_0}{z}\\
\mathbf{if}\;t_0 \leq -9 \cdot 10^{-273}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;t_0 \leq 0:\\
\;\;\;\;x \cdot \frac{\frac{\sin y}{z}}{y}\\

\mathbf{else}:\\
\;\;\;\;t_1\\


\end{array}

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original2.6
Target0.2
Herbie0.3
\[\begin{array}{l} \mathbf{if}\;z < -4.2173720203427147 \cdot 10^{-29}:\\ \;\;\;\;\frac{x \cdot \frac{1}{\frac{y}{\sin y}}}{z}\\ \mathbf{elif}\;z < 4.446702369113811 \cdot 10^{+64}:\\ \;\;\;\;\frac{x}{z \cdot \frac{y}{\sin y}}\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot \frac{1}{\frac{y}{\sin y}}}{z}\\ \end{array} \]

Derivation

  1. Split input into 2 regimes
  2. if (*.f64 x (/.f64 (sin.f64 y) y)) < -8.99999999999999921e-273 or -0.0 < (*.f64 x (/.f64 (sin.f64 y) y))

    1. Initial program 0.3

      \[\frac{x \cdot \frac{\sin y}{y}}{z} \]

    if -8.99999999999999921e-273 < (*.f64 x (/.f64 (sin.f64 y) y)) < -0.0

    1. Initial program 15.2

      \[\frac{x \cdot \frac{\sin y}{y}}{z} \]
    2. Simplified15.9

      \[\leadsto \color{blue}{\frac{\sin y}{z \cdot \frac{y}{x}}} \]
      Proof
      (/.f64 (sin.f64 y) (*.f64 z (/.f64 y x))): 0 points increase in error, 0 points decrease in error
      (Rewrite<= associate-/l/_binary64 (/.f64 (/.f64 (sin.f64 y) (/.f64 y x)) z)): 15 points increase in error, 47 points decrease in error
      (/.f64 (Rewrite=> associate-/r/_binary64 (*.f64 (/.f64 (sin.f64 y) y) x)) z): 12 points increase in error, 48 points decrease in error
      (/.f64 (Rewrite<= *-commutative_binary64 (*.f64 x (/.f64 (sin.f64 y) y))) z): 0 points increase in error, 0 points decrease in error
    3. Applied egg-rr0.2

      \[\leadsto \color{blue}{\frac{\frac{\sin y}{z}}{y} \cdot x} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification0.3

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \cdot \frac{\sin y}{y} \leq -9 \cdot 10^{-273}:\\ \;\;\;\;\frac{x \cdot \frac{\sin y}{y}}{z}\\ \mathbf{elif}\;x \cdot \frac{\sin y}{y} \leq 0:\\ \;\;\;\;x \cdot \frac{\frac{\sin y}{z}}{y}\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot \frac{\sin y}{y}}{z}\\ \end{array} \]

Alternatives

Alternative 1
Error2.8
Cost7112
\[\begin{array}{l} t_0 := x \cdot \frac{\sin y}{y \cdot z}\\ \mathbf{if}\;y \leq -7.453258451605268 \cdot 10^{-6}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 4.157821438955228 \cdot 10^{-18}:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 2
Error2.8
Cost7112
\[\begin{array}{l} \mathbf{if}\;y \leq -7.453258451605268 \cdot 10^{-6}:\\ \;\;\;\;\sin y \cdot \frac{x}{y \cdot z}\\ \mathbf{elif}\;y \leq 4.157821438955228 \cdot 10^{-18}:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;x \cdot \frac{\sin y}{y \cdot z}\\ \end{array} \]
Alternative 3
Error2.8
Cost7112
\[\begin{array}{l} \mathbf{if}\;y \leq -7.453258451605268 \cdot 10^{-6}:\\ \;\;\;\;\frac{x \cdot \sin y}{y \cdot z}\\ \mathbf{elif}\;y \leq 4.157821438955228 \cdot 10^{-18}:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;x \cdot \frac{\sin y}{y \cdot z}\\ \end{array} \]
Alternative 4
Error2.7
Cost7112
\[\begin{array}{l} \mathbf{if}\;y \leq -7.453258451605268 \cdot 10^{-6}:\\ \;\;\;\;\frac{x \cdot \sin y}{y \cdot z}\\ \mathbf{elif}\;y \leq 4.157821438955228 \cdot 10^{-18}:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;x \cdot \frac{\frac{\sin y}{z}}{y}\\ \end{array} \]
Alternative 5
Error28.3
Cost712
\[\begin{array}{l} \mathbf{if}\;x \leq 3.3360514296809222 \cdot 10^{-93}:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{elif}\;x \leq 3.61271154004458 \cdot 10^{-11}:\\ \;\;\;\;\frac{x \cdot y}{y \cdot z}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{z}\\ \end{array} \]
Alternative 6
Error27.0
Cost712
\[\begin{array}{l} \mathbf{if}\;x \leq -3.729805295106613 \cdot 10^{-168}:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{elif}\;x \leq 3.3360514296809222 \cdot 10^{-93}:\\ \;\;\;\;\frac{y \cdot \frac{x}{y}}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot y}{y \cdot z}\\ \end{array} \]
Alternative 7
Error23.3
Cost712
\[\begin{array}{l} t_0 := y \cdot \frac{x}{y \cdot z}\\ \mathbf{if}\;y \leq -4.896529830071695 \cdot 10^{+69}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 1.172391021827818 \cdot 10^{+74}:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 8
Error22.9
Cost712
\[\begin{array}{l} t_0 := \frac{y}{z \cdot \frac{y}{x}}\\ \mathbf{if}\;y \leq -4.896529830071695 \cdot 10^{+69}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 1.3872364812726551 \cdot 10^{-9}:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 9
Error22.9
Cost712
\[\begin{array}{l} \mathbf{if}\;y \leq -4.896529830071695 \cdot 10^{+69}:\\ \;\;\;\;\frac{y}{z \cdot \frac{y}{x}}\\ \mathbf{elif}\;y \leq 173683702205.44278:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;\left(\frac{x}{z} + 1\right) + -1\\ \end{array} \]
Alternative 10
Error28.0
Cost192
\[\frac{x}{z} \]

Error

Reproduce

herbie shell --seed 2022308 
(FPCore (x y z)
  :name "Linear.Quaternion:$ctanh from linear-1.19.1.3"
  :precision binary64

  :herbie-target
  (if (< z -4.2173720203427147e-29) (/ (* x (/ 1.0 (/ y (sin y)))) z) (if (< z 4.446702369113811e+64) (/ x (* z (/ y (sin y)))) (/ (* x (/ 1.0 (/ y (sin y)))) z)))

  (/ (* x (/ (sin y) y)) z))