
(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 11 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
(let* ((t_0 (fabs (* (- 1.0 z) (/ x y_m)))))
(if (<= x -9.8e+14)
t_0
(if (<= x 3.4e+16) (* (fabs (- (fma x z -4.0) x)) (/ 1.0 y_m)) t_0))))y_m = fabs(y);
double code(double x, double y_m, double z) {
double t_0 = fabs(((1.0 - z) * (x / y_m)));
double tmp;
if (x <= -9.8e+14) {
tmp = t_0;
} else if (x <= 3.4e+16) {
tmp = fabs((fma(x, z, -4.0) - x)) * (1.0 / y_m);
} else {
tmp = t_0;
}
return tmp;
}
y_m = abs(y) function code(x, y_m, z) t_0 = abs(Float64(Float64(1.0 - z) * Float64(x / y_m))) tmp = 0.0 if (x <= -9.8e+14) tmp = t_0; elseif (x <= 3.4e+16) tmp = Float64(abs(Float64(fma(x, z, -4.0) - x)) * Float64(1.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[(1.0 - z), $MachinePrecision] * N[(x / y$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[x, -9.8e+14], t$95$0, If[LessEqual[x, 3.4e+16], N[(N[Abs[N[(N[(x * z + -4.0), $MachinePrecision] - x), $MachinePrecision]], $MachinePrecision] * N[(1.0 / y$95$m), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
y_m = \left|y\right|
\\
\begin{array}{l}
t_0 := \left|\left(1 - z\right) \cdot \frac{x}{y\_m}\right|\\
\mathbf{if}\;x \leq -9.8 \cdot 10^{+14}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 3.4 \cdot 10^{+16}:\\
\;\;\;\;\left|\mathsf{fma}\left(x, z, -4\right) - x\right| \cdot \frac{1}{y\_m}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -9.8e14 or 3.4e16 < x Initial program 84.2%
Taylor expanded in x around inf
distribute-lft-out--N/A
associate-*r/N/A
*-rgt-identityN/A
associate-/l*N/A
*-commutativeN/A
associate-/l*N/A
cancel-sign-sub-invN/A
mul-1-negN/A
distribute-rgt1-inN/A
lower-*.f64N/A
+-commutativeN/A
mul-1-negN/A
sub-negN/A
lower--.f64N/A
lower-/.f6499.9
Applied rewrites99.9%
if -9.8e14 < x < 3.4e16Initial program 97.8%
lift-fabs.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 rewrites99.9%
lift-fabs.f64N/A
lift-/.f64N/A
clear-numN/A
associate-/r/N/A
lift-/.f64N/A
fabs-mulN/A
lift-/.f64N/A
inv-powN/A
sqr-powN/A
fabs-sqrN/A
sqr-powN/A
inv-powN/A
lift-/.f64N/A
lower-*.f64N/A
lift-fma.f64N/A
lift-*.f64N/A
lift--.f64N/A
associate-+r-N/A
fabs-subN/A
lower-fabs.f64N/A
lower--.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6452.8
Applied rewrites52.8%
Final simplification76.2%
y_m = (fabs.f64 y) (FPCore (x y_m z) :precision binary64 (let* ((t_0 (/ (+ 4.0 x) y_m)) (t_1 (* (/ x y_m) z))) (if (<= (- t_0 t_1) INFINITY) (fabs (- t_1 t_0)) (fabs (/ (- x) y_m)))))
y_m = fabs(y);
double code(double x, double y_m, double z) {
double t_0 = (4.0 + x) / y_m;
double t_1 = (x / y_m) * z;
double tmp;
if ((t_0 - t_1) <= ((double) INFINITY)) {
tmp = fabs((t_1 - t_0));
} else {
tmp = fabs((-x / y_m));
}
return tmp;
}
y_m = Math.abs(y);
public static double code(double x, double y_m, double z) {
double t_0 = (4.0 + x) / y_m;
double t_1 = (x / y_m) * z;
double tmp;
if ((t_0 - t_1) <= Double.POSITIVE_INFINITY) {
tmp = Math.abs((t_1 - t_0));
} else {
tmp = Math.abs((-x / y_m));
}
return tmp;
}
y_m = math.fabs(y) def code(x, y_m, z): t_0 = (4.0 + x) / y_m t_1 = (x / y_m) * z tmp = 0 if (t_0 - t_1) <= math.inf: tmp = math.fabs((t_1 - t_0)) else: tmp = math.fabs((-x / y_m)) return tmp
y_m = abs(y) function code(x, y_m, z) t_0 = Float64(Float64(4.0 + x) / y_m) t_1 = Float64(Float64(x / y_m) * z) tmp = 0.0 if (Float64(t_0 - t_1) <= Inf) tmp = abs(Float64(t_1 - t_0)); else tmp = abs(Float64(Float64(-x) / y_m)); end return tmp end
y_m = abs(y); function tmp_2 = code(x, y_m, z) t_0 = (4.0 + x) / y_m; t_1 = (x / y_m) * z; tmp = 0.0; if ((t_0 - t_1) <= Inf) tmp = abs((t_1 - t_0)); else tmp = abs((-x / y_m)); end tmp_2 = tmp; end
y_m = N[Abs[y], $MachinePrecision]
code[x_, y$95$m_, z_] := Block[{t$95$0 = N[(N[(4.0 + x), $MachinePrecision] / y$95$m), $MachinePrecision]}, Block[{t$95$1 = N[(N[(x / y$95$m), $MachinePrecision] * z), $MachinePrecision]}, If[LessEqual[N[(t$95$0 - t$95$1), $MachinePrecision], Infinity], N[Abs[N[(t$95$1 - t$95$0), $MachinePrecision]], $MachinePrecision], N[Abs[N[((-x) / y$95$m), $MachinePrecision]], $MachinePrecision]]]]
\begin{array}{l}
y_m = \left|y\right|
\\
\begin{array}{l}
t_0 := \frac{4 + x}{y\_m}\\
t_1 := \frac{x}{y\_m} \cdot z\\
\mathbf{if}\;t\_0 - t\_1 \leq \infty:\\
\;\;\;\;\left|t\_1 - t\_0\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\frac{-x}{y\_m}\right|\\
\end{array}
\end{array}
if (-.f64 (/.f64 (+.f64 x #s(literal 4 binary64)) y) (*.f64 (/.f64 x y) z)) < +inf.0Initial program 98.7%
if +inf.0 < (-.f64 (/.f64 (+.f64 x #s(literal 4 binary64)) y) (*.f64 (/.f64 x y) z)) Initial program 0.0%
lift-fabs.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 rewrites100.0%
Taylor expanded in z around 0
distribute-lft-inN/A
metadata-evalN/A
mul-1-negN/A
unsub-negN/A
lower--.f64100.0
Applied rewrites100.0%
Taylor expanded in x around inf
Applied rewrites100.0%
Final simplification98.8%
y_m = (fabs.f64 y) (FPCore (x y_m z) :precision binary64 (if (<= y_m 1e-79) (fabs (/ (fma z x (- -4.0 x)) y_m)) (fabs (fma (- x) (/ z y_m) (/ (+ 4.0 x) y_m)))))
y_m = fabs(y);
double code(double x, double y_m, double z) {
double tmp;
if (y_m <= 1e-79) {
tmp = fabs((fma(z, x, (-4.0 - x)) / y_m));
} else {
tmp = fabs(fma(-x, (z / y_m), ((4.0 + x) / y_m)));
}
return tmp;
}
y_m = abs(y) function code(x, y_m, z) tmp = 0.0 if (y_m <= 1e-79) tmp = abs(Float64(fma(z, x, Float64(-4.0 - x)) / y_m)); else tmp = abs(fma(Float64(-x), Float64(z / y_m), Float64(Float64(4.0 + x) / y_m))); end return tmp end
y_m = N[Abs[y], $MachinePrecision] code[x_, y$95$m_, z_] := If[LessEqual[y$95$m, 1e-79], N[Abs[N[(N[(z * x + N[(-4.0 - x), $MachinePrecision]), $MachinePrecision] / y$95$m), $MachinePrecision]], $MachinePrecision], N[Abs[N[((-x) * N[(z / y$95$m), $MachinePrecision] + N[(N[(4.0 + x), $MachinePrecision] / y$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
y_m = \left|y\right|
\\
\begin{array}{l}
\mathbf{if}\;y\_m \leq 10^{-79}:\\
\;\;\;\;\left|\frac{\mathsf{fma}\left(z, x, -4 - x\right)}{y\_m}\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\mathsf{fma}\left(-x, \frac{z}{y\_m}, \frac{4 + x}{y\_m}\right)\right|\\
\end{array}
\end{array}
if y < 1e-79Initial program 88.7%
lift-fabs.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 rewrites98.8%
if 1e-79 < y Initial program 95.5%
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.9
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.9
Applied rewrites99.9%
y_m = (fabs.f64 y)
(FPCore (x y_m z)
:precision binary64
(let* ((t_0 (fabs (* (- 1.0 z) (/ x y_m)))))
(if (<= x -9.8e+14)
t_0
(if (<= x 1.75e+20) (fabs (/ (fma z x (- -4.0 x)) y_m)) t_0))))y_m = fabs(y);
double code(double x, double y_m, double z) {
double t_0 = fabs(((1.0 - z) * (x / y_m)));
double tmp;
if (x <= -9.8e+14) {
tmp = t_0;
} else if (x <= 1.75e+20) {
tmp = fabs((fma(z, x, (-4.0 - x)) / y_m));
} else {
tmp = t_0;
}
return tmp;
}
y_m = abs(y) function code(x, y_m, z) t_0 = abs(Float64(Float64(1.0 - z) * Float64(x / y_m))) tmp = 0.0 if (x <= -9.8e+14) tmp = t_0; elseif (x <= 1.75e+20) tmp = abs(Float64(fma(z, x, Float64(-4.0 - x)) / 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[(1.0 - z), $MachinePrecision] * N[(x / y$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[x, -9.8e+14], t$95$0, If[LessEqual[x, 1.75e+20], N[Abs[N[(N[(z * x + N[(-4.0 - x), $MachinePrecision]), $MachinePrecision] / y$95$m), $MachinePrecision]], $MachinePrecision], t$95$0]]]
\begin{array}{l}
y_m = \left|y\right|
\\
\begin{array}{l}
t_0 := \left|\left(1 - z\right) \cdot \frac{x}{y\_m}\right|\\
\mathbf{if}\;x \leq -9.8 \cdot 10^{+14}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 1.75 \cdot 10^{+20}:\\
\;\;\;\;\left|\frac{\mathsf{fma}\left(z, x, -4 - x\right)}{y\_m}\right|\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -9.8e14 or 1.75e20 < x Initial program 84.2%
Taylor expanded in x around inf
distribute-lft-out--N/A
associate-*r/N/A
*-rgt-identityN/A
associate-/l*N/A
*-commutativeN/A
associate-/l*N/A
cancel-sign-sub-invN/A
mul-1-negN/A
distribute-rgt1-inN/A
lower-*.f64N/A
+-commutativeN/A
mul-1-negN/A
sub-negN/A
lower--.f64N/A
lower-/.f6499.9
Applied rewrites99.9%
if -9.8e14 < x < 1.75e20Initial program 97.8%
lift-fabs.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 rewrites99.9%
y_m = (fabs.f64 y)
(FPCore (x y_m z)
:precision binary64
(let* ((t_0 (fabs (* (- 1.0 z) (/ x y_m)))))
(if (<= x -1.55)
t_0
(if (<= x 5.6e-26) (fabs (/ (fma z x -4.0) y_m)) t_0))))y_m = fabs(y);
double code(double x, double y_m, double z) {
double t_0 = fabs(((1.0 - z) * (x / y_m)));
double tmp;
if (x <= -1.55) {
tmp = t_0;
} else if (x <= 5.6e-26) {
tmp = fabs((fma(z, 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(Float64(1.0 - z) * Float64(x / y_m))) tmp = 0.0 if (x <= -1.55) tmp = t_0; elseif (x <= 5.6e-26) tmp = abs(Float64(fma(z, 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[(1.0 - z), $MachinePrecision] * N[(x / y$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[x, -1.55], t$95$0, If[LessEqual[x, 5.6e-26], N[Abs[N[(N[(z * 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|\left(1 - z\right) \cdot \frac{x}{y\_m}\right|\\
\mathbf{if}\;x \leq -1.55:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 5.6 \cdot 10^{-26}:\\
\;\;\;\;\left|\frac{\mathsf{fma}\left(z, x, -4\right)}{y\_m}\right|\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -1.55000000000000004 or 5.6000000000000002e-26 < x Initial program 85.5%
Taylor expanded in x around inf
distribute-lft-out--N/A
associate-*r/N/A
*-rgt-identityN/A
associate-/l*N/A
*-commutativeN/A
associate-/l*N/A
cancel-sign-sub-invN/A
mul-1-negN/A
distribute-rgt1-inN/A
lower-*.f64N/A
+-commutativeN/A
mul-1-negN/A
sub-negN/A
lower--.f64N/A
lower-/.f6499.0
Applied rewrites99.0%
if -1.55000000000000004 < x < 5.6000000000000002e-26Initial program 97.5%
lift-fabs.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 rewrites99.9%
Taylor expanded in x around 0
Applied rewrites99.7%
y_m = (fabs.f64 y) (FPCore (x y_m z) :precision binary64 (let* ((t_0 (fabs (/ (fma z x -4.0) y_m)))) (if (<= z -2.2e+15) t_0 (if (<= z 2.6) (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(z, x, -4.0) / y_m));
double tmp;
if (z <= -2.2e+15) {
tmp = t_0;
} else if (z <= 2.6) {
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(z, x, -4.0) / y_m)) tmp = 0.0 if (z <= -2.2e+15) tmp = t_0; elseif (z <= 2.6) 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[(z * x + -4.0), $MachinePrecision] / y$95$m), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[z, -2.2e+15], t$95$0, If[LessEqual[z, 2.6], 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(z, x, -4\right)}{y\_m}\right|\\
\mathbf{if}\;z \leq -2.2 \cdot 10^{+15}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 2.6:\\
\;\;\;\;\left|\frac{x - -4}{y\_m}\right|\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if z < -2.2e15 or 2.60000000000000009 < z Initial program 89.2%
lift-fabs.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 rewrites91.2%
Taylor expanded in x around 0
Applied rewrites90.1%
if -2.2e15 < z < 2.60000000000000009Initial program 92.9%
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
+-commutativeN/A
metadata-evalN/A
metadata-evalN/A
sub-negN/A
lower--.f64N/A
metadata-eval98.7
Applied rewrites98.7%
y_m = (fabs.f64 y) (FPCore (x y_m z) :precision binary64 (if (<= z -1.3e+25) (fabs (/ (* x z) y_m)) (if (<= z 9.5e+69) (fabs (/ (- x -4.0) y_m)) (fabs (* (/ x y_m) z)))))
y_m = fabs(y);
double code(double x, double y_m, double z) {
double tmp;
if (z <= -1.3e+25) {
tmp = fabs(((x * z) / y_m));
} else if (z <= 9.5e+69) {
tmp = fabs(((x - -4.0) / y_m));
} else {
tmp = fabs(((x / y_m) * z));
}
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 <= (-1.3d+25)) then
tmp = abs(((x * z) / y_m))
else if (z <= 9.5d+69) then
tmp = abs(((x - (-4.0d0)) / y_m))
else
tmp = abs(((x / y_m) * z))
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 <= -1.3e+25) {
tmp = Math.abs(((x * z) / y_m));
} else if (z <= 9.5e+69) {
tmp = Math.abs(((x - -4.0) / y_m));
} else {
tmp = Math.abs(((x / y_m) * z));
}
return tmp;
}
y_m = math.fabs(y) def code(x, y_m, z): tmp = 0 if z <= -1.3e+25: tmp = math.fabs(((x * z) / y_m)) elif z <= 9.5e+69: tmp = math.fabs(((x - -4.0) / y_m)) else: tmp = math.fabs(((x / y_m) * z)) return tmp
y_m = abs(y) function code(x, y_m, z) tmp = 0.0 if (z <= -1.3e+25) tmp = abs(Float64(Float64(x * z) / y_m)); elseif (z <= 9.5e+69) tmp = abs(Float64(Float64(x - -4.0) / y_m)); else tmp = abs(Float64(Float64(x / y_m) * z)); end return tmp end
y_m = abs(y); function tmp_2 = code(x, y_m, z) tmp = 0.0; if (z <= -1.3e+25) tmp = abs(((x * z) / y_m)); elseif (z <= 9.5e+69) tmp = abs(((x - -4.0) / y_m)); else tmp = abs(((x / y_m) * z)); end tmp_2 = tmp; end
y_m = N[Abs[y], $MachinePrecision] code[x_, y$95$m_, z_] := If[LessEqual[z, -1.3e+25], N[Abs[N[(N[(x * z), $MachinePrecision] / y$95$m), $MachinePrecision]], $MachinePrecision], If[LessEqual[z, 9.5e+69], N[Abs[N[(N[(x - -4.0), $MachinePrecision] / y$95$m), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[(x / y$95$m), $MachinePrecision] * z), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
y_m = \left|y\right|
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.3 \cdot 10^{+25}:\\
\;\;\;\;\left|\frac{x \cdot z}{y\_m}\right|\\
\mathbf{elif}\;z \leq 9.5 \cdot 10^{+69}:\\
\;\;\;\;\left|\frac{x - -4}{y\_m}\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\frac{x}{y\_m} \cdot z\right|\\
\end{array}
\end{array}
if z < -1.2999999999999999e25Initial program 96.4%
lift-fabs.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 rewrites96.5%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f6476.4
Applied rewrites76.4%
if -1.2999999999999999e25 < z < 9.4999999999999995e69Initial program 92.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
+-commutativeN/A
metadata-evalN/A
metadata-evalN/A
sub-negN/A
lower--.f64N/A
metadata-eval94.5
Applied rewrites94.5%
if 9.4999999999999995e69 < z Initial program 81.9%
lift-fabs.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 rewrites84.6%
Taylor expanded in z around 0
distribute-lft-inN/A
metadata-evalN/A
mul-1-negN/A
unsub-negN/A
lower--.f6435.2
Applied rewrites35.2%
Taylor expanded in x around inf
Applied rewrites20.7%
Taylor expanded in z around inf
*-commutativeN/A
associate-*r/N/A
lower-*.f64N/A
lower-/.f6483.3
Applied rewrites83.3%
Final simplification88.1%
y_m = (fabs.f64 y) (FPCore (x y_m z) :precision binary64 (let* ((t_0 (fabs (* (/ x y_m) z)))) (if (<= z -7.8e+24) t_0 (if (<= z 9.5e+69) (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(((x / y_m) * z));
double tmp;
if (z <= -7.8e+24) {
tmp = t_0;
} else if (z <= 9.5e+69) {
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(((x / y_m) * z))
if (z <= (-7.8d+24)) then
tmp = t_0
else if (z <= 9.5d+69) 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(((x / y_m) * z));
double tmp;
if (z <= -7.8e+24) {
tmp = t_0;
} else if (z <= 9.5e+69) {
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(((x / y_m) * z)) tmp = 0 if z <= -7.8e+24: tmp = t_0 elif z <= 9.5e+69: 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(Float64(x / y_m) * z)) tmp = 0.0 if (z <= -7.8e+24) tmp = t_0; elseif (z <= 9.5e+69) 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(((x / y_m) * z)); tmp = 0.0; if (z <= -7.8e+24) tmp = t_0; elseif (z <= 9.5e+69) 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[(N[(x / y$95$m), $MachinePrecision] * z), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[z, -7.8e+24], t$95$0, If[LessEqual[z, 9.5e+69], 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{x}{y\_m} \cdot z\right|\\
\mathbf{if}\;z \leq -7.8 \cdot 10^{+24}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 9.5 \cdot 10^{+69}:\\
\;\;\;\;\left|\frac{x - -4}{y\_m}\right|\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if z < -7.7999999999999995e24 or 9.4999999999999995e69 < z Initial program 89.3%
lift-fabs.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 rewrites90.6%
Taylor expanded in z around 0
distribute-lft-inN/A
metadata-evalN/A
mul-1-negN/A
unsub-negN/A
lower--.f6436.5
Applied rewrites36.5%
Taylor expanded in x around inf
Applied rewrites19.6%
Taylor expanded in z around inf
*-commutativeN/A
associate-*r/N/A
lower-*.f64N/A
lower-/.f6479.8
Applied rewrites79.8%
if -7.7999999999999995e24 < z < 9.4999999999999995e69Initial program 92.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
+-commutativeN/A
metadata-evalN/A
metadata-evalN/A
sub-negN/A
lower--.f64N/A
metadata-eval94.5
Applied rewrites94.5%
Final simplification88.1%
y_m = (fabs.f64 y) (FPCore (x y_m z) :precision binary64 (let* ((t_0 (fabs (/ (- x) y_m)))) (if (<= x -1.52) 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 <= -1.52) {
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 <= (-1.52d0)) 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 <= -1.52) {
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 <= -1.52: 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(Float64(-x) / y_m)) tmp = 0.0 if (x <= -1.52) 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 <= -1.52) 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, -1.52], 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 -1.52:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 4:\\
\;\;\;\;\left|\frac{4}{y\_m}\right|\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -1.52 or 4 < x Initial program 84.9%
lift-fabs.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 rewrites91.5%
Taylor expanded in z around 0
distribute-lft-inN/A
metadata-evalN/A
mul-1-negN/A
unsub-negN/A
lower--.f6466.4
Applied rewrites66.4%
Taylor expanded in x around inf
Applied rewrites65.8%
if -1.52 < x < 4Initial program 97.7%
Taylor expanded in x around 0
lower-/.f6472.4
Applied rewrites72.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.0%
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
+-commutativeN/A
metadata-evalN/A
metadata-evalN/A
sub-negN/A
lower--.f64N/A
metadata-eval69.3
Applied rewrites69.3%
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.0%
Taylor expanded in x around 0
lower-/.f6437.5
Applied rewrites37.5%
herbie shell --seed 2024235
(FPCore (x y z)
:name "fabs fraction 1"
:precision binary64
(fabs (- (/ (+ x 4.0) y) (* (/ x y) z))))