Average Error: 2.7 → 0.3
Time: 8.8s
Precision: binary64
Cost: 20424
\[\frac{x \cdot \frac{\sin y}{y}}{z} \]
\[\begin{array}{l} t_0 := \frac{\sin y}{y}\\ t_1 := x \cdot t_0\\ t_2 := \frac{t_1}{z}\\ \mathbf{if}\;t_1 \leq -1 \cdot 10^{-117}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t_1 \leq 5 \cdot 10^{-317}:\\ \;\;\;\;t_0 \cdot \frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
(FPCore (x y z) :precision binary64 (/ (* x (/ (sin y) y)) z))
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (/ (sin y) y)) (t_1 (* x t_0)) (t_2 (/ t_1 z)))
   (if (<= t_1 -1e-117) t_2 (if (<= t_1 5e-317) (* t_0 (/ x z)) t_2))))
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 = sin(y) / y;
	double t_1 = x * t_0;
	double t_2 = t_1 / z;
	double tmp;
	if (t_1 <= -1e-117) {
		tmp = t_2;
	} else if (t_1 <= 5e-317) {
		tmp = t_0 * (x / z);
	} else {
		tmp = t_2;
	}
	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) :: t_2
    real(8) :: tmp
    t_0 = sin(y) / y
    t_1 = x * t_0
    t_2 = t_1 / z
    if (t_1 <= (-1d-117)) then
        tmp = t_2
    else if (t_1 <= 5d-317) then
        tmp = t_0 * (x / z)
    else
        tmp = t_2
    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 = Math.sin(y) / y;
	double t_1 = x * t_0;
	double t_2 = t_1 / z;
	double tmp;
	if (t_1 <= -1e-117) {
		tmp = t_2;
	} else if (t_1 <= 5e-317) {
		tmp = t_0 * (x / z);
	} else {
		tmp = t_2;
	}
	return tmp;
}
def code(x, y, z):
	return (x * (math.sin(y) / y)) / z
def code(x, y, z):
	t_0 = math.sin(y) / y
	t_1 = x * t_0
	t_2 = t_1 / z
	tmp = 0
	if t_1 <= -1e-117:
		tmp = t_2
	elif t_1 <= 5e-317:
		tmp = t_0 * (x / z)
	else:
		tmp = t_2
	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(sin(y) / y)
	t_1 = Float64(x * t_0)
	t_2 = Float64(t_1 / z)
	tmp = 0.0
	if (t_1 <= -1e-117)
		tmp = t_2;
	elseif (t_1 <= 5e-317)
		tmp = Float64(t_0 * Float64(x / z));
	else
		tmp = t_2;
	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 = sin(y) / y;
	t_1 = x * t_0;
	t_2 = t_1 / z;
	tmp = 0.0;
	if (t_1 <= -1e-117)
		tmp = t_2;
	elseif (t_1 <= 5e-317)
		tmp = t_0 * (x / z);
	else
		tmp = t_2;
	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[(N[Sin[y], $MachinePrecision] / y), $MachinePrecision]}, Block[{t$95$1 = N[(x * t$95$0), $MachinePrecision]}, Block[{t$95$2 = N[(t$95$1 / z), $MachinePrecision]}, If[LessEqual[t$95$1, -1e-117], t$95$2, If[LessEqual[t$95$1, 5e-317], N[(t$95$0 * N[(x / z), $MachinePrecision]), $MachinePrecision], t$95$2]]]]]
\frac{x \cdot \frac{\sin y}{y}}{z}
\begin{array}{l}
t_0 := \frac{\sin y}{y}\\
t_1 := x \cdot t_0\\
t_2 := \frac{t_1}{z}\\
\mathbf{if}\;t_1 \leq -1 \cdot 10^{-117}:\\
\;\;\;\;t_2\\

\mathbf{elif}\;t_1 \leq 5 \cdot 10^{-317}:\\
\;\;\;\;t_0 \cdot \frac{x}{z}\\

\mathbf{else}:\\
\;\;\;\;t_2\\


