
(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 2e-131) (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 <= 2e-131) {
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 <= 2e-131) tmp = abs(Float64(Float64(fma(z, x, -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, 2e-131], N[Abs[N[(N[(N[(z * x + -4.0), $MachinePrecision] - x), $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 2 \cdot 10^{-131}:\\
\;\;\;\;\left|\frac{\mathsf{fma}\left(z, x, -4\right) - x}{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 < 2e-131Initial program 89.6%
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 rewrites97.0%
lift-fma.f64N/A
lift-*.f64N/A
lift--.f64N/A
associate-+r-N/A
lower--.f64N/A
lift-*.f64N/A
lower-fma.f6497.0
Applied rewrites97.0%
if 2e-131 < y Initial program 96.0%
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 (<= (- (/ (+ 4.0 x) y_m) (* (/ x y_m) z)) -2e+62) (fabs (* (- 1.0 z) (/ x y_m))) (fabs (/ (- (fma z x -4.0) x) y_m))))
y_m = fabs(y);
double code(double x, double y_m, double z) {
double tmp;
if ((((4.0 + x) / y_m) - ((x / y_m) * z)) <= -2e+62) {
tmp = fabs(((1.0 - z) * (x / y_m)));
} else {
tmp = fabs(((fma(z, x, -4.0) - x) / y_m));
}
return tmp;
}
y_m = abs(y) function code(x, y_m, z) tmp = 0.0 if (Float64(Float64(Float64(4.0 + x) / y_m) - Float64(Float64(x / y_m) * z)) <= -2e+62) tmp = abs(Float64(Float64(1.0 - z) * Float64(x / y_m))); else tmp = abs(Float64(Float64(fma(z, x, -4.0) - x) / y_m)); end return tmp end
y_m = N[Abs[y], $MachinePrecision] code[x_, y$95$m_, z_] := If[LessEqual[N[(N[(N[(4.0 + x), $MachinePrecision] / y$95$m), $MachinePrecision] - N[(N[(x / y$95$m), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision], -2e+62], N[Abs[N[(N[(1.0 - z), $MachinePrecision] * N[(x / y$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[(N[(z * x + -4.0), $MachinePrecision] - x), $MachinePrecision] / y$95$m), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
y_m = \left|y\right|
\\
\begin{array}{l}
\mathbf{if}\;\frac{4 + x}{y\_m} - \frac{x}{y\_m} \cdot z \leq -2 \cdot 10^{+62}:\\
\;\;\;\;\left|\left(1 - z\right) \cdot \frac{x}{y\_m}\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\frac{\mathsf{fma}\left(z, x, -4\right) - x}{y\_m}\right|\\
\end{array}
\end{array}
if (-.f64 (/.f64 (+.f64 x #s(literal 4 binary64)) y) (*.f64 (/.f64 x y) z)) < -2.00000000000000007e62Initial program 99.8%
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-/.f6478.6
Applied rewrites78.6%
if -2.00000000000000007e62 < (-.f64 (/.f64 (+.f64 x #s(literal 4 binary64)) y) (*.f64 (/.f64 x y) z)) Initial program 89.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 rewrites97.9%
lift-fma.f64N/A
lift-*.f64N/A
lift--.f64N/A
associate-+r-N/A
lower--.f64N/A
lift-*.f64N/A
lower-fma.f6497.9
Applied rewrites97.9%
Final simplification92.3%
y_m = (fabs.f64 y)
(FPCore (x y_m z)
:precision binary64
(if (<= x -9.5)
(fabs (* (- 1.0 z) (/ x y_m)))
(if (<= x 4.2)
(fabs (/ (fma z x -4.0) y_m))
(fabs (* (/ (- z 1.0) y_m) x)))))y_m = fabs(y);
double code(double x, double y_m, double z) {
double tmp;
if (x <= -9.5) {
tmp = fabs(((1.0 - z) * (x / y_m)));
} else if (x <= 4.2) {
tmp = fabs((fma(z, x, -4.0) / y_m));
} else {
tmp = fabs((((z - 1.0) / y_m) * x));
}
return tmp;
}
y_m = abs(y) function code(x, y_m, z) tmp = 0.0 if (x <= -9.5) tmp = abs(Float64(Float64(1.0 - z) * Float64(x / y_m))); elseif (x <= 4.2) tmp = abs(Float64(fma(z, x, -4.0) / y_m)); else tmp = abs(Float64(Float64(Float64(z - 1.0) / y_m) * x)); end return tmp end
y_m = N[Abs[y], $MachinePrecision] code[x_, y$95$m_, z_] := If[LessEqual[x, -9.5], N[Abs[N[(N[(1.0 - z), $MachinePrecision] * N[(x / y$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[x, 4.2], N[Abs[N[(N[(z * x + -4.0), $MachinePrecision] / y$95$m), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[(N[(z - 1.0), $MachinePrecision] / y$95$m), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
y_m = \left|y\right|
\\
\begin{array}{l}
\mathbf{if}\;x \leq -9.5:\\
\;\;\;\;\left|\left(1 - z\right) \cdot \frac{x}{y\_m}\right|\\
\mathbf{elif}\;x \leq 4.2:\\
\;\;\;\;\left|\frac{\mathsf{fma}\left(z, x, -4\right)}{y\_m}\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\frac{z - 1}{y\_m} \cdot x\right|\\
\end{array}
\end{array}
if x < -9.5Initial program 87.7%
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 -9.5 < x < 4.20000000000000018Initial program 95.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%
Taylor expanded in x around 0
Applied rewrites98.2%
if 4.20000000000000018 < x Initial program 90.1%
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 rewrites93.5%
lift-fma.f64N/A
lift-*.f64N/A
lift--.f64N/A
associate-+r-N/A
lower--.f64N/A
lift-*.f64N/A
lower-fma.f6493.5
Applied rewrites93.5%
Taylor expanded in x around inf
*-commutativeN/A
associate-*l/N/A
div-subN/A
sub-negN/A
+-commutativeN/A
neg-sub0N/A
associate-+l-N/A
div-subN/A
sub-negN/A
mul-1-negN/A
neg-sub0N/A
mul-1-negN/A
lower-*.f64N/A
Applied rewrites99.0%
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.5) t_0 (if (<= x 3.8) (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 <= -9.5) {
tmp = t_0;
} else if (x <= 3.8) {
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 <= -9.5) tmp = t_0; elseif (x <= 3.8) 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, -9.5], t$95$0, If[LessEqual[x, 3.8], 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 -9.5:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 3.8:\\
\;\;\;\;\left|\frac{\mathsf{fma}\left(z, x, -4\right)}{y\_m}\right|\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -9.5 or 3.7999999999999998 < x Initial program 89.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.0
Applied rewrites99.0%
if -9.5 < x < 3.7999999999999998Initial program 95.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%
Taylor expanded in x around 0
Applied rewrites98.2%
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 -1.0) t_0 (if (<= z 9e-16) (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 <= -1.0) {
tmp = t_0;
} else if (z <= 9e-16) {
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 <= -1.0) tmp = t_0; elseif (z <= 9e-16) 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, -1.0], t$95$0, If[LessEqual[z, 9e-16], 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 -1:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 9 \cdot 10^{-16}:\\
\;\;\;\;\left|\frac{x - -4}{y\_m}\right|\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if z < -1 or 9.0000000000000003e-16 < z Initial program 90.6%
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 rewrites93.9%
Taylor expanded in x around 0
Applied rewrites93.0%
if -1 < z < 9.0000000000000003e-16Initial program 93.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-eval99.3
Applied rewrites99.3%
y_m = (fabs.f64 y)
(FPCore (x y_m z)
:precision binary64
(let* ((t_0 (fabs (* (/ z y_m) x))))
(if (<= z -7.2e+30)
t_0
(if (<= z 170000.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 / y_m) * x));
double tmp;
if (z <= -7.2e+30) {
tmp = t_0;
} else if (z <= 170000.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 / y_m) * x))
if (z <= (-7.2d+30)) then
tmp = t_0
else if (z <= 170000.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 / y_m) * x));
double tmp;
if (z <= -7.2e+30) {
tmp = t_0;
} else if (z <= 170000.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 / y_m) * x)) tmp = 0 if z <= -7.2e+30: tmp = t_0 elif z <= 170000.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(Float64(z / y_m) * x)) tmp = 0.0 if (z <= -7.2e+30) tmp = t_0; elseif (z <= 170000.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 / y_m) * x)); tmp = 0.0; if (z <= -7.2e+30) tmp = t_0; elseif (z <= 170000.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[(N[(z / y$95$m), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[z, -7.2e+30], t$95$0, If[LessEqual[z, 170000.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|\frac{z}{y\_m} \cdot x\right|\\
\mathbf{if}\;z \leq -7.2 \cdot 10^{+30}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 170000:\\
\;\;\;\;\left|\frac{x - -4}{y\_m}\right|\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if z < -7.2000000000000004e30 or 1.7e5 < z Initial program 89.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 rewrites93.3%
lift-fma.f64N/A
lift-*.f64N/A
lift--.f64N/A
associate-+r-N/A
lower--.f64N/A
lift-*.f64N/A
lower-fma.f6493.3
Applied rewrites93.3%
Taylor expanded in x around inf
*-commutativeN/A
associate-*l/N/A
div-subN/A
sub-negN/A
+-commutativeN/A
neg-sub0N/A
associate-+l-N/A
div-subN/A
sub-negN/A
mul-1-negN/A
neg-sub0N/A
mul-1-negN/A
lower-*.f64N/A
Applied rewrites79.5%
Taylor expanded in z around inf
Applied rewrites79.2%
if -7.2000000000000004e30 < z < 1.7e5Initial program 94.5%
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.0
Applied rewrites98.0%
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(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 89.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 rewrites93.9%
lift-fma.f64N/A
lift-*.f64N/A
lift--.f64N/A
associate-+r-N/A
lower--.f64N/A
lift-*.f64N/A
lower-fma.f6493.9
Applied rewrites93.9%
Taylor expanded in x around inf
*-commutativeN/A
associate-*l/N/A
div-subN/A
sub-negN/A
+-commutativeN/A
neg-sub0N/A
associate-+l-N/A
div-subN/A
sub-negN/A
mul-1-negN/A
neg-sub0N/A
mul-1-negN/A
lower-*.f64N/A
Applied rewrites98.9%
Taylor expanded in z around 0
Applied rewrites59.1%
if -10.5 < x < 4Initial program 95.8%
Taylor expanded in x around 0
lower-/.f6472.3
Applied rewrites72.3%
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 92.1%
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-eval66.3
Applied rewrites66.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 92.1%
Taylor expanded in x around 0
lower-/.f6435.8
Applied rewrites35.8%
herbie shell --seed 2024248
(FPCore (x y z)
:name "fabs fraction 1"
:precision binary64
(fabs (- (/ (+ x 4.0) y) (* (/ x y) z))))