
(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 #s(literal 1 binary64) z) (FPCore (z_s x y z_m) :precision binary64 (* z_s (if (<= z_m 8e-81) (/ x (* y (/ z_m (sin y)))) (/ (/ x (/ y (sin 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 <= 8e-81) {
tmp = x / (y * (z_m / sin(y)));
} else {
tmp = (x / (y / sin(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 <= 8d-81) then
tmp = x / (y * (z_m / sin(y)))
else
tmp = (x / (y / sin(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 <= 8e-81) {
tmp = x / (y * (z_m / Math.sin(y)));
} else {
tmp = (x / (y / Math.sin(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 <= 8e-81: tmp = x / (y * (z_m / math.sin(y))) else: tmp = (x / (y / math.sin(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 <= 8e-81) tmp = Float64(x / Float64(y * Float64(z_m / sin(y)))); else tmp = Float64(Float64(x / Float64(y / sin(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 <= 8e-81) tmp = x / (y * (z_m / sin(y))); else tmp = (x / (y / sin(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, 8e-81], N[(x / N[(y * N[(z$95$m / N[Sin[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x / N[(y / N[Sin[y], $MachinePrecision]), $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 8 \cdot 10^{-81}:\\
\;\;\;\;\frac{x}{y \cdot \frac{z\_m}{\sin y}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{x}{\frac{y}{\sin y}}}{z\_m}\\
\end{array}
\end{array}
if z < 7.9999999999999997e-81Initial program 95.3%
associate-/l*94.5%
associate-/l/86.9%
*-commutative86.9%
Simplified86.9%
associate-/r*94.5%
clear-num93.9%
un-div-inv94.6%
clear-num94.0%
associate-/r*86.9%
clear-num87.0%
associate-/l*90.0%
Applied egg-rr90.0%
if 7.9999999999999997e-81 < z Initial program 99.8%
clear-num99.8%
un-div-inv99.8%
Applied egg-rr99.8%
Final simplification92.8%
z\_m = (fabs.f64 z) z\_s = (copysign.f64 #s(literal 1 binary64) z) (FPCore (z_s x y z_m) :precision binary64 (* z_s (if (<= y 4e-15) (/ 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 <= 4e-15) {
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 <= 4d-15) 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 <= 4e-15) {
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 <= 4e-15: 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 <= 4e-15) 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 <= 4e-15) 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, 4e-15], 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 4 \cdot 10^{-15}:\\
\;\;\;\;\frac{x}{z\_m}\\
\mathbf{else}:\\
\;\;\;\;x \cdot \frac{\sin y}{z\_m \cdot y}\\
\end{array}
\end{array}
if y < 4.0000000000000003e-15Initial program 97.0%
associate-/l*95.6%
associate-/l/87.5%
*-commutative87.5%
Simplified87.5%
Taylor expanded in y around 0 66.3%
if 4.0000000000000003e-15 < y Initial program 95.7%
associate-/l*91.7%
associate-/l/90.5%
*-commutative90.5%
Simplified90.5%
Final simplification73.2%
z\_m = (fabs.f64 z)
z\_s = (copysign.f64 #s(literal 1 binary64) z)
(FPCore (z_s x y z_m)
:precision binary64
(*
z_s
(if (<= z_m 2.45e+38)
(* x (/ (/ (sin y) y) 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 (z_m <= 2.45e+38) {
tmp = x * ((sin(y) / y) / 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 (z_m <= 2.45d+38) then
tmp = x * ((sin(y) / y) / 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 (z_m <= 2.45e+38) {
tmp = x * ((Math.sin(y) / y) / 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 z_m <= 2.45e+38: tmp = x * ((math.sin(y) / y) / 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 (z_m <= 2.45e+38) tmp = Float64(x * Float64(Float64(sin(y) / y) / 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 (z_m <= 2.45e+38) tmp = x * ((sin(y) / y) / 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[z$95$m, 2.45e+38], N[(x * N[(N[(N[Sin[y], $MachinePrecision] / y), $MachinePrecision] / 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}\;z\_m \leq 2.45 \cdot 10^{+38}:\\
\;\;\;\;x \cdot \frac{\frac{\sin y}{y}}{z\_m}\\
\mathbf{else}:\\
\;\;\;\;\sin y \cdot \frac{\frac{x}{y}}{z\_m}\\
\end{array}
\end{array}
if z < 2.45000000000000001e38Initial program 95.9%
associate-/l*95.2%
Simplified95.2%
if 2.45000000000000001e38 < z Initial program 99.8%
*-commutative99.8%
associate-*l/99.0%
associate-/l*99.8%
associate-/l*99.8%
Simplified99.8%
Final simplification96.0%
z\_m = (fabs.f64 z)
z\_s = (copysign.f64 #s(literal 1 binary64) z)
(FPCore (z_s x y z_m)
:precision binary64
(*
z_s
(if (<= z_m 5.5e+39)
(/ x (* y (/ z_m (sin 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 (z_m <= 5.5e+39) {
tmp = x / (y * (z_m / sin(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 (z_m <= 5.5d+39) then
tmp = x / (y * (z_m / sin(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 (z_m <= 5.5e+39) {
tmp = x / (y * (z_m / Math.sin(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 z_m <= 5.5e+39: tmp = x / (y * (z_m / math.sin(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 (z_m <= 5.5e+39) tmp = Float64(x / Float64(y * Float64(z_m / sin(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 (z_m <= 5.5e+39) tmp = x / (y * (z_m / sin(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[z$95$m, 5.5e+39], N[(x / N[(y * N[(z$95$m / N[Sin[y], $MachinePrecision]), $MachinePrecision]), $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}\;z\_m \leq 5.5 \cdot 10^{+39}:\\
\;\;\;\;\frac{x}{y \cdot \frac{z\_m}{\sin y}}\\
\mathbf{else}:\\
\;\;\;\;\sin y \cdot \frac{\frac{x}{y}}{z\_m}\\
\end{array}
\end{array}
if z < 5.4999999999999997e39Initial program 95.9%
associate-/l*95.2%
associate-/l/87.7%
*-commutative87.7%
Simplified87.7%
associate-/r*95.2%
clear-num94.7%
un-div-inv95.3%
clear-num94.8%
associate-/r*87.7%
clear-num87.8%
associate-/l*91.3%
Applied egg-rr91.3%
if 5.4999999999999997e39 < z Initial program 99.8%
*-commutative99.8%
associate-*l/99.0%
associate-/l*99.8%
associate-/l*99.8%
Simplified99.8%
Final simplification92.8%
z\_m = (fabs.f64 z)
z\_s = (copysign.f64 #s(literal 1 binary64) z)
(FPCore (z_s x y z_m)
:precision binary64
(*
z_s
(if (<= z_m 420000000.0)
(/ x (* y (/ z_m (sin y))))
(/ (* 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 <= 420000000.0) {
tmp = x / (y * (z_m / sin(y)));
} 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 <= 420000000.0d0) then
tmp = x / (y * (z_m / sin(y)))
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 <= 420000000.0) {
tmp = x / (y * (z_m / Math.sin(y)));
} 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 <= 420000000.0: tmp = x / (y * (z_m / math.sin(y))) 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 <= 420000000.0) tmp = Float64(x / Float64(y * Float64(z_m / sin(y)))); 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 <= 420000000.0) tmp = x / (y * (z_m / sin(y))); 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, 420000000.0], N[(x / N[(y * N[(z$95$m / N[Sin[y], $MachinePrecision]), $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 420000000:\\
\;\;\;\;\frac{x}{y \cdot \frac{z\_m}{\sin y}}\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot \frac{\sin y}{y}}{z\_m}\\
\end{array}
\end{array}
if z < 4.2e8Initial program 95.9%
associate-/l*95.1%
associate-/l/87.5%
*-commutative87.5%
Simplified87.5%
associate-/r*95.1%
clear-num94.6%
un-div-inv95.2%
clear-num94.7%
associate-/r*87.5%
clear-num87.6%
associate-/l*91.2%
Applied egg-rr91.2%
if 4.2e8 < z Initial program 99.8%
Final simplification92.8%
z\_m = (fabs.f64 z) z\_s = (copysign.f64 #s(literal 1 binary64) z) (FPCore (z_s x y z_m) :precision binary64 (* z_s (* 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) {
return z_s * (x * ((sin(y) / y) / 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 * ((sin(y) / y) / 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 * ((Math.sin(y) / y) / 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 * ((math.sin(y) / y) / 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 * Float64(Float64(sin(y) / y) / 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 * ((sin(y) / y) / 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 * N[(N[(N[Sin[y], $MachinePrecision] / 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 \left(x \cdot \frac{\frac{\sin y}{y}}{z\_m}\right)
\end{array}
Initial program 96.6%
associate-/l*94.5%
Simplified94.5%
Final simplification94.5%
z\_m = (fabs.f64 z) z\_s = (copysign.f64 #s(literal 1 binary64) z) (FPCore (z_s x y z_m) :precision binary64 (* z_s (if (<= y 1.65e+132) (/ x z_m) (* x (/ 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 <= 1.65e+132) {
tmp = x / z_m;
} else {
tmp = x * (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 <= 1.65d+132) then
tmp = x / z_m
else
tmp = x * (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 <= 1.65e+132) {
tmp = x / z_m;
} else {
tmp = x * (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 <= 1.65e+132: tmp = x / z_m else: tmp = x * (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 <= 1.65e+132) tmp = Float64(x / z_m); else tmp = Float64(x * Float64(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 <= 1.65e+132) tmp = x / z_m; else tmp = x * (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, 1.65e+132], N[(x / z$95$m), $MachinePrecision], N[(x * N[(y / 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 1.65 \cdot 10^{+132}:\\
\;\;\;\;\frac{x}{z\_m}\\
\mathbf{else}:\\
\;\;\;\;x \cdot \frac{y}{z\_m \cdot y}\\
\end{array}
\end{array}
if y < 1.65000000000000015e132Initial program 97.0%
associate-/l*96.1%
associate-/l/89.2%
*-commutative89.2%
Simplified89.2%
Taylor expanded in y around 0 61.2%
if 1.65000000000000015e132 < y Initial program 94.2%
associate-/l*83.8%
associate-/l/82.9%
*-commutative82.9%
Simplified82.9%
Taylor expanded in y around 0 26.6%
Final simplification56.6%
z\_m = (fabs.f64 z) z\_s = (copysign.f64 #s(literal 1 binary64) z) (FPCore (z_s x y z_m) :precision binary64 (* z_s (if (<= y 1e+73) (/ x z_m) (* 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 <= 1e+73) {
tmp = x / z_m;
} else {
tmp = 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 <= 1d+73) then
tmp = x / z_m
else
tmp = 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 <= 1e+73) {
tmp = x / z_m;
} else {
tmp = 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 <= 1e+73: tmp = x / z_m else: tmp = 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 <= 1e+73) tmp = Float64(x / z_m); else tmp = Float64(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 <= 1e+73) tmp = x / z_m; else tmp = 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, 1e+73], N[(x / z$95$m), $MachinePrecision], N[(y * 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 10^{+73}:\\
\;\;\;\;\frac{x}{z\_m}\\
\mathbf{else}:\\
\;\;\;\;y \cdot \frac{\frac{x}{y}}{z\_m}\\
\end{array}
\end{array}
if y < 9.99999999999999983e72Initial program 97.3%
associate-/l*96.1%
associate-/l/89.0%
*-commutative89.0%
Simplified89.0%
Taylor expanded in y around 0 64.0%
if 9.99999999999999983e72 < y Initial program 93.6%
*-commutative93.6%
associate-*l/93.6%
associate-/l*93.4%
associate-/l*93.3%
Simplified93.3%
Taylor expanded in y around 0 36.9%
Final simplification59.1%
z\_m = (fabs.f64 z) z\_s = (copysign.f64 #s(literal 1 binary64) z) (FPCore (z_s x y z_m) :precision binary64 (* z_s (if (<= y 1.02e-10) (/ 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 <= 1.02e-10) {
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 <= 1.02d-10) 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 <= 1.02e-10) {
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 <= 1.02e-10: 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 <= 1.02e-10) 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 <= 1.02e-10) 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, 1.02e-10], 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 1.02 \cdot 10^{-10}:\\
\;\;\;\;\frac{x}{z\_m}\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{z\_m \cdot \frac{y}{x}}\\
\end{array}
\end{array}
if y < 1.01999999999999997e-10Initial program 97.0%
associate-/l*95.7%
associate-/l/87.6%
*-commutative87.6%
Simplified87.6%
Taylor expanded in y around 0 66.7%
if 1.01999999999999997e-10 < y Initial program 95.6%
associate-/l*91.4%
associate-/l/90.3%
*-commutative90.3%
Simplified90.3%
Taylor expanded in y around 0 30.4%
associate-*r/27.1%
*-commutative27.1%
associate-/r*27.3%
Applied egg-rr27.3%
associate-/l/27.1%
times-frac32.5%
Applied egg-rr32.5%
clear-num32.5%
frac-times39.9%
*-un-lft-identity39.9%
Applied egg-rr39.9%
Final simplification59.2%
z\_m = (fabs.f64 z) z\_s = (copysign.f64 #s(literal 1 binary64) 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.6%
associate-/l*94.5%
associate-/l/88.4%
*-commutative88.4%
Simplified88.4%
Taylor expanded in y around 0 55.8%
Final simplification55.8%
(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 2024078
(FPCore (x y z)
:name "Linear.Quaternion:$ctanh from linear-1.19.1.3"
:precision binary64
:alt
(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))