?

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

\mathbf{elif}\;t_0 \leq 2 \cdot 10^{-316}:\\
\;\;\;\;\frac{\sin y \cdot x}{y \cdot z}\\

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


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original2.5
Target0.3
Herbie0.4
\[\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)) < -5.0000000000000001e-290 or 2.000000017e-316 < (*.f64 x (/.f64 (sin.f64 y) y))

    1. Initial program 0.2

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

    if -5.0000000000000001e-290 < (*.f64 x (/.f64 (sin.f64 y) y)) < 2.000000017e-316

    1. Initial program 16.4

      \[\frac{x \cdot \frac{\sin y}{y}}{z} \]
    2. Taylor expanded in x around 0 1.7

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

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

Alternatives

Alternative 1
Error2.5
Cost6848
\[\frac{x \cdot \frac{\sin y}{y}}{z} \]
Alternative 2
Error23.8
Cost1096
\[\begin{array}{l} t_0 := \left(0 - \left(-1 - \frac{y \cdot x}{y \cdot z}\right)\right) - 1\\ \mathbf{if}\;y \leq -1.95 \cdot 10^{+87}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 9 \cdot 10^{+51}:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 3
Error24.4
Cost840
\[\begin{array}{l} t_0 := \frac{\left(0 - \left(-1 - x\right)\right) - 1}{z}\\ \mathbf{if}\;y \leq -2.3 \cdot 10^{+87}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 3.3 \cdot 10^{+36}:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 4
Error27.4
Cost580
\[\begin{array}{l} \mathbf{if}\;y \leq 1.62 \cdot 10^{+125}:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{y \cdot x}{y \cdot z}\\ \end{array} \]
Alternative 5
Error28.2
Cost192
\[\frac{x}{z} \]

Error

Reproduce?

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