
(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 9 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 3e-25) (fabs (/ (fma z x (- -4.0 x)) y_m)) (fabs (- (/ x (/ y_m z)) (/ (+ x 4.0) y_m)))))
y_m = fabs(y);
double code(double x, double y_m, double z) {
double tmp;
if (y_m <= 3e-25) {
tmp = fabs((fma(z, x, (-4.0 - x)) / y_m));
} else {
tmp = fabs(((x / (y_m / z)) - ((x + 4.0) / y_m)));
}
return tmp;
}
y_m = abs(y) function code(x, y_m, z) tmp = 0.0 if (y_m <= 3e-25) tmp = abs(Float64(fma(z, x, Float64(-4.0 - x)) / y_m)); else tmp = abs(Float64(Float64(x / Float64(y_m / z)) - 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, 3e-25], N[Abs[N[(N[(z * x + N[(-4.0 - x), $MachinePrecision]), $MachinePrecision] / y$95$m), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[(x / N[(y$95$m / z), $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 3 \cdot 10^{-25}:\\
\;\;\;\;\left|\frac{\mathsf{fma}\left(z, x, -4 - x\right)}{y\_m}\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\frac{x}{\frac{y\_m}{z}} - \frac{x + 4}{y\_m}\right|\\
\end{array}
\end{array}
if y < 2.9999999999999998e-25Initial program 89.5%
lift-fabs.f64N/A
lift--.f64N/A
fabs-subN/A
lower-fabs.f64N/A
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
lift-/.f64N/A
sub-divN/A
lower-/.f64N/A
sub-negN/A
*-commutativeN/A
lower-fma.f64N/A
lift-+.f64N/A
+-commutativeN/A
distribute-neg-inN/A
unsub-negN/A
lower--.f64N/A
metadata-eval98.0
Applied rewrites98.0%
if 2.9999999999999998e-25 < y Initial program 93.6%
lift-*.f64N/A
*-commutativeN/A
lift-/.f64N/A
clear-numN/A
un-div-invN/A
clear-numN/A
lower-/.f64N/A
lower-/.f64N/A
lower-/.f6492.4
Applied rewrites92.4%
lift-/.f64N/A
lift-/.f64N/A
associate-/r/N/A
lift-/.f64N/A
clear-numN/A
div-invN/A
associate-*l*N/A
associate-/r/N/A
un-div-invN/A
lower-/.f64N/A
lower-/.f6499.9
Applied rewrites99.9%
Final simplification98.4%
y_m = (fabs.f64 y) (FPCore (x y_m z) :precision binary64 (if (<= y_m 4e-30) (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 <= 4e-30) {
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 <= 4e-30) 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, 4e-30], 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 4 \cdot 10^{-30}:\\
\;\;\;\;\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 < 4e-30Initial program 89.4%
lift-fabs.f64N/A
lift--.f64N/A
fabs-subN/A
lower-fabs.f64N/A
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
lift-/.f64N/A
sub-divN/A
lower-/.f64N/A
sub-negN/A
*-commutativeN/A
lower-fma.f64N/A
lift-+.f64N/A
+-commutativeN/A
distribute-neg-inN/A
unsub-negN/A
lower--.f64N/A
metadata-eval97.9
Applied rewrites97.9%
if 4e-30 < y Initial program 93.7%
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
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.8
Applied rewrites99.8%
y_m = (fabs.f64 y)
(FPCore (x y_m z)
:precision binary64
(if (<= z -1.9e+72)
(fabs (* (/ z y_m) x))
(if (<= z 4.3e+117)
(fabs (/ (- -4.0 x) y_m))
(fabs (* (- 1.0 z) (/ x y_m))))))y_m = fabs(y);
double code(double x, double y_m, double z) {
double tmp;
if (z <= -1.9e+72) {
tmp = fabs(((z / y_m) * x));
} else if (z <= 4.3e+117) {
tmp = fabs(((-4.0 - x) / y_m));
} else {
tmp = fabs(((1.0 - z) * (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 (z <= (-1.9d+72)) then
tmp = abs(((z / y_m) * x))
else if (z <= 4.3d+117) then
tmp = abs((((-4.0d0) - x) / y_m))
else
tmp = abs(((1.0d0 - z) * (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 (z <= -1.9e+72) {
tmp = Math.abs(((z / y_m) * x));
} else if (z <= 4.3e+117) {
tmp = Math.abs(((-4.0 - x) / y_m));
} else {
tmp = Math.abs(((1.0 - z) * (x / y_m)));
}
return tmp;
}
y_m = math.fabs(y) def code(x, y_m, z): tmp = 0 if z <= -1.9e+72: tmp = math.fabs(((z / y_m) * x)) elif z <= 4.3e+117: tmp = math.fabs(((-4.0 - x) / y_m)) else: tmp = math.fabs(((1.0 - z) * (x / y_m))) return tmp
y_m = abs(y) function code(x, y_m, z) tmp = 0.0 if (z <= -1.9e+72) tmp = abs(Float64(Float64(z / y_m) * x)); elseif (z <= 4.3e+117) tmp = abs(Float64(Float64(-4.0 - x) / y_m)); else tmp = abs(Float64(Float64(1.0 - z) * Float64(x / y_m))); end return tmp end
y_m = abs(y); function tmp_2 = code(x, y_m, z) tmp = 0.0; if (z <= -1.9e+72) tmp = abs(((z / y_m) * x)); elseif (z <= 4.3e+117) tmp = abs(((-4.0 - x) / y_m)); else tmp = abs(((1.0 - z) * (x / y_m))); end tmp_2 = tmp; end
y_m = N[Abs[y], $MachinePrecision] code[x_, y$95$m_, z_] := If[LessEqual[z, -1.9e+72], N[Abs[N[(N[(z / y$95$m), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision], If[LessEqual[z, 4.3e+117], N[Abs[N[(N[(-4.0 - x), $MachinePrecision] / y$95$m), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[(1.0 - z), $MachinePrecision] * N[(x / y$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
y_m = \left|y\right|
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.9 \cdot 10^{+72}:\\
\;\;\;\;\left|\frac{z}{y\_m} \cdot x\right|\\
\mathbf{elif}\;z \leq 4.3 \cdot 10^{+117}:\\
\;\;\;\;\left|\frac{-4 - x}{y\_m}\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\left(1 - z\right) \cdot \frac{x}{y\_m}\right|\\
\end{array}
\end{array}
if z < -1.90000000000000003e72Initial program 91.3%
lift-fabs.f64N/A
lift--.f64N/A
fabs-subN/A
lower-fabs.f64N/A
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
lift-/.f64N/A
sub-divN/A
lower-/.f64N/A
sub-negN/A
*-commutativeN/A
lower-fma.f64N/A
lift-+.f64N/A
+-commutativeN/A
distribute-neg-inN/A
unsub-negN/A
lower--.f64N/A
metadata-eval90.3
Applied rewrites90.3%
Taylor expanded in z around 0
mul-1-negN/A
neg-sub0N/A
associate--r+N/A
metadata-evalN/A
lft-mult-inverseN/A
associate-*l*N/A
neg-sub0N/A
lower--.f64N/A
distribute-rgt-neg-inN/A
mul-1-negN/A
associate-*l*N/A
mul-1-negN/A
distribute-rgt-neg-outN/A
lft-mult-inverseN/A
metadata-evalN/A
metadata-eval35.6
Applied rewrites35.6%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f6474.0
Applied rewrites74.0%
Taylor expanded in z around inf
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6478.9
Applied rewrites78.9%
if -1.90000000000000003e72 < z < 4.29999999999999998e117Initial program 92.1%
lift-fabs.f64N/A
lift--.f64N/A
fabs-subN/A
lower-fabs.f64N/A
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
lift-/.f64N/A
sub-divN/A
lower-/.f64N/A
sub-negN/A
*-commutativeN/A
lower-fma.f64N/A
lift-+.f64N/A
+-commutativeN/A
distribute-neg-inN/A
unsub-negN/A
lower--.f64N/A
metadata-eval100.0
Applied rewrites100.0%
Taylor expanded in z around 0
mul-1-negN/A
neg-sub0N/A
associate--r+N/A
metadata-evalN/A
lft-mult-inverseN/A
associate-*l*N/A
neg-sub0N/A
lower--.f64N/A
distribute-rgt-neg-inN/A
mul-1-negN/A
associate-*l*N/A
mul-1-negN/A
distribute-rgt-neg-outN/A
lft-mult-inverseN/A
metadata-evalN/A
metadata-eval92.8
Applied rewrites92.8%
if 4.29999999999999998e117 < z Initial program 80.4%
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-/.f6485.7
Applied rewrites85.7%
y_m = (fabs.f64 y) (FPCore (x y_m z) :precision binary64 (if (<= z -1.9e+72) (fabs (* (/ z y_m) x)) (if (<= z 4.3e+117) (fabs (/ (- -4.0 x) y_m)) (fabs (* (- z) (/ x y_m))))))
y_m = fabs(y);
double code(double x, double y_m, double z) {
double tmp;
if (z <= -1.9e+72) {
tmp = fabs(((z / y_m) * x));
} else if (z <= 4.3e+117) {
tmp = fabs(((-4.0 - x) / y_m));
} else {
tmp = fabs((-z * (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 (z <= (-1.9d+72)) then
tmp = abs(((z / y_m) * x))
else if (z <= 4.3d+117) then
tmp = abs((((-4.0d0) - x) / y_m))
else
tmp = abs((-z * (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 (z <= -1.9e+72) {
tmp = Math.abs(((z / y_m) * x));
} else if (z <= 4.3e+117) {
tmp = Math.abs(((-4.0 - x) / y_m));
} else {
tmp = Math.abs((-z * (x / y_m)));
}
return tmp;
}
y_m = math.fabs(y) def code(x, y_m, z): tmp = 0 if z <= -1.9e+72: tmp = math.fabs(((z / y_m) * x)) elif z <= 4.3e+117: tmp = math.fabs(((-4.0 - x) / y_m)) else: tmp = math.fabs((-z * (x / y_m))) return tmp
y_m = abs(y) function code(x, y_m, z) tmp = 0.0 if (z <= -1.9e+72) tmp = abs(Float64(Float64(z / y_m) * x)); elseif (z <= 4.3e+117) tmp = abs(Float64(Float64(-4.0 - x) / y_m)); else tmp = abs(Float64(Float64(-z) * Float64(x / y_m))); end return tmp end
y_m = abs(y); function tmp_2 = code(x, y_m, z) tmp = 0.0; if (z <= -1.9e+72) tmp = abs(((z / y_m) * x)); elseif (z <= 4.3e+117) tmp = abs(((-4.0 - x) / y_m)); else tmp = abs((-z * (x / y_m))); end tmp_2 = tmp; end
y_m = N[Abs[y], $MachinePrecision] code[x_, y$95$m_, z_] := If[LessEqual[z, -1.9e+72], N[Abs[N[(N[(z / y$95$m), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision], If[LessEqual[z, 4.3e+117], N[Abs[N[(N[(-4.0 - x), $MachinePrecision] / y$95$m), $MachinePrecision]], $MachinePrecision], N[Abs[N[((-z) * N[(x / y$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
y_m = \left|y\right|
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.9 \cdot 10^{+72}:\\
\;\;\;\;\left|\frac{z}{y\_m} \cdot x\right|\\
\mathbf{elif}\;z \leq 4.3 \cdot 10^{+117}:\\
\;\;\;\;\left|\frac{-4 - x}{y\_m}\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\left(-z\right) \cdot \frac{x}{y\_m}\right|\\
\end{array}
\end{array}
if z < -1.90000000000000003e72Initial program 91.3%
lift-fabs.f64N/A
lift--.f64N/A
fabs-subN/A
lower-fabs.f64N/A
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
lift-/.f64N/A
sub-divN/A
lower-/.f64N/A
sub-negN/A
*-commutativeN/A
lower-fma.f64N/A
lift-+.f64N/A
+-commutativeN/A
distribute-neg-inN/A
unsub-negN/A
lower--.f64N/A
metadata-eval90.3
Applied rewrites90.3%
Taylor expanded in z around 0
mul-1-negN/A
neg-sub0N/A
associate--r+N/A
metadata-evalN/A
lft-mult-inverseN/A
associate-*l*N/A
neg-sub0N/A
lower--.f64N/A
distribute-rgt-neg-inN/A
mul-1-negN/A
associate-*l*N/A
mul-1-negN/A
distribute-rgt-neg-outN/A
lft-mult-inverseN/A
metadata-evalN/A
metadata-eval35.6
Applied rewrites35.6%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f6474.0
Applied rewrites74.0%
Taylor expanded in z around inf
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6478.9
Applied rewrites78.9%
if -1.90000000000000003e72 < z < 4.29999999999999998e117Initial program 92.1%
lift-fabs.f64N/A
lift--.f64N/A
fabs-subN/A
lower-fabs.f64N/A
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
lift-/.f64N/A
sub-divN/A
lower-/.f64N/A
sub-negN/A
*-commutativeN/A
lower-fma.f64N/A
lift-+.f64N/A
+-commutativeN/A
distribute-neg-inN/A
unsub-negN/A
lower--.f64N/A
metadata-eval100.0
Applied rewrites100.0%
Taylor expanded in z around 0
mul-1-negN/A
neg-sub0N/A
associate--r+N/A
metadata-evalN/A
lft-mult-inverseN/A
associate-*l*N/A
neg-sub0N/A
lower--.f64N/A
distribute-rgt-neg-inN/A
mul-1-negN/A
associate-*l*N/A
mul-1-negN/A
distribute-rgt-neg-outN/A
lft-mult-inverseN/A
metadata-evalN/A
metadata-eval92.8
Applied rewrites92.8%
if 4.29999999999999998e117 < z Initial program 80.4%
Taylor expanded in z around inf
*-commutativeN/A
associate-/l*N/A
associate-*r*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower-/.f6485.7
Applied rewrites85.7%
y_m = (fabs.f64 y) (FPCore (x y_m z) :precision binary64 (if (or (<= z -1.9e+72) (not (<= z 4.3e+117))) (fabs (* (/ z y_m) x)) (fabs (/ (- -4.0 x) y_m))))
y_m = fabs(y);
double code(double x, double y_m, double z) {
double tmp;
if ((z <= -1.9e+72) || !(z <= 4.3e+117)) {
tmp = fabs(((z / y_m) * x));
} else {
tmp = fabs(((-4.0 - 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 ((z <= (-1.9d+72)) .or. (.not. (z <= 4.3d+117))) then
tmp = abs(((z / y_m) * x))
else
tmp = abs((((-4.0d0) - 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 ((z <= -1.9e+72) || !(z <= 4.3e+117)) {
tmp = Math.abs(((z / y_m) * x));
} else {
tmp = Math.abs(((-4.0 - x) / y_m));
}
return tmp;
}
y_m = math.fabs(y) def code(x, y_m, z): tmp = 0 if (z <= -1.9e+72) or not (z <= 4.3e+117): tmp = math.fabs(((z / y_m) * x)) else: tmp = math.fabs(((-4.0 - x) / y_m)) return tmp
y_m = abs(y) function code(x, y_m, z) tmp = 0.0 if ((z <= -1.9e+72) || !(z <= 4.3e+117)) tmp = abs(Float64(Float64(z / y_m) * x)); else tmp = abs(Float64(Float64(-4.0 - x) / y_m)); end return tmp end
y_m = abs(y); function tmp_2 = code(x, y_m, z) tmp = 0.0; if ((z <= -1.9e+72) || ~((z <= 4.3e+117))) tmp = abs(((z / y_m) * x)); else tmp = abs(((-4.0 - x) / y_m)); end tmp_2 = tmp; end
y_m = N[Abs[y], $MachinePrecision] code[x_, y$95$m_, z_] := If[Or[LessEqual[z, -1.9e+72], N[Not[LessEqual[z, 4.3e+117]], $MachinePrecision]], N[Abs[N[(N[(z / y$95$m), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[(-4.0 - x), $MachinePrecision] / y$95$m), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
y_m = \left|y\right|
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.9 \cdot 10^{+72} \lor \neg \left(z \leq 4.3 \cdot 10^{+117}\right):\\
\;\;\;\;\left|\frac{z}{y\_m} \cdot x\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\frac{-4 - x}{y\_m}\right|\\
\end{array}
\end{array}
if z < -1.90000000000000003e72 or 4.29999999999999998e117 < z Initial program 87.6%
lift-fabs.f64N/A
lift--.f64N/A
fabs-subN/A
lower-fabs.f64N/A
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
lift-/.f64N/A
sub-divN/A
lower-/.f64N/A
sub-negN/A
*-commutativeN/A
lower-fma.f64N/A
lift-+.f64N/A
+-commutativeN/A
distribute-neg-inN/A
unsub-negN/A
lower--.f64N/A
metadata-eval90.5
Applied rewrites90.5%
Taylor expanded in z around 0
mul-1-negN/A
neg-sub0N/A
associate--r+N/A
metadata-evalN/A
lft-mult-inverseN/A
associate-*l*N/A
neg-sub0N/A
lower--.f64N/A
distribute-rgt-neg-inN/A
mul-1-negN/A
associate-*l*N/A
mul-1-negN/A
distribute-rgt-neg-outN/A
lft-mult-inverseN/A
metadata-evalN/A
metadata-eval35.8
Applied rewrites35.8%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f6475.0
Applied rewrites75.0%
Taylor expanded in z around inf
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6480.0
Applied rewrites80.0%
if -1.90000000000000003e72 < z < 4.29999999999999998e117Initial program 92.1%
lift-fabs.f64N/A
lift--.f64N/A
fabs-subN/A
lower-fabs.f64N/A
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
lift-/.f64N/A
sub-divN/A
lower-/.f64N/A
sub-negN/A
*-commutativeN/A
lower-fma.f64N/A
lift-+.f64N/A
+-commutativeN/A
distribute-neg-inN/A
unsub-negN/A
lower--.f64N/A
metadata-eval100.0
Applied rewrites100.0%
Taylor expanded in z around 0
mul-1-negN/A
neg-sub0N/A
associate--r+N/A
metadata-evalN/A
lft-mult-inverseN/A
associate-*l*N/A
neg-sub0N/A
lower--.f64N/A
distribute-rgt-neg-inN/A
mul-1-negN/A
associate-*l*N/A
mul-1-negN/A
distribute-rgt-neg-outN/A
lft-mult-inverseN/A
metadata-evalN/A
metadata-eval92.8
Applied rewrites92.8%
Final simplification88.3%
y_m = (fabs.f64 y) (FPCore (x y_m z) :precision binary64 (if (<= x 200.0) (fabs (/ (fma z x (- -4.0 x)) y_m)) (fabs (* (- 1.0 z) (/ x y_m)))))
y_m = fabs(y);
double code(double x, double y_m, double z) {
double tmp;
if (x <= 200.0) {
tmp = fabs((fma(z, x, (-4.0 - x)) / y_m));
} else {
tmp = fabs(((1.0 - z) * (x / y_m)));
}
return tmp;
}
y_m = abs(y) function code(x, y_m, z) tmp = 0.0 if (x <= 200.0) tmp = abs(Float64(fma(z, x, Float64(-4.0 - x)) / y_m)); else tmp = abs(Float64(Float64(1.0 - z) * Float64(x / y_m))); end return tmp end
y_m = N[Abs[y], $MachinePrecision] code[x_, y$95$m_, z_] := If[LessEqual[x, 200.0], N[Abs[N[(N[(z * x + N[(-4.0 - x), $MachinePrecision]), $MachinePrecision] / y$95$m), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[(1.0 - z), $MachinePrecision] * N[(x / y$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
y_m = \left|y\right|
\\
\begin{array}{l}
\mathbf{if}\;x \leq 200:\\
\;\;\;\;\left|\frac{\mathsf{fma}\left(z, x, -4 - x\right)}{y\_m}\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\left(1 - z\right) \cdot \frac{x}{y\_m}\right|\\
\end{array}
\end{array}
if x < 200Initial program 91.4%
lift-fabs.f64N/A
lift--.f64N/A
fabs-subN/A
lower-fabs.f64N/A
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
lift-/.f64N/A
sub-divN/A
lower-/.f64N/A
sub-negN/A
*-commutativeN/A
lower-fma.f64N/A
lift-+.f64N/A
+-commutativeN/A
distribute-neg-inN/A
unsub-negN/A
lower--.f64N/A
metadata-eval98.1
Applied rewrites98.1%
if 200 < x Initial program 87.0%
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%
y_m = (fabs.f64 y) (FPCore (x y_m z) :precision binary64 (if (or (<= x -10.2) (not (<= x 4.0))) (fabs (/ x y_m)) (fabs (/ 4.0 y_m))))
y_m = fabs(y);
double code(double x, double y_m, double z) {
double tmp;
if ((x <= -10.2) || !(x <= 4.0)) {
tmp = fabs((x / y_m));
} else {
tmp = fabs((4.0 / 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 <= (-10.2d0)) .or. (.not. (x <= 4.0d0))) then
tmp = abs((x / y_m))
else
tmp = abs((4.0d0 / 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 <= -10.2) || !(x <= 4.0)) {
tmp = Math.abs((x / y_m));
} else {
tmp = Math.abs((4.0 / y_m));
}
return tmp;
}
y_m = math.fabs(y) def code(x, y_m, z): tmp = 0 if (x <= -10.2) or not (x <= 4.0): tmp = math.fabs((x / y_m)) else: tmp = math.fabs((4.0 / y_m)) return tmp
y_m = abs(y) function code(x, y_m, z) tmp = 0.0 if ((x <= -10.2) || !(x <= 4.0)) tmp = abs(Float64(x / y_m)); else tmp = abs(Float64(4.0 / y_m)); end return tmp end
y_m = abs(y); function tmp_2 = code(x, y_m, z) tmp = 0.0; if ((x <= -10.2) || ~((x <= 4.0))) tmp = abs((x / y_m)); else tmp = abs((4.0 / y_m)); end tmp_2 = tmp; end
y_m = N[Abs[y], $MachinePrecision] code[x_, y$95$m_, z_] := If[Or[LessEqual[x, -10.2], N[Not[LessEqual[x, 4.0]], $MachinePrecision]], N[Abs[N[(x / y$95$m), $MachinePrecision]], $MachinePrecision], N[Abs[N[(4.0 / y$95$m), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
y_m = \left|y\right|
\\
\begin{array}{l}
\mathbf{if}\;x \leq -10.2 \lor \neg \left(x \leq 4\right):\\
\;\;\;\;\left|\frac{x}{y\_m}\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\frac{4}{y\_m}\right|\\
\end{array}
\end{array}
if x < -10.199999999999999 or 4 < x Initial program 82.9%
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.4
Applied rewrites99.4%
Applied rewrites86.9%
Applied rewrites91.9%
Taylor expanded in z around 0
Applied rewrites67.1%
if -10.199999999999999 < x < 4Initial program 96.4%
Taylor expanded in x around 0
lower-/.f6474.4
Applied rewrites74.4%
Final simplification71.2%
y_m = (fabs.f64 y) (FPCore (x y_m z) :precision binary64 (fabs (/ (- -4.0 x) y_m)))
y_m = fabs(y);
double code(double x, double y_m, double z) {
return fabs(((-4.0 - x) / 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) - x) / 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 - x) / y_m));
}
y_m = math.fabs(y) def code(x, y_m, z): return math.fabs(((-4.0 - x) / y_m))
y_m = abs(y) function code(x, y_m, z) return abs(Float64(Float64(-4.0 - x) / y_m)) end
y_m = abs(y); function tmp = code(x, y_m, z) tmp = abs(((-4.0 - x) / y_m)); end
y_m = N[Abs[y], $MachinePrecision] code[x_, y$95$m_, z_] := N[Abs[N[(N[(-4.0 - x), $MachinePrecision] / y$95$m), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
y_m = \left|y\right|
\\
\left|\frac{-4 - x}{y\_m}\right|
\end{array}
Initial program 90.5%
lift-fabs.f64N/A
lift--.f64N/A
fabs-subN/A
lower-fabs.f64N/A
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
lift-/.f64N/A
sub-divN/A
lower-/.f64N/A
sub-negN/A
*-commutativeN/A
lower-fma.f64N/A
lift-+.f64N/A
+-commutativeN/A
distribute-neg-inN/A
unsub-negN/A
lower--.f64N/A
metadata-eval96.6
Applied rewrites96.6%
Taylor expanded in z around 0
mul-1-negN/A
neg-sub0N/A
associate--r+N/A
metadata-evalN/A
lft-mult-inverseN/A
associate-*l*N/A
neg-sub0N/A
lower--.f64N/A
distribute-rgt-neg-inN/A
mul-1-negN/A
associate-*l*N/A
mul-1-negN/A
distribute-rgt-neg-outN/A
lft-mult-inverseN/A
metadata-evalN/A
metadata-eval72.6
Applied rewrites72.6%
y_m = (fabs.f64 y) (FPCore (x y_m z) :precision binary64 (fabs (/ x y_m)))
y_m = fabs(y);
double code(double x, double y_m, double z) {
return fabs((x / 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 / y_m))
end function
y_m = Math.abs(y);
public static double code(double x, double y_m, double z) {
return Math.abs((x / y_m));
}
y_m = math.fabs(y) def code(x, y_m, z): return math.fabs((x / y_m))
y_m = abs(y) function code(x, y_m, z) return abs(Float64(x / y_m)) end
y_m = abs(y); function tmp = code(x, y_m, z) tmp = abs((x / y_m)); end
y_m = N[Abs[y], $MachinePrecision] code[x_, y$95$m_, z_] := N[Abs[N[(x / y$95$m), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
y_m = \left|y\right|
\\
\left|\frac{x}{y\_m}\right|
\end{array}
Initial program 90.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-/.f6457.1
Applied rewrites57.1%
Applied rewrites52.0%
Applied rewrites55.7%
Taylor expanded in z around 0
Applied rewrites32.4%
herbie shell --seed 2024313
(FPCore (x y z)
:name "fabs fraction 1"
:precision binary64
(fabs (- (/ (+ x 4.0) y) (* (/ x y) z))))