
(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 2e-114)
(+ x_m (* (/ 1.0 z) (/ x_m (/ 1.0 y))))
(+ 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) {
double tmp;
if (x_m <= 2e-114) {
tmp = x_m + ((1.0 / z) * (x_m / (1.0 / y)));
} else {
tmp = x_m + (x_m / (z / y));
}
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 <= 2d-114) then
tmp = x_m + ((1.0d0 / z) * (x_m / (1.0d0 / y)))
else
tmp = x_m + (x_m / (z / y))
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 <= 2e-114) {
tmp = x_m + ((1.0 / z) * (x_m / (1.0 / y)));
} else {
tmp = x_m + (x_m / (z / y));
}
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 <= 2e-114: tmp = x_m + ((1.0 / z) * (x_m / (1.0 / y))) else: tmp = x_m + (x_m / (z / y)) 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 <= 2e-114) 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(z / y))); 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 <= 2e-114) tmp = x_m + ((1.0 / z) * (x_m / (1.0 / y))); else tmp = x_m + (x_m / (z / y)); 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, 2e-114], 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[(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 \begin{array}{l}
\mathbf{if}\;x\_m \leq 2 \cdot 10^{-114}:\\
\;\;\;\;x\_m + \frac{1}{z} \cdot \frac{x\_m}{\frac{1}{y}}\\
\mathbf{else}:\\
\;\;\;\;x\_m + \frac{x\_m}{\frac{z}{y}}\\
\end{array}
\end{array}
if x < 2.0000000000000001e-114Initial program 86.5%
associate-/l*93.6%
remove-double-neg93.6%
distribute-frac-neg293.6%
neg-sub093.6%
remove-double-neg93.6%
unsub-neg93.6%
div-sub93.6%
*-inverses93.6%
metadata-eval93.6%
associate--r-93.6%
neg-sub093.6%
distribute-frac-neg293.6%
remove-double-neg93.6%
sub-neg93.6%
Simplified93.6%
sub-neg93.6%
metadata-eval93.6%
distribute-rgt-in93.7%
*-commutative93.7%
*-un-lft-identity93.7%
Applied egg-rr93.7%
clear-num93.6%
un-div-inv95.0%
Applied egg-rr95.0%
*-un-lft-identity95.0%
div-inv95.0%
times-frac93.7%
Applied egg-rr93.7%
if 2.0000000000000001e-114 < x Initial program 82.5%
associate-/l*99.9%
remove-double-neg99.9%
distribute-frac-neg299.9%
neg-sub099.9%
remove-double-neg99.9%
unsub-neg99.9%
div-sub99.8%
*-inverses99.8%
metadata-eval99.8%
associate--r-99.8%
neg-sub099.8%
distribute-frac-neg299.8%
remove-double-neg99.8%
sub-neg99.8%
Simplified99.8%
sub-neg99.8%
metadata-eval99.8%
distribute-rgt-in99.8%
*-commutative99.8%
*-un-lft-identity99.8%
Applied egg-rr99.8%
clear-num99.8%
un-div-inv99.9%
Applied egg-rr99.9%
Final simplification95.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 (or (<= y -1.6e-130)
(not
(or (<= y 2.2e-35) (and (not (<= y 4.4e+114)) (<= y 2.3e+133)))))
(* 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 ((y <= -1.6e-130) || !((y <= 2.2e-35) || (!(y <= 4.4e+114) && (y <= 2.3e+133)))) {
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 ((y <= (-1.6d-130)) .or. (.not. (y <= 2.2d-35) .or. (.not. (y <= 4.4d+114)) .and. (y <= 2.3d+133))) 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 ((y <= -1.6e-130) || !((y <= 2.2e-35) || (!(y <= 4.4e+114) && (y <= 2.3e+133)))) {
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 (y <= -1.6e-130) or not ((y <= 2.2e-35) or (not (y <= 4.4e+114) and (y <= 2.3e+133))): 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 ((y <= -1.6e-130) || !((y <= 2.2e-35) || (!(y <= 4.4e+114) && (y <= 2.3e+133)))) 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 ((y <= -1.6e-130) || ~(((y <= 2.2e-35) || (~((y <= 4.4e+114)) && (y <= 2.3e+133))))) 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[Or[LessEqual[y, -1.6e-130], N[Not[Or[LessEqual[y, 2.2e-35], And[N[Not[LessEqual[y, 4.4e+114]], $MachinePrecision], LessEqual[y, 2.3e+133]]]], $MachinePrecision]], 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}\;y \leq -1.6 \cdot 10^{-130} \lor \neg \left(y \leq 2.2 \cdot 10^{-35} \lor \neg \left(y \leq 4.4 \cdot 10^{+114}\right) \land y \leq 2.3 \cdot 10^{+133}\right):\\
\;\;\;\;x\_m \cdot \frac{y}{z}\\
\mathbf{else}:\\
\;\;\;\;x\_m\\
\end{array}
\end{array}
if y < -1.6e-130 or 2.19999999999999994e-35 < y < 4.4000000000000001e114 or 2.2999999999999999e133 < y Initial program 89.5%
associate-/l*94.0%
remove-double-neg94.0%
distribute-frac-neg294.0%
neg-sub094.0%
remove-double-neg94.0%
unsub-neg94.0%
div-sub94.0%
*-inverses94.0%
metadata-eval94.0%
associate--r-94.0%
neg-sub094.0%
distribute-frac-neg294.0%
remove-double-neg94.0%
sub-neg94.0%
Simplified94.0%
Taylor expanded in y around inf 68.5%
if -1.6e-130 < y < 2.19999999999999994e-35 or 4.4000000000000001e114 < y < 2.2999999999999999e133Initial program 77.4%
associate-/l*98.9%
remove-double-neg98.9%
distribute-frac-neg298.9%
neg-sub098.9%
remove-double-neg98.9%
unsub-neg98.9%
div-sub98.9%
*-inverses98.9%
metadata-eval98.9%
associate--r-98.9%
neg-sub098.9%
distribute-frac-neg298.9%
remove-double-neg98.9%
sub-neg98.9%
Simplified98.9%
Taylor expanded in y around 0 83.7%
Final simplification74.0%
x\_m = (fabs.f64 x)
x\_s = (copysign.f64 #s(literal 1 binary64) x)
(FPCore (x_s x_m y z)
:precision binary64
(let* ((t_0 (/ x_m (/ z y))))
(*
x_s
(if (<= y -2.1e-129)
t_0
(if (<= y 1.35e-34)
x_m
(if (<= y 6.6e+113) t_0 (if (<= y 4.5e+129) x_m (* 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 t_0 = x_m / (z / y);
double tmp;
if (y <= -2.1e-129) {
tmp = t_0;
} else if (y <= 1.35e-34) {
tmp = x_m;
} else if (y <= 6.6e+113) {
tmp = t_0;
} else if (y <= 4.5e+129) {
tmp = x_m;
} else {
tmp = 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) :: t_0
real(8) :: tmp
t_0 = x_m / (z / y)
if (y <= (-2.1d-129)) then
tmp = t_0
else if (y <= 1.35d-34) then
tmp = x_m
else if (y <= 6.6d+113) then
tmp = t_0
else if (y <= 4.5d+129) then
tmp = x_m
else
tmp = 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 t_0 = x_m / (z / y);
double tmp;
if (y <= -2.1e-129) {
tmp = t_0;
} else if (y <= 1.35e-34) {
tmp = x_m;
} else if (y <= 6.6e+113) {
tmp = t_0;
} else if (y <= 4.5e+129) {
tmp = x_m;
} else {
tmp = 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): t_0 = x_m / (z / y) tmp = 0 if y <= -2.1e-129: tmp = t_0 elif y <= 1.35e-34: tmp = x_m elif y <= 6.6e+113: tmp = t_0 elif y <= 4.5e+129: tmp = x_m else: tmp = 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) t_0 = Float64(x_m / Float64(z / y)) tmp = 0.0 if (y <= -2.1e-129) tmp = t_0; elseif (y <= 1.35e-34) tmp = x_m; elseif (y <= 6.6e+113) tmp = t_0; elseif (y <= 4.5e+129) tmp = x_m; else tmp = Float64(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) t_0 = x_m / (z / y); tmp = 0.0; if (y <= -2.1e-129) tmp = t_0; elseif (y <= 1.35e-34) tmp = x_m; elseif (y <= 6.6e+113) tmp = t_0; elseif (y <= 4.5e+129) tmp = x_m; else tmp = 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_] := Block[{t$95$0 = N[(x$95$m / N[(z / y), $MachinePrecision]), $MachinePrecision]}, N[(x$95$s * If[LessEqual[y, -2.1e-129], t$95$0, If[LessEqual[y, 1.35e-34], x$95$m, If[LessEqual[y, 6.6e+113], t$95$0, If[LessEqual[y, 4.5e+129], x$95$m, N[(y * N[(x$95$m / z), $MachinePrecision]), $MachinePrecision]]]]]), $MachinePrecision]]
\begin{array}{l}
x\_m = \left|x\right|
\\
x\_s = \mathsf{copysign}\left(1, x\right)
\\
\begin{array}{l}
t_0 := \frac{x\_m}{\frac{z}{y}}\\
x\_s \cdot \begin{array}{l}
\mathbf{if}\;y \leq -2.1 \cdot 10^{-129}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 1.35 \cdot 10^{-34}:\\
\;\;\;\;x\_m\\
\mathbf{elif}\;y \leq 6.6 \cdot 10^{+113}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 4.5 \cdot 10^{+129}:\\
\;\;\;\;x\_m\\
\mathbf{else}:\\
\;\;\;\;y \cdot \frac{x\_m}{z}\\
\end{array}
\end{array}
\end{array}
if y < -2.1e-129 or 1.35000000000000008e-34 < y < 6.6000000000000006e113Initial program 90.3%
associate-/l*95.3%
remove-double-neg95.3%
distribute-frac-neg295.3%
neg-sub095.3%
remove-double-neg95.3%
unsub-neg95.3%
div-sub95.3%
*-inverses95.3%
metadata-eval95.3%
associate--r-95.3%
neg-sub095.3%
distribute-frac-neg295.3%
remove-double-neg95.3%
sub-neg95.3%
Simplified95.3%
Taylor expanded in y around inf 68.6%
*-commutative68.6%
associate-*l/67.0%
Applied egg-rr67.0%
*-commutative67.0%
clear-num67.0%
div-inv68.6%
Applied egg-rr68.6%
if -2.1e-129 < y < 1.35000000000000008e-34 or 6.6000000000000006e113 < y < 4.5000000000000001e129Initial program 77.4%
associate-/l*98.9%
remove-double-neg98.9%
distribute-frac-neg298.9%
neg-sub098.9%
remove-double-neg98.9%
unsub-neg98.9%
div-sub98.9%
*-inverses98.9%
metadata-eval98.9%
associate--r-98.9%
neg-sub098.9%
distribute-frac-neg298.9%
remove-double-neg98.9%
sub-neg98.9%
Simplified98.9%
Taylor expanded in y around 0 83.7%
if 4.5000000000000001e129 < y Initial program 86.4%
associate-/l*88.9%
remove-double-neg88.9%
distribute-frac-neg288.9%
neg-sub088.9%
remove-double-neg88.9%
unsub-neg88.9%
div-sub88.9%
*-inverses88.9%
metadata-eval88.9%
associate--r-88.9%
neg-sub088.9%
distribute-frac-neg288.9%
remove-double-neg88.9%
sub-neg88.9%
Simplified88.9%
Taylor expanded in y around inf 79.6%
associate-*l/79.6%
*-commutative79.6%
Simplified79.6%
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 (or (<= y -2.8e-106) (not (<= y 1.2e-34))) (/ (* 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 ((y <= -2.8e-106) || !(y <= 1.2e-34)) {
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 ((y <= (-2.8d-106)) .or. (.not. (y <= 1.2d-34))) 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 ((y <= -2.8e-106) || !(y <= 1.2e-34)) {
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 (y <= -2.8e-106) or not (y <= 1.2e-34): 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 ((y <= -2.8e-106) || !(y <= 1.2e-34)) 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 ((y <= -2.8e-106) || ~((y <= 1.2e-34))) 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[Or[LessEqual[y, -2.8e-106], N[Not[LessEqual[y, 1.2e-34]], $MachinePrecision]], 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}\;y \leq -2.8 \cdot 10^{-106} \lor \neg \left(y \leq 1.2 \cdot 10^{-34}\right):\\
\;\;\;\;\frac{x\_m \cdot y}{z}\\
\mathbf{else}:\\
\;\;\;\;x\_m\\
\end{array}
\end{array}
if y < -2.79999999999999988e-106 or 1.19999999999999996e-34 < y Initial program 89.5%
associate-/l*93.4%
remove-double-neg93.4%
distribute-frac-neg293.4%
neg-sub093.4%
remove-double-neg93.4%
unsub-neg93.4%
div-sub93.4%
*-inverses93.4%
metadata-eval93.4%
associate--r-93.4%
neg-sub093.4%
distribute-frac-neg293.4%
remove-double-neg93.4%
sub-neg93.4%
Simplified93.4%
Taylor expanded in y around inf 70.4%
if -2.79999999999999988e-106 < y < 1.19999999999999996e-34Initial program 77.4%
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 81.6%
Final simplification74.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 (if (or (<= y -2.1e-129) (not (<= y 7e-35))) (* 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 ((y <= -2.1e-129) || !(y <= 7e-35)) {
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 ((y <= (-2.1d-129)) .or. (.not. (y <= 7d-35))) 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 ((y <= -2.1e-129) || !(y <= 7e-35)) {
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 (y <= -2.1e-129) or not (y <= 7e-35): 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 ((y <= -2.1e-129) || !(y <= 7e-35)) 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 ((y <= -2.1e-129) || ~((y <= 7e-35))) 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[Or[LessEqual[y, -2.1e-129], N[Not[LessEqual[y, 7e-35]], $MachinePrecision]], 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}\;y \leq -2.1 \cdot 10^{-129} \lor \neg \left(y \leq 7 \cdot 10^{-35}\right):\\
\;\;\;\;y \cdot \frac{x\_m}{z}\\
\mathbf{else}:\\
\;\;\;\;x\_m\\
\end{array}
\end{array}
if y < -2.1e-129 or 6.99999999999999992e-35 < y Initial program 88.7%
associate-/l*93.6%
remove-double-neg93.6%
distribute-frac-neg293.6%
neg-sub093.6%
remove-double-neg93.6%
unsub-neg93.6%
div-sub93.6%
*-inverses93.6%
metadata-eval93.6%
associate--r-93.6%
neg-sub093.6%
distribute-frac-neg293.6%
remove-double-neg93.6%
sub-neg93.6%
Simplified93.6%
Taylor expanded in y around inf 69.1%
associate-*l/68.4%
*-commutative68.4%
Simplified68.4%
if -2.1e-129 < y < 6.99999999999999992e-35Initial program 78.0%
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 83.7%
Final simplification73.6%
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.1%
associate-/l*95.8%
remove-double-neg95.8%
distribute-frac-neg295.8%
neg-sub095.8%
remove-double-neg95.8%
unsub-neg95.8%
div-sub95.7%
*-inverses95.7%
metadata-eval95.7%
associate--r-95.7%
neg-sub095.7%
distribute-frac-neg295.7%
remove-double-neg95.7%
sub-neg95.7%
Simplified95.7%
sub-neg95.7%
metadata-eval95.7%
distribute-rgt-in95.8%
*-commutative95.8%
*-un-lft-identity95.8%
Applied egg-rr95.8%
clear-num95.7%
un-div-inv96.7%
Applied egg-rr96.7%
Final simplification96.7%
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 85.1%
associate-/l*95.8%
remove-double-neg95.8%
distribute-frac-neg295.8%
neg-sub095.8%
remove-double-neg95.8%
unsub-neg95.8%
div-sub95.7%
*-inverses95.7%
metadata-eval95.7%
associate--r-95.7%
neg-sub095.7%
distribute-frac-neg295.7%
remove-double-neg95.7%
sub-neg95.7%
Simplified95.7%
sub-neg95.7%
metadata-eval95.7%
distribute-rgt-in95.8%
*-commutative95.8%
*-un-lft-identity95.8%
Applied egg-rr95.8%
Final simplification95.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 (* 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.1%
associate-/l*95.8%
remove-double-neg95.8%
distribute-frac-neg295.8%
neg-sub095.8%
remove-double-neg95.8%
unsub-neg95.8%
div-sub95.7%
*-inverses95.7%
metadata-eval95.7%
associate--r-95.7%
neg-sub095.7%
distribute-frac-neg295.7%
remove-double-neg95.7%
sub-neg95.7%
Simplified95.7%
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.1%
associate-/l*95.8%
remove-double-neg95.8%
distribute-frac-neg295.8%
neg-sub095.8%
remove-double-neg95.8%
unsub-neg95.8%
div-sub95.7%
*-inverses95.7%
metadata-eval95.7%
associate--r-95.7%
neg-sub095.7%
distribute-frac-neg295.7%
remove-double-neg95.7%
sub-neg95.7%
Simplified95.7%
Taylor expanded in y around 0 47.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 2024110
(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))