
(FPCore (x y z) :precision binary64 (/ (* x (+ y z)) z))
double code(double x, double y, double z) {
return (x * (y + z)) / 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 * (y + z)) / z
end function
public static double code(double x, double y, double z) {
return (x * (y + z)) / z;
}
def code(x, y, z): return (x * (y + z)) / z
function code(x, y, z) return Float64(Float64(x * Float64(y + z)) / z) end
function tmp = code(x, y, z) tmp = (x * (y + z)) / z; end
code[x_, y_, z_] := N[(N[(x * N[(y + z), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]
\begin{array}{l}
\\
\frac{x \cdot \left(y + z\right)}{z}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 8 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 (/ (* x (+ y z)) z))
double code(double x, double y, double z) {
return (x * (y + z)) / 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 * (y + z)) / z
end function
public static double code(double x, double y, double z) {
return (x * (y + z)) / z;
}
def code(x, y, z): return (x * (y + z)) / z
function code(x, y, z) return Float64(Float64(x * Float64(y + z)) / z) end
function tmp = code(x, y, z) tmp = (x * (y + z)) / z; end
code[x_, y_, z_] := N[(N[(x * N[(y + z), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]
\begin{array}{l}
\\
\frac{x \cdot \left(y + z\right)}{z}
\end{array}
x_m = (fabs.f64 x) x_s = (copysign.f64 1 x) (FPCore (x_s x_m y z) :precision binary64 (* x_s (if (<= x_m 1.6e-48) (+ x_m (/ 1.0 (/ z (* x_m y)))) (fma x_m (/ y z) x_m))))
x_m = fabs(x);
x_s = copysign(1.0, x);
double code(double x_s, double x_m, double y, double z) {
double tmp;
if (x_m <= 1.6e-48) {
tmp = x_m + (1.0 / (z / (x_m * y)));
} else {
tmp = fma(x_m, (y / z), x_m);
}
return x_s * tmp;
}
x_m = abs(x) x_s = copysign(1.0, x) function code(x_s, x_m, y, z) tmp = 0.0 if (x_m <= 1.6e-48) tmp = Float64(x_m + Float64(1.0 / Float64(z / Float64(x_m * y)))); else tmp = fma(x_m, Float64(y / z), x_m); end return Float64(x_s * tmp) end
x_m = N[Abs[x], $MachinePrecision]
x_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[x$95$s_, x$95$m_, y_, z_] := N[(x$95$s * If[LessEqual[x$95$m, 1.6e-48], N[(x$95$m + N[(1.0 / N[(z / N[(x$95$m * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x$95$m * N[(y / z), $MachinePrecision] + x$95$m), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
x_m = \left|x\right|
\\
x_s = \mathsf{copysign}\left(1, x\right)
\\
x\_s \cdot \begin{array}{l}
\mathbf{if}\;x\_m \leq 1.6 \cdot 10^{-48}:\\
\;\;\;\;x\_m + \frac{1}{\frac{z}{x\_m \cdot y}}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(x\_m, \frac{y}{z}, x\_m\right)\\
\end{array}
\end{array}
if x < 1.5999999999999999e-48Initial program 86.4%
remove-double-neg86.4%
distribute-lft-neg-out86.4%
*-commutative86.4%
distribute-lft-neg-in86.4%
associate-/l*83.4%
distribute-neg-in83.4%
unsub-neg83.4%
div-sub80.3%
distribute-frac-neg80.3%
associate-/r/74.9%
distribute-rgt-neg-out74.9%
remove-double-neg74.9%
associate-/r/90.6%
*-inverses90.6%
*-lft-identity90.6%
*-commutative90.6%
fma-neg90.6%
remove-double-neg90.6%
Simplified90.6%
fma-udef90.6%
Applied egg-rr90.6%
associate-*r/92.3%
clear-num92.3%
Applied egg-rr92.3%
if 1.5999999999999999e-48 < x Initial program 70.9%
remove-double-neg70.9%
distribute-lft-neg-out70.9%
*-commutative70.9%
distribute-lft-neg-in70.9%
associate-/l*94.3%
distribute-neg-in94.3%
unsub-neg94.3%
div-sub89.3%
distribute-frac-neg89.3%
associate-/r/90.0%
distribute-rgt-neg-out90.0%
remove-double-neg90.0%
associate-/r/99.8%
*-inverses99.8%
*-lft-identity99.8%
*-commutative99.8%
fma-neg99.9%
remove-double-neg99.9%
Simplified99.9%
Final simplification94.1%
x_m = (fabs.f64 x)
x_s = (copysign.f64 1 x)
(FPCore (x_s x_m y z)
:precision binary64
(*
x_s
(if (or (<= z -1.45e-61) (not (<= z 2.5e-7)))
(+ x_m (* x_m (/ y z)))
(* (+ z y) (/ x_m z)))))x_m = fabs(x);
x_s = copysign(1.0, x);
double code(double x_s, double x_m, double y, double z) {
double tmp;
if ((z <= -1.45e-61) || !(z <= 2.5e-7)) {
tmp = x_m + (x_m * (y / z));
} else {
tmp = (z + y) * (x_m / z);
}
return x_s * tmp;
}
x_m = abs(x)
x_s = copysign(1.0d0, x)
real(8) function code(x_s, x_m, y, z)
real(8), intent (in) :: x_s
real(8), intent (in) :: x_m
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if ((z <= (-1.45d-61)) .or. (.not. (z <= 2.5d-7))) then
tmp = x_m + (x_m * (y / z))
else
tmp = (z + y) * (x_m / z)
end if
code = x_s * tmp
end function
x_m = Math.abs(x);
x_s = Math.copySign(1.0, x);
public static double code(double x_s, double x_m, double y, double z) {
double tmp;
if ((z <= -1.45e-61) || !(z <= 2.5e-7)) {
tmp = x_m + (x_m * (y / z));
} else {
tmp = (z + y) * (x_m / z);
}
return x_s * tmp;
}
x_m = math.fabs(x) x_s = math.copysign(1.0, x) def code(x_s, x_m, y, z): tmp = 0 if (z <= -1.45e-61) or not (z <= 2.5e-7): tmp = x_m + (x_m * (y / z)) else: tmp = (z + y) * (x_m / z) return x_s * tmp
x_m = abs(x) x_s = copysign(1.0, x) function code(x_s, x_m, y, z) tmp = 0.0 if ((z <= -1.45e-61) || !(z <= 2.5e-7)) tmp = Float64(x_m + Float64(x_m * Float64(y / z))); else tmp = Float64(Float64(z + y) * Float64(x_m / z)); end return Float64(x_s * tmp) end
x_m = abs(x); x_s = sign(x) * abs(1.0); function tmp_2 = code(x_s, x_m, y, z) tmp = 0.0; if ((z <= -1.45e-61) || ~((z <= 2.5e-7))) tmp = x_m + (x_m * (y / z)); else tmp = (z + y) * (x_m / z); end tmp_2 = x_s * tmp; end
x_m = N[Abs[x], $MachinePrecision]
x_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[x$95$s_, x$95$m_, y_, z_] := N[(x$95$s * If[Or[LessEqual[z, -1.45e-61], N[Not[LessEqual[z, 2.5e-7]], $MachinePrecision]], N[(x$95$m + N[(x$95$m * N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(z + y), $MachinePrecision] * N[(x$95$m / z), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
x_m = \left|x\right|
\\
x_s = \mathsf{copysign}\left(1, x\right)
\\
x\_s \cdot \begin{array}{l}
\mathbf{if}\;z \leq -1.45 \cdot 10^{-61} \lor \neg \left(z \leq 2.5 \cdot 10^{-7}\right):\\
\;\;\;\;x\_m + x\_m \cdot \frac{y}{z}\\
\mathbf{else}:\\
\;\;\;\;\left(z + y\right) \cdot \frac{x\_m}{z}\\
\end{array}
\end{array}
if z < -1.45e-61 or 2.49999999999999989e-7 < z Initial program 78.0%
remove-double-neg78.0%
distribute-lft-neg-out78.0%
*-commutative78.0%
distribute-lft-neg-in78.0%
associate-/l*79.1%
distribute-neg-in79.1%
unsub-neg79.1%
div-sub78.4%
distribute-frac-neg78.4%
associate-/r/83.5%
distribute-rgt-neg-out83.5%
remove-double-neg83.5%
associate-/r/99.8%
*-inverses99.8%
*-lft-identity99.8%
*-commutative99.8%
fma-neg99.8%
remove-double-neg99.8%
Simplified99.8%
fma-udef99.8%
Applied egg-rr99.8%
if -1.45e-61 < z < 2.49999999999999989e-7Initial program 88.8%
associate-*l/93.9%
*-commutative93.9%
Simplified93.9%
Final simplification97.3%
x_m = (fabs.f64 x) x_s = (copysign.f64 1 x) (FPCore (x_s x_m y z) :precision binary64 (* x_s (if (<= z -4.6e+164) x_m (if (<= z 2.4e+146) (* (+ z y) (/ x_m z)) x_m))))
x_m = fabs(x);
x_s = copysign(1.0, x);
double code(double x_s, double x_m, double y, double z) {
double tmp;
if (z <= -4.6e+164) {
tmp = x_m;
} else if (z <= 2.4e+146) {
tmp = (z + y) * (x_m / z);
} else {
tmp = x_m;
}
return x_s * tmp;
}
x_m = abs(x)
x_s = copysign(1.0d0, x)
real(8) function code(x_s, x_m, y, z)
real(8), intent (in) :: x_s
real(8), intent (in) :: x_m
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (z <= (-4.6d+164)) then
tmp = x_m
else if (z <= 2.4d+146) then
tmp = (z + y) * (x_m / z)
else
tmp = x_m
end if
code = x_s * tmp
end function
x_m = Math.abs(x);
x_s = Math.copySign(1.0, x);
public static double code(double x_s, double x_m, double y, double z) {
double tmp;
if (z <= -4.6e+164) {
tmp = x_m;
} else if (z <= 2.4e+146) {
tmp = (z + y) * (x_m / z);
} else {
tmp = x_m;
}
return x_s * tmp;
}
x_m = math.fabs(x) x_s = math.copysign(1.0, x) def code(x_s, x_m, y, z): tmp = 0 if z <= -4.6e+164: tmp = x_m elif z <= 2.4e+146: tmp = (z + y) * (x_m / z) else: tmp = x_m return x_s * tmp
x_m = abs(x) x_s = copysign(1.0, x) function code(x_s, x_m, y, z) tmp = 0.0 if (z <= -4.6e+164) tmp = x_m; elseif (z <= 2.4e+146) tmp = Float64(Float64(z + y) * Float64(x_m / z)); else tmp = x_m; end return Float64(x_s * tmp) end
x_m = abs(x); x_s = sign(x) * abs(1.0); function tmp_2 = code(x_s, x_m, y, z) tmp = 0.0; if (z <= -4.6e+164) tmp = x_m; elseif (z <= 2.4e+146) tmp = (z + y) * (x_m / z); else tmp = x_m; end tmp_2 = x_s * tmp; end
x_m = N[Abs[x], $MachinePrecision]
x_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[x$95$s_, x$95$m_, y_, z_] := N[(x$95$s * If[LessEqual[z, -4.6e+164], x$95$m, If[LessEqual[z, 2.4e+146], N[(N[(z + y), $MachinePrecision] * N[(x$95$m / z), $MachinePrecision]), $MachinePrecision], x$95$m]]), $MachinePrecision]
\begin{array}{l}
x_m = \left|x\right|
\\
x_s = \mathsf{copysign}\left(1, x\right)
\\
x\_s \cdot \begin{array}{l}
\mathbf{if}\;z \leq -4.6 \cdot 10^{+164}:\\
\;\;\;\;x\_m\\
\mathbf{elif}\;z \leq 2.4 \cdot 10^{+146}:\\
\;\;\;\;\left(z + y\right) \cdot \frac{x\_m}{z}\\
\mathbf{else}:\\
\;\;\;\;x\_m\\
\end{array}
\end{array}
if z < -4.5999999999999999e164 or 2.4000000000000002e146 < z Initial program 66.3%
associate-*l/64.2%
*-commutative64.2%
Simplified64.2%
Taylor expanded in y around 0 86.2%
if -4.5999999999999999e164 < z < 2.4000000000000002e146Initial program 88.1%
associate-*l/93.6%
*-commutative93.6%
Simplified93.6%
Final simplification91.8%
x_m = (fabs.f64 x) x_s = (copysign.f64 1 x) (FPCore (x_s x_m y z) :precision binary64 (* x_s (if (<= z -7.8e-19) x_m (if (<= z 2.75e+63) (* y (/ x_m z)) x_m))))
x_m = fabs(x);
x_s = copysign(1.0, x);
double code(double x_s, double x_m, double y, double z) {
double tmp;
if (z <= -7.8e-19) {
tmp = x_m;
} else if (z <= 2.75e+63) {
tmp = y * (x_m / z);
} else {
tmp = x_m;
}
return x_s * tmp;
}
x_m = abs(x)
x_s = copysign(1.0d0, x)
real(8) function code(x_s, x_m, y, z)
real(8), intent (in) :: x_s
real(8), intent (in) :: x_m
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (z <= (-7.8d-19)) then
tmp = x_m
else if (z <= 2.75d+63) then
tmp = y * (x_m / z)
else
tmp = x_m
end if
code = x_s * tmp
end function
x_m = Math.abs(x);
x_s = Math.copySign(1.0, x);
public static double code(double x_s, double x_m, double y, double z) {
double tmp;
if (z <= -7.8e-19) {
tmp = x_m;
} else if (z <= 2.75e+63) {
tmp = y * (x_m / z);
} else {
tmp = x_m;
}
return x_s * tmp;
}
x_m = math.fabs(x) x_s = math.copysign(1.0, x) def code(x_s, x_m, y, z): tmp = 0 if z <= -7.8e-19: tmp = x_m elif z <= 2.75e+63: tmp = y * (x_m / z) else: tmp = x_m return x_s * tmp
x_m = abs(x) x_s = copysign(1.0, x) function code(x_s, x_m, y, z) tmp = 0.0 if (z <= -7.8e-19) tmp = x_m; elseif (z <= 2.75e+63) tmp = Float64(y * Float64(x_m / z)); else tmp = x_m; end return Float64(x_s * tmp) end
x_m = abs(x); x_s = sign(x) * abs(1.0); function tmp_2 = code(x_s, x_m, y, z) tmp = 0.0; if (z <= -7.8e-19) tmp = x_m; elseif (z <= 2.75e+63) tmp = y * (x_m / z); else tmp = x_m; end tmp_2 = x_s * tmp; end
x_m = N[Abs[x], $MachinePrecision]
x_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[x$95$s_, x$95$m_, y_, z_] := N[(x$95$s * If[LessEqual[z, -7.8e-19], x$95$m, If[LessEqual[z, 2.75e+63], N[(y * N[(x$95$m / z), $MachinePrecision]), $MachinePrecision], x$95$m]]), $MachinePrecision]
\begin{array}{l}
x_m = \left|x\right|
\\
x_s = \mathsf{copysign}\left(1, x\right)
\\
x\_s \cdot \begin{array}{l}
\mathbf{if}\;z \leq -7.8 \cdot 10^{-19}:\\
\;\;\;\;x\_m\\
\mathbf{elif}\;z \leq 2.75 \cdot 10^{+63}:\\
\;\;\;\;y \cdot \frac{x\_m}{z}\\
\mathbf{else}:\\
\;\;\;\;x\_m\\
\end{array}
\end{array}
if z < -7.7999999999999999e-19 or 2.75000000000000002e63 < z Initial program 74.2%
associate-*l/77.3%
*-commutative77.3%
Simplified77.3%
Taylor expanded in y around 0 74.0%
if -7.7999999999999999e-19 < z < 2.75000000000000002e63Initial program 90.2%
associate-*l/94.1%
*-commutative94.1%
Simplified94.1%
Taylor expanded in y around inf 78.2%
associate-*l/78.2%
*-commutative78.2%
Simplified78.2%
Final simplification76.2%
x_m = (fabs.f64 x) x_s = (copysign.f64 1 x) (FPCore (x_s x_m y z) :precision binary64 (* x_s (if (<= z -7.8e-19) x_m (if (<= z 1.45e+64) (/ y (/ z x_m)) x_m))))
x_m = fabs(x);
x_s = copysign(1.0, x);
double code(double x_s, double x_m, double y, double z) {
double tmp;
if (z <= -7.8e-19) {
tmp = x_m;
} else if (z <= 1.45e+64) {
tmp = y / (z / x_m);
} else {
tmp = x_m;
}
return x_s * tmp;
}
x_m = abs(x)
x_s = copysign(1.0d0, x)
real(8) function code(x_s, x_m, y, z)
real(8), intent (in) :: x_s
real(8), intent (in) :: x_m
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (z <= (-7.8d-19)) then
tmp = x_m
else if (z <= 1.45d+64) then
tmp = y / (z / x_m)
else
tmp = x_m
end if
code = x_s * tmp
end function
x_m = Math.abs(x);
x_s = Math.copySign(1.0, x);
public static double code(double x_s, double x_m, double y, double z) {
double tmp;
if (z <= -7.8e-19) {
tmp = x_m;
} else if (z <= 1.45e+64) {
tmp = y / (z / x_m);
} else {
tmp = x_m;
}
return x_s * tmp;
}
x_m = math.fabs(x) x_s = math.copysign(1.0, x) def code(x_s, x_m, y, z): tmp = 0 if z <= -7.8e-19: tmp = x_m elif z <= 1.45e+64: tmp = y / (z / x_m) else: tmp = x_m return x_s * tmp
x_m = abs(x) x_s = copysign(1.0, x) function code(x_s, x_m, y, z) tmp = 0.0 if (z <= -7.8e-19) tmp = x_m; elseif (z <= 1.45e+64) tmp = Float64(y / Float64(z / x_m)); else tmp = x_m; end return Float64(x_s * tmp) end
x_m = abs(x); x_s = sign(x) * abs(1.0); function tmp_2 = code(x_s, x_m, y, z) tmp = 0.0; if (z <= -7.8e-19) tmp = x_m; elseif (z <= 1.45e+64) tmp = y / (z / x_m); else tmp = x_m; end tmp_2 = x_s * tmp; end
x_m = N[Abs[x], $MachinePrecision]
x_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[x$95$s_, x$95$m_, y_, z_] := N[(x$95$s * If[LessEqual[z, -7.8e-19], x$95$m, If[LessEqual[z, 1.45e+64], N[(y / N[(z / x$95$m), $MachinePrecision]), $MachinePrecision], x$95$m]]), $MachinePrecision]
\begin{array}{l}
x_m = \left|x\right|
\\
x_s = \mathsf{copysign}\left(1, x\right)
\\
x\_s \cdot \begin{array}{l}
\mathbf{if}\;z \leq -7.8 \cdot 10^{-19}:\\
\;\;\;\;x\_m\\
\mathbf{elif}\;z \leq 1.45 \cdot 10^{+64}:\\
\;\;\;\;\frac{y}{\frac{z}{x\_m}}\\
\mathbf{else}:\\
\;\;\;\;x\_m\\
\end{array}
\end{array}
if z < -7.7999999999999999e-19 or 1.44999999999999997e64 < z Initial program 74.2%
associate-*l/77.3%
*-commutative77.3%
Simplified77.3%
Taylor expanded in y around 0 74.0%
if -7.7999999999999999e-19 < z < 1.44999999999999997e64Initial program 90.2%
associate-*l/94.1%
*-commutative94.1%
Simplified94.1%
Taylor expanded in y around inf 78.2%
associate-/l*70.0%
Simplified70.0%
associate-/l*78.2%
associate-*r/70.0%
*-commutative70.0%
Applied egg-rr70.0%
associate-/r/78.8%
Applied egg-rr78.8%
Final simplification76.5%
x_m = (fabs.f64 x) x_s = (copysign.f64 1 x) (FPCore (x_s x_m y z) :precision binary64 (* x_s (if (<= x_m 1e-46) (+ x_m (/ 1.0 (/ z (* x_m y)))) (+ x_m (* x_m (/ y z))))))
x_m = fabs(x);
x_s = copysign(1.0, x);
double code(double x_s, double x_m, double y, double z) {
double tmp;
if (x_m <= 1e-46) {
tmp = x_m + (1.0 / (z / (x_m * y)));
} else {
tmp = x_m + (x_m * (y / z));
}
return x_s * tmp;
}
x_m = abs(x)
x_s = copysign(1.0d0, x)
real(8) function code(x_s, x_m, y, z)
real(8), intent (in) :: x_s
real(8), intent (in) :: x_m
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (x_m <= 1d-46) then
tmp = x_m + (1.0d0 / (z / (x_m * y)))
else
tmp = x_m + (x_m * (y / z))
end if
code = x_s * tmp
end function
x_m = Math.abs(x);
x_s = Math.copySign(1.0, x);
public static double code(double x_s, double x_m, double y, double z) {
double tmp;
if (x_m <= 1e-46) {
tmp = x_m + (1.0 / (z / (x_m * y)));
} else {
tmp = x_m + (x_m * (y / z));
}
return x_s * tmp;
}
x_m = math.fabs(x) x_s = math.copysign(1.0, x) def code(x_s, x_m, y, z): tmp = 0 if x_m <= 1e-46: tmp = x_m + (1.0 / (z / (x_m * y))) else: tmp = x_m + (x_m * (y / z)) return x_s * tmp
x_m = abs(x) x_s = copysign(1.0, x) function code(x_s, x_m, y, z) tmp = 0.0 if (x_m <= 1e-46) tmp = Float64(x_m + Float64(1.0 / Float64(z / Float64(x_m * y)))); else tmp = Float64(x_m + Float64(x_m * Float64(y / z))); end return Float64(x_s * tmp) end
x_m = abs(x); x_s = sign(x) * abs(1.0); function tmp_2 = code(x_s, x_m, y, z) tmp = 0.0; if (x_m <= 1e-46) tmp = x_m + (1.0 / (z / (x_m * y))); else tmp = x_m + (x_m * (y / z)); end tmp_2 = x_s * tmp; end
x_m = N[Abs[x], $MachinePrecision]
x_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[x$95$s_, x$95$m_, y_, z_] := N[(x$95$s * If[LessEqual[x$95$m, 1e-46], N[(x$95$m + N[(1.0 / N[(z / N[(x$95$m * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x$95$m + N[(x$95$m * N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
x_m = \left|x\right|
\\
x_s = \mathsf{copysign}\left(1, x\right)
\\
x\_s \cdot \begin{array}{l}
\mathbf{if}\;x\_m \leq 10^{-46}:\\
\;\;\;\;x\_m + \frac{1}{\frac{z}{x\_m \cdot y}}\\
\mathbf{else}:\\
\;\;\;\;x\_m + x\_m \cdot \frac{y}{z}\\
\end{array}
\end{array}
if x < 1.00000000000000002e-46Initial program 86.4%
remove-double-neg86.4%
distribute-lft-neg-out86.4%
*-commutative86.4%
distribute-lft-neg-in86.4%
associate-/l*83.4%
distribute-neg-in83.4%
unsub-neg83.4%
div-sub80.3%
distribute-frac-neg80.3%
associate-/r/74.9%
distribute-rgt-neg-out74.9%
remove-double-neg74.9%
associate-/r/90.6%
*-inverses90.6%
*-lft-identity90.6%
*-commutative90.6%
fma-neg90.6%
remove-double-neg90.6%
Simplified90.6%
fma-udef90.6%
Applied egg-rr90.6%
associate-*r/92.3%
clear-num92.3%
Applied egg-rr92.3%
if 1.00000000000000002e-46 < x Initial program 70.9%
remove-double-neg70.9%
distribute-lft-neg-out70.9%
*-commutative70.9%
distribute-lft-neg-in70.9%
associate-/l*94.3%
distribute-neg-in94.3%
unsub-neg94.3%
div-sub89.3%
distribute-frac-neg89.3%
associate-/r/90.0%
distribute-rgt-neg-out90.0%
remove-double-neg90.0%
associate-/r/99.8%
*-inverses99.8%
*-lft-identity99.8%
*-commutative99.8%
fma-neg99.9%
remove-double-neg99.9%
Simplified99.9%
fma-udef99.8%
Applied egg-rr99.8%
Final simplification94.1%
x_m = (fabs.f64 x) x_s = (copysign.f64 1 x) (FPCore (x_s x_m y z) :precision binary64 (* x_s (if (<= x_m 2.1e-127) (+ x_m (/ y (/ z x_m))) (+ x_m (* x_m (/ y z))))))
x_m = fabs(x);
x_s = copysign(1.0, x);
double code(double x_s, double x_m, double y, double z) {
double tmp;
if (x_m <= 2.1e-127) {
tmp = x_m + (y / (z / x_m));
} else {
tmp = x_m + (x_m * (y / z));
}
return x_s * tmp;
}
x_m = abs(x)
x_s = copysign(1.0d0, x)
real(8) function code(x_s, x_m, y, z)
real(8), intent (in) :: x_s
real(8), intent (in) :: x_m
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (x_m <= 2.1d-127) then
tmp = x_m + (y / (z / x_m))
else
tmp = x_m + (x_m * (y / z))
end if
code = x_s * tmp
end function
x_m = Math.abs(x);
x_s = Math.copySign(1.0, x);
public static double code(double x_s, double x_m, double y, double z) {
double tmp;
if (x_m <= 2.1e-127) {
tmp = x_m + (y / (z / x_m));
} else {
tmp = x_m + (x_m * (y / z));
}
return x_s * tmp;
}
x_m = math.fabs(x) x_s = math.copysign(1.0, x) def code(x_s, x_m, y, z): tmp = 0 if x_m <= 2.1e-127: tmp = x_m + (y / (z / x_m)) else: tmp = x_m + (x_m * (y / z)) return x_s * tmp
x_m = abs(x) x_s = copysign(1.0, x) function code(x_s, x_m, y, z) tmp = 0.0 if (x_m <= 2.1e-127) tmp = Float64(x_m + Float64(y / Float64(z / x_m))); else tmp = Float64(x_m + Float64(x_m * Float64(y / z))); end return Float64(x_s * tmp) end
x_m = abs(x); x_s = sign(x) * abs(1.0); function tmp_2 = code(x_s, x_m, y, z) tmp = 0.0; if (x_m <= 2.1e-127) tmp = x_m + (y / (z / x_m)); else tmp = x_m + (x_m * (y / z)); end tmp_2 = x_s * tmp; end
x_m = N[Abs[x], $MachinePrecision]
x_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[x$95$s_, x$95$m_, y_, z_] := N[(x$95$s * If[LessEqual[x$95$m, 2.1e-127], N[(x$95$m + N[(y / N[(z / x$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x$95$m + N[(x$95$m * N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
x_m = \left|x\right|
\\
x_s = \mathsf{copysign}\left(1, x\right)
\\
x\_s \cdot \begin{array}{l}
\mathbf{if}\;x\_m \leq 2.1 \cdot 10^{-127}:\\
\;\;\;\;x\_m + \frac{y}{\frac{z}{x\_m}}\\
\mathbf{else}:\\
\;\;\;\;x\_m + x\_m \cdot \frac{y}{z}\\
\end{array}
\end{array}
if x < 2.1000000000000001e-127Initial program 85.3%
remove-double-neg85.3%
distribute-lft-neg-out85.3%
*-commutative85.3%
distribute-lft-neg-in85.3%
associate-/l*83.7%
distribute-neg-in83.7%
unsub-neg83.7%
div-sub80.4%
distribute-frac-neg80.4%
associate-/r/75.1%
distribute-rgt-neg-out75.1%
remove-double-neg75.1%
associate-/r/90.4%
*-inverses90.4%
*-lft-identity90.4%
*-commutative90.4%
fma-neg90.4%
remove-double-neg90.4%
Simplified90.4%
fma-udef90.4%
Applied egg-rr90.4%
associate-*r/91.7%
*-commutative91.7%
associate-/l*94.1%
Applied egg-rr94.1%
if 2.1000000000000001e-127 < x Initial program 76.3%
remove-double-neg76.3%
distribute-lft-neg-out76.3%
*-commutative76.3%
distribute-lft-neg-in76.3%
associate-/l*91.5%
distribute-neg-in91.5%
unsub-neg91.5%
div-sub87.4%
distribute-frac-neg87.4%
associate-/r/86.8%
distribute-rgt-neg-out86.8%
remove-double-neg86.8%
associate-/r/98.6%
*-inverses98.6%
*-lft-identity98.6%
*-commutative98.6%
fma-neg98.6%
remove-double-neg98.6%
Simplified98.6%
fma-udef98.6%
Applied egg-rr98.6%
Final simplification95.5%
x_m = (fabs.f64 x) x_s = (copysign.f64 1 x) (FPCore (x_s x_m y z) :precision binary64 (* x_s x_m))
x_m = fabs(x);
x_s = copysign(1.0, x);
double code(double x_s, double x_m, double y, double z) {
return x_s * x_m;
}
x_m = abs(x)
x_s = copysign(1.0d0, x)
real(8) function code(x_s, x_m, y, z)
real(8), intent (in) :: x_s
real(8), intent (in) :: x_m
real(8), intent (in) :: y
real(8), intent (in) :: z
code = x_s * x_m
end function
x_m = Math.abs(x);
x_s = Math.copySign(1.0, x);
public static double code(double x_s, double x_m, double y, double z) {
return x_s * x_m;
}
x_m = math.fabs(x) x_s = math.copysign(1.0, x) def code(x_s, x_m, y, z): return x_s * x_m
x_m = abs(x) x_s = copysign(1.0, x) function code(x_s, x_m, y, z) return Float64(x_s * x_m) end
x_m = abs(x); x_s = sign(x) * abs(1.0); function tmp = code(x_s, x_m, y, z) tmp = x_s * x_m; end
x_m = N[Abs[x], $MachinePrecision]
x_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[x$95$s_, x$95$m_, y_, z_] := N[(x$95$s * x$95$m), $MachinePrecision]
\begin{array}{l}
x_m = \left|x\right|
\\
x_s = \mathsf{copysign}\left(1, x\right)
\\
x\_s \cdot x\_m
\end{array}
Initial program 82.7%
associate-*l/86.3%
*-commutative86.3%
Simplified86.3%
Taylor expanded in y around 0 44.5%
Final simplification44.5%
(FPCore (x y z) :precision binary64 (/ x (/ z (+ y z))))
double code(double x, double y, double z) {
return x / (z / (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 / (z / (y + z))
end function
public static double code(double x, double y, double z) {
return x / (z / (y + z));
}
def code(x, y, z): return x / (z / (y + z))
function code(x, y, z) return Float64(x / Float64(z / Float64(y + z))) end
function tmp = code(x, y, z) tmp = x / (z / (y + z)); end
code[x_, y_, z_] := N[(x / N[(z / N[(y + z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x}{\frac{z}{y + z}}
\end{array}
herbie shell --seed 2024096
(FPCore (x y z)
:name "Numeric.SpecFunctions:choose from math-functions-0.1.5.2"
:precision binary64
:herbie-target
(/ x (/ z (+ y z)))
(/ (* x (+ y z)) z))