
(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 1 x) (FPCore (x_s x_m y z) :precision binary64 (let* ((t_0 (/ (* x_m (+ y z)) z))) (* x_s (if (<= t_0 -5e+124) t_0 (+ 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 t_0 = (x_m * (y + z)) / z;
double tmp;
if (t_0 <= -5e+124) {
tmp = t_0;
} 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) :: t_0
real(8) :: tmp
t_0 = (x_m * (y + z)) / z
if (t_0 <= (-5d+124)) then
tmp = t_0
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 t_0 = (x_m * (y + z)) / z;
double tmp;
if (t_0 <= -5e+124) {
tmp = t_0;
} 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): t_0 = (x_m * (y + z)) / z tmp = 0 if t_0 <= -5e+124: tmp = t_0 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) t_0 = Float64(Float64(x_m * Float64(y + z)) / z) tmp = 0.0 if (t_0 <= -5e+124) tmp = t_0; 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) t_0 = (x_m * (y + z)) / z; tmp = 0.0; if (t_0 <= -5e+124) tmp = t_0; 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_] := Block[{t$95$0 = N[(N[(x$95$m * N[(y + z), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]}, N[(x$95$s * If[LessEqual[t$95$0, -5e+124], t$95$0, 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)
\\
\begin{array}{l}
t_0 := \frac{x_m \cdot \left(y + z\right)}{z}\\
x_s \cdot \begin{array}{l}
\mathbf{if}\;t_0 \leq -5 \cdot 10^{+124}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;x_m + \frac{x_m}{\frac{z}{y}}\\
\end{array}
\end{array}
\end{array}
if (/.f64 (*.f64 x (+.f64 y z)) z) < -4.9999999999999996e124Initial program 79.7%
if -4.9999999999999996e124 < (/.f64 (*.f64 x (+.f64 y z)) z) Initial program 86.5%
remove-double-neg86.5%
distribute-lft-neg-out86.5%
*-commutative86.5%
distribute-lft-neg-in86.5%
associate-/l*84.2%
distribute-neg-in84.2%
unsub-neg84.2%
div-sub81.5%
distribute-frac-neg81.5%
associate-/r/82.2%
distribute-rgt-neg-out82.2%
remove-double-neg82.2%
associate-/r/97.5%
*-inverses97.5%
*-lft-identity97.5%
*-commutative97.5%
fma-neg97.4%
remove-double-neg97.4%
Simplified97.4%
fma-udef97.5%
Applied egg-rr97.5%
associate-*r/93.2%
associate-/l*97.9%
Applied egg-rr97.9%
Final simplification93.4%
x_m = (fabs.f64 x)
x_s = (copysign.f64 1 x)
(FPCore (x_s x_m y z)
:precision binary64
(*
x_s
(if (<= z -1.85e+101)
x_m
(if (<= z -1.4e+43)
(* x_m (/ y z))
(if (<= z -5.2e-12)
x_m
(if (<= z 8.6e-249)
(/ x_m (/ z y))
(if (<= z 2.85e+38) (/ 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 <= -1.85e+101) {
tmp = x_m;
} else if (z <= -1.4e+43) {
tmp = x_m * (y / z);
} else if (z <= -5.2e-12) {
tmp = x_m;
} else if (z <= 8.6e-249) {
tmp = x_m / (z / y);
} else if (z <= 2.85e+38) {
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 <= (-1.85d+101)) then
tmp = x_m
else if (z <= (-1.4d+43)) then
tmp = x_m * (y / z)
else if (z <= (-5.2d-12)) then
tmp = x_m
else if (z <= 8.6d-249) then
tmp = x_m / (z / y)
else if (z <= 2.85d+38) 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 <= -1.85e+101) {
tmp = x_m;
} else if (z <= -1.4e+43) {
tmp = x_m * (y / z);
} else if (z <= -5.2e-12) {
tmp = x_m;
} else if (z <= 8.6e-249) {
tmp = x_m / (z / y);
} else if (z <= 2.85e+38) {
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 <= -1.85e+101: tmp = x_m elif z <= -1.4e+43: tmp = x_m * (y / z) elif z <= -5.2e-12: tmp = x_m elif z <= 8.6e-249: tmp = x_m / (z / y) elif z <= 2.85e+38: 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 <= -1.85e+101) tmp = x_m; elseif (z <= -1.4e+43) tmp = Float64(x_m * Float64(y / z)); elseif (z <= -5.2e-12) tmp = x_m; elseif (z <= 8.6e-249) tmp = Float64(x_m / Float64(z / y)); elseif (z <= 2.85e+38) 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 <= -1.85e+101) tmp = x_m; elseif (z <= -1.4e+43) tmp = x_m * (y / z); elseif (z <= -5.2e-12) tmp = x_m; elseif (z <= 8.6e-249) tmp = x_m / (z / y); elseif (z <= 2.85e+38) 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, -1.85e+101], x$95$m, If[LessEqual[z, -1.4e+43], N[(x$95$m * N[(y / z), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, -5.2e-12], x$95$m, If[LessEqual[z, 8.6e-249], N[(x$95$m / N[(z / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 2.85e+38], 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 -1.85 \cdot 10^{+101}:\\
\;\;\;\;x_m\\
\mathbf{elif}\;z \leq -1.4 \cdot 10^{+43}:\\
\;\;\;\;x_m \cdot \frac{y}{z}\\
\mathbf{elif}\;z \leq -5.2 \cdot 10^{-12}:\\
\;\;\;\;x_m\\
\mathbf{elif}\;z \leq 8.6 \cdot 10^{-249}:\\
\;\;\;\;\frac{x_m}{\frac{z}{y}}\\
\mathbf{elif}\;z \leq 2.85 \cdot 10^{+38}:\\
\;\;\;\;\frac{y}{\frac{z}{x_m}}\\
\mathbf{else}:\\
\;\;\;\;x_m\\
\end{array}
\end{array}
if z < -1.8499999999999999e101 or -1.40000000000000009e43 < z < -5.19999999999999965e-12 or 2.8499999999999999e38 < z Initial program 71.5%
associate-*l/77.8%
*-commutative77.8%
Simplified77.8%
Taylor expanded in y around 0 79.5%
if -1.8499999999999999e101 < z < -1.40000000000000009e43Initial program 89.7%
associate-*l/88.9%
*-commutative88.9%
Simplified88.9%
Taylor expanded in y around inf 57.9%
associate-*r/68.0%
Simplified68.0%
if -5.19999999999999965e-12 < z < 8.6000000000000003e-249Initial program 92.9%
associate-*l/88.9%
*-commutative88.9%
Simplified88.9%
Taylor expanded in y around inf 77.7%
associate-*r/83.4%
Simplified83.4%
associate-*r/94.3%
associate-/l*99.9%
Applied egg-rr83.4%
if 8.6000000000000003e-249 < z < 2.8499999999999999e38Initial program 95.6%
associate-*l/94.3%
*-commutative94.3%
Simplified94.3%
Taylor expanded in y around inf 70.8%
associate-*r/62.4%
Simplified62.4%
associate-*r/70.8%
*-commutative70.8%
associate-/l*70.8%
Applied egg-rr70.8%
Final simplification77.5%
x_m = (fabs.f64 x)
x_s = (copysign.f64 1 x)
(FPCore (x_s x_m y z)
:precision binary64
(let* ((t_0 (* (+ y z) (/ x_m z))))
(*
x_s
(if (<= z -5.6e+153)
x_m
(if (<= z -3.6e-200)
t_0
(if (<= z 5.5e-283) (* x_m (/ y z)) (if (<= z 1.7e+201) t_0 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 t_0 = (y + z) * (x_m / z);
double tmp;
if (z <= -5.6e+153) {
tmp = x_m;
} else if (z <= -3.6e-200) {
tmp = t_0;
} else if (z <= 5.5e-283) {
tmp = x_m * (y / z);
} else if (z <= 1.7e+201) {
tmp = t_0;
} 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) :: t_0
real(8) :: tmp
t_0 = (y + z) * (x_m / z)
if (z <= (-5.6d+153)) then
tmp = x_m
else if (z <= (-3.6d-200)) then
tmp = t_0
else if (z <= 5.5d-283) then
tmp = x_m * (y / z)
else if (z <= 1.7d+201) then
tmp = t_0
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 t_0 = (y + z) * (x_m / z);
double tmp;
if (z <= -5.6e+153) {
tmp = x_m;
} else if (z <= -3.6e-200) {
tmp = t_0;
} else if (z <= 5.5e-283) {
tmp = x_m * (y / z);
} else if (z <= 1.7e+201) {
tmp = t_0;
} 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): t_0 = (y + z) * (x_m / z) tmp = 0 if z <= -5.6e+153: tmp = x_m elif z <= -3.6e-200: tmp = t_0 elif z <= 5.5e-283: tmp = x_m * (y / z) elif z <= 1.7e+201: tmp = t_0 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) t_0 = Float64(Float64(y + z) * Float64(x_m / z)) tmp = 0.0 if (z <= -5.6e+153) tmp = x_m; elseif (z <= -3.6e-200) tmp = t_0; elseif (z <= 5.5e-283) tmp = Float64(x_m * Float64(y / z)); elseif (z <= 1.7e+201) tmp = t_0; 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) t_0 = (y + z) * (x_m / z); tmp = 0.0; if (z <= -5.6e+153) tmp = x_m; elseif (z <= -3.6e-200) tmp = t_0; elseif (z <= 5.5e-283) tmp = x_m * (y / z); elseif (z <= 1.7e+201) tmp = t_0; 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_] := Block[{t$95$0 = N[(N[(y + z), $MachinePrecision] * N[(x$95$m / z), $MachinePrecision]), $MachinePrecision]}, N[(x$95$s * If[LessEqual[z, -5.6e+153], x$95$m, If[LessEqual[z, -3.6e-200], t$95$0, If[LessEqual[z, 5.5e-283], N[(x$95$m * N[(y / z), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 1.7e+201], t$95$0, x$95$m]]]]), $MachinePrecision]]
\begin{array}{l}
x_m = \left|x\right|
\\
x_s = \mathsf{copysign}\left(1, x\right)
\\
\begin{array}{l}
t_0 := \left(y + z\right) \cdot \frac{x_m}{z}\\
x_s \cdot \begin{array}{l}
\mathbf{if}\;z \leq -5.6 \cdot 10^{+153}:\\
\;\;\;\;x_m\\
\mathbf{elif}\;z \leq -3.6 \cdot 10^{-200}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;z \leq 5.5 \cdot 10^{-283}:\\
\;\;\;\;x_m \cdot \frac{y}{z}\\
\mathbf{elif}\;z \leq 1.7 \cdot 10^{+201}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;x_m\\
\end{array}
\end{array}
\end{array}
if z < -5.5999999999999997e153 or 1.7e201 < z Initial program 56.2%
associate-*l/63.5%
*-commutative63.5%
Simplified63.5%
Taylor expanded in y around 0 94.2%
if -5.5999999999999997e153 < z < -3.6000000000000002e-200 or 5.49999999999999953e-283 < z < 1.7e201Initial program 92.5%
associate-*l/93.6%
*-commutative93.6%
Simplified93.6%
if -3.6000000000000002e-200 < z < 5.49999999999999953e-283Initial program 85.8%
associate-*l/75.5%
*-commutative75.5%
Simplified75.5%
Taylor expanded in y around inf 85.5%
associate-*r/96.1%
Simplified96.1%
Final simplification94.0%
x_m = (fabs.f64 x)
x_s = (copysign.f64 1 x)
(FPCore (x_s x_m y z)
:precision binary64
(*
x_s
(if (<= z -1.85e+101)
x_m
(if (<= z -1.55e+43)
(* x_m (/ y z))
(if (<= z -4.5e-22) x_m (if (<= z 6.1e+38) (/ x_m (/ z y)) 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 <= -1.85e+101) {
tmp = x_m;
} else if (z <= -1.55e+43) {
tmp = x_m * (y / z);
} else if (z <= -4.5e-22) {
tmp = x_m;
} else if (z <= 6.1e+38) {
tmp = x_m / (z / y);
} 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 <= (-1.85d+101)) then
tmp = x_m
else if (z <= (-1.55d+43)) then
tmp = x_m * (y / z)
else if (z <= (-4.5d-22)) then
tmp = x_m
else if (z <= 6.1d+38) then
tmp = x_m / (z / y)
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 <= -1.85e+101) {
tmp = x_m;
} else if (z <= -1.55e+43) {
tmp = x_m * (y / z);
} else if (z <= -4.5e-22) {
tmp = x_m;
} else if (z <= 6.1e+38) {
tmp = x_m / (z / y);
} 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 <= -1.85e+101: tmp = x_m elif z <= -1.55e+43: tmp = x_m * (y / z) elif z <= -4.5e-22: tmp = x_m elif z <= 6.1e+38: tmp = x_m / (z / y) 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 <= -1.85e+101) tmp = x_m; elseif (z <= -1.55e+43) tmp = Float64(x_m * Float64(y / z)); elseif (z <= -4.5e-22) tmp = x_m; elseif (z <= 6.1e+38) tmp = Float64(x_m / Float64(z / y)); 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 <= -1.85e+101) tmp = x_m; elseif (z <= -1.55e+43) tmp = x_m * (y / z); elseif (z <= -4.5e-22) tmp = x_m; elseif (z <= 6.1e+38) tmp = x_m / (z / y); 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, -1.85e+101], x$95$m, If[LessEqual[z, -1.55e+43], N[(x$95$m * N[(y / z), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, -4.5e-22], x$95$m, If[LessEqual[z, 6.1e+38], N[(x$95$m / N[(z / y), $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 -1.85 \cdot 10^{+101}:\\
\;\;\;\;x_m\\
\mathbf{elif}\;z \leq -1.55 \cdot 10^{+43}:\\
\;\;\;\;x_m \cdot \frac{y}{z}\\
\mathbf{elif}\;z \leq -4.5 \cdot 10^{-22}:\\
\;\;\;\;x_m\\
\mathbf{elif}\;z \leq 6.1 \cdot 10^{+38}:\\
\;\;\;\;\frac{x_m}{\frac{z}{y}}\\
\mathbf{else}:\\
\;\;\;\;x_m\\
\end{array}
\end{array}
if z < -1.8499999999999999e101 or -1.5500000000000001e43 < z < -4.49999999999999987e-22 or 6.0999999999999999e38 < z Initial program 71.5%
associate-*l/77.8%
*-commutative77.8%
Simplified77.8%
Taylor expanded in y around 0 79.5%
if -1.8499999999999999e101 < z < -1.5500000000000001e43Initial program 89.7%
associate-*l/88.9%
*-commutative88.9%
Simplified88.9%
Taylor expanded in y around inf 57.9%
associate-*r/68.0%
Simplified68.0%
if -4.49999999999999987e-22 < z < 6.0999999999999999e38Initial program 94.2%
associate-*l/91.6%
*-commutative91.6%
Simplified91.6%
Taylor expanded in y around inf 74.3%
associate-*r/73.0%
Simplified73.0%
associate-*r/96.2%
associate-/l*96.2%
Applied egg-rr74.2%
Final simplification75.9%
x_m = (fabs.f64 x)
x_s = (copysign.f64 1 x)
(FPCore (x_s x_m y z)
:precision binary64
(*
x_s
(if (<= z -1.85e+101)
x_m
(if (<= z -4.6e+42)
(* x_m (/ y z))
(if (<= z -3.6e-21) x_m (if (<= z 3.15e+38) (/ (* 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 <= -1.85e+101) {
tmp = x_m;
} else if (z <= -4.6e+42) {
tmp = x_m * (y / z);
} else if (z <= -3.6e-21) {
tmp = x_m;
} else if (z <= 3.15e+38) {
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 <= (-1.85d+101)) then
tmp = x_m
else if (z <= (-4.6d+42)) then
tmp = x_m * (y / z)
else if (z <= (-3.6d-21)) then
tmp = x_m
else if (z <= 3.15d+38) 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 <= -1.85e+101) {
tmp = x_m;
} else if (z <= -4.6e+42) {
tmp = x_m * (y / z);
} else if (z <= -3.6e-21) {
tmp = x_m;
} else if (z <= 3.15e+38) {
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 <= -1.85e+101: tmp = x_m elif z <= -4.6e+42: tmp = x_m * (y / z) elif z <= -3.6e-21: tmp = x_m elif z <= 3.15e+38: 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 <= -1.85e+101) tmp = x_m; elseif (z <= -4.6e+42) tmp = Float64(x_m * Float64(y / z)); elseif (z <= -3.6e-21) tmp = x_m; elseif (z <= 3.15e+38) 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 <= -1.85e+101) tmp = x_m; elseif (z <= -4.6e+42) tmp = x_m * (y / z); elseif (z <= -3.6e-21) tmp = x_m; elseif (z <= 3.15e+38) 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, -1.85e+101], x$95$m, If[LessEqual[z, -4.6e+42], N[(x$95$m * N[(y / z), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, -3.6e-21], x$95$m, If[LessEqual[z, 3.15e+38], 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 -1.85 \cdot 10^{+101}:\\
\;\;\;\;x_m\\
\mathbf{elif}\;z \leq -4.6 \cdot 10^{+42}:\\
\;\;\;\;x_m \cdot \frac{y}{z}\\
\mathbf{elif}\;z \leq -3.6 \cdot 10^{-21}:\\
\;\;\;\;x_m\\
\mathbf{elif}\;z \leq 3.15 \cdot 10^{+38}:\\
\;\;\;\;\frac{x_m \cdot y}{z}\\
\mathbf{else}:\\
\;\;\;\;x_m\\
\end{array}
\end{array}
if z < -1.8499999999999999e101 or -4.6e42 < z < -3.59999999999999989e-21 or 3.15000000000000001e38 < z Initial program 71.5%
associate-*l/77.8%
*-commutative77.8%
Simplified77.8%
Taylor expanded in y around 0 79.5%
if -1.8499999999999999e101 < z < -4.6e42Initial program 89.7%
associate-*l/88.9%
*-commutative88.9%
Simplified88.9%
Taylor expanded in y around inf 57.9%
associate-*r/68.0%
Simplified68.0%
if -3.59999999999999989e-21 < z < 3.15000000000000001e38Initial program 94.2%
associate-*l/91.6%
*-commutative91.6%
Simplified91.6%
Taylor expanded in y around inf 74.3%
Final simplification75.9%
x_m = (fabs.f64 x)
x_s = (copysign.f64 1 x)
(FPCore (x_s x_m y z)
:precision binary64
(*
x_s
(if (<= z -1.85e+101)
x_m
(if (<= z -5.4e+42)
(* x_m (/ y z))
(if (<= z -6.5e-17)
(/ (* x_m z) z)
(if (<= z 4.1e+38) (/ (* 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 <= -1.85e+101) {
tmp = x_m;
} else if (z <= -5.4e+42) {
tmp = x_m * (y / z);
} else if (z <= -6.5e-17) {
tmp = (x_m * z) / z;
} else if (z <= 4.1e+38) {
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 <= (-1.85d+101)) then
tmp = x_m
else if (z <= (-5.4d+42)) then
tmp = x_m * (y / z)
else if (z <= (-6.5d-17)) then
tmp = (x_m * z) / z
else if (z <= 4.1d+38) 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 <= -1.85e+101) {
tmp = x_m;
} else if (z <= -5.4e+42) {
tmp = x_m * (y / z);
} else if (z <= -6.5e-17) {
tmp = (x_m * z) / z;
} else if (z <= 4.1e+38) {
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 <= -1.85e+101: tmp = x_m elif z <= -5.4e+42: tmp = x_m * (y / z) elif z <= -6.5e-17: tmp = (x_m * z) / z elif z <= 4.1e+38: 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 <= -1.85e+101) tmp = x_m; elseif (z <= -5.4e+42) tmp = Float64(x_m * Float64(y / z)); elseif (z <= -6.5e-17) tmp = Float64(Float64(x_m * z) / z); elseif (z <= 4.1e+38) 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 <= -1.85e+101) tmp = x_m; elseif (z <= -5.4e+42) tmp = x_m * (y / z); elseif (z <= -6.5e-17) tmp = (x_m * z) / z; elseif (z <= 4.1e+38) 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, -1.85e+101], x$95$m, If[LessEqual[z, -5.4e+42], N[(x$95$m * N[(y / z), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, -6.5e-17], N[(N[(x$95$m * z), $MachinePrecision] / z), $MachinePrecision], If[LessEqual[z, 4.1e+38], 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 -1.85 \cdot 10^{+101}:\\
\;\;\;\;x_m\\
\mathbf{elif}\;z \leq -5.4 \cdot 10^{+42}:\\
\;\;\;\;x_m \cdot \frac{y}{z}\\
\mathbf{elif}\;z \leq -6.5 \cdot 10^{-17}:\\
\;\;\;\;\frac{x_m \cdot z}{z}\\
\mathbf{elif}\;z \leq 4.1 \cdot 10^{+38}:\\
\;\;\;\;\frac{x_m \cdot y}{z}\\
\mathbf{else}:\\
\;\;\;\;x_m\\
\end{array}
\end{array}
if z < -1.8499999999999999e101 or 4.1000000000000003e38 < z Initial program 68.4%
associate-*l/75.4%
*-commutative75.4%
Simplified75.4%
Taylor expanded in y around 0 79.4%
if -1.8499999999999999e101 < z < -5.4000000000000001e42Initial program 89.7%
associate-*l/88.9%
*-commutative88.9%
Simplified88.9%
Taylor expanded in y around inf 57.9%
associate-*r/68.0%
Simplified68.0%
if -5.4000000000000001e42 < z < -6.4999999999999996e-17Initial program 99.8%
Taylor expanded in y around 0 80.4%
if -6.4999999999999996e-17 < z < 4.1000000000000003e38Initial program 94.2%
associate-*l/91.6%
*-commutative91.6%
Simplified91.6%
Taylor expanded in y around inf 74.3%
Final simplification75.9%
x_m = (fabs.f64 x) x_s = (copysign.f64 1 x) (FPCore (x_s x_m y z) :precision binary64 (* x_s (if (or (<= y -1.35e-81) (not (<= y 2.7e-111))) (* 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.35e-81) || !(y <= 2.7e-111)) {
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.35d-81)) .or. (.not. (y <= 2.7d-111))) 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.35e-81) || !(y <= 2.7e-111)) {
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.35e-81) or not (y <= 2.7e-111): 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.35e-81) || !(y <= 2.7e-111)) 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.35e-81) || ~((y <= 2.7e-111))) 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.35e-81], N[Not[LessEqual[y, 2.7e-111]], $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.35 \cdot 10^{-81} \lor \neg \left(y \leq 2.7 \cdot 10^{-111}\right):\\
\;\;\;\;x_m \cdot \frac{y}{z}\\
\mathbf{else}:\\
\;\;\;\;x_m\\
\end{array}
\end{array}
if y < -1.34999999999999995e-81 or 2.69999999999999989e-111 < y Initial program 88.5%
associate-*l/86.3%
*-commutative86.3%
Simplified86.3%
Taylor expanded in y around inf 70.7%
associate-*r/70.2%
Simplified70.2%
if -1.34999999999999995e-81 < y < 2.69999999999999989e-111Initial program 78.1%
associate-*l/85.2%
*-commutative85.2%
Simplified85.2%
Taylor expanded in y around 0 82.3%
Final simplification74.5%
x_m = (fabs.f64 x) x_s = (copysign.f64 1 x) (FPCore (x_s x_m y z) :precision binary64 (* x_s (+ x_m (* x_m (/ 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 84.8%
remove-double-neg84.8%
distribute-lft-neg-out84.8%
*-commutative84.8%
distribute-lft-neg-in84.8%
associate-/l*86.2%
distribute-neg-in86.2%
unsub-neg86.2%
div-sub80.6%
distribute-frac-neg80.6%
associate-/r/80.5%
distribute-rgt-neg-out80.5%
remove-double-neg80.5%
associate-/r/97.3%
*-inverses97.3%
*-lft-identity97.3%
*-commutative97.3%
fma-neg97.3%
remove-double-neg97.3%
Simplified97.3%
fma-udef97.3%
Applied egg-rr97.3%
Final simplification97.3%
x_m = (fabs.f64 x) x_s = (copysign.f64 1 x) (FPCore (x_s x_m y z) :precision binary64 (* x_s (+ 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 84.8%
remove-double-neg84.8%
distribute-lft-neg-out84.8%
*-commutative84.8%
distribute-lft-neg-in84.8%
associate-/l*86.2%
distribute-neg-in86.2%
unsub-neg86.2%
div-sub80.6%
distribute-frac-neg80.6%
associate-/r/80.5%
distribute-rgt-neg-out80.5%
remove-double-neg80.5%
associate-/r/97.3%
*-inverses97.3%
*-lft-identity97.3%
*-commutative97.3%
fma-neg97.3%
remove-double-neg97.3%
Simplified97.3%
fma-udef97.3%
Applied egg-rr97.3%
associate-*r/94.2%
associate-/l*98.0%
Applied egg-rr98.0%
Final simplification98.0%
x_m = (fabs.f64 x) x_s = (copysign.f64 1 x) (FPCore (x_s x_m y z) :precision binary64 (* x_s x_m))
x_m = fabs(x);
x_s = copysign(1.0, x);
double code(double x_s, double x_m, double y, double z) {
return x_s * x_m;
}
x_m = abs(x)
x_s = copysign(1.0d0, x)
real(8) function code(x_s, x_m, y, z)
real(8), intent (in) :: x_s
real(8), intent (in) :: x_m
real(8), intent (in) :: y
real(8), intent (in) :: z
code = x_s * x_m
end function
x_m = Math.abs(x);
x_s = Math.copySign(1.0, x);
public static double code(double x_s, double x_m, double y, double z) {
return x_s * x_m;
}
x_m = math.fabs(x) x_s = math.copysign(1.0, x) def code(x_s, x_m, y, z): return x_s * x_m
x_m = abs(x) x_s = copysign(1.0, x) function code(x_s, x_m, y, z) return Float64(x_s * x_m) end
x_m = abs(x); x_s = sign(x) * abs(1.0); function tmp = code(x_s, x_m, y, z) tmp = x_s * x_m; end
x_m = N[Abs[x], $MachinePrecision]
x_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[x$95$s_, x$95$m_, y_, z_] := N[(x$95$s * x$95$m), $MachinePrecision]
\begin{array}{l}
x_m = \left|x\right|
\\
x_s = \mathsf{copysign}\left(1, x\right)
\\
x_s \cdot x_m
\end{array}
Initial program 84.8%
associate-*l/85.9%
*-commutative85.9%
Simplified85.9%
Taylor expanded in y around 0 47.1%
Final simplification47.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 2024020
(FPCore (x y z)
:name "Numeric.SpecFunctions:choose from math-functions-0.1.5.2"
:precision binary64
:herbie-target
(/ x (/ z (+ y z)))
(/ (* x (+ y z)) z))