
(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 2e-20) (/ x (/ y (/ (sin y) z_m))) (/ (/ x z_m) (/ y (sin 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 (z_m <= 2e-20) {
tmp = x / (y / (sin(y) / z_m));
} else {
tmp = (x / z_m) / (y / sin(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 (z_m <= 2d-20) then
tmp = x / (y / (sin(y) / z_m))
else
tmp = (x / z_m) / (y / sin(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 (z_m <= 2e-20) {
tmp = x / (y / (Math.sin(y) / z_m));
} else {
tmp = (x / z_m) / (y / Math.sin(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 z_m <= 2e-20: tmp = x / (y / (math.sin(y) / z_m)) else: tmp = (x / z_m) / (y / math.sin(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 (z_m <= 2e-20) tmp = Float64(x / Float64(y / Float64(sin(y) / z_m))); else tmp = Float64(Float64(x / z_m) / Float64(y / sin(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 (z_m <= 2e-20) tmp = x / (y / (sin(y) / z_m)); else tmp = (x / z_m) / (y / sin(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[z$95$m, 2e-20], N[(x / N[(y / N[(N[Sin[y], $MachinePrecision] / z$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x / z$95$m), $MachinePrecision] / N[(y / N[Sin[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}\;z_m \leq 2 \cdot 10^{-20}:\\
\;\;\;\;\frac{x}{\frac{y}{\frac{\sin y}{z_m}}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{x}{z_m}}{\frac{y}{\sin y}}\\
\end{array}
\end{array}
if z < 1.99999999999999989e-20Initial program 95.7%
associate-*r/97.1%
associate-/l/84.0%
*-commutative84.0%
Simplified84.0%
clear-num83.9%
un-div-inv84.0%
associate-/l*93.9%
Applied egg-rr93.9%
if 1.99999999999999989e-20 < z Initial program 99.8%
associate-*r/92.4%
associate-/l/90.6%
*-commutative90.6%
Simplified90.6%
associate-*r/87.9%
*-commutative87.9%
frac-times99.8%
clear-num99.8%
un-div-inv99.9%
Applied egg-rr99.9%
Final simplification95.4%
z_m = (fabs.f64 z) z_s = (copysign.f64 1 z) (FPCore (z_s x y z_m) :precision binary64 (* z_s (if (<= y 5e-21) (/ 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 <= 5e-21) {
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 <= 5d-21) 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 <= 5e-21) {
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 <= 5e-21: 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 <= 5e-21) 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 <= 5e-21) 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, 5e-21], 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 5 \cdot 10^{-21}:\\
\;\;\;\;\frac{x}{z_m}\\
\mathbf{else}:\\
\;\;\;\;x \cdot \frac{\sin y}{z_m \cdot y}\\
\end{array}
\end{array}
if y < 4.99999999999999973e-21Initial program 97.9%
Taylor expanded in y around 0 72.9%
if 4.99999999999999973e-21 < y Initial program 93.4%
associate-*r/88.4%
associate-/l/86.0%
*-commutative86.0%
Simplified86.0%
Final simplification76.4%
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.7e-14) (/ 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 <= 2.7e-14) {
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 <= 2.7d-14) 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 <= 2.7e-14) {
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 <= 2.7e-14: 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 <= 2.7e-14) 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 <= 2.7e-14) 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, 2.7e-14], 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 2.7 \cdot 10^{-14}:\\
\;\;\;\;\frac{x}{z_m}\\
\mathbf{else}:\\
\;\;\;\;\sin y \cdot \frac{\frac{x}{y}}{z_m}\\
\end{array}
\end{array}
if y < 2.6999999999999999e-14Initial program 97.9%
Taylor expanded in y around 0 73.0%
if 2.6999999999999999e-14 < y Initial program 93.3%
*-lft-identity93.3%
metadata-eval93.3%
times-frac93.3%
neg-mul-193.3%
distribute-lft-neg-out93.3%
associate-*r/93.4%
associate-*l/93.3%
*-commutative93.3%
times-frac93.5%
remove-double-neg93.5%
distribute-frac-neg93.5%
sin-neg93.5%
sin-neg93.5%
neg-mul-193.5%
associate-/l*93.4%
associate-/r/93.5%
distribute-lft-neg-in93.5%
metadata-eval93.5%
metadata-eval93.5%
neg-mul-193.5%
sin-neg93.5%
*-commutative93.5%
Simplified93.5%
Final simplification78.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 1.25e+167)
(* (/ x z_m) (/ (sin y) y))
(* (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 <= 1.25e+167) {
tmp = (x / z_m) * (sin(y) / y);
} 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 <= 1.25d+167) then
tmp = (x / z_m) * (sin(y) / y)
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 <= 1.25e+167) {
tmp = (x / z_m) * (Math.sin(y) / y);
} 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 <= 1.25e+167: tmp = (x / z_m) * (math.sin(y) / y) 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 <= 1.25e+167) tmp = Float64(Float64(x / z_m) * Float64(sin(y) / y)); 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 <= 1.25e+167) tmp = (x / z_m) * (sin(y) / y); 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, 1.25e+167], N[(N[(x / z$95$m), $MachinePrecision] * N[(N[Sin[y], $MachinePrecision] / y), $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 1.25 \cdot 10^{+167}:\\
\;\;\;\;\frac{x}{z_m} \cdot \frac{\sin y}{y}\\
\mathbf{else}:\\
\;\;\;\;\sin y \cdot \frac{\frac{x}{y}}{z_m}\\
\end{array}
\end{array}
if y < 1.2499999999999999e167Initial program 96.9%
*-commutative96.9%
associate-*r/96.5%
Simplified96.5%
if 1.2499999999999999e167 < y Initial program 95.3%
*-lft-identity95.3%
metadata-eval95.3%
times-frac95.3%
neg-mul-195.3%
distribute-lft-neg-out95.3%
associate-*r/95.3%
associate-*l/95.4%
*-commutative95.4%
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 simplification96.4%
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 2.45e-20)
(/ x (/ y (/ (sin y) z_m)))
(* (/ x z_m) (/ (sin y) 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 (z_m <= 2.45e-20) {
tmp = x / (y / (sin(y) / z_m));
} else {
tmp = (x / z_m) * (sin(y) / 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 (z_m <= 2.45d-20) then
tmp = x / (y / (sin(y) / z_m))
else
tmp = (x / z_m) * (sin(y) / 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 (z_m <= 2.45e-20) {
tmp = x / (y / (Math.sin(y) / z_m));
} else {
tmp = (x / z_m) * (Math.sin(y) / 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 z_m <= 2.45e-20: tmp = x / (y / (math.sin(y) / z_m)) else: tmp = (x / z_m) * (math.sin(y) / 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 (z_m <= 2.45e-20) tmp = Float64(x / Float64(y / Float64(sin(y) / z_m))); else tmp = Float64(Float64(x / z_m) * Float64(sin(y) / 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 (z_m <= 2.45e-20) tmp = x / (y / (sin(y) / z_m)); else tmp = (x / z_m) * (sin(y) / 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[z$95$m, 2.45e-20], N[(x / N[(y / N[(N[Sin[y], $MachinePrecision] / z$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x / z$95$m), $MachinePrecision] * N[(N[Sin[y], $MachinePrecision] / y), $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 2.45 \cdot 10^{-20}:\\
\;\;\;\;\frac{x}{\frac{y}{\frac{\sin y}{z_m}}}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{z_m} \cdot \frac{\sin y}{y}\\
\end{array}
\end{array}
if z < 2.4500000000000001e-20Initial program 95.7%
associate-*r/97.1%
associate-/l/84.0%
*-commutative84.0%
Simplified84.0%
clear-num83.9%
un-div-inv84.0%
associate-/l*93.9%
Applied egg-rr93.9%
if 2.4500000000000001e-20 < z Initial program 99.8%
*-commutative99.8%
associate-*r/99.8%
Simplified99.8%
Final simplification95.4%
z_m = (fabs.f64 z) z_s = (copysign.f64 1 z) (FPCore (z_s x y z_m) :precision binary64 (let* ((t_0 (/ (sin y) y))) (* z_s (if (<= z_m 1e+16) (/ x (/ z_m t_0)) (* (/ x z_m) t_0)))))
z_m = fabs(z);
z_s = copysign(1.0, z);
double code(double z_s, double x, double y, double z_m) {
double t_0 = sin(y) / y;
double tmp;
if (z_m <= 1e+16) {
tmp = x / (z_m / t_0);
} else {
tmp = (x / z_m) * t_0;
}
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) :: t_0
real(8) :: tmp
t_0 = sin(y) / y
if (z_m <= 1d+16) then
tmp = x / (z_m / t_0)
else
tmp = (x / z_m) * t_0
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 t_0 = Math.sin(y) / y;
double tmp;
if (z_m <= 1e+16) {
tmp = x / (z_m / t_0);
} else {
tmp = (x / z_m) * t_0;
}
return z_s * tmp;
}
z_m = math.fabs(z) z_s = math.copysign(1.0, z) def code(z_s, x, y, z_m): t_0 = math.sin(y) / y tmp = 0 if z_m <= 1e+16: tmp = x / (z_m / t_0) else: tmp = (x / z_m) * t_0 return z_s * tmp
z_m = abs(z) z_s = copysign(1.0, z) function code(z_s, x, y, z_m) t_0 = Float64(sin(y) / y) tmp = 0.0 if (z_m <= 1e+16) tmp = Float64(x / Float64(z_m / t_0)); else tmp = Float64(Float64(x / z_m) * t_0); 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) t_0 = sin(y) / y; tmp = 0.0; if (z_m <= 1e+16) tmp = x / (z_m / t_0); else tmp = (x / z_m) * t_0; 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_] := Block[{t$95$0 = N[(N[Sin[y], $MachinePrecision] / y), $MachinePrecision]}, N[(z$95$s * If[LessEqual[z$95$m, 1e+16], N[(x / N[(z$95$m / t$95$0), $MachinePrecision]), $MachinePrecision], N[(N[(x / z$95$m), $MachinePrecision] * t$95$0), $MachinePrecision]]), $MachinePrecision]]
\begin{array}{l}
z_m = \left|z\right|
\\
z_s = \mathsf{copysign}\left(1, z\right)
\\
\begin{array}{l}
t_0 := \frac{\sin y}{y}\\
z_s \cdot \begin{array}{l}
\mathbf{if}\;z_m \leq 10^{+16}:\\
\;\;\;\;\frac{x}{\frac{z_m}{t_0}}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{z_m} \cdot t_0\\
\end{array}
\end{array}
\end{array}
if z < 1e16Initial program 95.8%
associate-/l*97.0%
Simplified97.0%
if 1e16 < z Initial program 99.7%
*-commutative99.7%
associate-*r/99.8%
Simplified99.8%
Final simplification97.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 4.6e+74) (/ 1.0 (/ z_m x)) (/ x (/ (* z_m (- y)) 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 <= 4.6e+74) {
tmp = 1.0 / (z_m / x);
} else {
tmp = x / ((z_m * -y) / 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 <= 4.6d+74) then
tmp = 1.0d0 / (z_m / x)
else
tmp = x / ((z_m * -y) / 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 <= 4.6e+74) {
tmp = 1.0 / (z_m / x);
} else {
tmp = x / ((z_m * -y) / 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 <= 4.6e+74: tmp = 1.0 / (z_m / x) else: tmp = x / ((z_m * -y) / 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 <= 4.6e+74) tmp = Float64(1.0 / Float64(z_m / x)); else tmp = Float64(x / Float64(Float64(z_m * Float64(-y)) / 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 <= 4.6e+74) tmp = 1.0 / (z_m / x); else tmp = x / ((z_m * -y) / 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, 4.6e+74], N[(1.0 / N[(z$95$m / x), $MachinePrecision]), $MachinePrecision], N[(x / N[(N[(z$95$m * (-y)), $MachinePrecision] / y), $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.6 \cdot 10^{+74}:\\
\;\;\;\;\frac{1}{\frac{z_m}{x}}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{\frac{z_m \cdot \left(-y\right)}{y}}\\
\end{array}
\end{array}
if y < 4.5999999999999997e74Initial program 98.1%
associate-*r/98.8%
associate-/l/86.8%
*-commutative86.8%
Simplified86.8%
Taylor expanded in y around 0 70.4%
div-inv70.7%
clear-num71.0%
Applied egg-rr71.0%
if 4.5999999999999997e74 < y Initial program 90.9%
associate-*r/83.9%
associate-/l/80.5%
*-commutative80.5%
Simplified80.5%
clear-num80.4%
un-div-inv80.5%
associate-/l*80.5%
Applied egg-rr80.5%
Taylor expanded in y around 0 21.3%
frac-2neg21.3%
div-inv21.3%
distribute-neg-frac21.3%
Applied egg-rr21.3%
un-div-inv21.3%
neg-mul-121.3%
*-commutative21.3%
clear-num21.3%
associate-/r/21.3%
frac-times33.6%
associate-*r/33.6%
associate-/r/33.6%
/-rgt-identity33.6%
*-commutative33.6%
add-sqr-sqrt0.0%
sqrt-unprod3.7%
sqr-neg3.7%
sqrt-unprod31.2%
add-sqr-sqrt31.2%
Applied egg-rr31.2%
Final simplification63.4%
z_m = (fabs.f64 z) z_s = (copysign.f64 1 z) (FPCore (z_s x y z_m) :precision binary64 (* z_s (if (<= y 1e-6) (/ x z_m) (/ x (/ (* z_m y) 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 <= 1e-6) {
tmp = x / z_m;
} else {
tmp = x / ((z_m * y) / 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 <= 1d-6) then
tmp = x / z_m
else
tmp = x / ((z_m * y) / 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 <= 1e-6) {
tmp = x / z_m;
} else {
tmp = x / ((z_m * y) / 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 <= 1e-6: tmp = x / z_m else: tmp = x / ((z_m * y) / 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 <= 1e-6) tmp = Float64(x / z_m); else tmp = Float64(x / Float64(Float64(z_m * y) / 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 <= 1e-6) tmp = x / z_m; else tmp = x / ((z_m * y) / 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, 1e-6], N[(x / z$95$m), $MachinePrecision], N[(x / N[(N[(z$95$m * y), $MachinePrecision] / y), $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 10^{-6}:\\
\;\;\;\;\frac{x}{z_m}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{\frac{z_m \cdot y}{y}}\\
\end{array}
\end{array}
if y < 9.99999999999999955e-7Initial program 98.0%
Taylor expanded in y around 0 73.4%
if 9.99999999999999955e-7 < y Initial program 93.0%
associate-*r/87.7%
associate-/l/85.2%
*-commutative85.2%
Simplified85.2%
clear-num85.1%
un-div-inv85.2%
associate-/l*85.3%
Applied egg-rr85.3%
Taylor expanded in y around 0 25.4%
frac-2neg25.4%
div-inv25.4%
distribute-neg-frac25.4%
Applied egg-rr25.4%
distribute-lft-neg-out25.4%
distribute-rgt-neg-in25.4%
clear-num25.5%
distribute-frac-neg25.5%
frac-2neg25.5%
associate-*r/35.2%
*-commutative35.2%
Applied egg-rr35.2%
Final simplification63.7%
z_m = (fabs.f64 z) z_s = (copysign.f64 1 z) (FPCore (z_s x y z_m) :precision binary64 (* z_s (/ 1.0 (/ z_m x))))
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 * (1.0 / (z_m / x));
}
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 * (1.0d0 / (z_m / x))
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 * (1.0 / (z_m / x));
}
z_m = math.fabs(z) z_s = math.copysign(1.0, z) def code(z_s, x, y, z_m): return z_s * (1.0 / (z_m / x))
z_m = abs(z) z_s = copysign(1.0, z) function code(z_s, x, y, z_m) return Float64(z_s * Float64(1.0 / Float64(z_m / x))) end
z_m = abs(z); z_s = sign(z) * abs(1.0); function tmp = code(z_s, x, y, z_m) tmp = z_s * (1.0 / (z_m / x)); 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[(1.0 / N[(z$95$m / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
z_m = \left|z\right|
\\
z_s = \mathsf{copysign}\left(1, z\right)
\\
z_s \cdot \frac{1}{\frac{z_m}{x}}
\end{array}
Initial program 96.7%
associate-*r/95.9%
associate-/l/85.6%
*-commutative85.6%
Simplified85.6%
Taylor expanded in y around 0 61.1%
div-inv61.3%
clear-num61.5%
Applied egg-rr61.5%
Final simplification61.5%
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%
Taylor expanded in y around 0 61.3%
Final simplification61.3%
(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 2023334
(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))