
(FPCore (x y z) :precision binary64 (/ (* x (/ (sin y) y)) z))
double code(double x, double y, double z) {
return (x * (sin(y) / y)) / z;
}
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
public static double code(double x, double y, double z) {
return (x * (Math.sin(y) / y)) / z;
}
def code(x, y, z): return (x * (math.sin(y) / y)) / z
function code(x, y, z) return Float64(Float64(x * Float64(sin(y) / y)) / z) end
function tmp = code(x, y, z) tmp = (x * (sin(y) / y)) / z; end
code[x_, y_, z_] := N[(N[(x * N[(N[Sin[y], $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]
\begin{array}{l}
\\
\frac{x \cdot \frac{\sin y}{y}}{z}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 10 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 (/ (* x (/ (sin y) y)) z))
double code(double x, double y, double z) {
return (x * (sin(y) / y)) / z;
}
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
public static double code(double x, double y, double z) {
return (x * (Math.sin(y) / y)) / z;
}
def code(x, y, z): return (x * (math.sin(y) / y)) / z
function code(x, y, z) return Float64(Float64(x * Float64(sin(y) / y)) / z) end
function tmp = code(x, y, z) tmp = (x * (sin(y) / y)) / z; end
code[x_, y_, z_] := N[(N[(x * N[(N[Sin[y], $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]
\begin{array}{l}
\\
\frac{x \cdot \frac{\sin y}{y}}{z}
\end{array}
z_m = (fabs.f64 z)
z_s = (copysign.f64 1 z)
(FPCore (z_s x y z_m)
:precision binary64
(*
z_s
(if (<= z_m 3.3e+19)
(/ x (/ y (/ (sin y) z_m)))
(/ (* x (/ (sin y) y)) z_m))))z_m = fabs(z);
z_s = copysign(1.0, z);
double code(double z_s, double x, double y, double z_m) {
double tmp;
if (z_m <= 3.3e+19) {
tmp = x / (y / (sin(y) / z_m));
} else {
tmp = (x * (sin(y) / y)) / z_m;
}
return z_s * tmp;
}
z_m = abs(z)
z_s = copysign(1.0d0, z)
real(8) function code(z_s, x, y, z_m)
real(8), intent (in) :: z_s
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z_m
real(8) :: tmp
if (z_m <= 3.3d+19) then
tmp = x / (y / (sin(y) / z_m))
else
tmp = (x * (sin(y) / y)) / z_m
end if
code = z_s * tmp
end function
z_m = Math.abs(z);
z_s = Math.copySign(1.0, z);
public static double code(double z_s, double x, double y, double z_m) {
double tmp;
if (z_m <= 3.3e+19) {
tmp = x / (y / (Math.sin(y) / z_m));
} else {
tmp = (x * (Math.sin(y) / y)) / z_m;
}
return z_s * tmp;
}
z_m = math.fabs(z) z_s = math.copysign(1.0, z) def code(z_s, x, y, z_m): tmp = 0 if z_m <= 3.3e+19: tmp = x / (y / (math.sin(y) / z_m)) else: tmp = (x * (math.sin(y) / y)) / z_m return z_s * tmp
z_m = abs(z) z_s = copysign(1.0, z) function code(z_s, x, y, z_m) tmp = 0.0 if (z_m <= 3.3e+19) tmp = Float64(x / Float64(y / Float64(sin(y) / z_m))); else tmp = Float64(Float64(x * Float64(sin(y) / y)) / z_m); end return Float64(z_s * tmp) end
z_m = abs(z); z_s = sign(z) * abs(1.0); function tmp_2 = code(z_s, x, y, z_m) tmp = 0.0; if (z_m <= 3.3e+19) tmp = x / (y / (sin(y) / z_m)); else tmp = (x * (sin(y) / y)) / z_m; end tmp_2 = z_s * tmp; end
z_m = N[Abs[z], $MachinePrecision]
z_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[z]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[z$95$s_, x_, y_, z$95$m_] := N[(z$95$s * If[LessEqual[z$95$m, 3.3e+19], N[(x / N[(y / N[(N[Sin[y], $MachinePrecision] / z$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x * N[(N[Sin[y], $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision] / z$95$m), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
z_m = \left|z\right|
\\
z_s = \mathsf{copysign}\left(1, z\right)
\\
z\_s \cdot \begin{array}{l}
\mathbf{if}\;z\_m \leq 3.3 \cdot 10^{+19}:\\
\;\;\;\;\frac{x}{\frac{y}{\frac{\sin y}{z\_m}}}\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot \frac{\sin y}{y}}{z\_m}\\
\end{array}
\end{array}
if z < 3.3e19Initial program 96.0%
associate-*r/97.8%
associate-/l/87.0%
*-commutative87.0%
Simplified87.0%
associate-*r/81.8%
associate-/l*86.9%
associate-/l*93.3%
Applied egg-rr93.3%
if 3.3e19 < z Initial program 99.7%
Final simplification94.6%
z_m = (fabs.f64 z) z_s = (copysign.f64 1 z) (FPCore (z_s x y z_m) :precision binary64 (* z_s (if (<= y 2.45e-11) (/ x z_m) (* x (/ (sin y) (* z_m y))))))
z_m = fabs(z);
z_s = copysign(1.0, z);
double code(double z_s, double x, double y, double z_m) {
double tmp;
if (y <= 2.45e-11) {
tmp = x / z_m;
} else {
tmp = x * (sin(y) / (z_m * y));
}
return z_s * tmp;
}
z_m = abs(z)
z_s = copysign(1.0d0, z)
real(8) function code(z_s, x, y, z_m)
real(8), intent (in) :: z_s
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z_m
real(8) :: tmp
if (y <= 2.45d-11) then
tmp = x / z_m
else
tmp = x * (sin(y) / (z_m * y))
end if
code = z_s * tmp
end function
z_m = Math.abs(z);
z_s = Math.copySign(1.0, z);
public static double code(double z_s, double x, double y, double z_m) {
double tmp;
if (y <= 2.45e-11) {
tmp = x / z_m;
} else {
tmp = x * (Math.sin(y) / (z_m * y));
}
return z_s * tmp;
}
z_m = math.fabs(z) z_s = math.copysign(1.0, z) def code(z_s, x, y, z_m): tmp = 0 if y <= 2.45e-11: tmp = x / z_m else: tmp = x * (math.sin(y) / (z_m * y)) return z_s * tmp
z_m = abs(z) z_s = copysign(1.0, z) function code(z_s, x, y, z_m) tmp = 0.0 if (y <= 2.45e-11) tmp = Float64(x / z_m); else tmp = Float64(x * Float64(sin(y) / Float64(z_m * y))); end return Float64(z_s * tmp) end
z_m = abs(z); z_s = sign(z) * abs(1.0); function tmp_2 = code(z_s, x, y, z_m) tmp = 0.0; if (y <= 2.45e-11) tmp = x / z_m; else tmp = x * (sin(y) / (z_m * y)); end tmp_2 = z_s * tmp; end
z_m = N[Abs[z], $MachinePrecision]
z_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[z]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[z$95$s_, x_, y_, z$95$m_] := N[(z$95$s * If[LessEqual[y, 2.45e-11], N[(x / z$95$m), $MachinePrecision], N[(x * N[(N[Sin[y], $MachinePrecision] / N[(z$95$m * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
z_m = \left|z\right|
\\
z_s = \mathsf{copysign}\left(1, z\right)
\\
z\_s \cdot \begin{array}{l}
\mathbf{if}\;y \leq 2.45 \cdot 10^{-11}:\\
\;\;\;\;\frac{x}{z\_m}\\
\mathbf{else}:\\
\;\;\;\;x \cdot \frac{\sin y}{z\_m \cdot y}\\
\end{array}
\end{array}
if y < 2.4499999999999999e-11Initial program 97.2%
associate-*r/97.7%
associate-/l/85.5%
*-commutative85.5%
Simplified85.5%
Taylor expanded in y around 0 71.7%
if 2.4499999999999999e-11 < y Initial program 95.4%
associate-*r/91.3%
associate-/l/90.7%
*-commutative90.7%
Simplified90.7%
Final simplification77.3%
z_m = (fabs.f64 z) z_s = (copysign.f64 1 z) (FPCore (z_s x y z_m) :precision binary64 (* z_s (if (<= y 8.6e-31) (/ x z_m) (* (sin y) (/ (/ x y) z_m)))))
z_m = fabs(z);
z_s = copysign(1.0, z);
double code(double z_s, double x, double y, double z_m) {
double tmp;
if (y <= 8.6e-31) {
tmp = x / z_m;
} else {
tmp = sin(y) * ((x / y) / z_m);
}
return z_s * tmp;
}
z_m = abs(z)
z_s = copysign(1.0d0, z)
real(8) function code(z_s, x, y, z_m)
real(8), intent (in) :: z_s
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z_m
real(8) :: tmp
if (y <= 8.6d-31) then
tmp = x / z_m
else
tmp = sin(y) * ((x / y) / z_m)
end if
code = z_s * tmp
end function
z_m = Math.abs(z);
z_s = Math.copySign(1.0, z);
public static double code(double z_s, double x, double y, double z_m) {
double tmp;
if (y <= 8.6e-31) {
tmp = x / z_m;
} else {
tmp = Math.sin(y) * ((x / y) / z_m);
}
return z_s * tmp;
}
z_m = math.fabs(z) z_s = math.copysign(1.0, z) def code(z_s, x, y, z_m): tmp = 0 if y <= 8.6e-31: tmp = x / z_m else: tmp = math.sin(y) * ((x / y) / z_m) return z_s * tmp
z_m = abs(z) z_s = copysign(1.0, z) function code(z_s, x, y, z_m) tmp = 0.0 if (y <= 8.6e-31) tmp = Float64(x / z_m); else tmp = Float64(sin(y) * Float64(Float64(x / y) / z_m)); end return Float64(z_s * tmp) end
z_m = abs(z); z_s = sign(z) * abs(1.0); function tmp_2 = code(z_s, x, y, z_m) tmp = 0.0; if (y <= 8.6e-31) tmp = x / z_m; else tmp = sin(y) * ((x / y) / z_m); end tmp_2 = z_s * tmp; end
z_m = N[Abs[z], $MachinePrecision]
z_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[z]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[z$95$s_, x_, y_, z$95$m_] := N[(z$95$s * If[LessEqual[y, 8.6e-31], N[(x / z$95$m), $MachinePrecision], N[(N[Sin[y], $MachinePrecision] * N[(N[(x / y), $MachinePrecision] / z$95$m), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
z_m = \left|z\right|
\\
z_s = \mathsf{copysign}\left(1, z\right)
\\
z\_s \cdot \begin{array}{l}
\mathbf{if}\;y \leq 8.6 \cdot 10^{-31}:\\
\;\;\;\;\frac{x}{z\_m}\\
\mathbf{else}:\\
\;\;\;\;\sin y \cdot \frac{\frac{x}{y}}{z\_m}\\
\end{array}
\end{array}
if y < 8.6e-31Initial program 97.2%
associate-*r/97.7%
associate-/l/85.2%
*-commutative85.2%
Simplified85.2%
Taylor expanded in y around 0 71.3%
if 8.6e-31 < y Initial program 95.6%
*-lft-identity95.6%
metadata-eval95.6%
times-frac95.6%
neg-mul-195.6%
distribute-lft-neg-out95.6%
associate-*r/95.7%
associate-*l/95.6%
*-commutative95.6%
times-frac95.5%
remove-double-neg95.5%
distribute-frac-neg95.5%
sin-neg95.5%
sin-neg95.5%
neg-mul-195.5%
associate-/l*95.5%
associate-/r/95.5%
distribute-lft-neg-in95.5%
metadata-eval95.5%
metadata-eval95.5%
neg-mul-195.5%
sin-neg95.5%
*-commutative95.5%
Simplified95.5%
Final simplification78.7%
z_m = (fabs.f64 z) z_s = (copysign.f64 1 z) (FPCore (z_s x y z_m) :precision binary64 (* z_s (if (<= y 4.5e+51) (* (/ (sin y) y) (/ x z_m)) (* (sin y) (/ (/ x y) z_m)))))
z_m = fabs(z);
z_s = copysign(1.0, z);
double code(double z_s, double x, double y, double z_m) {
double tmp;
if (y <= 4.5e+51) {
tmp = (sin(y) / y) * (x / z_m);
} else {
tmp = sin(y) * ((x / y) / z_m);
}
return z_s * tmp;
}
z_m = abs(z)
z_s = copysign(1.0d0, z)
real(8) function code(z_s, x, y, z_m)
real(8), intent (in) :: z_s
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z_m
real(8) :: tmp
if (y <= 4.5d+51) then
tmp = (sin(y) / y) * (x / z_m)
else
tmp = sin(y) * ((x / y) / z_m)
end if
code = z_s * tmp
end function
z_m = Math.abs(z);
z_s = Math.copySign(1.0, z);
public static double code(double z_s, double x, double y, double z_m) {
double tmp;
if (y <= 4.5e+51) {
tmp = (Math.sin(y) / y) * (x / z_m);
} else {
tmp = Math.sin(y) * ((x / y) / z_m);
}
return z_s * tmp;
}
z_m = math.fabs(z) z_s = math.copysign(1.0, z) def code(z_s, x, y, z_m): tmp = 0 if y <= 4.5e+51: tmp = (math.sin(y) / y) * (x / z_m) else: tmp = math.sin(y) * ((x / y) / z_m) return z_s * tmp
z_m = abs(z) z_s = copysign(1.0, z) function code(z_s, x, y, z_m) tmp = 0.0 if (y <= 4.5e+51) tmp = Float64(Float64(sin(y) / y) * Float64(x / z_m)); else tmp = Float64(sin(y) * Float64(Float64(x / y) / z_m)); end return Float64(z_s * tmp) end
z_m = abs(z); z_s = sign(z) * abs(1.0); function tmp_2 = code(z_s, x, y, z_m) tmp = 0.0; if (y <= 4.5e+51) tmp = (sin(y) / y) * (x / z_m); else tmp = sin(y) * ((x / y) / z_m); end tmp_2 = z_s * tmp; end
z_m = N[Abs[z], $MachinePrecision]
z_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[z]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[z$95$s_, x_, y_, z$95$m_] := N[(z$95$s * If[LessEqual[y, 4.5e+51], N[(N[(N[Sin[y], $MachinePrecision] / y), $MachinePrecision] * N[(x / z$95$m), $MachinePrecision]), $MachinePrecision], N[(N[Sin[y], $MachinePrecision] * N[(N[(x / y), $MachinePrecision] / z$95$m), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
z_m = \left|z\right|
\\
z_s = \mathsf{copysign}\left(1, z\right)
\\
z\_s \cdot \begin{array}{l}
\mathbf{if}\;y \leq 4.5 \cdot 10^{+51}:\\
\;\;\;\;\frac{\sin y}{y} \cdot \frac{x}{z\_m}\\
\mathbf{else}:\\
\;\;\;\;\sin y \cdot \frac{\frac{x}{y}}{z\_m}\\
\end{array}
\end{array}
if y < 4.5e51Initial program 97.4%
*-commutative97.4%
associate-*r/96.5%
Simplified96.5%
if 4.5e51 < y Initial program 94.5%
*-lft-identity94.5%
metadata-eval94.5%
times-frac94.5%
neg-mul-194.5%
distribute-lft-neg-out94.5%
associate-*r/94.5%
associate-*l/94.5%
*-commutative94.5%
times-frac94.3%
remove-double-neg94.3%
distribute-frac-neg94.3%
sin-neg94.3%
sin-neg94.3%
neg-mul-194.3%
associate-/l*94.3%
associate-/r/94.3%
distribute-lft-neg-in94.3%
metadata-eval94.3%
metadata-eval94.3%
neg-mul-194.3%
sin-neg94.3%
*-commutative94.3%
Simplified94.3%
Final simplification96.0%
z_m = (fabs.f64 z)
z_s = (copysign.f64 1 z)
(FPCore (z_s x y z_m)
:precision binary64
(*
z_s
(if (<= z_m 5.5e+19)
(/ x (/ y (/ (sin y) z_m)))
(* (/ (sin y) y) (/ x z_m)))))z_m = fabs(z);
z_s = copysign(1.0, z);
double code(double z_s, double x, double y, double z_m) {
double tmp;
if (z_m <= 5.5e+19) {
tmp = x / (y / (sin(y) / z_m));
} else {
tmp = (sin(y) / y) * (x / z_m);
}
return z_s * tmp;
}
z_m = abs(z)
z_s = copysign(1.0d0, z)
real(8) function code(z_s, x, y, z_m)
real(8), intent (in) :: z_s
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z_m
real(8) :: tmp
if (z_m <= 5.5d+19) then
tmp = x / (y / (sin(y) / z_m))
else
tmp = (sin(y) / y) * (x / z_m)
end if
code = z_s * tmp
end function
z_m = Math.abs(z);
z_s = Math.copySign(1.0, z);
public static double code(double z_s, double x, double y, double z_m) {
double tmp;
if (z_m <= 5.5e+19) {
tmp = x / (y / (Math.sin(y) / z_m));
} else {
tmp = (Math.sin(y) / y) * (x / z_m);
}
return z_s * tmp;
}
z_m = math.fabs(z) z_s = math.copysign(1.0, z) def code(z_s, x, y, z_m): tmp = 0 if z_m <= 5.5e+19: tmp = x / (y / (math.sin(y) / z_m)) else: tmp = (math.sin(y) / y) * (x / z_m) return z_s * tmp
z_m = abs(z) z_s = copysign(1.0, z) function code(z_s, x, y, z_m) tmp = 0.0 if (z_m <= 5.5e+19) tmp = Float64(x / Float64(y / Float64(sin(y) / z_m))); else tmp = Float64(Float64(sin(y) / y) * Float64(x / z_m)); end return Float64(z_s * tmp) end
z_m = abs(z); z_s = sign(z) * abs(1.0); function tmp_2 = code(z_s, x, y, z_m) tmp = 0.0; if (z_m <= 5.5e+19) tmp = x / (y / (sin(y) / z_m)); else tmp = (sin(y) / y) * (x / z_m); end tmp_2 = z_s * tmp; end
z_m = N[Abs[z], $MachinePrecision]
z_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[z]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[z$95$s_, x_, y_, z$95$m_] := N[(z$95$s * If[LessEqual[z$95$m, 5.5e+19], N[(x / N[(y / N[(N[Sin[y], $MachinePrecision] / z$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Sin[y], $MachinePrecision] / y), $MachinePrecision] * N[(x / z$95$m), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
z_m = \left|z\right|
\\
z_s = \mathsf{copysign}\left(1, z\right)
\\
z\_s \cdot \begin{array}{l}
\mathbf{if}\;z\_m \leq 5.5 \cdot 10^{+19}:\\
\;\;\;\;\frac{x}{\frac{y}{\frac{\sin y}{z\_m}}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sin y}{y} \cdot \frac{x}{z\_m}\\
\end{array}
\end{array}
if z < 5.5e19Initial program 96.0%
associate-*r/97.8%
associate-/l/87.0%
*-commutative87.0%
Simplified87.0%
associate-*r/81.8%
associate-/l*86.9%
associate-/l*93.3%
Applied egg-rr93.3%
if 5.5e19 < z Initial program 99.7%
*-commutative99.7%
associate-*r/99.7%
Simplified99.7%
Final simplification94.6%
z_m = (fabs.f64 z) z_s = (copysign.f64 1 z) (FPCore (z_s x y z_m) :precision binary64 (* z_s (if (<= y 3.7e+79) (/ x z_m) (/ y (* (/ y x) (- z_m))))))
z_m = fabs(z);
z_s = copysign(1.0, z);
double code(double z_s, double x, double y, double z_m) {
double tmp;
if (y <= 3.7e+79) {
tmp = x / z_m;
} else {
tmp = y / ((y / x) * -z_m);
}
return z_s * tmp;
}
z_m = abs(z)
z_s = copysign(1.0d0, z)
real(8) function code(z_s, x, y, z_m)
real(8), intent (in) :: z_s
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z_m
real(8) :: tmp
if (y <= 3.7d+79) then
tmp = x / z_m
else
tmp = y / ((y / x) * -z_m)
end if
code = z_s * tmp
end function
z_m = Math.abs(z);
z_s = Math.copySign(1.0, z);
public static double code(double z_s, double x, double y, double z_m) {
double tmp;
if (y <= 3.7e+79) {
tmp = x / z_m;
} else {
tmp = y / ((y / x) * -z_m);
}
return z_s * tmp;
}
z_m = math.fabs(z) z_s = math.copysign(1.0, z) def code(z_s, x, y, z_m): tmp = 0 if y <= 3.7e+79: tmp = x / z_m else: tmp = y / ((y / x) * -z_m) return z_s * tmp
z_m = abs(z) z_s = copysign(1.0, z) function code(z_s, x, y, z_m) tmp = 0.0 if (y <= 3.7e+79) tmp = Float64(x / z_m); else tmp = Float64(y / Float64(Float64(y / x) * Float64(-z_m))); end return Float64(z_s * tmp) end
z_m = abs(z); z_s = sign(z) * abs(1.0); function tmp_2 = code(z_s, x, y, z_m) tmp = 0.0; if (y <= 3.7e+79) tmp = x / z_m; else tmp = y / ((y / x) * -z_m); end tmp_2 = z_s * tmp; end
z_m = N[Abs[z], $MachinePrecision]
z_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[z]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[z$95$s_, x_, y_, z$95$m_] := N[(z$95$s * If[LessEqual[y, 3.7e+79], N[(x / z$95$m), $MachinePrecision], N[(y / N[(N[(y / x), $MachinePrecision] * (-z$95$m)), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
z_m = \left|z\right|
\\
z_s = \mathsf{copysign}\left(1, z\right)
\\
z\_s \cdot \begin{array}{l}
\mathbf{if}\;y \leq 3.7 \cdot 10^{+79}:\\
\;\;\;\;\frac{x}{z\_m}\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{\frac{y}{x} \cdot \left(-z\_m\right)}\\
\end{array}
\end{array}
if y < 3.70000000000000009e79Initial program 97.5%
associate-*r/97.5%
associate-/l/86.8%
*-commutative86.8%
Simplified86.8%
Taylor expanded in y around 0 67.3%
if 3.70000000000000009e79 < y Initial program 93.4%
associate-*r/88.8%
associate-/l/88.0%
*-commutative88.0%
Simplified88.0%
Taylor expanded in y around 0 9.0%
un-div-inv9.0%
clear-num9.1%
Applied egg-rr9.1%
associate-/l*9.0%
*-inverses9.0%
associate-/r/14.6%
associate-/r*23.9%
associate-/l/14.2%
div-inv14.2%
clear-num14.2%
Applied egg-rr14.2%
associate-*r/8.8%
associate-/l*14.2%
frac-2neg14.2%
associate-/l/23.9%
add-sqr-sqrt0.0%
sqrt-unprod9.9%
sqr-neg9.9%
sqrt-unprod26.6%
add-sqr-sqrt26.6%
Applied egg-rr26.6%
Final simplification59.5%
z_m = (fabs.f64 z) z_s = (copysign.f64 1 z) (FPCore (z_s x y z_m) :precision binary64 (* z_s (if (<= y 0.01) (/ x z_m) (* y (/ x (* z_m y))))))
z_m = fabs(z);
z_s = copysign(1.0, z);
double code(double z_s, double x, double y, double z_m) {
double tmp;
if (y <= 0.01) {
tmp = x / z_m;
} else {
tmp = y * (x / (z_m * y));
}
return z_s * tmp;
}
z_m = abs(z)
z_s = copysign(1.0d0, z)
real(8) function code(z_s, x, y, z_m)
real(8), intent (in) :: z_s
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z_m
real(8) :: tmp
if (y <= 0.01d0) then
tmp = x / z_m
else
tmp = y * (x / (z_m * y))
end if
code = z_s * tmp
end function
z_m = Math.abs(z);
z_s = Math.copySign(1.0, z);
public static double code(double z_s, double x, double y, double z_m) {
double tmp;
if (y <= 0.01) {
tmp = x / z_m;
} else {
tmp = y * (x / (z_m * y));
}
return z_s * tmp;
}
z_m = math.fabs(z) z_s = math.copysign(1.0, z) def code(z_s, x, y, z_m): tmp = 0 if y <= 0.01: tmp = x / z_m else: tmp = y * (x / (z_m * y)) return z_s * tmp
z_m = abs(z) z_s = copysign(1.0, z) function code(z_s, x, y, z_m) tmp = 0.0 if (y <= 0.01) tmp = Float64(x / z_m); else tmp = Float64(y * Float64(x / Float64(z_m * y))); end return Float64(z_s * tmp) end
z_m = abs(z); z_s = sign(z) * abs(1.0); function tmp_2 = code(z_s, x, y, z_m) tmp = 0.0; if (y <= 0.01) tmp = x / z_m; else tmp = y * (x / (z_m * y)); end tmp_2 = z_s * tmp; end
z_m = N[Abs[z], $MachinePrecision]
z_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[z]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[z$95$s_, x_, y_, z$95$m_] := N[(z$95$s * If[LessEqual[y, 0.01], N[(x / z$95$m), $MachinePrecision], N[(y * N[(x / N[(z$95$m * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
z_m = \left|z\right|
\\
z_s = \mathsf{copysign}\left(1, z\right)
\\
z\_s \cdot \begin{array}{l}
\mathbf{if}\;y \leq 0.01:\\
\;\;\;\;\frac{x}{z\_m}\\
\mathbf{else}:\\
\;\;\;\;y \cdot \frac{x}{z\_m \cdot y}\\
\end{array}
\end{array}
if y < 0.0100000000000000002Initial program 97.3%
associate-*r/97.7%
associate-/l/85.6%
*-commutative85.6%
Simplified85.6%
Taylor expanded in y around 0 71.8%
if 0.0100000000000000002 < y Initial program 95.3%
associate-*r/91.1%
associate-/l/90.5%
*-commutative90.5%
Simplified90.5%
Taylor expanded in y around 0 16.8%
un-div-inv16.8%
clear-num16.8%
Applied egg-rr16.8%
associate-/l*16.8%
*-inverses16.8%
associate-/r/20.5%
associate-/r*26.8%
associate-/l/20.3%
div-inv20.3%
div-inv20.3%
clear-num20.3%
associate-*l*25.6%
Applied egg-rr25.6%
Taylor expanded in z around 0 25.9%
*-commutative25.9%
Simplified25.9%
Final simplification58.7%
z_m = (fabs.f64 z) z_s = (copysign.f64 1 z) (FPCore (z_s x y z_m) :precision binary64 (* z_s (if (<= y 0.0075) (/ x z_m) (/ y (* z_m (/ y x))))))
z_m = fabs(z);
z_s = copysign(1.0, z);
double code(double z_s, double x, double y, double z_m) {
double tmp;
if (y <= 0.0075) {
tmp = x / z_m;
} else {
tmp = y / (z_m * (y / x));
}
return z_s * tmp;
}
z_m = abs(z)
z_s = copysign(1.0d0, z)
real(8) function code(z_s, x, y, z_m)
real(8), intent (in) :: z_s
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z_m
real(8) :: tmp
if (y <= 0.0075d0) then
tmp = x / z_m
else
tmp = y / (z_m * (y / x))
end if
code = z_s * tmp
end function
z_m = Math.abs(z);
z_s = Math.copySign(1.0, z);
public static double code(double z_s, double x, double y, double z_m) {
double tmp;
if (y <= 0.0075) {
tmp = x / z_m;
} else {
tmp = y / (z_m * (y / x));
}
return z_s * tmp;
}
z_m = math.fabs(z) z_s = math.copysign(1.0, z) def code(z_s, x, y, z_m): tmp = 0 if y <= 0.0075: tmp = x / z_m else: tmp = y / (z_m * (y / x)) return z_s * tmp
z_m = abs(z) z_s = copysign(1.0, z) function code(z_s, x, y, z_m) tmp = 0.0 if (y <= 0.0075) tmp = Float64(x / z_m); else tmp = Float64(y / Float64(z_m * Float64(y / x))); end return Float64(z_s * tmp) end
z_m = abs(z); z_s = sign(z) * abs(1.0); function tmp_2 = code(z_s, x, y, z_m) tmp = 0.0; if (y <= 0.0075) tmp = x / z_m; else tmp = y / (z_m * (y / x)); end tmp_2 = z_s * tmp; end
z_m = N[Abs[z], $MachinePrecision]
z_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[z]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[z$95$s_, x_, y_, z$95$m_] := N[(z$95$s * If[LessEqual[y, 0.0075], N[(x / z$95$m), $MachinePrecision], N[(y / N[(z$95$m * N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
z_m = \left|z\right|
\\
z_s = \mathsf{copysign}\left(1, z\right)
\\
z\_s \cdot \begin{array}{l}
\mathbf{if}\;y \leq 0.0075:\\
\;\;\;\;\frac{x}{z\_m}\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{z\_m \cdot \frac{y}{x}}\\
\end{array}
\end{array}
if y < 0.0074999999999999997Initial program 97.3%
associate-*r/97.7%
associate-/l/85.6%
*-commutative85.6%
Simplified85.6%
Taylor expanded in y around 0 71.8%
if 0.0074999999999999997 < y Initial program 95.3%
associate-*r/91.1%
associate-/l/90.5%
*-commutative90.5%
Simplified90.5%
Taylor expanded in y around 0 16.8%
un-div-inv16.8%
clear-num16.8%
Applied egg-rr16.8%
associate-/l*16.8%
*-inverses16.8%
associate-/r/20.5%
associate-/r*26.8%
associate-/l/20.3%
div-inv20.3%
clear-num20.3%
Applied egg-rr20.3%
associate-*r/16.6%
associate-/l*20.3%
associate-/l/26.8%
Applied egg-rr26.8%
Final simplification59.0%
z_m = (fabs.f64 z) z_s = (copysign.f64 1 z) (FPCore (z_s x y z_m) :precision binary64 (* z_s (if (<= y 0.0075) (/ x z_m) (/ y (/ (* z_m y) x)))))
z_m = fabs(z);
z_s = copysign(1.0, z);
double code(double z_s, double x, double y, double z_m) {
double tmp;
if (y <= 0.0075) {
tmp = x / z_m;
} else {
tmp = y / ((z_m * y) / x);
}
return z_s * tmp;
}
z_m = abs(z)
z_s = copysign(1.0d0, z)
real(8) function code(z_s, x, y, z_m)
real(8), intent (in) :: z_s
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z_m
real(8) :: tmp
if (y <= 0.0075d0) then
tmp = x / z_m
else
tmp = y / ((z_m * y) / x)
end if
code = z_s * tmp
end function
z_m = Math.abs(z);
z_s = Math.copySign(1.0, z);
public static double code(double z_s, double x, double y, double z_m) {
double tmp;
if (y <= 0.0075) {
tmp = x / z_m;
} else {
tmp = y / ((z_m * y) / x);
}
return z_s * tmp;
}
z_m = math.fabs(z) z_s = math.copysign(1.0, z) def code(z_s, x, y, z_m): tmp = 0 if y <= 0.0075: tmp = x / z_m else: tmp = y / ((z_m * y) / x) return z_s * tmp
z_m = abs(z) z_s = copysign(1.0, z) function code(z_s, x, y, z_m) tmp = 0.0 if (y <= 0.0075) tmp = Float64(x / z_m); else tmp = Float64(y / Float64(Float64(z_m * y) / x)); end return Float64(z_s * tmp) end
z_m = abs(z); z_s = sign(z) * abs(1.0); function tmp_2 = code(z_s, x, y, z_m) tmp = 0.0; if (y <= 0.0075) tmp = x / z_m; else tmp = y / ((z_m * y) / x); end tmp_2 = z_s * tmp; end
z_m = N[Abs[z], $MachinePrecision]
z_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[z]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[z$95$s_, x_, y_, z$95$m_] := N[(z$95$s * If[LessEqual[y, 0.0075], N[(x / z$95$m), $MachinePrecision], N[(y / N[(N[(z$95$m * y), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
z_m = \left|z\right|
\\
z_s = \mathsf{copysign}\left(1, z\right)
\\
z\_s \cdot \begin{array}{l}
\mathbf{if}\;y \leq 0.0075:\\
\;\;\;\;\frac{x}{z\_m}\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{\frac{z\_m \cdot y}{x}}\\
\end{array}
\end{array}
if y < 0.0074999999999999997Initial program 97.3%
associate-*r/97.7%
associate-/l/85.6%
*-commutative85.6%
Simplified85.6%
Taylor expanded in y around 0 71.8%
if 0.0074999999999999997 < y Initial program 95.3%
associate-*r/91.1%
associate-/l/90.5%
*-commutative90.5%
Simplified90.5%
Taylor expanded in y around 0 16.8%
un-div-inv16.8%
clear-num16.8%
Applied egg-rr16.8%
associate-/l*16.8%
*-inverses16.8%
associate-/r/20.5%
associate-/r*26.8%
associate-/l/20.3%
div-inv20.3%
clear-num20.3%
Applied egg-rr20.3%
frac-times16.3%
associate-/l*26.9%
*-commutative26.9%
Applied egg-rr26.9%
Final simplification59.0%
z_m = (fabs.f64 z) z_s = (copysign.f64 1 z) (FPCore (z_s x y z_m) :precision binary64 (* z_s (/ x z_m)))
z_m = fabs(z);
z_s = copysign(1.0, z);
double code(double z_s, double x, double y, double z_m) {
return z_s * (x / z_m);
}
z_m = abs(z)
z_s = copysign(1.0d0, z)
real(8) function code(z_s, x, y, z_m)
real(8), intent (in) :: z_s
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z_m
code = z_s * (x / z_m)
end function
z_m = Math.abs(z);
z_s = Math.copySign(1.0, z);
public static double code(double z_s, double x, double y, double z_m) {
return z_s * (x / z_m);
}
z_m = math.fabs(z) z_s = math.copysign(1.0, z) def code(z_s, x, y, z_m): return z_s * (x / z_m)
z_m = abs(z) z_s = copysign(1.0, z) function code(z_s, x, y, z_m) return Float64(z_s * Float64(x / z_m)) end
z_m = abs(z); z_s = sign(z) * abs(1.0); function tmp = code(z_s, x, y, z_m) tmp = z_s * (x / z_m); end
z_m = N[Abs[z], $MachinePrecision]
z_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[z]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[z$95$s_, x_, y_, z$95$m_] := N[(z$95$s * N[(x / z$95$m), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
z_m = \left|z\right|
\\
z_s = \mathsf{copysign}\left(1, z\right)
\\
z\_s \cdot \frac{x}{z\_m}
\end{array}
Initial program 96.7%
associate-*r/95.8%
associate-/l/87.0%
*-commutative87.0%
Simplified87.0%
Taylor expanded in y around 0 56.1%
Final simplification56.1%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (/ y (sin y))) (t_1 (/ (* x (/ 1.0 t_0)) z)))
(if (< z -4.2173720203427147e-29)
t_1
(if (< z 4.446702369113811e+64) (/ x (* z t_0)) t_1))))
double code(double x, double y, double z) {
double t_0 = y / sin(y);
double t_1 = (x * (1.0 / t_0)) / z;
double tmp;
if (z < -4.2173720203427147e-29) {
tmp = t_1;
} else if (z < 4.446702369113811e+64) {
tmp = x / (z * t_0);
} 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
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = y / sin(y)
t_1 = (x * (1.0d0 / t_0)) / z
if (z < (-4.2173720203427147d-29)) then
tmp = t_1
else if (z < 4.446702369113811d+64) then
tmp = x / (z * t_0)
else
tmp = t_1
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = y / Math.sin(y);
double t_1 = (x * (1.0 / t_0)) / z;
double tmp;
if (z < -4.2173720203427147e-29) {
tmp = t_1;
} else if (z < 4.446702369113811e+64) {
tmp = x / (z * t_0);
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z): t_0 = y / math.sin(y) t_1 = (x * (1.0 / t_0)) / z tmp = 0 if z < -4.2173720203427147e-29: tmp = t_1 elif z < 4.446702369113811e+64: tmp = x / (z * t_0) else: tmp = t_1 return tmp
function code(x, y, z) t_0 = Float64(y / sin(y)) t_1 = Float64(Float64(x * Float64(1.0 / t_0)) / z) tmp = 0.0 if (z < -4.2173720203427147e-29) tmp = t_1; elseif (z < 4.446702369113811e+64) tmp = Float64(x / Float64(z * t_0)); else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z) t_0 = y / sin(y); t_1 = (x * (1.0 / t_0)) / z; tmp = 0.0; if (z < -4.2173720203427147e-29) tmp = t_1; elseif (z < 4.446702369113811e+64) tmp = x / (z * t_0); else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(y / N[Sin[y], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(x * N[(1.0 / t$95$0), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]}, If[Less[z, -4.2173720203427147e-29], t$95$1, If[Less[z, 4.446702369113811e+64], N[(x / N[(z * t$95$0), $MachinePrecision]), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{y}{\sin y}\\
t_1 := \frac{x \cdot \frac{1}{t\_0}}{z}\\
\mathbf{if}\;z < -4.2173720203427147 \cdot 10^{-29}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z < 4.446702369113811 \cdot 10^{+64}:\\
\;\;\;\;\frac{x}{z \cdot t\_0}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
herbie shell --seed 2024029
(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))