
(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 9 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.35e-191)
(+ x_m (* x_m (/ y z)))
(if (<= x_m 1e-73) (/ (* x_m (+ y z)) z) (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.35e-191) {
tmp = x_m + (x_m * (y / z));
} else if (x_m <= 1e-73) {
tmp = (x_m * (y + z)) / z;
} 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.35e-191) tmp = Float64(x_m + Float64(x_m * Float64(y / z))); elseif (x_m <= 1e-73) tmp = Float64(Float64(x_m * Float64(y + z)) / z); 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.35e-191], N[(x$95$m + N[(x$95$m * N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x$95$m, 1e-73], N[(N[(x$95$m * N[(y + z), $MachinePrecision]), $MachinePrecision] / z), $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.35 \cdot 10^{-191}:\\
\;\;\;\;x\_m + x\_m \cdot \frac{y}{z}\\
\mathbf{elif}\;x\_m \leq 10^{-73}:\\
\;\;\;\;\frac{x\_m \cdot \left(y + z\right)}{z}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(x\_m, \frac{y}{z}, x\_m\right)\\
\end{array}
\end{array}
if x < 1.34999999999999999e-191Initial program 85.0%
associate-/l*93.7%
remove-double-neg93.7%
unsub-neg93.7%
div-sub93.7%
remove-double-neg93.7%
distribute-frac-neg293.7%
*-inverses93.7%
metadata-eval93.7%
Simplified93.7%
sub-neg93.7%
metadata-eval93.7%
distribute-rgt-in93.8%
*-commutative93.8%
*-un-lft-identity93.8%
Applied egg-rr93.8%
if 1.34999999999999999e-191 < x < 9.99999999999999997e-74Initial program 99.7%
if 9.99999999999999997e-74 < x Initial program 83.4%
associate-*l/85.2%
distribute-lft-in84.5%
remove-double-neg84.5%
distribute-lft-neg-out84.5%
distribute-frac-neg84.5%
distribute-rgt-neg-out84.5%
distribute-frac-neg84.5%
distribute-lft-neg-out84.5%
distribute-rgt-neg-out84.5%
remove-double-neg84.5%
associate-*l/81.1%
associate-*r/84.7%
fma-undefine84.7%
remove-double-neg84.7%
distribute-rgt-neg-out84.7%
distribute-lft-neg-out84.7%
distribute-frac-neg284.7%
associate-*l/83.4%
associate-/l*100.0%
*-inverses100.0%
*-rgt-identity100.0%
Simplified100.0%
Final simplification96.2%
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 -9.0)
x_m
(if (or (<= z -8.5e-100) (and (not (<= z -9.5e-136)) (<= z 2.2e+69)))
(* 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 <= -9.0) {
tmp = x_m;
} else if ((z <= -8.5e-100) || (!(z <= -9.5e-136) && (z <= 2.2e+69))) {
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 <= (-9.0d0)) then
tmp = x_m
else if ((z <= (-8.5d-100)) .or. (.not. (z <= (-9.5d-136))) .and. (z <= 2.2d+69)) 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 <= -9.0) {
tmp = x_m;
} else if ((z <= -8.5e-100) || (!(z <= -9.5e-136) && (z <= 2.2e+69))) {
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 <= -9.0: tmp = x_m elif (z <= -8.5e-100) or (not (z <= -9.5e-136) and (z <= 2.2e+69)): 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 <= -9.0) tmp = x_m; elseif ((z <= -8.5e-100) || (!(z <= -9.5e-136) && (z <= 2.2e+69))) 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 <= -9.0) tmp = x_m; elseif ((z <= -8.5e-100) || (~((z <= -9.5e-136)) && (z <= 2.2e+69))) 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, -9.0], x$95$m, If[Or[LessEqual[z, -8.5e-100], And[N[Not[LessEqual[z, -9.5e-136]], $MachinePrecision], LessEqual[z, 2.2e+69]]], 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 -9:\\
\;\;\;\;x\_m\\
\mathbf{elif}\;z \leq -8.5 \cdot 10^{-100} \lor \neg \left(z \leq -9.5 \cdot 10^{-136}\right) \land z \leq 2.2 \cdot 10^{+69}:\\
\;\;\;\;x\_m \cdot \frac{y}{z}\\
\mathbf{else}:\\
\;\;\;\;x\_m\\
\end{array}
\end{array}
if z < -9 or -8.50000000000000017e-100 < z < -9.5000000000000007e-136 or 2.2000000000000002e69 < z Initial program 76.7%
associate-/l*99.2%
remove-double-neg99.2%
unsub-neg99.2%
div-sub99.2%
remove-double-neg99.2%
distribute-frac-neg299.2%
*-inverses99.2%
metadata-eval99.2%
Simplified99.2%
Taylor expanded in y around 0 80.9%
if -9 < z < -8.50000000000000017e-100 or -9.5000000000000007e-136 < z < 2.2000000000000002e69Initial program 94.1%
associate-/l*90.1%
remove-double-neg90.1%
unsub-neg90.1%
div-sub90.2%
remove-double-neg90.2%
distribute-frac-neg290.2%
*-inverses90.2%
metadata-eval90.2%
Simplified90.2%
Taylor expanded in y around inf 72.2%
associate-*r/66.9%
Simplified66.9%
Final simplification73.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 (<= x_m 1.36e-191)
(+ x_m (* x_m (/ y z)))
(if (<= x_m 5e-73) (/ (* x_m (+ y z)) z) (* 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) {
double tmp;
if (x_m <= 1.36e-191) {
tmp = x_m + (x_m * (y / z));
} else if (x_m <= 5e-73) {
tmp = (x_m * (y + z)) / z;
} else {
tmp = x_m * ((y / z) - -1.0);
}
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.36d-191) then
tmp = x_m + (x_m * (y / z))
else if (x_m <= 5d-73) then
tmp = (x_m * (y + z)) / z
else
tmp = x_m * ((y / z) - (-1.0d0))
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.36e-191) {
tmp = x_m + (x_m * (y / z));
} else if (x_m <= 5e-73) {
tmp = (x_m * (y + z)) / z;
} else {
tmp = x_m * ((y / z) - -1.0);
}
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.36e-191: tmp = x_m + (x_m * (y / z)) elif x_m <= 5e-73: tmp = (x_m * (y + z)) / z else: tmp = x_m * ((y / z) - -1.0) 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.36e-191) tmp = Float64(x_m + Float64(x_m * Float64(y / z))); elseif (x_m <= 5e-73) tmp = Float64(Float64(x_m * Float64(y + z)) / z); else tmp = Float64(x_m * Float64(Float64(y / z) - -1.0)); 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.36e-191) tmp = x_m + (x_m * (y / z)); elseif (x_m <= 5e-73) tmp = (x_m * (y + z)) / z; else tmp = x_m * ((y / z) - -1.0); 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.36e-191], N[(x$95$m + N[(x$95$m * N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x$95$m, 5e-73], N[(N[(x$95$m * N[(y + z), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision], 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 \begin{array}{l}
\mathbf{if}\;x\_m \leq 1.36 \cdot 10^{-191}:\\
\;\;\;\;x\_m + x\_m \cdot \frac{y}{z}\\
\mathbf{elif}\;x\_m \leq 5 \cdot 10^{-73}:\\
\;\;\;\;\frac{x\_m \cdot \left(y + z\right)}{z}\\
\mathbf{else}:\\
\;\;\;\;x\_m \cdot \left(\frac{y}{z} - -1\right)\\
\end{array}
\end{array}
if x < 1.36000000000000001e-191Initial program 85.0%
associate-/l*93.7%
remove-double-neg93.7%
unsub-neg93.7%
div-sub93.7%
remove-double-neg93.7%
distribute-frac-neg293.7%
*-inverses93.7%
metadata-eval93.7%
Simplified93.7%
sub-neg93.7%
metadata-eval93.7%
distribute-rgt-in93.8%
*-commutative93.8%
*-un-lft-identity93.8%
Applied egg-rr93.8%
if 1.36000000000000001e-191 < x < 4.9999999999999998e-73Initial program 99.7%
if 4.9999999999999998e-73 < x Initial program 83.4%
associate-/l*99.9%
remove-double-neg99.9%
unsub-neg99.9%
div-sub99.9%
remove-double-neg99.9%
distribute-frac-neg299.9%
*-inverses99.9%
metadata-eval99.9%
Simplified99.9%
Final simplification96.2%
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 -5.2) x_m (if (<= z 1.7e+69) (* 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 <= -5.2) {
tmp = x_m;
} else if (z <= 1.7e+69) {
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 <= (-5.2d0)) then
tmp = x_m
else if (z <= 1.7d+69) 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 <= -5.2) {
tmp = x_m;
} else if (z <= 1.7e+69) {
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 <= -5.2: tmp = x_m elif z <= 1.7e+69: 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 <= -5.2) tmp = x_m; elseif (z <= 1.7e+69) 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 <= -5.2) tmp = x_m; elseif (z <= 1.7e+69) 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, -5.2], x$95$m, If[LessEqual[z, 1.7e+69], 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 -5.2:\\
\;\;\;\;x\_m\\
\mathbf{elif}\;z \leq 1.7 \cdot 10^{+69}:\\
\;\;\;\;y \cdot \frac{x\_m}{z}\\
\mathbf{else}:\\
\;\;\;\;x\_m\\
\end{array}
\end{array}
if z < -5.20000000000000018 or 1.69999999999999993e69 < z Initial program 76.9%
associate-/l*100.0%
remove-double-neg100.0%
unsub-neg100.0%
div-sub100.0%
remove-double-neg100.0%
distribute-frac-neg2100.0%
*-inverses100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around 0 81.4%
if -5.20000000000000018 < z < 1.69999999999999993e69Initial program 93.1%
associate-/l*90.0%
remove-double-neg90.0%
unsub-neg90.0%
div-sub90.0%
remove-double-neg90.0%
distribute-frac-neg290.0%
*-inverses90.0%
metadata-eval90.0%
Simplified90.0%
Taylor expanded in y around inf 69.8%
*-commutative69.8%
associate-/l*67.6%
Applied egg-rr67.6%
Final simplification73.8%
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 -20.0) x_m (if (<= z 8.5e+69) (/ 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 <= -20.0) {
tmp = x_m;
} else if (z <= 8.5e+69) {
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 <= (-20.0d0)) then
tmp = x_m
else if (z <= 8.5d+69) 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 <= -20.0) {
tmp = x_m;
} else if (z <= 8.5e+69) {
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 <= -20.0: tmp = x_m elif z <= 8.5e+69: 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 <= -20.0) tmp = x_m; elseif (z <= 8.5e+69) 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 <= -20.0) tmp = x_m; elseif (z <= 8.5e+69) 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, -20.0], x$95$m, If[LessEqual[z, 8.5e+69], 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 -20:\\
\;\;\;\;x\_m\\
\mathbf{elif}\;z \leq 8.5 \cdot 10^{+69}:\\
\;\;\;\;\frac{y}{\frac{z}{x\_m}}\\
\mathbf{else}:\\
\;\;\;\;x\_m\\
\end{array}
\end{array}
if z < -20 or 8.5000000000000002e69 < z Initial program 76.9%
associate-/l*100.0%
remove-double-neg100.0%
unsub-neg100.0%
div-sub100.0%
remove-double-neg100.0%
distribute-frac-neg2100.0%
*-inverses100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around 0 81.4%
if -20 < z < 8.5000000000000002e69Initial program 93.1%
associate-/l*90.0%
remove-double-neg90.0%
unsub-neg90.0%
div-sub90.0%
remove-double-neg90.0%
distribute-frac-neg290.0%
*-inverses90.0%
metadata-eval90.0%
Simplified90.0%
Taylor expanded in y around inf 69.8%
*-commutative69.8%
associate-/l*67.6%
Applied egg-rr67.6%
clear-num67.6%
un-div-inv68.3%
Applied egg-rr68.3%
Final simplification74.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 (if (<= z -6.8) x_m (if (<= z 1.65e+69) (/ (* 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.8) {
tmp = x_m;
} else if (z <= 1.65e+69) {
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.8d0)) then
tmp = x_m
else if (z <= 1.65d+69) 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.8) {
tmp = x_m;
} else if (z <= 1.65e+69) {
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.8: tmp = x_m elif z <= 1.65e+69: 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.8) tmp = x_m; elseif (z <= 1.65e+69) 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.8) tmp = x_m; elseif (z <= 1.65e+69) 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.8], x$95$m, If[LessEqual[z, 1.65e+69], 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:\\
\;\;\;\;x\_m\\
\mathbf{elif}\;z \leq 1.65 \cdot 10^{+69}:\\
\;\;\;\;\frac{x\_m \cdot y}{z}\\
\mathbf{else}:\\
\;\;\;\;x\_m\\
\end{array}
\end{array}
if z < -6.79999999999999982 or 1.6499999999999999e69 < z Initial program 76.9%
associate-/l*100.0%
remove-double-neg100.0%
unsub-neg100.0%
div-sub100.0%
remove-double-neg100.0%
distribute-frac-neg2100.0%
*-inverses100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around 0 81.4%
if -6.79999999999999982 < z < 1.6499999999999999e69Initial program 93.1%
associate-/l*90.0%
remove-double-neg90.0%
unsub-neg90.0%
div-sub90.0%
remove-double-neg90.0%
distribute-frac-neg290.0%
*-inverses90.0%
metadata-eval90.0%
Simplified90.0%
Taylor expanded in y around inf 69.8%
Final simplification75.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 (- (/ 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 85.9%
associate-/l*94.4%
remove-double-neg94.4%
unsub-neg94.4%
div-sub94.4%
remove-double-neg94.4%
distribute-frac-neg294.4%
*-inverses94.4%
metadata-eval94.4%
Simplified94.4%
Final simplification94.4%
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 (/ z y)))))
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 / (z / y)));
}
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 / (z / y)))
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 / (z / y)));
}
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 / (z / y)))
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(z / y)))) 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 / (z / y))); 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[(z / y), $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 + \frac{x\_m}{\frac{z}{y}}\right)
\end{array}
Initial program 85.9%
associate-/l*94.4%
remove-double-neg94.4%
unsub-neg94.4%
div-sub94.4%
remove-double-neg94.4%
distribute-frac-neg294.4%
*-inverses94.4%
metadata-eval94.4%
Simplified94.4%
sub-neg94.4%
metadata-eval94.4%
distribute-rgt-in94.4%
*-commutative94.4%
*-un-lft-identity94.4%
Applied egg-rr94.4%
Taylor expanded in x around 0 94.6%
associate-*l/92.4%
associate-/r/94.5%
Simplified94.5%
Final simplification94.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 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 85.9%
associate-/l*94.4%
remove-double-neg94.4%
unsub-neg94.4%
div-sub94.4%
remove-double-neg94.4%
distribute-frac-neg294.4%
*-inverses94.4%
metadata-eval94.4%
Simplified94.4%
Taylor expanded in y around 0 51.1%
Final simplification51.1%
(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 2024095
(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))