
(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 10 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 #s(literal 1 binary64) x)
(FPCore (x_s x_m y z)
:precision binary64
(*
x_s
(if (<= x_m 1.8e-218)
(+ x_m (/ (/ 1.0 z) (/ 1.0 (* 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.8e-218) {
tmp = x_m + ((1.0 / z) / (1.0 / (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.8e-218) tmp = Float64(x_m + Float64(Float64(1.0 / z) / Float64(1.0 / 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.8e-218], N[(x$95$m + N[(N[(1.0 / z), $MachinePrecision] / N[(1.0 / 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.8 \cdot 10^{-218}:\\
\;\;\;\;x\_m + \frac{\frac{1}{z}}{\frac{1}{x\_m \cdot y}}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(x\_m, \frac{y}{z}, x\_m\right)\\
\end{array}
\end{array}
if x < 1.80000000000000006e-218Initial program 80.9%
associate-/l*92.4%
remove-double-neg92.4%
distribute-frac-neg292.4%
neg-sub092.4%
remove-double-neg92.4%
unsub-neg92.4%
div-sub92.4%
*-inverses92.4%
metadata-eval92.4%
associate--r-92.4%
neg-sub092.4%
distribute-frac-neg292.4%
remove-double-neg92.4%
sub-neg92.4%
Simplified92.4%
sub-neg92.4%
metadata-eval92.4%
distribute-rgt-in92.4%
*-commutative92.4%
*-un-lft-identity92.4%
Applied egg-rr92.4%
clear-num92.4%
un-div-inv92.4%
Applied egg-rr92.4%
*-un-lft-identity92.4%
div-inv92.4%
times-frac92.7%
Applied egg-rr92.7%
clear-num92.7%
un-div-inv92.7%
associate-/l/92.7%
Applied egg-rr92.7%
if 1.80000000000000006e-218 < x Initial program 83.3%
associate-*l/90.7%
remove-double-neg90.7%
unsub-neg90.7%
distribute-rgt-out--86.7%
associate-*r/80.3%
*-commutative80.3%
associate-*r/86.9%
associate-*r/83.3%
distribute-lft-neg-out83.3%
distribute-frac-neg83.3%
distribute-frac-neg283.3%
fma-neg83.3%
distribute-frac-neg83.3%
distribute-lft-neg-out83.3%
*-commutative83.3%
associate-/l*99.0%
*-inverses99.0%
*-rgt-identity99.0%
Simplified99.0%
Final simplification95.3%
x\_m = (fabs.f64 x)
x\_s = (copysign.f64 #s(literal 1 binary64) x)
(FPCore (x_s x_m y z)
:precision binary64
(*
x_s
(if (<= x_m 1.65e-218)
(+ x_m (/ (/ 1.0 z) (/ 1.0 (* 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 <= 1.65e-218) {
tmp = x_m + ((1.0 / z) / (1.0 / (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 <= 1.65d-218) then
tmp = x_m + ((1.0d0 / z) / (1.0d0 / (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 <= 1.65e-218) {
tmp = x_m + ((1.0 / z) / (1.0 / (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 <= 1.65e-218: tmp = x_m + ((1.0 / z) / (1.0 / (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 <= 1.65e-218) tmp = Float64(x_m + Float64(Float64(1.0 / z) / Float64(1.0 / 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 <= 1.65e-218) tmp = x_m + ((1.0 / z) / (1.0 / (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, 1.65e-218], N[(x$95$m + N[(N[(1.0 / z), $MachinePrecision] / N[(1.0 / 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 1.65 \cdot 10^{-218}:\\
\;\;\;\;x\_m + \frac{\frac{1}{z}}{\frac{1}{x\_m \cdot y}}\\
\mathbf{else}:\\
\;\;\;\;x\_m + x\_m \cdot \frac{y}{z}\\
\end{array}
\end{array}
if x < 1.65000000000000012e-218Initial program 80.9%
associate-/l*92.4%
remove-double-neg92.4%
distribute-frac-neg292.4%
neg-sub092.4%
remove-double-neg92.4%
unsub-neg92.4%
div-sub92.4%
*-inverses92.4%
metadata-eval92.4%
associate--r-92.4%
neg-sub092.4%
distribute-frac-neg292.4%
remove-double-neg92.4%
sub-neg92.4%
Simplified92.4%
sub-neg92.4%
metadata-eval92.4%
distribute-rgt-in92.4%
*-commutative92.4%
*-un-lft-identity92.4%
Applied egg-rr92.4%
clear-num92.4%
un-div-inv92.4%
Applied egg-rr92.4%
*-un-lft-identity92.4%
div-inv92.4%
times-frac92.7%
Applied egg-rr92.7%
clear-num92.7%
un-div-inv92.7%
associate-/l/92.7%
Applied egg-rr92.7%
if 1.65000000000000012e-218 < x Initial program 83.3%
associate-/l*99.0%
remove-double-neg99.0%
distribute-frac-neg299.0%
neg-sub099.0%
remove-double-neg99.0%
unsub-neg99.0%
div-sub99.0%
*-inverses99.0%
metadata-eval99.0%
associate--r-99.0%
neg-sub099.0%
distribute-frac-neg299.0%
remove-double-neg99.0%
sub-neg99.0%
Simplified99.0%
sub-neg99.0%
metadata-eval99.0%
distribute-rgt-in99.0%
*-commutative99.0%
*-un-lft-identity99.0%
Applied egg-rr99.0%
Final simplification95.3%
x\_m = (fabs.f64 x)
x\_s = (copysign.f64 #s(literal 1 binary64) x)
(FPCore (x_s x_m y z)
:precision binary64
(*
x_s
(if (<= x_m 1.9e-218)
(+ x_m (* (/ 1.0 z) (/ x_m (/ 1.0 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 <= 1.9e-218) {
tmp = x_m + ((1.0 / z) * (x_m / (1.0 / 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 <= 1.9d-218) then
tmp = x_m + ((1.0d0 / z) * (x_m / (1.0d0 / 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 <= 1.9e-218) {
tmp = x_m + ((1.0 / z) * (x_m / (1.0 / 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 <= 1.9e-218: tmp = x_m + ((1.0 / z) * (x_m / (1.0 / 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 <= 1.9e-218) tmp = Float64(x_m + Float64(Float64(1.0 / z) * Float64(x_m / Float64(1.0 / 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 <= 1.9e-218) tmp = x_m + ((1.0 / z) * (x_m / (1.0 / 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, 1.9e-218], N[(x$95$m + N[(N[(1.0 / z), $MachinePrecision] * N[(x$95$m / N[(1.0 / 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 1.9 \cdot 10^{-218}:\\
\;\;\;\;x\_m + \frac{1}{z} \cdot \frac{x\_m}{\frac{1}{y}}\\
\mathbf{else}:\\
\;\;\;\;x\_m + x\_m \cdot \frac{y}{z}\\
\end{array}
\end{array}
if x < 1.8999999999999999e-218Initial program 80.9%
associate-/l*92.4%
remove-double-neg92.4%
distribute-frac-neg292.4%
neg-sub092.4%
remove-double-neg92.4%
unsub-neg92.4%
div-sub92.4%
*-inverses92.4%
metadata-eval92.4%
associate--r-92.4%
neg-sub092.4%
distribute-frac-neg292.4%
remove-double-neg92.4%
sub-neg92.4%
Simplified92.4%
sub-neg92.4%
metadata-eval92.4%
distribute-rgt-in92.4%
*-commutative92.4%
*-un-lft-identity92.4%
Applied egg-rr92.4%
clear-num92.4%
un-div-inv92.4%
Applied egg-rr92.4%
*-un-lft-identity92.4%
div-inv92.4%
times-frac92.7%
Applied egg-rr92.7%
if 1.8999999999999999e-218 < x Initial program 83.3%
associate-/l*99.0%
remove-double-neg99.0%
distribute-frac-neg299.0%
neg-sub099.0%
remove-double-neg99.0%
unsub-neg99.0%
div-sub99.0%
*-inverses99.0%
metadata-eval99.0%
associate--r-99.0%
neg-sub099.0%
distribute-frac-neg299.0%
remove-double-neg99.0%
sub-neg99.0%
Simplified99.0%
sub-neg99.0%
metadata-eval99.0%
distribute-rgt-in99.0%
*-commutative99.0%
*-un-lft-identity99.0%
Applied egg-rr99.0%
Final simplification95.3%
x\_m = (fabs.f64 x) x\_s = (copysign.f64 #s(literal 1 binary64) x) (FPCore (x_s x_m y z) :precision binary64 (* x_s (if (<= z -6.8e-10) x_m (if (<= z 1.5e-49) (/ (* 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 (z <= -6.8e-10) {
tmp = x_m;
} else if (z <= 1.5e-49) {
tmp = (x_m * y) / 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 <= (-6.8d-10)) then
tmp = x_m
else if (z <= 1.5d-49) then
tmp = (x_m * y) / 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 <= -6.8e-10) {
tmp = x_m;
} else if (z <= 1.5e-49) {
tmp = (x_m * y) / 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 <= -6.8e-10: tmp = x_m elif z <= 1.5e-49: tmp = (x_m * y) / 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 <= -6.8e-10) tmp = x_m; elseif (z <= 1.5e-49) tmp = Float64(Float64(x_m * y) / 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 <= -6.8e-10) tmp = x_m; elseif (z <= 1.5e-49) tmp = (x_m * y) / 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, -6.8e-10], x$95$m, If[LessEqual[z, 1.5e-49], N[(N[(x$95$m * y), $MachinePrecision] / z), $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 -6.8 \cdot 10^{-10}:\\
\;\;\;\;x\_m\\
\mathbf{elif}\;z \leq 1.5 \cdot 10^{-49}:\\
\;\;\;\;\frac{x\_m \cdot y}{z}\\
\mathbf{else}:\\
\;\;\;\;x\_m\\
\end{array}
\end{array}
if z < -6.8000000000000003e-10 or 1.5e-49 < z Initial program 74.2%
associate-/l*99.9%
remove-double-neg99.9%
distribute-frac-neg299.9%
neg-sub099.9%
remove-double-neg99.9%
unsub-neg99.9%
div-sub99.9%
*-inverses99.9%
metadata-eval99.9%
associate--r-99.9%
neg-sub099.9%
distribute-frac-neg299.9%
remove-double-neg99.9%
sub-neg99.9%
Simplified99.9%
Taylor expanded in y around 0 75.2%
if -6.8000000000000003e-10 < z < 1.5e-49Initial program 90.0%
associate-/l*89.9%
remove-double-neg89.9%
distribute-frac-neg289.9%
neg-sub089.9%
remove-double-neg89.9%
unsub-neg89.9%
div-sub89.9%
*-inverses89.9%
metadata-eval89.9%
associate--r-89.9%
neg-sub089.9%
distribute-frac-neg289.9%
remove-double-neg89.9%
sub-neg89.9%
Simplified89.9%
Taylor expanded in y around inf 73.5%
x\_m = (fabs.f64 x) x\_s = (copysign.f64 #s(literal 1 binary64) x) (FPCore (x_s x_m y z) :precision binary64 (* x_s (if (<= z -3.75e-13) x_m (if (<= z 1e-51) (* 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 <= -3.75e-13) {
tmp = x_m;
} else if (z <= 1e-51) {
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 <= (-3.75d-13)) then
tmp = x_m
else if (z <= 1d-51) 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 <= -3.75e-13) {
tmp = x_m;
} else if (z <= 1e-51) {
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 <= -3.75e-13: tmp = x_m elif z <= 1e-51: 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 <= -3.75e-13) tmp = x_m; elseif (z <= 1e-51) 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 <= -3.75e-13) tmp = x_m; elseif (z <= 1e-51) 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, -3.75e-13], x$95$m, If[LessEqual[z, 1e-51], 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 -3.75 \cdot 10^{-13}:\\
\;\;\;\;x\_m\\
\mathbf{elif}\;z \leq 10^{-51}:\\
\;\;\;\;y \cdot \frac{x\_m}{z}\\
\mathbf{else}:\\
\;\;\;\;x\_m\\
\end{array}
\end{array}
if z < -3.7500000000000002e-13 or 1e-51 < z Initial program 74.6%
associate-/l*99.9%
remove-double-neg99.9%
distribute-frac-neg299.9%
neg-sub099.9%
remove-double-neg99.9%
unsub-neg99.9%
div-sub99.9%
*-inverses99.9%
metadata-eval99.9%
associate--r-99.9%
neg-sub099.9%
distribute-frac-neg299.9%
remove-double-neg99.9%
sub-neg99.9%
Simplified99.9%
Taylor expanded in y around 0 74.8%
if -3.7500000000000002e-13 < z < 1e-51Initial program 89.8%
associate-/l*89.7%
remove-double-neg89.7%
distribute-frac-neg289.7%
neg-sub089.7%
remove-double-neg89.7%
unsub-neg89.7%
div-sub89.7%
*-inverses89.7%
metadata-eval89.7%
associate--r-89.7%
neg-sub089.7%
distribute-frac-neg289.7%
remove-double-neg89.7%
sub-neg89.7%
Simplified89.7%
Taylor expanded in y around inf 73.9%
associate-*l/73.0%
*-commutative73.0%
Simplified73.0%
x\_m = (fabs.f64 x) x\_s = (copysign.f64 #s(literal 1 binary64) x) (FPCore (x_s x_m y z) :precision binary64 (* x_s (if (<= z -8e-8) x_m (if (<= z 9.5e-50) (* 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 (z <= -8e-8) {
tmp = x_m;
} else if (z <= 9.5e-50) {
tmp = x_m * (y / 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 <= (-8d-8)) then
tmp = x_m
else if (z <= 9.5d-50) then
tmp = x_m * (y / 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 <= -8e-8) {
tmp = x_m;
} else if (z <= 9.5e-50) {
tmp = x_m * (y / 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 <= -8e-8: tmp = x_m elif z <= 9.5e-50: tmp = x_m * (y / 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 <= -8e-8) tmp = x_m; elseif (z <= 9.5e-50) tmp = Float64(x_m * Float64(y / 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 <= -8e-8) tmp = x_m; elseif (z <= 9.5e-50) tmp = x_m * (y / 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, -8e-8], x$95$m, If[LessEqual[z, 9.5e-50], N[(x$95$m * N[(y / 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 -8 \cdot 10^{-8}:\\
\;\;\;\;x\_m\\
\mathbf{elif}\;z \leq 9.5 \cdot 10^{-50}:\\
\;\;\;\;x\_m \cdot \frac{y}{z}\\
\mathbf{else}:\\
\;\;\;\;x\_m\\
\end{array}
\end{array}
if z < -8.0000000000000002e-8 or 9.4999999999999993e-50 < z Initial program 74.2%
associate-/l*99.9%
remove-double-neg99.9%
distribute-frac-neg299.9%
neg-sub099.9%
remove-double-neg99.9%
unsub-neg99.9%
div-sub99.9%
*-inverses99.9%
metadata-eval99.9%
associate--r-99.9%
neg-sub099.9%
distribute-frac-neg299.9%
remove-double-neg99.9%
sub-neg99.9%
Simplified99.9%
Taylor expanded in y around 0 75.2%
if -8.0000000000000002e-8 < z < 9.4999999999999993e-50Initial program 90.0%
associate-/l*89.9%
remove-double-neg89.9%
distribute-frac-neg289.9%
neg-sub089.9%
remove-double-neg89.9%
unsub-neg89.9%
div-sub89.9%
*-inverses89.9%
metadata-eval89.9%
associate--r-89.9%
neg-sub089.9%
distribute-frac-neg289.9%
remove-double-neg89.9%
sub-neg89.9%
Simplified89.9%
Taylor expanded in y around inf 73.5%
associate-*r/67.5%
Simplified67.5%
x\_m = (fabs.f64 x) x\_s = (copysign.f64 #s(literal 1 binary64) x) (FPCore (x_s x_m y z) :precision binary64 (* x_s (if (<= y -6.8e+20) (/ (* x_m (+ z y)) z) (+ 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 (y <= -6.8e+20) {
tmp = (x_m * (z + y)) / z;
} 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 (y <= (-6.8d+20)) then
tmp = (x_m * (z + y)) / z
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 (y <= -6.8e+20) {
tmp = (x_m * (z + y)) / z;
} 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 y <= -6.8e+20: tmp = (x_m * (z + y)) / z 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 (y <= -6.8e+20) tmp = Float64(Float64(x_m * Float64(z + y)) / z); 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 (y <= -6.8e+20) tmp = (x_m * (z + y)) / z; 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[y, -6.8e+20], N[(N[(x$95$m * N[(z + y), $MachinePrecision]), $MachinePrecision] / z), $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}\;y \leq -6.8 \cdot 10^{+20}:\\
\;\;\;\;\frac{x\_m \cdot \left(z + y\right)}{z}\\
\mathbf{else}:\\
\;\;\;\;x\_m + x\_m \cdot \frac{y}{z}\\
\end{array}
\end{array}
if y < -6.8e20Initial program 93.9%
if -6.8e20 < y Initial program 77.8%
associate-/l*97.9%
remove-double-neg97.9%
distribute-frac-neg297.9%
neg-sub097.9%
remove-double-neg97.9%
unsub-neg97.9%
div-sub97.9%
*-inverses97.9%
metadata-eval97.9%
associate--r-97.9%
neg-sub097.9%
distribute-frac-neg297.9%
remove-double-neg97.9%
sub-neg97.9%
Simplified97.9%
sub-neg97.9%
metadata-eval97.9%
distribute-rgt-in97.9%
*-commutative97.9%
*-un-lft-identity97.9%
Applied egg-rr97.9%
Final simplification96.9%
x\_m = (fabs.f64 x) x\_s = (copysign.f64 #s(literal 1 binary64) x) (FPCore (x_s x_m y z) :precision binary64 (* x_s (+ 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) {
return x_s * (x_m + (x_m * (y / z)));
}
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 + (x_m * (y / z)))
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 * (y / z)));
}
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 * (y / z)))
x\_m = abs(x) x\_s = copysign(1.0, x) function code(x_s, x_m, y, z) return Float64(x_s * Float64(x_m + Float64(x_m * Float64(y / z)))) 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 + (x_m * (y / z))); 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 * 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 \left(x\_m + x\_m \cdot \frac{y}{z}\right)
\end{array}
Initial program 81.9%
associate-/l*95.0%
remove-double-neg95.0%
distribute-frac-neg295.0%
neg-sub095.0%
remove-double-neg95.0%
unsub-neg95.0%
div-sub95.0%
*-inverses95.0%
metadata-eval95.0%
associate--r-95.0%
neg-sub095.0%
distribute-frac-neg295.0%
remove-double-neg95.0%
sub-neg95.0%
Simplified95.0%
sub-neg95.0%
metadata-eval95.0%
distribute-rgt-in95.1%
*-commutative95.1%
*-un-lft-identity95.1%
Applied egg-rr95.1%
Final simplification95.1%
x\_m = (fabs.f64 x) x\_s = (copysign.f64 #s(literal 1 binary64) x) (FPCore (x_s x_m y z) :precision binary64 (* x_s (* x_m (- (/ y z) -1.0))))
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 * ((y / z) - -1.0));
}
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 * ((y / z) - (-1.0d0)))
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 * ((y / z) - -1.0));
}
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 * ((y / z) - -1.0))
x\_m = abs(x) x\_s = copysign(1.0, x) function code(x_s, x_m, y, z) return Float64(x_s * Float64(x_m * Float64(Float64(y / z) - -1.0))) 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 * ((y / z) - -1.0)); 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 * N[(x$95$m * N[(N[(y / z), $MachinePrecision] - -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
x\_m = \left|x\right|
\\
x\_s = \mathsf{copysign}\left(1, x\right)
\\
x\_s \cdot \left(x\_m \cdot \left(\frac{y}{z} - -1\right)\right)
\end{array}
Initial program 81.9%
associate-/l*95.0%
remove-double-neg95.0%
distribute-frac-neg295.0%
neg-sub095.0%
remove-double-neg95.0%
unsub-neg95.0%
div-sub95.0%
*-inverses95.0%
metadata-eval95.0%
associate--r-95.0%
neg-sub095.0%
distribute-frac-neg295.0%
remove-double-neg95.0%
sub-neg95.0%
Simplified95.0%
x\_m = (fabs.f64 x) x\_s = (copysign.f64 #s(literal 1 binary64) 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 81.9%
associate-/l*95.0%
remove-double-neg95.0%
distribute-frac-neg295.0%
neg-sub095.0%
remove-double-neg95.0%
unsub-neg95.0%
div-sub95.0%
*-inverses95.0%
metadata-eval95.0%
associate--r-95.0%
neg-sub095.0%
distribute-frac-neg295.0%
remove-double-neg95.0%
sub-neg95.0%
Simplified95.0%
Taylor expanded in y around 0 49.6%
(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 2024103
(FPCore (x y z)
:name "Numeric.SpecFunctions:choose from math-functions-0.1.5.2"
:precision binary64
:alt
(/ x (/ z (+ y z)))
(/ (* x (+ y z)) z))