
(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 1.8e-40) (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 <= 1.8e-40) {
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 <= 1.8e-40) tmp = abs(Float64(fma(z, x, Float64(-4.0 - x)) / y_m)); else tmp = abs(fma(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, 1.8e-40], 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 1.8 \cdot 10^{-40}:\\
\;\;\;\;\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 < 1.8e-40Initial 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
div-subN/A
sub-negN/A
remove-double-negN/A
distribute-neg-inN/A
+-commutativeN/A
sub-negN/A
sub-negN/A
/-rgt-identityN/A
metadata-evalN/A
distribute-neg-frac2N/A
distribute-neg-outN/A
remove-double-negN/A
Applied rewrites96.5%
if 1.8e-40 < y Initial program 97.2%
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
div-subN/A
sub-negN/A
remove-double-negN/A
distribute-neg-inN/A
+-commutativeN/A
sub-negN/A
sub-negN/A
/-rgt-identityN/A
metadata-evalN/A
distribute-neg-frac2N/A
distribute-neg-outN/A
remove-double-negN/A
Applied rewrites94.2%
lift-/.f64N/A
lift-fma.f64N/A
lift--.f64N/A
sub-negN/A
metadata-evalN/A
distribute-neg-inN/A
+-commutativeN/A
lift-+.f64N/A
sub-negN/A
sub-divN/A
*-commutativeN/A
associate-*l/N/A
lift-/.f64N/A
lift-*.f64N/A
lift-/.f64N/A
sub-negN/A
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
lift-/.f64N/A
frac-2negN/A
Applied rewrites99.9%
y_m = (fabs.f64 y) (FPCore (x y_m z) :precision binary64 (let* ((t_0 (fabs (/ (fma z x (- x)) y_m)))) (if (<= x -5.5e+15) t_0 (if (<= x 4.0) (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((fma(z, x, -x) / y_m));
double tmp;
if (x <= -5.5e+15) {
tmp = t_0;
} else if (x <= 4.0) {
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(fma(z, x, Float64(-x)) / y_m)) tmp = 0.0 if (x <= -5.5e+15) tmp = t_0; elseif (x <= 4.0) 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[(z * x + (-x)), $MachinePrecision] / y$95$m), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[x, -5.5e+15], t$95$0, If[LessEqual[x, 4.0], 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|\frac{\mathsf{fma}\left(z, x, -x\right)}{y\_m}\right|\\
\mathbf{if}\;x \leq -5.5 \cdot 10^{+15}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 4:\\
\;\;\;\;\left|\frac{\mathsf{fma}\left(z, x, -4\right)}{y\_m}\right|\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -5.5e15 or 4 < x Initial program 85.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
div-subN/A
sub-negN/A
remove-double-negN/A
distribute-neg-inN/A
+-commutativeN/A
sub-negN/A
sub-negN/A
/-rgt-identityN/A
metadata-evalN/A
distribute-neg-frac2N/A
distribute-neg-outN/A
remove-double-negN/A
Applied rewrites91.5%
Taylor expanded in x around inf
mul-1-negN/A
lower-neg.f6491.2
Applied rewrites91.2%
if -5.5e15 < x < 4Initial program 97.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
div-subN/A
sub-negN/A
remove-double-negN/A
distribute-neg-inN/A
+-commutativeN/A
sub-negN/A
sub-negN/A
/-rgt-identityN/A
metadata-evalN/A
distribute-neg-frac2N/A
distribute-neg-outN/A
remove-double-negN/A
Applied rewrites99.9%
Taylor expanded in x around 0
Applied rewrites99.4%
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 2.5) (fabs (/ (- -4.0 x) 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 <= 2.5) {
tmp = fabs(((-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(fma(z, x, -4.0) / y_m)) tmp = 0.0 if (z <= -1.0) tmp = t_0; elseif (z <= 2.5) tmp = abs(Float64(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[(z * x + -4.0), $MachinePrecision] / y$95$m), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[z, -1.0], t$95$0, If[LessEqual[z, 2.5], N[Abs[N[(N[(-4.0 - x), $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 2.5:\\
\;\;\;\;\left|\frac{-4 - x}{y\_m}\right|\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if z < -1 or 2.5 < z Initial program 85.2%
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
div-subN/A
sub-negN/A
remove-double-negN/A
distribute-neg-inN/A
+-commutativeN/A
sub-negN/A
sub-negN/A
/-rgt-identityN/A
metadata-evalN/A
distribute-neg-frac2N/A
distribute-neg-outN/A
remove-double-negN/A
Applied rewrites92.1%
Taylor expanded in x around 0
Applied rewrites92.1%
if -1 < z < 2.5Initial program 98.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
div-subN/A
sub-negN/A
remove-double-negN/A
distribute-neg-inN/A
+-commutativeN/A
sub-negN/A
sub-negN/A
/-rgt-identityN/A
metadata-evalN/A
distribute-neg-frac2N/A
distribute-neg-outN/A
remove-double-negN/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--.f6498.5
Applied rewrites98.5%
y_m = (fabs.f64 y) (FPCore (x y_m z) :precision binary64 (if (<= z -1.42e+32) (fabs (* (/ x y_m) z)) (if (<= z 3.3e+34) (fabs (/ (- -4.0 x) y_m)) (fabs (* (/ z y_m) x)))))
y_m = fabs(y);
double code(double x, double y_m, double z) {
double tmp;
if (z <= -1.42e+32) {
tmp = fabs(((x / y_m) * z));
} else if (z <= 3.3e+34) {
tmp = fabs(((-4.0 - x) / y_m));
} else {
tmp = fabs(((z / y_m) * x));
}
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.42d+32)) then
tmp = abs(((x / y_m) * z))
else if (z <= 3.3d+34) then
tmp = abs((((-4.0d0) - x) / y_m))
else
tmp = abs(((z / y_m) * x))
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.42e+32) {
tmp = Math.abs(((x / y_m) * z));
} else if (z <= 3.3e+34) {
tmp = Math.abs(((-4.0 - x) / y_m));
} else {
tmp = Math.abs(((z / y_m) * x));
}
return tmp;
}
y_m = math.fabs(y) def code(x, y_m, z): tmp = 0 if z <= -1.42e+32: tmp = math.fabs(((x / y_m) * z)) elif z <= 3.3e+34: tmp = math.fabs(((-4.0 - x) / y_m)) else: tmp = math.fabs(((z / y_m) * x)) return tmp
y_m = abs(y) function code(x, y_m, z) tmp = 0.0 if (z <= -1.42e+32) tmp = abs(Float64(Float64(x / y_m) * z)); elseif (z <= 3.3e+34) tmp = abs(Float64(Float64(-4.0 - x) / y_m)); else tmp = abs(Float64(Float64(z / y_m) * x)); end return tmp end
y_m = abs(y); function tmp_2 = code(x, y_m, z) tmp = 0.0; if (z <= -1.42e+32) tmp = abs(((x / y_m) * z)); elseif (z <= 3.3e+34) tmp = abs(((-4.0 - x) / y_m)); else tmp = abs(((z / y_m) * x)); end tmp_2 = tmp; end
y_m = N[Abs[y], $MachinePrecision] code[x_, y$95$m_, z_] := If[LessEqual[z, -1.42e+32], N[Abs[N[(N[(x / y$95$m), $MachinePrecision] * z), $MachinePrecision]], $MachinePrecision], If[LessEqual[z, 3.3e+34], N[Abs[N[(N[(-4.0 - x), $MachinePrecision] / y$95$m), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[(z / y$95$m), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
y_m = \left|y\right|
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.42 \cdot 10^{+32}:\\
\;\;\;\;\left|\frac{x}{y\_m} \cdot z\right|\\
\mathbf{elif}\;z \leq 3.3 \cdot 10^{+34}:\\
\;\;\;\;\left|\frac{-4 - x}{y\_m}\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\frac{z}{y\_m} \cdot x\right|\\
\end{array}
\end{array}
if z < -1.41999999999999992e32Initial program 99.8%
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
div-subN/A
sub-negN/A
remove-double-negN/A
distribute-neg-inN/A
+-commutativeN/A
sub-negN/A
sub-negN/A
/-rgt-identityN/A
metadata-evalN/A
distribute-neg-frac2N/A
distribute-neg-outN/A
remove-double-negN/A
Applied rewrites85.3%
Taylor expanded in z around inf
associate-*l/N/A
lower-*.f64N/A
lower-/.f6483.3
Applied rewrites83.3%
if -1.41999999999999992e32 < z < 3.29999999999999988e34Initial program 98.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
div-subN/A
sub-negN/A
remove-double-negN/A
distribute-neg-inN/A
+-commutativeN/A
sub-negN/A
sub-negN/A
/-rgt-identityN/A
metadata-evalN/A
distribute-neg-frac2N/A
distribute-neg-outN/A
remove-double-negN/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--.f6497.2
Applied rewrites97.2%
if 3.29999999999999988e34 < z Initial program 73.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
div-subN/A
sub-negN/A
remove-double-negN/A
distribute-neg-inN/A
+-commutativeN/A
sub-negN/A
sub-negN/A
/-rgt-identityN/A
metadata-evalN/A
distribute-neg-frac2N/A
distribute-neg-outN/A
remove-double-negN/A
Applied rewrites96.1%
Taylor expanded in z around inf
associate-*l/N/A
lower-*.f64N/A
lower-/.f6478.4
Applied rewrites78.4%
Applied rewrites79.1%
y_m = (fabs.f64 y) (FPCore (x y_m z) :precision binary64 (let* ((t_0 (fabs (* (/ x y_m) z)))) (if (<= z -1.42e+32) t_0 (if (<= z 4e+34) (fabs (/ (- -4.0 x) 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 <= -1.42e+32) {
tmp = t_0;
} else if (z <= 4e+34) {
tmp = fabs(((-4.0 - x) / 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 <= (-1.42d+32)) then
tmp = t_0
else if (z <= 4d+34) then
tmp = abs((((-4.0d0) - x) / 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 <= -1.42e+32) {
tmp = t_0;
} else if (z <= 4e+34) {
tmp = Math.abs(((-4.0 - x) / 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 <= -1.42e+32: tmp = t_0 elif z <= 4e+34: tmp = math.fabs(((-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(x / y_m) * z)) tmp = 0.0 if (z <= -1.42e+32) tmp = t_0; elseif (z <= 4e+34) tmp = abs(Float64(Float64(-4.0 - x) / 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 <= -1.42e+32) tmp = t_0; elseif (z <= 4e+34) tmp = abs(((-4.0 - x) / 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, -1.42e+32], t$95$0, If[LessEqual[z, 4e+34], N[Abs[N[(N[(-4.0 - x), $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 -1.42 \cdot 10^{+32}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 4 \cdot 10^{+34}:\\
\;\;\;\;\left|\frac{-4 - x}{y\_m}\right|\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if z < -1.41999999999999992e32 or 3.99999999999999978e34 < z Initial program 84.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
div-subN/A
sub-negN/A
remove-double-negN/A
distribute-neg-inN/A
+-commutativeN/A
sub-negN/A
sub-negN/A
/-rgt-identityN/A
metadata-evalN/A
distribute-neg-frac2N/A
distribute-neg-outN/A
remove-double-negN/A
Applied rewrites91.7%
Taylor expanded in z around inf
associate-*l/N/A
lower-*.f64N/A
lower-/.f6480.4
Applied rewrites80.4%
if -1.41999999999999992e32 < z < 3.99999999999999978e34Initial program 98.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
div-subN/A
sub-negN/A
remove-double-negN/A
distribute-neg-inN/A
+-commutativeN/A
sub-negN/A
sub-negN/A
/-rgt-identityN/A
metadata-evalN/A
distribute-neg-frac2N/A
distribute-neg-outN/A
remove-double-negN/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--.f6497.2
Applied rewrites97.2%
y_m = (fabs.f64 y) (FPCore (x y_m z) :precision binary64 (let* ((t_0 (fabs (/ (- x) y_m)))) (if (<= x -1.6) 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.6) {
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.6d0)) 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.6) {
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.6: 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.6) 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.6) 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.6], 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.6:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 4:\\
\;\;\;\;\left|\frac{-4}{y\_m}\right|\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -1.6000000000000001 or 4 < x Initial program 85.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
div-subN/A
sub-negN/A
remove-double-negN/A
distribute-neg-inN/A
+-commutativeN/A
sub-negN/A
sub-negN/A
/-rgt-identityN/A
metadata-evalN/A
distribute-neg-frac2N/A
distribute-neg-outN/A
remove-double-negN/A
Applied rewrites91.7%
Taylor expanded in z around 0
distribute-lft-inN/A
metadata-evalN/A
mul-1-negN/A
unsub-negN/A
lower--.f6463.8
Applied rewrites63.8%
Taylor expanded in x around inf
Applied rewrites63.4%
if -1.6000000000000001 < x < 4Initial program 97.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
div-subN/A
sub-negN/A
remove-double-negN/A
distribute-neg-inN/A
+-commutativeN/A
sub-negN/A
sub-negN/A
/-rgt-identityN/A
metadata-evalN/A
distribute-neg-frac2N/A
distribute-neg-outN/A
remove-double-negN/A
Applied rewrites99.9%
Taylor expanded in x around 0
Applied rewrites73.2%
y_m = (fabs.f64 y) (FPCore (x y_m z) :precision binary64 (fabs (/ (fma z x (- -4.0 x)) y_m)))
y_m = fabs(y);
double code(double x, double y_m, double z) {
return fabs((fma(z, x, (-4.0 - x)) / y_m));
}
y_m = abs(y) function code(x, y_m, z) return abs(Float64(fma(z, x, Float64(-4.0 - x)) / y_m)) end
y_m = N[Abs[y], $MachinePrecision] code[x_, y$95$m_, z_] := N[Abs[N[(N[(z * x + N[(-4.0 - x), $MachinePrecision]), $MachinePrecision] / y$95$m), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
y_m = \left|y\right|
\\
\left|\frac{\mathsf{fma}\left(z, x, -4 - x\right)}{y\_m}\right|
\end{array}
Initial program 91.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
div-subN/A
sub-negN/A
remove-double-negN/A
distribute-neg-inN/A
+-commutativeN/A
sub-negN/A
sub-negN/A
/-rgt-identityN/A
metadata-evalN/A
distribute-neg-frac2N/A
distribute-neg-outN/A
remove-double-negN/A
Applied rewrites95.9%
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 91.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
div-subN/A
sub-negN/A
remove-double-negN/A
distribute-neg-inN/A
+-commutativeN/A
sub-negN/A
sub-negN/A
/-rgt-identityN/A
metadata-evalN/A
distribute-neg-frac2N/A
distribute-neg-outN/A
remove-double-negN/A
Applied rewrites95.9%
Taylor expanded in z around 0
distribute-lft-inN/A
metadata-evalN/A
mul-1-negN/A
unsub-negN/A
lower--.f6468.9
Applied rewrites68.9%
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.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
div-subN/A
sub-negN/A
remove-double-negN/A
distribute-neg-inN/A
+-commutativeN/A
sub-negN/A
sub-negN/A
/-rgt-identityN/A
metadata-evalN/A
distribute-neg-frac2N/A
distribute-neg-outN/A
remove-double-negN/A
Applied rewrites95.9%
Taylor expanded in x around 0
Applied rewrites40.0%
herbie shell --seed 2024272
(FPCore (x y z)
:name "fabs fraction 1"
:precision binary64
(fabs (- (/ (+ x 4.0) y) (* (/ x y) z))))