\end{array}

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original2.7
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)) < -1.00000000000000003e-117 or 5.00000017e-317 < (*.f64 x (/.f64 (sin.f64 y) y))

    1. Initial program 0.2

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

    if -1.00000000000000003e-117 < (*.f64 x (/.f64 (sin.f64 y) y)) < 5.00000017e-317

    1. Initial program 8.4

      \[\frac{x \cdot \frac{\sin y}{y}}{z} \]
    2. Applied egg-rr0.5

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \cdot \frac{\sin y}{y} \leq -1 \cdot 10^{-117}:\\ \;\;\;\;\frac{x \cdot \frac{\sin y}{y}}{z}\\ \mathbf{elif}\;x \cdot \frac{\sin y}{y} \leq 5 \cdot 10^{-317}:\\ \;\;\;\;\frac{\sin y}{y} \cdot \frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot \frac{\sin y}{y}}{z}\\ \end{array} \]

Alternatives

Alternative 1
Error3.0
Cost20168
\[\begin{array}{l} t_0 := \frac{\sin y}{y}\\ t_1 := \frac{x}{\frac{z}{t_0}}\\ \mathbf{if}\;t_0 \leq -1 \cdot 10^{-258}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t_0 \leq 5 \cdot 10^{-25}:\\ \;\;\;\;\frac{\frac{x}{\frac{z}{\sin y}}}{y}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 2
Error2.9
Cost7112
\[\begin{array}{l} t_0 := \frac{\frac{x}{\frac{z}{\sin y}}}{y}\\ \mathbf{if}\;y \leq -1.467999354333999 \cdot 10^{-7}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 1.0809945267035009 \cdot 10^{-17}:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 3
Error1.6
Cost6980
\[\begin{array}{l} t_0 := \frac{\sin y}{y}\\ \mathbf{if}\;z \leq -1.799571542239586 \cdot 10^{+47}:\\ \;\;\;\;\frac{t_0}{\frac{z}{x}}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{\frac{z}{t_0}}\\ \end{array} \]
Alternative 4
Error1.4
Cost6980
\[\begin{array}{l} t_0 := \frac{\sin y}{y}\\ \mathbf{if}\;z \leq -1.8026665755075868 \cdot 10^{+21}:\\ \;\;\;\;t_0 \cdot \frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{\frac{z}{t_0}}\\ \end{array} \]
Alternative 5
Error22.7
Cost1096
\[\begin{array}{l} t_0 := \frac{\frac{x}{0.16666666666666666 \cdot \left(y \cdot z\right) + \frac{z}{y}}}{y}\\ \mathbf{if}\;y \leq -1.467999354333999 \cdot 10^{-7}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 1.0809945267035009 \cdot 10^{-17}:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 6
Error23.0
Cost968
\[\begin{array}{l} t_0 := y \cdot \left(\left(1 + \frac{x}{y \cdot z}\right) + -1\right)\\ \mathbf{if}\;y \leq -3.20918786529037 \cdot 10^{+46}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 1.318017379925562 \cdot 10^{+32}:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 7
Error23.5
Cost712
\[\begin{array}{l} t_0 := y \cdot \frac{\frac{x}{y}}{z}\\ \mathbf{if}\;y \leq -7.011061312531396 \cdot 10^{+68}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 8.762382294511842 \cdot 10^{+46}:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 8
Error23.3
Cost712
\[\begin{array}{l} \mathbf{if}\;y \leq -7.011061312531396 \cdot 10^{+68}:\\ \;\;\;\;y \cdot \frac{\frac{x}{y}}{z}\\ \mathbf{elif}\;y \leq 1.318017379925562 \cdot 10^{+32}:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;\left(\frac{x}{z} + 1\right) + -1\\ \end{array} \]
Alternative 9
Error28.7
Cost320
\[\frac{1}{\frac{z}{x}} \]
Alternative 10
Error28.6
Cost192
\[\frac{x}{z} \]

Error

Reproduce

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