
(FPCore (x y z) :precision binary64 (fabs (- (/ (+ x 4.0) y) (* (/ x y) z))))
double code(double x, double y, double z) {
return fabs((((x + 4.0) / y) - ((x / 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 = abs((((x + 4.0d0) / y) - ((x / y) * z)))
end function
public static double code(double x, double y, double z) {
return Math.abs((((x + 4.0) / y) - ((x / y) * z)));
}
def code(x, y, z): return math.fabs((((x + 4.0) / y) - ((x / y) * z)))
function code(x, y, z) return abs(Float64(Float64(Float64(x + 4.0) / y) - Float64(Float64(x / y) * z))) end
function tmp = code(x, y, z) tmp = abs((((x + 4.0) / y) - ((x / y) * z))); end
code[x_, y_, z_] := N[Abs[N[(N[(N[(x + 4.0), $MachinePrecision] / y), $MachinePrecision] - N[(N[(x / y), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right|
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 13 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 (fabs (- (/ (+ x 4.0) y) (* (/ x y) z))))
double code(double x, double y, double z) {
return fabs((((x + 4.0) / y) - ((x / 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 = abs((((x + 4.0d0) / y) - ((x / y) * z)))
end function
public static double code(double x, double y, double z) {
return Math.abs((((x + 4.0) / y) - ((x / y) * z)));
}
def code(x, y, z): return math.fabs((((x + 4.0) / y) - ((x / y) * z)))
function code(x, y, z) return abs(Float64(Float64(Float64(x + 4.0) / y) - Float64(Float64(x / y) * z))) end
function tmp = code(x, y, z) tmp = abs((((x + 4.0) / y) - ((x / y) * z))); end
code[x_, y_, z_] := N[Abs[N[(N[(N[(x + 4.0), $MachinePrecision] / y), $MachinePrecision] - N[(N[(x / y), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right|
\end{array}
y_m = (fabs.f64 y) (FPCore (x y_m z) :precision binary64 (if (<= y_m 7.2e-25) (fabs (/ (fma x z (- -4.0 x)) y_m)) (fabs (fma x (* z (/ -1.0 y_m)) (/ (+ x 4.0) y_m)))))
y_m = fabs(y);
double code(double x, double y_m, double z) {
double tmp;
if (y_m <= 7.2e-25) {
tmp = fabs((fma(x, z, (-4.0 - x)) / y_m));
} else {
tmp = fabs(fma(x, (z * (-1.0 / y_m)), ((x + 4.0) / y_m)));
}
return tmp;
}
y_m = abs(y) function code(x, y_m, z) tmp = 0.0 if (y_m <= 7.2e-25) tmp = abs(Float64(fma(x, z, Float64(-4.0 - x)) / y_m)); else tmp = abs(fma(x, Float64(z * Float64(-1.0 / y_m)), Float64(Float64(x + 4.0) / y_m))); end return tmp end
y_m = N[Abs[y], $MachinePrecision] code[x_, y$95$m_, z_] := If[LessEqual[y$95$m, 7.2e-25], N[Abs[N[(N[(x * z + N[(-4.0 - x), $MachinePrecision]), $MachinePrecision] / y$95$m), $MachinePrecision]], $MachinePrecision], N[Abs[N[(x * N[(z * N[(-1.0 / y$95$m), $MachinePrecision]), $MachinePrecision] + N[(N[(x + 4.0), $MachinePrecision] / y$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
y_m = \left|y\right|
\\
\begin{array}{l}
\mathbf{if}\;y\_m \leq 7.2 \cdot 10^{-25}:\\
\;\;\;\;\left|\frac{\mathsf{fma}\left(x, z, -4 - x\right)}{y\_m}\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\mathsf{fma}\left(x, z \cdot \frac{-1}{y\_m}, \frac{x + 4}{y\_m}\right)\right|\\
\end{array}
\end{array}
if y < 7.1999999999999998e-25Initial program 89.2%
lift-+.f64N/A
lift-/.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift--.f64N/A
neg-fabsN/A
lower-fabs.f64N/A
lift--.f64N/A
sub-negN/A
+-commutativeN/A
distribute-neg-inN/A
remove-double-negN/A
sub-negN/A
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
lift-/.f64N/A
sub-divN/A
lower-/.f64N/A
Applied egg-rr96.2%
if 7.1999999999999998e-25 < y Initial program 97.5%
lift-+.f64N/A
lift-/.f64N/A
lift-/.f64N/A
lift-*.f64N/A
sub-negN/A
+-commutativeN/A
lift-*.f64N/A
distribute-lft-neg-inN/A
lift-/.f64N/A
distribute-neg-frac2N/A
div-invN/A
associate-*l*N/A
lower-fma.f64N/A
lower-*.f64N/A
distribute-frac-neg2N/A
distribute-neg-fracN/A
metadata-evalN/A
lower-/.f6499.8
Applied egg-rr99.8%
Final simplification97.3%
y_m = (fabs.f64 y)
(FPCore (x y_m z)
:precision binary64
(let* ((t_0 (* z (/ x y_m))))
(if (<= (- (/ (+ x 4.0) y_m) t_0) -20000000000.0)
(fabs (- (/ x y_m) t_0))
(fabs (/ (fma x z (- -4.0 x)) y_m)))))y_m = fabs(y);
double code(double x, double y_m, double z) {
double t_0 = z * (x / y_m);
double tmp;
if ((((x + 4.0) / y_m) - t_0) <= -20000000000.0) {
tmp = fabs(((x / y_m) - t_0));
} else {
tmp = fabs((fma(x, z, (-4.0 - x)) / y_m));
}
return tmp;
}
y_m = abs(y) function code(x, y_m, z) t_0 = Float64(z * Float64(x / y_m)) tmp = 0.0 if (Float64(Float64(Float64(x + 4.0) / y_m) - t_0) <= -20000000000.0) tmp = abs(Float64(Float64(x / y_m) - t_0)); else tmp = abs(Float64(fma(x, z, Float64(-4.0 - x)) / y_m)); end return tmp end
y_m = N[Abs[y], $MachinePrecision]
code[x_, y$95$m_, z_] := Block[{t$95$0 = N[(z * N[(x / y$95$m), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(N[(N[(x + 4.0), $MachinePrecision] / y$95$m), $MachinePrecision] - t$95$0), $MachinePrecision], -20000000000.0], N[Abs[N[(N[(x / y$95$m), $MachinePrecision] - t$95$0), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[(x * z + N[(-4.0 - x), $MachinePrecision]), $MachinePrecision] / y$95$m), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
y_m = \left|y\right|
\\
\begin{array}{l}
t_0 := z \cdot \frac{x}{y\_m}\\
\mathbf{if}\;\frac{x + 4}{y\_m} - t\_0 \leq -20000000000:\\
\;\;\;\;\left|\frac{x}{y\_m} - t\_0\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\frac{\mathsf{fma}\left(x, z, -4 - x\right)}{y\_m}\right|\\
\end{array}
\end{array}
if (-.f64 (/.f64 (+.f64 x #s(literal 4 binary64)) y) (*.f64 (/.f64 x y) z)) < -2e10Initial program 99.9%
Taylor expanded in x around inf
lower-/.f6470.9
Simplified70.9%
if -2e10 < (-.f64 (/.f64 (+.f64 x #s(literal 4 binary64)) y) (*.f64 (/.f64 x y) z)) Initial program 88.1%
lift-+.f64N/A
lift-/.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift--.f64N/A
neg-fabsN/A
lower-fabs.f64N/A
lift--.f64N/A
sub-negN/A
+-commutativeN/A
distribute-neg-inN/A
remove-double-negN/A
sub-negN/A
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
lift-/.f64N/A
sub-divN/A
lower-/.f64N/A
Applied egg-rr95.7%
Final simplification88.2%
y_m = (fabs.f64 y) (FPCore (x y_m z) :precision binary64 (let* ((t_0 (/ (+ x 4.0) y_m)) (t_1 (* z (/ x y_m)))) (if (<= (- t_0 t_1) -1e+207) t_1 (fabs t_0))))
y_m = fabs(y);
double code(double x, double y_m, double z) {
double t_0 = (x + 4.0) / y_m;
double t_1 = z * (x / y_m);
double tmp;
if ((t_0 - t_1) <= -1e+207) {
tmp = t_1;
} else {
tmp = fabs(t_0);
}
return tmp;
}
y_m = abs(y)
real(8) function code(x, y_m, z)
real(8), intent (in) :: x
real(8), intent (in) :: y_m
real(8), intent (in) :: z
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = (x + 4.0d0) / y_m
t_1 = z * (x / y_m)
if ((t_0 - t_1) <= (-1d+207)) then
tmp = t_1
else
tmp = abs(t_0)
end if
code = tmp
end function
y_m = Math.abs(y);
public static double code(double x, double y_m, double z) {
double t_0 = (x + 4.0) / y_m;
double t_1 = z * (x / y_m);
double tmp;
if ((t_0 - t_1) <= -1e+207) {
tmp = t_1;
} else {
tmp = Math.abs(t_0);
}
return tmp;
}
y_m = math.fabs(y) def code(x, y_m, z): t_0 = (x + 4.0) / y_m t_1 = z * (x / y_m) tmp = 0 if (t_0 - t_1) <= -1e+207: tmp = t_1 else: tmp = math.fabs(t_0) return tmp
y_m = abs(y) function code(x, y_m, z) t_0 = Float64(Float64(x + 4.0) / y_m) t_1 = Float64(z * Float64(x / y_m)) tmp = 0.0 if (Float64(t_0 - t_1) <= -1e+207) tmp = t_1; else tmp = abs(t_0); end return tmp end
y_m = abs(y); function tmp_2 = code(x, y_m, z) t_0 = (x + 4.0) / y_m; t_1 = z * (x / y_m); tmp = 0.0; if ((t_0 - t_1) <= -1e+207) tmp = t_1; else tmp = abs(t_0); end tmp_2 = tmp; end
y_m = N[Abs[y], $MachinePrecision]
code[x_, y$95$m_, z_] := Block[{t$95$0 = N[(N[(x + 4.0), $MachinePrecision] / y$95$m), $MachinePrecision]}, Block[{t$95$1 = N[(z * N[(x / y$95$m), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(t$95$0 - t$95$1), $MachinePrecision], -1e+207], t$95$1, N[Abs[t$95$0], $MachinePrecision]]]]
\begin{array}{l}
y_m = \left|y\right|
\\
\begin{array}{l}
t_0 := \frac{x + 4}{y\_m}\\
t_1 := z \cdot \frac{x}{y\_m}\\
\mathbf{if}\;t\_0 - t\_1 \leq -1 \cdot 10^{+207}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;\left|t\_0\right|\\
\end{array}
\end{array}
if (-.f64 (/.f64 (+.f64 x #s(literal 4 binary64)) y) (*.f64 (/.f64 x y) z)) < -1e207Initial program 100.0%
Taylor expanded in z around inf
mul-1-negN/A
distribute-neg-frac2N/A
lower-/.f64N/A
lower-*.f64N/A
lower-neg.f6458.0
Simplified58.0%
lift-*.f64N/A
lift-neg.f64N/A
lift-neg.f64N/A
distribute-frac-neg2N/A
lift-*.f64N/A
associate-*l/N/A
lift-/.f64N/A
lift-*.f64N/A
fabs-negN/A
lower-fabs.f6468.5
lift-*.f64N/A
*-commutativeN/A
lower-*.f6468.5
Applied egg-rr68.5%
clear-numN/A
associate-/r/N/A
associate-*r*N/A
div-invN/A
lower-*.f64N/A
lower-/.f6460.7
Applied egg-rr60.7%
lift-/.f64N/A
*-commutativeN/A
lift-/.f64N/A
associate-/l*N/A
lift-*.f64N/A
clear-numN/A
inv-powN/A
sqr-powN/A
fabs-sqrN/A
sqr-powN/A
inv-powN/A
clear-numN/A
lift-*.f64N/A
associate-*l/N/A
lower-*.f64N/A
lower-/.f6467.9
Applied egg-rr67.9%
if -1e207 < (-.f64 (/.f64 (+.f64 x #s(literal 4 binary64)) y) (*.f64 (/.f64 x y) z)) Initial program 90.4%
Taylor expanded in z around 0
*-rgt-identityN/A
associate-*r/N/A
distribute-rgt-outN/A
associate-*l/N/A
metadata-evalN/A
associate-*r*N/A
associate-*r/N/A
neg-mul-1N/A
mul-1-negN/A
distribute-frac-negN/A
remove-double-negN/A
lower-/.f64N/A
lower-+.f6474.8
Simplified74.8%
Final simplification73.8%
y_m = (fabs.f64 y) (FPCore (x y_m z) :precision binary64 (if (<= y_m 5e+56) (fabs (/ (fma x z (- -4.0 x)) y_m)) (fabs (fma (- x) (/ z y_m) (/ (+ x 4.0) y_m)))))
y_m = fabs(y);
double code(double x, double y_m, double z) {
double tmp;
if (y_m <= 5e+56) {
tmp = fabs((fma(x, z, (-4.0 - x)) / y_m));
} else {
tmp = fabs(fma(-x, (z / y_m), ((x + 4.0) / y_m)));
}
return tmp;
}
y_m = abs(y) function code(x, y_m, z) tmp = 0.0 if (y_m <= 5e+56) tmp = abs(Float64(fma(x, z, Float64(-4.0 - x)) / y_m)); else tmp = abs(fma(Float64(-x), Float64(z / y_m), Float64(Float64(x + 4.0) / y_m))); end return tmp end
y_m = N[Abs[y], $MachinePrecision] code[x_, y$95$m_, z_] := If[LessEqual[y$95$m, 5e+56], N[Abs[N[(N[(x * z + N[(-4.0 - x), $MachinePrecision]), $MachinePrecision] / y$95$m), $MachinePrecision]], $MachinePrecision], N[Abs[N[((-x) * N[(z / y$95$m), $MachinePrecision] + N[(N[(x + 4.0), $MachinePrecision] / y$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
y_m = \left|y\right|
\\
\begin{array}{l}
\mathbf{if}\;y\_m \leq 5 \cdot 10^{+56}:\\
\;\;\;\;\left|\frac{\mathsf{fma}\left(x, z, -4 - x\right)}{y\_m}\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\mathsf{fma}\left(-x, \frac{z}{y\_m}, \frac{x + 4}{y\_m}\right)\right|\\
\end{array}
\end{array}
if y < 5.00000000000000024e56Initial program 90.6%
lift-+.f64N/A
lift-/.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift--.f64N/A
neg-fabsN/A
lower-fabs.f64N/A
lift--.f64N/A
sub-negN/A
+-commutativeN/A
distribute-neg-inN/A
remove-double-negN/A
sub-negN/A
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
lift-/.f64N/A
sub-divN/A
lower-/.f64N/A
Applied egg-rr96.7%
if 5.00000000000000024e56 < y Initial program 96.2%
lift-+.f64N/A
lift-/.f64N/A
lift-/.f64N/A
lift-*.f64N/A
sub-negN/A
+-commutativeN/A
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
associate-/l*N/A
distribute-lft-neg-inN/A
lower-fma.f64N/A
lower-neg.f64N/A
lower-/.f6499.8
Applied egg-rr99.8%
y_m = (fabs.f64 y) (FPCore (x y_m z) :precision binary64 (if (<= y_m 1.8e+103) (fabs (/ (fma x z (- -4.0 x)) y_m)) (fabs (- (/ (+ x 4.0) y_m) (* z (/ x y_m))))))
y_m = fabs(y);
double code(double x, double y_m, double z) {
double tmp;
if (y_m <= 1.8e+103) {
tmp = fabs((fma(x, z, (-4.0 - x)) / y_m));
} else {
tmp = fabs((((x + 4.0) / y_m) - (z * (x / y_m))));
}
return tmp;
}
y_m = abs(y) function code(x, y_m, z) tmp = 0.0 if (y_m <= 1.8e+103) tmp = abs(Float64(fma(x, z, Float64(-4.0 - x)) / y_m)); else tmp = abs(Float64(Float64(Float64(x + 4.0) / y_m) - Float64(z * Float64(x / y_m)))); end return tmp end
y_m = N[Abs[y], $MachinePrecision] code[x_, y$95$m_, z_] := If[LessEqual[y$95$m, 1.8e+103], N[Abs[N[(N[(x * z + N[(-4.0 - x), $MachinePrecision]), $MachinePrecision] / y$95$m), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[(N[(x + 4.0), $MachinePrecision] / y$95$m), $MachinePrecision] - N[(z * N[(x / y$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
y_m = \left|y\right|
\\
\begin{array}{l}
\mathbf{if}\;y\_m \leq 1.8 \cdot 10^{+103}:\\
\;\;\;\;\left|\frac{\mathsf{fma}\left(x, z, -4 - x\right)}{y\_m}\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\frac{x + 4}{y\_m} - z \cdot \frac{x}{y\_m}\right|\\
\end{array}
\end{array}
if y < 1.80000000000000008e103Initial program 91.0%
lift-+.f64N/A
lift-/.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift--.f64N/A
neg-fabsN/A
lower-fabs.f64N/A
lift--.f64N/A
sub-negN/A
+-commutativeN/A
distribute-neg-inN/A
remove-double-negN/A
sub-negN/A
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
lift-/.f64N/A
sub-divN/A
lower-/.f64N/A
Applied egg-rr96.8%
if 1.80000000000000008e103 < y Initial program 95.5%
Final simplification96.6%
y_m = (fabs.f64 y) (FPCore (x y_m z) :precision binary64 (let* ((t_0 (fabs (/ (fma x z -4.0) y_m)))) (if (<= z -140.0) t_0 (if (<= z 4.5e-11) (fabs (/ (+ x 4.0) y_m)) t_0))))
y_m = fabs(y);
double code(double x, double y_m, double z) {
double t_0 = fabs((fma(x, z, -4.0) / y_m));
double tmp;
if (z <= -140.0) {
tmp = t_0;
} else if (z <= 4.5e-11) {
tmp = fabs(((x + 4.0) / y_m));
} else {
tmp = t_0;
}
return tmp;
}
y_m = abs(y) function code(x, y_m, z) t_0 = abs(Float64(fma(x, z, -4.0) / y_m)) tmp = 0.0 if (z <= -140.0) tmp = t_0; elseif (z <= 4.5e-11) tmp = abs(Float64(Float64(x + 4.0) / y_m)); else tmp = t_0; end return tmp end
y_m = N[Abs[y], $MachinePrecision]
code[x_, y$95$m_, z_] := Block[{t$95$0 = N[Abs[N[(N[(x * z + -4.0), $MachinePrecision] / y$95$m), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[z, -140.0], t$95$0, If[LessEqual[z, 4.5e-11], N[Abs[N[(N[(x + 4.0), $MachinePrecision] / y$95$m), $MachinePrecision]], $MachinePrecision], t$95$0]]]
\begin{array}{l}
y_m = \left|y\right|
\\
\begin{array}{l}
t_0 := \left|\frac{\mathsf{fma}\left(x, z, -4\right)}{y\_m}\right|\\
\mathbf{if}\;z \leq -140:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 4.5 \cdot 10^{-11}:\\
\;\;\;\;\left|\frac{x + 4}{y\_m}\right|\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if z < -140 or 4.5e-11 < z Initial program 89.5%
lift-+.f64N/A
lift-/.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift--.f64N/A
neg-fabsN/A
lower-fabs.f64N/A
lift--.f64N/A
sub-negN/A
+-commutativeN/A
distribute-neg-inN/A
remove-double-negN/A
sub-negN/A
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
lift-/.f64N/A
sub-divN/A
lower-/.f64N/A
Applied egg-rr87.7%
Taylor expanded in x around 0
Simplified87.3%
if -140 < z < 4.5e-11Initial program 93.6%
Taylor expanded in z around 0
*-rgt-identityN/A
associate-*r/N/A
distribute-rgt-outN/A
associate-*l/N/A
metadata-evalN/A
associate-*r*N/A
associate-*r/N/A
neg-mul-1N/A
mul-1-negN/A
distribute-frac-negN/A
remove-double-negN/A
lower-/.f64N/A
lower-+.f6499.5
Simplified99.5%
Final simplification94.0%
y_m = (fabs.f64 y) (FPCore (x y_m z) :precision binary64 (if (<= z -51000000000000.0) (fabs (* z (/ x y_m))) (if (<= z 70000000000.0) (fabs (/ (+ x 4.0) y_m)) (fabs (* x (/ z y_m))))))
y_m = fabs(y);
double code(double x, double y_m, double z) {
double tmp;
if (z <= -51000000000000.0) {
tmp = fabs((z * (x / y_m)));
} else if (z <= 70000000000.0) {
tmp = fabs(((x + 4.0) / y_m));
} else {
tmp = fabs((x * (z / y_m)));
}
return tmp;
}
y_m = abs(y)
real(8) function code(x, y_m, z)
real(8), intent (in) :: x
real(8), intent (in) :: y_m
real(8), intent (in) :: z
real(8) :: tmp
if (z <= (-51000000000000.0d0)) then
tmp = abs((z * (x / y_m)))
else if (z <= 70000000000.0d0) then
tmp = abs(((x + 4.0d0) / y_m))
else
tmp = abs((x * (z / y_m)))
end if
code = tmp
end function
y_m = Math.abs(y);
public static double code(double x, double y_m, double z) {
double tmp;
if (z <= -51000000000000.0) {
tmp = Math.abs((z * (x / y_m)));
} else if (z <= 70000000000.0) {
tmp = Math.abs(((x + 4.0) / y_m));
} else {
tmp = Math.abs((x * (z / y_m)));
}
return tmp;
}
y_m = math.fabs(y) def code(x, y_m, z): tmp = 0 if z <= -51000000000000.0: tmp = math.fabs((z * (x / y_m))) elif z <= 70000000000.0: tmp = math.fabs(((x + 4.0) / y_m)) else: tmp = math.fabs((x * (z / y_m))) return tmp
y_m = abs(y) function code(x, y_m, z) tmp = 0.0 if (z <= -51000000000000.0) tmp = abs(Float64(z * Float64(x / y_m))); elseif (z <= 70000000000.0) tmp = abs(Float64(Float64(x + 4.0) / y_m)); else tmp = abs(Float64(x * Float64(z / y_m))); end return tmp end
y_m = abs(y); function tmp_2 = code(x, y_m, z) tmp = 0.0; if (z <= -51000000000000.0) tmp = abs((z * (x / y_m))); elseif (z <= 70000000000.0) tmp = abs(((x + 4.0) / y_m)); else tmp = abs((x * (z / y_m))); end tmp_2 = tmp; end
y_m = N[Abs[y], $MachinePrecision] code[x_, y$95$m_, z_] := If[LessEqual[z, -51000000000000.0], N[Abs[N[(z * N[(x / y$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[z, 70000000000.0], N[Abs[N[(N[(x + 4.0), $MachinePrecision] / y$95$m), $MachinePrecision]], $MachinePrecision], N[Abs[N[(x * N[(z / y$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
y_m = \left|y\right|
\\
\begin{array}{l}
\mathbf{if}\;z \leq -51000000000000:\\
\;\;\;\;\left|z \cdot \frac{x}{y\_m}\right|\\
\mathbf{elif}\;z \leq 70000000000:\\
\;\;\;\;\left|\frac{x + 4}{y\_m}\right|\\
\mathbf{else}:\\
\;\;\;\;\left|x \cdot \frac{z}{y\_m}\right|\\
\end{array}
\end{array}
if z < -5.1e13Initial program 99.7%
Taylor expanded in z around inf
mul-1-negN/A
distribute-neg-frac2N/A
lower-/.f64N/A
lower-*.f64N/A
lower-neg.f6465.1
Simplified65.1%
lift-*.f64N/A
lift-neg.f64N/A
lift-neg.f64N/A
distribute-frac-neg2N/A
lift-*.f64N/A
associate-*l/N/A
lift-/.f64N/A
lift-*.f64N/A
fabs-negN/A
lower-fabs.f6474.6
lift-*.f64N/A
*-commutativeN/A
lower-*.f6474.6
Applied egg-rr74.6%
if -5.1e13 < z < 7e10Initial program 93.7%
Taylor expanded in z around 0
*-rgt-identityN/A
associate-*r/N/A
distribute-rgt-outN/A
associate-*l/N/A
metadata-evalN/A
associate-*r*N/A
associate-*r/N/A
neg-mul-1N/A
mul-1-negN/A
distribute-frac-negN/A
remove-double-negN/A
lower-/.f64N/A
lower-+.f6499.1
Simplified99.1%
if 7e10 < z Initial program 80.8%
Taylor expanded in z around inf
mul-1-negN/A
distribute-neg-frac2N/A
lower-/.f64N/A
lower-*.f64N/A
lower-neg.f6461.1
Simplified61.1%
lift-*.f64N/A
lift-neg.f64N/A
lift-neg.f64N/A
distribute-frac-neg2N/A
lift-*.f64N/A
associate-*l/N/A
lift-/.f64N/A
lift-*.f64N/A
fabs-negN/A
lower-fabs.f6469.8
lift-*.f64N/A
*-commutativeN/A
lower-*.f6469.8
Applied egg-rr69.8%
clear-numN/A
associate-/r/N/A
associate-*r*N/A
div-invN/A
lower-*.f64N/A
lower-/.f6472.8
Applied egg-rr72.8%
Final simplification87.9%
y_m = (fabs.f64 y)
(FPCore (x y_m z)
:precision binary64
(let* ((t_0 (fabs (* z (/ x y_m)))))
(if (<= z -51000000000000.0)
t_0
(if (<= z 70000000000.0) (fabs (/ (+ x 4.0) y_m)) t_0))))y_m = fabs(y);
double code(double x, double y_m, double z) {
double t_0 = fabs((z * (x / y_m)));
double tmp;
if (z <= -51000000000000.0) {
tmp = t_0;
} else if (z <= 70000000000.0) {
tmp = fabs(((x + 4.0) / y_m));
} else {
tmp = t_0;
}
return tmp;
}
y_m = abs(y)
real(8) function code(x, y_m, z)
real(8), intent (in) :: x
real(8), intent (in) :: y_m
real(8), intent (in) :: z
real(8) :: t_0
real(8) :: tmp
t_0 = abs((z * (x / y_m)))
if (z <= (-51000000000000.0d0)) then
tmp = t_0
else if (z <= 70000000000.0d0) then
tmp = abs(((x + 4.0d0) / y_m))
else
tmp = t_0
end if
code = tmp
end function
y_m = Math.abs(y);
public static double code(double x, double y_m, double z) {
double t_0 = Math.abs((z * (x / y_m)));
double tmp;
if (z <= -51000000000000.0) {
tmp = t_0;
} else if (z <= 70000000000.0) {
tmp = Math.abs(((x + 4.0) / y_m));
} else {
tmp = t_0;
}
return tmp;
}
y_m = math.fabs(y) def code(x, y_m, z): t_0 = math.fabs((z * (x / y_m))) tmp = 0 if z <= -51000000000000.0: tmp = t_0 elif z <= 70000000000.0: tmp = math.fabs(((x + 4.0) / y_m)) else: tmp = t_0 return tmp
y_m = abs(y) function code(x, y_m, z) t_0 = abs(Float64(z * Float64(x / y_m))) tmp = 0.0 if (z <= -51000000000000.0) tmp = t_0; elseif (z <= 70000000000.0) tmp = abs(Float64(Float64(x + 4.0) / y_m)); else tmp = t_0; end return tmp end
y_m = abs(y); function tmp_2 = code(x, y_m, z) t_0 = abs((z * (x / y_m))); tmp = 0.0; if (z <= -51000000000000.0) tmp = t_0; elseif (z <= 70000000000.0) tmp = abs(((x + 4.0) / y_m)); else tmp = t_0; end tmp_2 = tmp; end
y_m = N[Abs[y], $MachinePrecision]
code[x_, y$95$m_, z_] := Block[{t$95$0 = N[Abs[N[(z * N[(x / y$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[z, -51000000000000.0], t$95$0, If[LessEqual[z, 70000000000.0], N[Abs[N[(N[(x + 4.0), $MachinePrecision] / y$95$m), $MachinePrecision]], $MachinePrecision], t$95$0]]]
\begin{array}{l}
y_m = \left|y\right|
\\
\begin{array}{l}
t_0 := \left|z \cdot \frac{x}{y\_m}\right|\\
\mathbf{if}\;z \leq -51000000000000:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 70000000000:\\
\;\;\;\;\left|\frac{x + 4}{y\_m}\right|\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if z < -5.1e13 or 7e10 < z Initial program 89.1%
Taylor expanded in z around inf
mul-1-negN/A
distribute-neg-frac2N/A
lower-/.f64N/A
lower-*.f64N/A
lower-neg.f6462.8
Simplified62.8%
lift-*.f64N/A
lift-neg.f64N/A
lift-neg.f64N/A
distribute-frac-neg2N/A
lift-*.f64N/A
associate-*l/N/A
lift-/.f64N/A
lift-*.f64N/A
fabs-negN/A
lower-fabs.f6471.9
lift-*.f64N/A
*-commutativeN/A
lower-*.f6471.9
Applied egg-rr71.9%
if -5.1e13 < z < 7e10Initial program 93.7%
Taylor expanded in z around 0
*-rgt-identityN/A
associate-*r/N/A
distribute-rgt-outN/A
associate-*l/N/A
metadata-evalN/A
associate-*r*N/A
associate-*r/N/A
neg-mul-1N/A
mul-1-negN/A
distribute-frac-negN/A
remove-double-negN/A
lower-/.f64N/A
lower-+.f6499.1
Simplified99.1%
Final simplification87.2%
y_m = (fabs.f64 y) (FPCore (x y_m z) :precision binary64 (if (<= x -4.0) (/ (- -4.0 x) y_m) (if (<= x 4.0) (fabs (/ 4.0 y_m)) (fabs (/ x y_m)))))
y_m = fabs(y);
double code(double x, double y_m, double z) {
double tmp;
if (x <= -4.0) {
tmp = (-4.0 - x) / y_m;
} else if (x <= 4.0) {
tmp = fabs((4.0 / y_m));
} else {
tmp = fabs((x / y_m));
}
return tmp;
}
y_m = abs(y)
real(8) function code(x, y_m, z)
real(8), intent (in) :: x
real(8), intent (in) :: y_m
real(8), intent (in) :: z
real(8) :: tmp
if (x <= (-4.0d0)) then
tmp = ((-4.0d0) - x) / y_m
else if (x <= 4.0d0) then
tmp = abs((4.0d0 / y_m))
else
tmp = abs((x / y_m))
end if
code = tmp
end function
y_m = Math.abs(y);
public static double code(double x, double y_m, double z) {
double tmp;
if (x <= -4.0) {
tmp = (-4.0 - x) / y_m;
} else if (x <= 4.0) {
tmp = Math.abs((4.0 / y_m));
} else {
tmp = Math.abs((x / y_m));
}
return tmp;
}
y_m = math.fabs(y) def code(x, y_m, z): tmp = 0 if x <= -4.0: tmp = (-4.0 - x) / y_m elif x <= 4.0: tmp = math.fabs((4.0 / y_m)) else: tmp = math.fabs((x / y_m)) return tmp
y_m = abs(y) function code(x, y_m, z) tmp = 0.0 if (x <= -4.0) tmp = Float64(Float64(-4.0 - x) / y_m); elseif (x <= 4.0) tmp = abs(Float64(4.0 / y_m)); else tmp = abs(Float64(x / y_m)); end return tmp end
y_m = abs(y); function tmp_2 = code(x, y_m, z) tmp = 0.0; if (x <= -4.0) tmp = (-4.0 - x) / y_m; elseif (x <= 4.0) tmp = abs((4.0 / y_m)); else tmp = abs((x / y_m)); end tmp_2 = tmp; end
y_m = N[Abs[y], $MachinePrecision] code[x_, y$95$m_, z_] := If[LessEqual[x, -4.0], N[(N[(-4.0 - x), $MachinePrecision] / y$95$m), $MachinePrecision], If[LessEqual[x, 4.0], N[Abs[N[(4.0 / y$95$m), $MachinePrecision]], $MachinePrecision], N[Abs[N[(x / y$95$m), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
y_m = \left|y\right|
\\
\begin{array}{l}
\mathbf{if}\;x \leq -4:\\
\;\;\;\;\frac{-4 - x}{y\_m}\\
\mathbf{elif}\;x \leq 4:\\
\;\;\;\;\left|\frac{4}{y\_m}\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\frac{x}{y\_m}\right|\\
\end{array}
\end{array}
if x < -4Initial program 89.0%
lift-+.f64N/A
lift-/.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift--.f64N/A
neg-fabsN/A
lower-fabs.f64N/A
lift--.f64N/A
sub-negN/A
+-commutativeN/A
distribute-neg-inN/A
remove-double-negN/A
sub-negN/A
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
lift-/.f64N/A
sub-divN/A
lower-/.f64N/A
Applied egg-rr91.2%
Taylor expanded in z around 0
associate-*r/N/A
lower-/.f64N/A
distribute-lft-inN/A
metadata-evalN/A
mul-1-negN/A
unsub-negN/A
lower--.f6464.9
Simplified64.9%
lift--.f64N/A
clear-numN/A
inv-powN/A
sqr-powN/A
fabs-sqrN/A
sqr-powN/A
inv-powN/A
clear-numN/A
lift-/.f6442.0
Applied egg-rr42.0%
if -4 < x < 4Initial program 96.9%
Taylor expanded in x around 0
lower-/.f6480.0
Simplified80.0%
if 4 < x Initial program 83.6%
Taylor expanded in x around inf
lower-/.f6481.1
Simplified81.1%
Taylor expanded in z around 0
lower-/.f6460.1
Simplified60.1%
y_m = (fabs.f64 y) (FPCore (x y_m z) :precision binary64 (let* ((t_0 (fabs (/ x y_m)))) (if (<= x -10.5) t_0 (if (<= x 4.0) (fabs (/ 4.0 y_m)) t_0))))
y_m = fabs(y);
double code(double x, double y_m, double z) {
double t_0 = fabs((x / y_m));
double tmp;
if (x <= -10.5) {
tmp = t_0;
} else if (x <= 4.0) {
tmp = fabs((4.0 / y_m));
} else {
tmp = t_0;
}
return tmp;
}
y_m = abs(y)
real(8) function code(x, y_m, z)
real(8), intent (in) :: x
real(8), intent (in) :: y_m
real(8), intent (in) :: z
real(8) :: t_0
real(8) :: tmp
t_0 = abs((x / y_m))
if (x <= (-10.5d0)) then
tmp = t_0
else if (x <= 4.0d0) then
tmp = abs((4.0d0 / y_m))
else
tmp = t_0
end if
code = tmp
end function
y_m = Math.abs(y);
public static double code(double x, double y_m, double z) {
double t_0 = Math.abs((x / y_m));
double tmp;
if (x <= -10.5) {
tmp = t_0;
} else if (x <= 4.0) {
tmp = Math.abs((4.0 / y_m));
} else {
tmp = t_0;
}
return tmp;
}
y_m = math.fabs(y) def code(x, y_m, z): t_0 = math.fabs((x / y_m)) tmp = 0 if x <= -10.5: tmp = t_0 elif x <= 4.0: tmp = math.fabs((4.0 / y_m)) else: tmp = t_0 return tmp
y_m = abs(y) function code(x, y_m, z) t_0 = abs(Float64(x / y_m)) tmp = 0.0 if (x <= -10.5) tmp = t_0; elseif (x <= 4.0) tmp = abs(Float64(4.0 / y_m)); else tmp = t_0; end return tmp end
y_m = abs(y); function tmp_2 = code(x, y_m, z) t_0 = abs((x / y_m)); tmp = 0.0; if (x <= -10.5) tmp = t_0; elseif (x <= 4.0) tmp = abs((4.0 / y_m)); else tmp = t_0; end tmp_2 = tmp; end
y_m = N[Abs[y], $MachinePrecision]
code[x_, y$95$m_, z_] := Block[{t$95$0 = N[Abs[N[(x / y$95$m), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[x, -10.5], t$95$0, If[LessEqual[x, 4.0], N[Abs[N[(4.0 / y$95$m), $MachinePrecision]], $MachinePrecision], t$95$0]]]
\begin{array}{l}
y_m = \left|y\right|
\\
\begin{array}{l}
t_0 := \left|\frac{x}{y\_m}\right|\\
\mathbf{if}\;x \leq -10.5:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 4:\\
\;\;\;\;\left|\frac{4}{y\_m}\right|\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -10.5 or 4 < x Initial program 86.3%
Taylor expanded in x around inf
lower-/.f6484.8
Simplified84.8%
Taylor expanded in z around 0
lower-/.f6462.3
Simplified62.3%
if -10.5 < x < 4Initial program 96.9%
Taylor expanded in x around 0
lower-/.f6480.0
Simplified80.0%
y_m = (fabs.f64 y) (FPCore (x y_m z) :precision binary64 (fabs (/ (fma x z (- -4.0 x)) y_m)))
y_m = fabs(y);
double code(double x, double y_m, double z) {
return fabs((fma(x, z, (-4.0 - x)) / y_m));
}
y_m = abs(y) function code(x, y_m, z) return abs(Float64(fma(x, z, Float64(-4.0 - x)) / y_m)) end
y_m = N[Abs[y], $MachinePrecision] code[x_, y$95$m_, z_] := N[Abs[N[(N[(x * z + N[(-4.0 - x), $MachinePrecision]), $MachinePrecision] / y$95$m), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
y_m = \left|y\right|
\\
\left|\frac{\mathsf{fma}\left(x, z, -4 - x\right)}{y\_m}\right|
\end{array}
Initial program 91.7%
lift-+.f64N/A
lift-/.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift--.f64N/A
neg-fabsN/A
lower-fabs.f64N/A
lift--.f64N/A
sub-negN/A
+-commutativeN/A
distribute-neg-inN/A
remove-double-negN/A
sub-negN/A
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
lift-/.f64N/A
sub-divN/A
lower-/.f64N/A
Applied egg-rr94.4%
y_m = (fabs.f64 y) (FPCore (x y_m z) :precision binary64 (fabs (/ (+ x 4.0) y_m)))
y_m = fabs(y);
double code(double x, double y_m, double z) {
return fabs(((x + 4.0) / y_m));
}
y_m = abs(y)
real(8) function code(x, y_m, z)
real(8), intent (in) :: x
real(8), intent (in) :: y_m
real(8), intent (in) :: z
code = abs(((x + 4.0d0) / y_m))
end function
y_m = Math.abs(y);
public static double code(double x, double y_m, double z) {
return Math.abs(((x + 4.0) / y_m));
}
y_m = math.fabs(y) def code(x, y_m, z): return math.fabs(((x + 4.0) / y_m))
y_m = abs(y) function code(x, y_m, z) return abs(Float64(Float64(x + 4.0) / y_m)) end
y_m = abs(y); function tmp = code(x, y_m, z) tmp = abs(((x + 4.0) / y_m)); end
y_m = N[Abs[y], $MachinePrecision] code[x_, y$95$m_, z_] := N[Abs[N[(N[(x + 4.0), $MachinePrecision] / y$95$m), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
y_m = \left|y\right|
\\
\left|\frac{x + 4}{y\_m}\right|
\end{array}
Initial program 91.7%
Taylor expanded in z around 0
*-rgt-identityN/A
associate-*r/N/A
distribute-rgt-outN/A
associate-*l/N/A
metadata-evalN/A
associate-*r*N/A
associate-*r/N/A
neg-mul-1N/A
mul-1-negN/A
distribute-frac-negN/A
remove-double-negN/A
lower-/.f64N/A
lower-+.f6472.8
Simplified72.8%
Final simplification72.8%
y_m = (fabs.f64 y) (FPCore (x y_m z) :precision binary64 (fabs (/ 4.0 y_m)))
y_m = fabs(y);
double code(double x, double y_m, double z) {
return fabs((4.0 / y_m));
}
y_m = abs(y)
real(8) function code(x, y_m, z)
real(8), intent (in) :: x
real(8), intent (in) :: y_m
real(8), intent (in) :: z
code = abs((4.0d0 / y_m))
end function
y_m = Math.abs(y);
public static double code(double x, double y_m, double z) {
return Math.abs((4.0 / y_m));
}
y_m = math.fabs(y) def code(x, y_m, z): return math.fabs((4.0 / y_m))
y_m = abs(y) function code(x, y_m, z) return abs(Float64(4.0 / y_m)) end
y_m = abs(y); function tmp = code(x, y_m, z) tmp = abs((4.0 / y_m)); end
y_m = N[Abs[y], $MachinePrecision] code[x_, y$95$m_, z_] := N[Abs[N[(4.0 / y$95$m), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
y_m = \left|y\right|
\\
\left|\frac{4}{y\_m}\right|
\end{array}
Initial program 91.7%
Taylor expanded in x around 0
lower-/.f6443.1
Simplified43.1%
herbie shell --seed 2024208
(FPCore (x y z)
:name "fabs fraction 1"
:precision binary64
(fabs (- (/ (+ x 4.0) y) (* (/ x y) z))))