?

Average Error: 2.9 → 0.3
Time: 12.6s
Precision: binary64
Cost: 20680

?

\[\frac{x \cdot \frac{\sin y}{y}}{z} \]
\[\begin{array}{l} t_0 := \frac{\sin y}{y}\\ t_1 := \frac{x \cdot t_0}{z}\\ \mathbf{if}\;t_1 \leq -5 \cdot 10^{-239}:\\ \;\;\;\;\frac{\frac{x}{\frac{y}{\sin y}}}{z}\\ \mathbf{elif}\;t_1 \leq 2 \cdot 10^{-87}:\\ \;\;\;\;t_0 \cdot \frac{x}{z}\\ \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 (/ (sin y) y)) (t_1 (/ (* x t_0) z)))
   (if (<= t_1 -5e-239)
     (/ (/ x (/ y (sin y))) z)
     (if (<= t_1 2e-87) (* t_0 (/ x z)) 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 = sin(y) / y;
	double t_1 = (x * t_0) / z;
	double tmp;
	if (t_1 <= -5e-239) {
		tmp = (x / (y / sin(y))) / z;
	} else if (t_1 <= 2e-87) {
		tmp = t_0 * (x / z);
	} 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 = sin(y) / y
    t_1 = (x * t_0) / z
    if (t_1 <= (-5d-239)) then
        tmp = (x / (y / sin(y))) / z
    else if (t_1 <= 2d-87) then
        tmp = t_0 * (x / z)
    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 = Math.sin(y) / y;
	double t_1 = (x * t_0) / z;
	double tmp;
	if (t_1 <= -5e-239) {
		tmp = (x / (y / Math.sin(y))) / z;
	} else if (t_1 <= 2e-87) {
		tmp = t_0 * (x / z);
	} 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 = math.sin(y) / y
	t_1 = (x * t_0) / z
	tmp = 0
	if t_1 <= -5e-239:
		tmp = (x / (y / math.sin(y))) / z
	elif t_1 <= 2e-87:
		tmp = t_0 * (x / z)
	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(sin(y) / y)
	t_1 = Float64(Float64(x * t_0) / z)
	tmp = 0.0
	if (t_1 <= -5e-239)
		tmp = Float64(Float64(x / Float64(y / sin(y))) / z);
	elseif (t_1 <= 2e-87)
		tmp = Float64(t_0 * Float64(x / z));
	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 = sin(y) / y;
	t_1 = (x * t_0) / z;
	tmp = 0.0;
	if (t_1 <= -5e-239)
		tmp = (x / (y / sin(y))) / z;
	elseif (t_1 <= 2e-87)
		tmp = t_0 * (x / z);
	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[(N[Sin[y], $MachinePrecision] / y), $MachinePrecision]}, Block[{t$95$1 = N[(N[(x * t$95$0), $MachinePrecision] / z), $MachinePrecision]}, If[LessEqual[t$95$1, -5e-239], N[(N[(x / N[(y / N[Sin[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision], If[LessEqual[t$95$1, 2e-87], N[(t$95$0 * N[(x / z), $MachinePrecision]), $MachinePrecision], t$95$1]]]]
\frac{x \cdot \frac{\sin y}{y}}{z}
\begin{array}{l}
t_0 := \frac{\sin y}{y}\\
t_1 := \frac{x \cdot t_0}{z}\\
\mathbf{if}\;t_1 \leq -5 \cdot 10^{-239}:\\
\;\;\;\;\frac{\frac{x}{\frac{y}{\sin y}}}{z}\\

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

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


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original2.9
Target0.3
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 3 regimes
  2. if (/.f64 (*.f64 x (/.f64 (sin.f64 y) y)) z) < -5e-239

    1. Initial program 0.4

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

      \[\leadsto \frac{\color{blue}{\frac{x}{\frac{y}{\sin y}}}}{z} \]

    if -5e-239 < (/.f64 (*.f64 x (/.f64 (sin.f64 y) y)) z) < 2.00000000000000004e-87

    1. Initial program 6.3

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

      \[\leadsto \color{blue}{\frac{x}{\frac{z}{\frac{\sin y}{y}}}} \]
      Proof

      [Start]6.3

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

      associate-/l* [=>]4.2

      \[ \color{blue}{\frac{x}{\frac{z}{\frac{\sin y}{y}}}} \]
    3. Applied egg-rr0.1

      \[\leadsto \color{blue}{\frac{\sin y}{y} \cdot \frac{x}{z}} \]

    if 2.00000000000000004e-87 < (/.f64 (*.f64 x (/.f64 (sin.f64 y) y)) z)

    1. Initial program 0.2

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

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

Alternatives

Alternative 1
Error0.2
Cost20681
\[\begin{array}{l} t_0 := \frac{\sin y}{y}\\ t_1 := \frac{x \cdot t_0}{z}\\ \mathbf{if}\;t_1 \leq -5 \cdot 10^{-239} \lor \neg \left(t_1 \leq 2 \cdot 10^{-87}\right):\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_0 \cdot \frac{x}{z}\\ \end{array} \]
Alternative 2
Error2.9
Cost7113
\[\begin{array}{l} \mathbf{if}\;y \leq -2 \cdot 10^{-8} \lor \neg \left(y \leq 1.7 \cdot 10^{-8}\right):\\ \;\;\;\;x \cdot \frac{\sin y}{y \cdot z}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{z}\\ \end{array} \]
Alternative 3
Error3.2
Cost7113
\[\begin{array}{l} \mathbf{if}\;z \leq -1.9 \cdot 10^{-226} \lor \neg \left(z \leq -4.1 \cdot 10^{-272}\right):\\ \;\;\;\;\frac{\sin y}{y} \cdot \frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;x \cdot \frac{\sin y}{y \cdot z}\\ \end{array} \]
Alternative 4
Error3.3
Cost7113
\[\begin{array}{l} \mathbf{if}\;z \leq -1.45 \cdot 10^{-227} \lor \neg \left(z \leq 5.8 \cdot 10^{-75}\right):\\ \;\;\;\;\frac{\sin y}{y} \cdot \frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sin y}{z} \cdot \frac{x}{y}\\ \end{array} \]
Alternative 5
Error0.7
Cost7113
\[\begin{array}{l} \mathbf{if}\;z \leq -2.45 \cdot 10^{-169} \lor \neg \left(z \leq 10^{-60}\right):\\ \;\;\;\;\frac{\sin y}{y} \cdot \frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{y \cdot \frac{z}{\sin y}}\\ \end{array} \]
Alternative 6
Error23.0
Cost968
\[\begin{array}{l} \mathbf{if}\;y \leq -240000000000:\\ \;\;\;\;\frac{\frac{6}{y \cdot \frac{y}{x}}}{z}\\ \mathbf{elif}\;y \leq 31:\\ \;\;\;\;\frac{x}{\frac{z}{1 + -0.16666666666666666 \cdot \left(y \cdot y\right)}}\\ \mathbf{else}:\\ \;\;\;\;6 \cdot \frac{x}{y \cdot \left(y \cdot z\right)}\\ \end{array} \]
Alternative 7
Error23.1
Cost841
\[\begin{array}{l} \mathbf{if}\;y \leq -2.4 \lor \neg \left(y \leq 2.4\right):\\ \;\;\;\;6 \cdot \frac{x}{y \cdot \left(y \cdot z\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{z}\\ \end{array} \]
Alternative 8
Error23.1
Cost840
\[\begin{array}{l} \mathbf{if}\;y \leq -2.4:\\ \;\;\;\;6 \cdot \frac{\frac{\frac{x}{y}}{z}}{y}\\ \mathbf{elif}\;y \leq 2.4:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;6 \cdot \frac{x}{y \cdot \left(y \cdot z\right)}\\ \end{array} \]
Alternative 9
Error23.1
Cost840
\[\begin{array}{l} \mathbf{if}\;y \leq -2.4:\\ \;\;\;\;\frac{\frac{x}{y}}{y} \cdot \frac{6}{z}\\ \mathbf{elif}\;y \leq 2.4:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;6 \cdot \frac{x}{y \cdot \left(y \cdot z\right)}\\ \end{array} \]
Alternative 10
Error23.1
Cost840
\[\begin{array}{l} \mathbf{if}\;y \leq -2.55:\\ \;\;\;\;\frac{\frac{6}{y \cdot \frac{y}{x}}}{z}\\ \mathbf{elif}\;y \leq 2.4:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;6 \cdot \frac{x}{y \cdot \left(y \cdot z\right)}\\ \end{array} \]
Alternative 11
Error26.2
Cost713
\[\begin{array}{l} \mathbf{if}\;z \leq -5 \cdot 10^{+76} \lor \neg \left(z \leq 5.5 \cdot 10^{+76}\right):\\ \;\;\;\;x \cdot \frac{y}{y \cdot z}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\frac{z}{x}}\\ \end{array} \]
Alternative 12
Error23.5
Cost713
\[\begin{array}{l} \mathbf{if}\;y \leq -1.65 \cdot 10^{+17} \lor \neg \left(y \leq 2.4 \cdot 10^{+78}\right):\\ \;\;\;\;\left(\frac{x}{z} + 1\right) + -1\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{z}\\ \end{array} \]
Alternative 13
Error28.2
Cost712
\[\begin{array}{l} \mathbf{if}\;x \leq -1.55 \cdot 10^{-258}:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{elif}\;x \leq 1.3 \cdot 10^{-87}:\\ \;\;\;\;\frac{x}{y} \cdot \frac{y}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{z}\\ \end{array} \]
Alternative 14
Error23.0
Cost704
\[\frac{\frac{x}{1 + y \cdot \left(y \cdot 0.16666666666666666\right)}}{z} \]
Alternative 15
Error28.9
Cost320
\[\frac{1}{\frac{z}{x}} \]
Alternative 16
Error28.8
Cost192
\[\frac{x}{z} \]

Error

Reproduce?

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