
(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.12e-138) (+ x_m (/ (* x_m y) 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.12e-138) {
tmp = x_m + ((x_m * y) / 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.12e-138) tmp = Float64(x_m + Float64(Float64(x_m * y) / 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.12e-138], N[(x$95$m + N[(N[(x$95$m * y), $MachinePrecision] / z), $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.12 \cdot 10^{-138}:\\
\;\;\;\;x\_m + \frac{x\_m \cdot y}{z}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(x\_m, \frac{y}{z}, x\_m\right)\\
\end{array}
\end{array}
if x < 1.1199999999999999e-138Initial program 84.6%
associate-/l*93.3%
remove-double-neg93.3%
distribute-frac-neg293.3%
neg-sub093.3%
remove-double-neg93.3%
unsub-neg93.3%
div-sub93.3%
*-inverses93.3%
metadata-eval93.3%
associate--r-93.3%
neg-sub093.3%
distribute-frac-neg293.3%
remove-double-neg93.3%
sub-neg93.3%
Simplified93.3%
Taylor expanded in y around 0 95.7%
if 1.1199999999999999e-138 < x Initial program 82.2%
remove-double-neg82.2%
distribute-frac-neg282.2%
distribute-frac-neg82.2%
distribute-rgt-neg-in82.2%
distribute-neg-in82.2%
distribute-lft-out82.1%
*-commutative82.1%
cancel-sign-sub-inv82.1%
div-sub82.2%
associate-*r/82.3%
distribute-neg-frac82.3%
distribute-frac-neg282.3%
remove-double-neg82.3%
fma-neg82.3%
distribute-frac-neg82.3%
distribute-lft-neg-out82.3%
*-commutative82.3%
associate-/l*99.0%
*-inverses99.0%
*-rgt-identity99.0%
Simplified99.0%
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
(if (or (<= y -1.5e+56)
(and (not (<= y -4.1e+27))
(or (<= y -5.8e-114) (not (<= y 2.4e+78)))))
(* 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.5e+56) || (!(y <= -4.1e+27) && ((y <= -5.8e-114) || !(y <= 2.4e+78)))) {
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.5d+56)) .or. (.not. (y <= (-4.1d+27))) .and. (y <= (-5.8d-114)) .or. (.not. (y <= 2.4d+78))) 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.5e+56) || (!(y <= -4.1e+27) && ((y <= -5.8e-114) || !(y <= 2.4e+78)))) {
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.5e+56) or (not (y <= -4.1e+27) and ((y <= -5.8e-114) or not (y <= 2.4e+78))): 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.5e+56) || (!(y <= -4.1e+27) && ((y <= -5.8e-114) || !(y <= 2.4e+78)))) 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.5e+56) || (~((y <= -4.1e+27)) && ((y <= -5.8e-114) || ~((y <= 2.4e+78))))) 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.5e+56], And[N[Not[LessEqual[y, -4.1e+27]], $MachinePrecision], Or[LessEqual[y, -5.8e-114], N[Not[LessEqual[y, 2.4e+78]], $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.5 \cdot 10^{+56} \lor \neg \left(y \leq -4.1 \cdot 10^{+27}\right) \land \left(y \leq -5.8 \cdot 10^{-114} \lor \neg \left(y \leq 2.4 \cdot 10^{+78}\right)\right):\\
\;\;\;\;x\_m \cdot \frac{y}{z}\\
\mathbf{else}:\\
\;\;\;\;x\_m\\
\end{array}
\end{array}
if y < -1.50000000000000003e56 or -4.1000000000000002e27 < y < -5.79999999999999993e-114 or 2.3999999999999999e78 < y Initial program 88.4%
associate-/l*91.1%
remove-double-neg91.1%
distribute-frac-neg291.1%
neg-sub091.1%
remove-double-neg91.1%
unsub-neg91.1%
div-sub91.1%
*-inverses91.1%
metadata-eval91.1%
associate--r-91.1%
neg-sub091.1%
distribute-frac-neg291.1%
remove-double-neg91.1%
sub-neg91.1%
Simplified91.1%
Taylor expanded in y around inf 76.1%
associate-*r/70.3%
Simplified70.3%
if -1.50000000000000003e56 < y < -4.1000000000000002e27 or -5.79999999999999993e-114 < y < 2.3999999999999999e78Initial program 78.8%
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.0%
Final simplification76.5%
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 (* y (/ x_m z))))
(*
x_s
(if (<= y -7.5e+54)
t_0
(if (<= y -8e+25)
x_m
(if (<= y -1e-114) (* x_m (/ y z)) (if (<= y 2.4e+78) x_m t_0)))))))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 = y * (x_m / z);
double tmp;
if (y <= -7.5e+54) {
tmp = t_0;
} else if (y <= -8e+25) {
tmp = x_m;
} else if (y <= -1e-114) {
tmp = x_m * (y / z);
} else if (y <= 2.4e+78) {
tmp = x_m;
} else {
tmp = t_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) :: t_0
real(8) :: tmp
t_0 = y * (x_m / z)
if (y <= (-7.5d+54)) then
tmp = t_0
else if (y <= (-8d+25)) then
tmp = x_m
else if (y <= (-1d-114)) then
tmp = x_m * (y / z)
else if (y <= 2.4d+78) then
tmp = x_m
else
tmp = t_0
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 = y * (x_m / z);
double tmp;
if (y <= -7.5e+54) {
tmp = t_0;
} else if (y <= -8e+25) {
tmp = x_m;
} else if (y <= -1e-114) {
tmp = x_m * (y / z);
} else if (y <= 2.4e+78) {
tmp = x_m;
} else {
tmp = t_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): t_0 = y * (x_m / z) tmp = 0 if y <= -7.5e+54: tmp = t_0 elif y <= -8e+25: tmp = x_m elif y <= -1e-114: tmp = x_m * (y / z) elif y <= 2.4e+78: tmp = x_m else: tmp = t_0 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(y * Float64(x_m / z)) tmp = 0.0 if (y <= -7.5e+54) tmp = t_0; elseif (y <= -8e+25) tmp = x_m; elseif (y <= -1e-114) tmp = Float64(x_m * Float64(y / z)); elseif (y <= 2.4e+78) tmp = x_m; else tmp = t_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) t_0 = y * (x_m / z); tmp = 0.0; if (y <= -7.5e+54) tmp = t_0; elseif (y <= -8e+25) tmp = x_m; elseif (y <= -1e-114) tmp = x_m * (y / z); elseif (y <= 2.4e+78) tmp = x_m; else tmp = t_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_] := Block[{t$95$0 = N[(y * N[(x$95$m / z), $MachinePrecision]), $MachinePrecision]}, N[(x$95$s * If[LessEqual[y, -7.5e+54], t$95$0, If[LessEqual[y, -8e+25], x$95$m, If[LessEqual[y, -1e-114], N[(x$95$m * N[(y / z), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 2.4e+78], x$95$m, t$95$0]]]]), $MachinePrecision]]
\begin{array}{l}
x\_m = \left|x\right|
\\
x\_s = \mathsf{copysign}\left(1, x\right)
\\
\begin{array}{l}
t_0 := y \cdot \frac{x\_m}{z}\\
x\_s \cdot \begin{array}{l}
\mathbf{if}\;y \leq -7.5 \cdot 10^{+54}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq -8 \cdot 10^{+25}:\\
\;\;\;\;x\_m\\
\mathbf{elif}\;y \leq -1 \cdot 10^{-114}:\\
\;\;\;\;x\_m \cdot \frac{y}{z}\\
\mathbf{elif}\;y \leq 2.4 \cdot 10^{+78}:\\
\;\;\;\;x\_m\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
\end{array}
if y < -7.50000000000000042e54 or 2.3999999999999999e78 < y Initial program 91.0%
associate-/l*90.1%
remove-double-neg90.1%
distribute-frac-neg290.1%
neg-sub090.1%
remove-double-neg90.1%
unsub-neg90.1%
div-sub90.1%
*-inverses90.1%
metadata-eval90.1%
associate--r-90.1%
neg-sub090.1%
distribute-frac-neg290.1%
remove-double-neg90.1%
sub-neg90.1%
Simplified90.1%
Taylor expanded in y around inf 79.2%
*-commutative79.2%
associate-/l*80.5%
Applied egg-rr80.5%
if -7.50000000000000042e54 < y < -8.00000000000000072e25 or -1.0000000000000001e-114 < y < 2.3999999999999999e78Initial program 78.8%
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.0%
if -8.00000000000000072e25 < y < -1.0000000000000001e-114Initial program 76.1%
associate-/l*95.5%
remove-double-neg95.5%
distribute-frac-neg295.5%
neg-sub095.5%
remove-double-neg95.5%
unsub-neg95.5%
div-sub95.5%
*-inverses95.5%
metadata-eval95.5%
associate--r-95.5%
neg-sub095.5%
distribute-frac-neg295.5%
remove-double-neg95.5%
sub-neg95.5%
Simplified95.5%
Taylor expanded in y around inf 61.9%
associate-*r/57.9%
Simplified57.9%
Final simplification79.7%
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 (* y (/ x_m z))))
(*
x_s
(if (<= y -8.5e+54)
t_0
(if (<= y -7.2e+27)
x_m
(if (<= y -5.8e-114) (/ x_m (/ z y)) (if (<= y 2.4e+78) x_m t_0)))))))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 = y * (x_m / z);
double tmp;
if (y <= -8.5e+54) {
tmp = t_0;
} else if (y <= -7.2e+27) {
tmp = x_m;
} else if (y <= -5.8e-114) {
tmp = x_m / (z / y);
} else if (y <= 2.4e+78) {
tmp = x_m;
} else {
tmp = t_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) :: t_0
real(8) :: tmp
t_0 = y * (x_m / z)
if (y <= (-8.5d+54)) then
tmp = t_0
else if (y <= (-7.2d+27)) then
tmp = x_m
else if (y <= (-5.8d-114)) then
tmp = x_m / (z / y)
else if (y <= 2.4d+78) then
tmp = x_m
else
tmp = t_0
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 = y * (x_m / z);
double tmp;
if (y <= -8.5e+54) {
tmp = t_0;
} else if (y <= -7.2e+27) {
tmp = x_m;
} else if (y <= -5.8e-114) {
tmp = x_m / (z / y);
} else if (y <= 2.4e+78) {
tmp = x_m;
} else {
tmp = t_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): t_0 = y * (x_m / z) tmp = 0 if y <= -8.5e+54: tmp = t_0 elif y <= -7.2e+27: tmp = x_m elif y <= -5.8e-114: tmp = x_m / (z / y) elif y <= 2.4e+78: tmp = x_m else: tmp = t_0 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(y * Float64(x_m / z)) tmp = 0.0 if (y <= -8.5e+54) tmp = t_0; elseif (y <= -7.2e+27) tmp = x_m; elseif (y <= -5.8e-114) tmp = Float64(x_m / Float64(z / y)); elseif (y <= 2.4e+78) tmp = x_m; else tmp = t_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) t_0 = y * (x_m / z); tmp = 0.0; if (y <= -8.5e+54) tmp = t_0; elseif (y <= -7.2e+27) tmp = x_m; elseif (y <= -5.8e-114) tmp = x_m / (z / y); elseif (y <= 2.4e+78) tmp = x_m; else tmp = t_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_] := Block[{t$95$0 = N[(y * N[(x$95$m / z), $MachinePrecision]), $MachinePrecision]}, N[(x$95$s * If[LessEqual[y, -8.5e+54], t$95$0, If[LessEqual[y, -7.2e+27], x$95$m, If[LessEqual[y, -5.8e-114], N[(x$95$m / N[(z / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 2.4e+78], x$95$m, t$95$0]]]]), $MachinePrecision]]
\begin{array}{l}
x\_m = \left|x\right|
\\
x\_s = \mathsf{copysign}\left(1, x\right)
\\
\begin{array}{l}
t_0 := y \cdot \frac{x\_m}{z}\\
x\_s \cdot \begin{array}{l}
\mathbf{if}\;y \leq -8.5 \cdot 10^{+54}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq -7.2 \cdot 10^{+27}:\\
\;\;\;\;x\_m\\
\mathbf{elif}\;y \leq -5.8 \cdot 10^{-114}:\\
\;\;\;\;\frac{x\_m}{\frac{z}{y}}\\
\mathbf{elif}\;y \leq 2.4 \cdot 10^{+78}:\\
\;\;\;\;x\_m\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
\end{array}
if y < -8.4999999999999995e54 or 2.3999999999999999e78 < y Initial program 91.0%
associate-/l*90.1%
remove-double-neg90.1%
distribute-frac-neg290.1%
neg-sub090.1%
remove-double-neg90.1%
unsub-neg90.1%
div-sub90.1%
*-inverses90.1%
metadata-eval90.1%
associate--r-90.1%
neg-sub090.1%
distribute-frac-neg290.1%
remove-double-neg90.1%
sub-neg90.1%
Simplified90.1%
Taylor expanded in y around inf 79.2%
*-commutative79.2%
associate-/l*80.5%
Applied egg-rr80.5%
if -8.4999999999999995e54 < y < -7.19999999999999966e27 or -5.79999999999999993e-114 < y < 2.3999999999999999e78Initial program 78.8%
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.0%
if -7.19999999999999966e27 < y < -5.79999999999999993e-114Initial program 76.1%
associate-/l*95.5%
remove-double-neg95.5%
distribute-frac-neg295.5%
neg-sub095.5%
remove-double-neg95.5%
unsub-neg95.5%
div-sub95.5%
*-inverses95.5%
metadata-eval95.5%
associate--r-95.5%
neg-sub095.5%
distribute-frac-neg295.5%
remove-double-neg95.5%
sub-neg95.5%
Simplified95.5%
Taylor expanded in y around inf 61.9%
*-commutative61.9%
associate-/l*54.2%
Applied egg-rr54.2%
associate-*r/61.9%
associate-*l/57.9%
*-commutative57.9%
clear-num57.8%
un-div-inv62.0%
Applied egg-rr62.0%
Final simplification80.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 (<= y -1.72e+56)
(* y (/ x_m z))
(if (<= y -5.4e+26)
x_m
(if (<= y -5.8e-114)
(/ x_m (/ z y))
(if (<= y 3.1e+78) 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 <= -1.72e+56) {
tmp = y * (x_m / z);
} else if (y <= -5.4e+26) {
tmp = x_m;
} else if (y <= -5.8e-114) {
tmp = x_m / (z / y);
} else if (y <= 3.1e+78) {
tmp = x_m;
} else {
tmp = (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 <= (-1.72d+56)) then
tmp = y * (x_m / z)
else if (y <= (-5.4d+26)) then
tmp = x_m
else if (y <= (-5.8d-114)) then
tmp = x_m / (z / y)
else if (y <= 3.1d+78) then
tmp = x_m
else
tmp = (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 <= -1.72e+56) {
tmp = y * (x_m / z);
} else if (y <= -5.4e+26) {
tmp = x_m;
} else if (y <= -5.8e-114) {
tmp = x_m / (z / y);
} else if (y <= 3.1e+78) {
tmp = x_m;
} else {
tmp = (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 <= -1.72e+56: tmp = y * (x_m / z) elif y <= -5.4e+26: tmp = x_m elif y <= -5.8e-114: tmp = x_m / (z / y) elif y <= 3.1e+78: tmp = x_m else: tmp = (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 <= -1.72e+56) tmp = Float64(y * Float64(x_m / z)); elseif (y <= -5.4e+26) tmp = x_m; elseif (y <= -5.8e-114) tmp = Float64(x_m / Float64(z / y)); elseif (y <= 3.1e+78) tmp = x_m; else tmp = Float64(Float64(x_m * 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 <= -1.72e+56) tmp = y * (x_m / z); elseif (y <= -5.4e+26) tmp = x_m; elseif (y <= -5.8e-114) tmp = x_m / (z / y); elseif (y <= 3.1e+78) tmp = x_m; else tmp = (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, -1.72e+56], N[(y * N[(x$95$m / z), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, -5.4e+26], x$95$m, If[LessEqual[y, -5.8e-114], N[(x$95$m / N[(z / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 3.1e+78], x$95$m, N[(N[(x$95$m * y), $MachinePrecision] / z), $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 -1.72 \cdot 10^{+56}:\\
\;\;\;\;y \cdot \frac{x\_m}{z}\\
\mathbf{elif}\;y \leq -5.4 \cdot 10^{+26}:\\
\;\;\;\;x\_m\\
\mathbf{elif}\;y \leq -5.8 \cdot 10^{-114}:\\
\;\;\;\;\frac{x\_m}{\frac{z}{y}}\\
\mathbf{elif}\;y \leq 3.1 \cdot 10^{+78}:\\
\;\;\;\;x\_m\\
\mathbf{else}:\\
\;\;\;\;\frac{x\_m \cdot y}{z}\\
\end{array}
\end{array}
if y < -1.72e56Initial program 90.9%
associate-/l*96.7%
remove-double-neg96.7%
distribute-frac-neg296.7%
neg-sub096.7%
remove-double-neg96.7%
unsub-neg96.7%
div-sub96.7%
*-inverses96.7%
metadata-eval96.7%
associate--r-96.7%
neg-sub096.7%
distribute-frac-neg296.7%
remove-double-neg96.7%
sub-neg96.7%
Simplified96.7%
Taylor expanded in y around inf 75.4%
*-commutative75.4%
associate-/l*77.8%
Applied egg-rr77.8%
if -1.72e56 < y < -5.4e26 or -5.79999999999999993e-114 < y < 3.1e78Initial program 78.8%
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.0%
if -5.4e26 < y < -5.79999999999999993e-114Initial program 76.1%
associate-/l*95.5%
remove-double-neg95.5%
distribute-frac-neg295.5%
neg-sub095.5%
remove-double-neg95.5%
unsub-neg95.5%
div-sub95.5%
*-inverses95.5%
metadata-eval95.5%
associate--r-95.5%
neg-sub095.5%
distribute-frac-neg295.5%
remove-double-neg95.5%
sub-neg95.5%
Simplified95.5%
Taylor expanded in y around inf 61.9%
*-commutative61.9%
associate-/l*54.2%
Applied egg-rr54.2%
associate-*r/61.9%
associate-*l/57.9%
*-commutative57.9%
clear-num57.8%
un-div-inv62.0%
Applied egg-rr62.0%
if 3.1e78 < y Initial program 91.1%
associate-/l*80.5%
remove-double-neg80.5%
distribute-frac-neg280.5%
neg-sub080.5%
remove-double-neg80.5%
unsub-neg80.5%
div-sub80.5%
*-inverses80.5%
metadata-eval80.5%
associate--r-80.5%
neg-sub080.5%
distribute-frac-neg280.5%
remove-double-neg80.5%
sub-neg80.5%
Simplified80.5%
Taylor expanded in y around inf 84.6%
Final simplification80.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 (<= y 1.8e+118) (* x_m (- (/ y z) -1.0)) (/ (* 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 <= 1.8e+118) {
tmp = x_m * ((y / z) - -1.0);
} else {
tmp = (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 <= 1.8d+118) then
tmp = x_m * ((y / z) - (-1.0d0))
else
tmp = (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 <= 1.8e+118) {
tmp = x_m * ((y / z) - -1.0);
} else {
tmp = (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 <= 1.8e+118: tmp = x_m * ((y / z) - -1.0) else: tmp = (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 <= 1.8e+118) tmp = Float64(x_m * Float64(Float64(y / z) - -1.0)); else tmp = Float64(Float64(x_m * 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 <= 1.8e+118) tmp = x_m * ((y / z) - -1.0); else tmp = (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, 1.8e+118], N[(x$95$m * N[(N[(y / z), $MachinePrecision] - -1.0), $MachinePrecision]), $MachinePrecision], N[(N[(x$95$m * y), $MachinePrecision] / z), $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 1.8 \cdot 10^{+118}:\\
\;\;\;\;x\_m \cdot \left(\frac{y}{z} - -1\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{x\_m \cdot y}{z}\\
\end{array}
\end{array}
if y < 1.8e118Initial program 82.2%
associate-/l*98.5%
remove-double-neg98.5%
distribute-frac-neg298.5%
neg-sub098.5%
remove-double-neg98.5%
unsub-neg98.5%
div-sub98.5%
*-inverses98.5%
metadata-eval98.5%
associate--r-98.5%
neg-sub098.5%
distribute-frac-neg298.5%
remove-double-neg98.5%
sub-neg98.5%
Simplified98.5%
if 1.8e118 < y Initial program 92.3%
associate-/l*77.5%
remove-double-neg77.5%
distribute-frac-neg277.5%
neg-sub077.5%
remove-double-neg77.5%
unsub-neg77.5%
div-sub77.5%
*-inverses77.5%
metadata-eval77.5%
associate--r-77.5%
neg-sub077.5%
distribute-frac-neg277.5%
remove-double-neg77.5%
sub-neg77.5%
Simplified77.5%
Taylor expanded in y around inf 89.6%
Final simplification97.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 (<= y 3.6e+123) (* x_m (- (/ y z) -1.0)) (* (+ y z) (/ 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 (y <= 3.6e+123) {
tmp = x_m * ((y / z) - -1.0);
} else {
tmp = (y + z) * (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 (y <= 3.6d+123) then
tmp = x_m * ((y / z) - (-1.0d0))
else
tmp = (y + z) * (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 (y <= 3.6e+123) {
tmp = x_m * ((y / z) - -1.0);
} else {
tmp = (y + z) * (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 y <= 3.6e+123: tmp = x_m * ((y / z) - -1.0) else: tmp = (y + z) * (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 (y <= 3.6e+123) tmp = Float64(x_m * Float64(Float64(y / z) - -1.0)); else tmp = Float64(Float64(y + z) * 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 (y <= 3.6e+123) tmp = x_m * ((y / z) - -1.0); else tmp = (y + z) * (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[LessEqual[y, 3.6e+123], N[(x$95$m * N[(N[(y / z), $MachinePrecision] - -1.0), $MachinePrecision]), $MachinePrecision], N[(N[(y + z), $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}\;y \leq 3.6 \cdot 10^{+123}:\\
\;\;\;\;x\_m \cdot \left(\frac{y}{z} - -1\right)\\
\mathbf{else}:\\
\;\;\;\;\left(y + z\right) \cdot \frac{x\_m}{z}\\
\end{array}
\end{array}
if y < 3.59999999999999998e123Initial program 82.3%
associate-/l*98.5%
remove-double-neg98.5%
distribute-frac-neg298.5%
neg-sub098.5%
remove-double-neg98.5%
unsub-neg98.5%
div-sub98.5%
*-inverses98.5%
metadata-eval98.5%
associate--r-98.5%
neg-sub098.5%
distribute-frac-neg298.5%
remove-double-neg98.5%
sub-neg98.5%
Simplified98.5%
if 3.59999999999999998e123 < y Initial program 92.1%
*-commutative92.1%
associate-/l*94.7%
Simplified94.7%
Final simplification97.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 (if (<= x_m 3.3e-131) (+ x_m (/ (* x_m y) 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 <= 3.3e-131) {
tmp = x_m + ((x_m * y) / 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 <= 3.3d-131) then
tmp = x_m + ((x_m * y) / 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 <= 3.3e-131) {
tmp = x_m + ((x_m * y) / 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 <= 3.3e-131: tmp = x_m + ((x_m * y) / 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 <= 3.3e-131) tmp = Float64(x_m + Float64(Float64(x_m * y) / 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 <= 3.3e-131) tmp = x_m + ((x_m * y) / 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, 3.3e-131], N[(x$95$m + N[(N[(x$95$m * y), $MachinePrecision] / z), $MachinePrecision]), $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 3.3 \cdot 10^{-131}:\\
\;\;\;\;x\_m + \frac{x\_m \cdot y}{z}\\
\mathbf{else}:\\
\;\;\;\;x\_m \cdot \left(\frac{y}{z} - -1\right)\\
\end{array}
\end{array}
if x < 3.3000000000000002e-131Initial program 84.8%
associate-/l*93.3%
remove-double-neg93.3%
distribute-frac-neg293.3%
neg-sub093.3%
remove-double-neg93.3%
unsub-neg93.3%
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 0 95.8%
if 3.3000000000000002e-131 < x Initial program 81.8%
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%
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 = 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 83.7%
associate-/l*95.4%
remove-double-neg95.4%
distribute-frac-neg295.4%
neg-sub095.4%
remove-double-neg95.4%
unsub-neg95.4%
div-sub95.4%
*-inverses95.4%
metadata-eval95.4%
associate--r-95.4%
neg-sub095.4%
distribute-frac-neg295.4%
remove-double-neg95.4%
sub-neg95.4%
Simplified95.4%
Taylor expanded in y around 0 51.8%
Final simplification51.8%
(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 2024059
(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))