
(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}
(FPCore (x y z) :precision binary64 (if (or (<= x -2.6e+20) (not (<= x 2e+19))) (fabs (* (- 1.0 z) (/ x y))) (fabs (/ (fma (- 1.0 z) x 4.0) y))))
double code(double x, double y, double z) {
double tmp;
if ((x <= -2.6e+20) || !(x <= 2e+19)) {
tmp = fabs(((1.0 - z) * (x / y)));
} else {
tmp = fabs((fma((1.0 - z), x, 4.0) / y));
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if ((x <= -2.6e+20) || !(x <= 2e+19)) tmp = abs(Float64(Float64(1.0 - z) * Float64(x / y))); else tmp = abs(Float64(fma(Float64(1.0 - z), x, 4.0) / y)); end return tmp end
code[x_, y_, z_] := If[Or[LessEqual[x, -2.6e+20], N[Not[LessEqual[x, 2e+19]], $MachinePrecision]], N[Abs[N[(N[(1.0 - z), $MachinePrecision] * N[(x / y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[(N[(1.0 - z), $MachinePrecision] * x + 4.0), $MachinePrecision] / y), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.6 \cdot 10^{+20} \lor \neg \left(x \leq 2 \cdot 10^{+19}\right):\\
\;\;\;\;\left|\left(1 - z\right) \cdot \frac{x}{y}\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\frac{\mathsf{fma}\left(1 - z, x, 4\right)}{y}\right|\\
\end{array}
\end{array}
if x < -2.6e20 or 2e19 < x Initial program 89.3%
Taylor expanded in x around inf
distribute-lft-out--N/A
associate-*r/N/A
*-rgt-identityN/A
associate-/l*N/A
div-subN/A
fp-cancel-sub-sign-invN/A
distribute-lft-neg-inN/A
mul-1-negN/A
*-commutativeN/A
associate-*r*N/A
distribute-rgt1-inN/A
associate-/l*N/A
lower-*.f64N/A
+-commutativeN/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f64N/A
lower-/.f6499.9
Applied rewrites99.9%
if -2.6e20 < x < 2e19Initial program 96.5%
Taylor expanded in x around 0
+-commutativeN/A
distribute-lft-out--N/A
associate-*r/N/A
*-rgt-identityN/A
associate-/l*N/A
associate--l+N/A
associate-*r/N/A
metadata-evalN/A
div-addN/A
div-subN/A
lower-/.f64N/A
Applied rewrites99.9%
Final simplification99.9%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (- (/ (+ x 4.0) y) (* (/ x y) z))))
(if (or (<= t_0 -2e-164) (not (<= t_0 1e+207)))
(fabs (* (- 1.0 z) (/ x y)))
(fabs (/ (- x -4.0) y)))))
double code(double x, double y, double z) {
double t_0 = ((x + 4.0) / y) - ((x / y) * z);
double tmp;
if ((t_0 <= -2e-164) || !(t_0 <= 1e+207)) {
tmp = fabs(((1.0 - z) * (x / y)));
} else {
tmp = fabs(((x - -4.0) / y));
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: t_0
real(8) :: tmp
t_0 = ((x + 4.0d0) / y) - ((x / y) * z)
if ((t_0 <= (-2d-164)) .or. (.not. (t_0 <= 1d+207))) then
tmp = abs(((1.0d0 - z) * (x / y)))
else
tmp = abs(((x - (-4.0d0)) / y))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = ((x + 4.0) / y) - ((x / y) * z);
double tmp;
if ((t_0 <= -2e-164) || !(t_0 <= 1e+207)) {
tmp = Math.abs(((1.0 - z) * (x / y)));
} else {
tmp = Math.abs(((x - -4.0) / y));
}
return tmp;
}
def code(x, y, z): t_0 = ((x + 4.0) / y) - ((x / y) * z) tmp = 0 if (t_0 <= -2e-164) or not (t_0 <= 1e+207): tmp = math.fabs(((1.0 - z) * (x / y))) else: tmp = math.fabs(((x - -4.0) / y)) return tmp
function code(x, y, z) t_0 = Float64(Float64(Float64(x + 4.0) / y) - Float64(Float64(x / y) * z)) tmp = 0.0 if ((t_0 <= -2e-164) || !(t_0 <= 1e+207)) tmp = abs(Float64(Float64(1.0 - z) * Float64(x / y))); else tmp = abs(Float64(Float64(x - -4.0) / y)); end return tmp end
function tmp_2 = code(x, y, z) t_0 = ((x + 4.0) / y) - ((x / y) * z); tmp = 0.0; if ((t_0 <= -2e-164) || ~((t_0 <= 1e+207))) tmp = abs(((1.0 - z) * (x / y))); else tmp = abs(((x - -4.0) / y)); end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(N[(x + 4.0), $MachinePrecision] / y), $MachinePrecision] - N[(N[(x / y), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$0, -2e-164], N[Not[LessEqual[t$95$0, 1e+207]], $MachinePrecision]], N[Abs[N[(N[(1.0 - z), $MachinePrecision] * N[(x / y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[(x - -4.0), $MachinePrecision] / y), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x + 4}{y} - \frac{x}{y} \cdot z\\
\mathbf{if}\;t\_0 \leq -2 \cdot 10^{-164} \lor \neg \left(t\_0 \leq 10^{+207}\right):\\
\;\;\;\;\left|\left(1 - z\right) \cdot \frac{x}{y}\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\frac{x - -4}{y}\right|\\
\end{array}
\end{array}
if (-.f64 (/.f64 (+.f64 x #s(literal 4 binary64)) y) (*.f64 (/.f64 x y) z)) < -1.99999999999999992e-164 or 1e207 < (-.f64 (/.f64 (+.f64 x #s(literal 4 binary64)) y) (*.f64 (/.f64 x y) z)) Initial program 90.3%
Taylor expanded in x around inf
distribute-lft-out--N/A
associate-*r/N/A
*-rgt-identityN/A
associate-/l*N/A
div-subN/A
fp-cancel-sub-sign-invN/A
distribute-lft-neg-inN/A
mul-1-negN/A
*-commutativeN/A
associate-*r*N/A
distribute-rgt1-inN/A
associate-/l*N/A
lower-*.f64N/A
+-commutativeN/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f64N/A
lower-/.f6476.9
Applied rewrites76.9%
if -1.99999999999999992e-164 < (-.f64 (/.f64 (+.f64 x #s(literal 4 binary64)) y) (*.f64 (/.f64 x y) z)) < 1e207Initial program 97.0%
Taylor expanded in x around 0
+-commutativeN/A
distribute-lft-out--N/A
associate-*r/N/A
*-rgt-identityN/A
associate-/l*N/A
associate--l+N/A
associate-*r/N/A
metadata-evalN/A
div-addN/A
div-subN/A
lower-/.f64N/A
Applied rewrites96.2%
Taylor expanded in z around 0
associate-*r/N/A
metadata-evalN/A
div-addN/A
lower-/.f64N/A
Applied rewrites79.0%
Final simplification77.8%
(FPCore (x y z) :precision binary64 (if (<= y 4e+57) (fabs (/ (fma (- 1.0 z) x 4.0) y)) (fabs (fma (- x) (/ z y) (/ (+ 4.0 x) y)))))
double code(double x, double y, double z) {
double tmp;
if (y <= 4e+57) {
tmp = fabs((fma((1.0 - z), x, 4.0) / y));
} else {
tmp = fabs(fma(-x, (z / y), ((4.0 + x) / y)));
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (y <= 4e+57) tmp = abs(Float64(fma(Float64(1.0 - z), x, 4.0) / y)); else tmp = abs(fma(Float64(-x), Float64(z / y), Float64(Float64(4.0 + x) / y))); end return tmp end
code[x_, y_, z_] := If[LessEqual[y, 4e+57], N[Abs[N[(N[(N[(1.0 - z), $MachinePrecision] * x + 4.0), $MachinePrecision] / y), $MachinePrecision]], $MachinePrecision], N[Abs[N[((-x) * N[(z / y), $MachinePrecision] + N[(N[(4.0 + x), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 4 \cdot 10^{+57}:\\
\;\;\;\;\left|\frac{\mathsf{fma}\left(1 - z, x, 4\right)}{y}\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\mathsf{fma}\left(-x, \frac{z}{y}, \frac{4 + x}{y}\right)\right|\\
\end{array}
\end{array}
if y < 4.00000000000000019e57Initial program 93.3%
Taylor expanded in x around 0
+-commutativeN/A
distribute-lft-out--N/A
associate-*r/N/A
*-rgt-identityN/A
associate-/l*N/A
associate--l+N/A
associate-*r/N/A
metadata-evalN/A
div-addN/A
div-subN/A
lower-/.f64N/A
Applied rewrites97.0%
if 4.00000000000000019e57 < y Initial program 92.4%
lift--.f64N/A
lift-*.f64N/A
fp-cancel-sub-sign-invN/A
+-commutativeN/A
distribute-lft-neg-outN/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%
(FPCore (x y z) :precision binary64 (if (<= y 6.5e+125) (fabs (/ (fma (- 1.0 z) x 4.0) y)) (fabs (fma x (/ (- 1.0 z) y) (/ 4.0 y)))))
double code(double x, double y, double z) {
double tmp;
if (y <= 6.5e+125) {
tmp = fabs((fma((1.0 - z), x, 4.0) / y));
} else {
tmp = fabs(fma(x, ((1.0 - z) / y), (4.0 / y)));
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (y <= 6.5e+125) tmp = abs(Float64(fma(Float64(1.0 - z), x, 4.0) / y)); else tmp = abs(fma(x, Float64(Float64(1.0 - z) / y), Float64(4.0 / y))); end return tmp end
code[x_, y_, z_] := If[LessEqual[y, 6.5e+125], N[Abs[N[(N[(N[(1.0 - z), $MachinePrecision] * x + 4.0), $MachinePrecision] / y), $MachinePrecision]], $MachinePrecision], N[Abs[N[(x * N[(N[(1.0 - z), $MachinePrecision] / y), $MachinePrecision] + N[(4.0 / y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 6.5 \cdot 10^{+125}:\\
\;\;\;\;\left|\frac{\mathsf{fma}\left(1 - z, x, 4\right)}{y}\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\mathsf{fma}\left(x, \frac{1 - z}{y}, \frac{4}{y}\right)\right|\\
\end{array}
\end{array}
if y < 6.4999999999999999e125Initial program 93.9%
Taylor expanded in x around 0
+-commutativeN/A
distribute-lft-out--N/A
associate-*r/N/A
*-rgt-identityN/A
associate-/l*N/A
associate--l+N/A
associate-*r/N/A
metadata-evalN/A
div-addN/A
div-subN/A
lower-/.f64N/A
Applied rewrites97.3%
if 6.4999999999999999e125 < y Initial program 88.3%
Taylor expanded in x around 0
+-commutativeN/A
distribute-lft-out--N/A
associate-*r/N/A
*-rgt-identityN/A
associate-/l*N/A
associate--l+N/A
associate-*r/N/A
metadata-evalN/A
div-addN/A
div-subN/A
lower-/.f64N/A
Applied rewrites85.5%
Applied rewrites99.7%
(FPCore (x y z) :precision binary64 (if (or (<= x -8.8e+15) (not (<= x 9e+18))) (fabs (* (- 1.0 z) (/ x y))) (fabs (/ (- (* z x) 4.0) y))))
double code(double x, double y, double z) {
double tmp;
if ((x <= -8.8e+15) || !(x <= 9e+18)) {
tmp = fabs(((1.0 - z) * (x / y)));
} else {
tmp = fabs((((z * x) - 4.0) / y));
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if ((x <= (-8.8d+15)) .or. (.not. (x <= 9d+18))) then
tmp = abs(((1.0d0 - z) * (x / y)))
else
tmp = abs((((z * x) - 4.0d0) / y))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((x <= -8.8e+15) || !(x <= 9e+18)) {
tmp = Math.abs(((1.0 - z) * (x / y)));
} else {
tmp = Math.abs((((z * x) - 4.0) / y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -8.8e+15) or not (x <= 9e+18): tmp = math.fabs(((1.0 - z) * (x / y))) else: tmp = math.fabs((((z * x) - 4.0) / y)) return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -8.8e+15) || !(x <= 9e+18)) tmp = abs(Float64(Float64(1.0 - z) * Float64(x / y))); else tmp = abs(Float64(Float64(Float64(z * x) - 4.0) / y)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -8.8e+15) || ~((x <= 9e+18))) tmp = abs(((1.0 - z) * (x / y))); else tmp = abs((((z * x) - 4.0) / y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -8.8e+15], N[Not[LessEqual[x, 9e+18]], $MachinePrecision]], N[Abs[N[(N[(1.0 - z), $MachinePrecision] * N[(x / y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[(N[(z * x), $MachinePrecision] - 4.0), $MachinePrecision] / y), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -8.8 \cdot 10^{+15} \lor \neg \left(x \leq 9 \cdot 10^{+18}\right):\\
\;\;\;\;\left|\left(1 - z\right) \cdot \frac{x}{y}\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\frac{z \cdot x - 4}{y}\right|\\
\end{array}
\end{array}
if x < -8.8e15 or 9e18 < x Initial program 89.5%
Taylor expanded in x around inf
distribute-lft-out--N/A
associate-*r/N/A
*-rgt-identityN/A
associate-/l*N/A
div-subN/A
fp-cancel-sub-sign-invN/A
distribute-lft-neg-inN/A
mul-1-negN/A
*-commutativeN/A
associate-*r*N/A
distribute-rgt1-inN/A
associate-/l*N/A
lower-*.f64N/A
+-commutativeN/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f64N/A
lower-/.f6499.9
Applied rewrites99.9%
if -8.8e15 < x < 9e18Initial program 96.4%
Taylor expanded in x around 0
Applied rewrites95.1%
lift--.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
sub-divN/A
lower-/.f64N/A
lower--.f64N/A
*-commutativeN/A
lower-*.f6498.5
Applied rewrites98.5%
Final simplification99.2%
(FPCore (x y z) :precision binary64 (if (or (<= z -3.2e+77) (not (<= z 1.7e+90))) (fabs (* (- z) (/ x y))) (fabs (/ (- x -4.0) y))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -3.2e+77) || !(z <= 1.7e+90)) {
tmp = fabs((-z * (x / y)));
} else {
tmp = fabs(((x - -4.0) / y));
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if ((z <= (-3.2d+77)) .or. (.not. (z <= 1.7d+90))) then
tmp = abs((-z * (x / y)))
else
tmp = abs(((x - (-4.0d0)) / y))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -3.2e+77) || !(z <= 1.7e+90)) {
tmp = Math.abs((-z * (x / y)));
} else {
tmp = Math.abs(((x - -4.0) / y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -3.2e+77) or not (z <= 1.7e+90): tmp = math.fabs((-z * (x / y))) else: tmp = math.fabs(((x - -4.0) / y)) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -3.2e+77) || !(z <= 1.7e+90)) tmp = abs(Float64(Float64(-z) * Float64(x / y))); else tmp = abs(Float64(Float64(x - -4.0) / y)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -3.2e+77) || ~((z <= 1.7e+90))) tmp = abs((-z * (x / y))); else tmp = abs(((x - -4.0) / y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -3.2e+77], N[Not[LessEqual[z, 1.7e+90]], $MachinePrecision]], N[Abs[N[((-z) * N[(x / y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[(x - -4.0), $MachinePrecision] / y), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -3.2 \cdot 10^{+77} \lor \neg \left(z \leq 1.7 \cdot 10^{+90}\right):\\
\;\;\;\;\left|\left(-z\right) \cdot \frac{x}{y}\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\frac{x - -4}{y}\right|\\
\end{array}
\end{array}
if z < -3.2000000000000002e77 or 1.70000000000000009e90 < z Initial program 88.9%
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-/.f6482.6
Applied rewrites82.6%
if -3.2000000000000002e77 < z < 1.70000000000000009e90Initial program 95.2%
Taylor expanded in x around 0
+-commutativeN/A
distribute-lft-out--N/A
associate-*r/N/A
*-rgt-identityN/A
associate-/l*N/A
associate--l+N/A
associate-*r/N/A
metadata-evalN/A
div-addN/A
div-subN/A
lower-/.f64N/A
Applied rewrites98.8%
Taylor expanded in z around 0
associate-*r/N/A
metadata-evalN/A
div-addN/A
lower-/.f64N/A
Applied rewrites91.6%
Final simplification88.5%
(FPCore (x y z) :precision binary64 (if (or (<= z -1.4e+145) (not (<= z 7e+216))) (* (/ x y) (- z)) (fabs (/ (- x -4.0) y))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -1.4e+145) || !(z <= 7e+216)) {
tmp = (x / y) * -z;
} else {
tmp = fabs(((x - -4.0) / y));
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if ((z <= (-1.4d+145)) .or. (.not. (z <= 7d+216))) then
tmp = (x / y) * -z
else
tmp = abs(((x - (-4.0d0)) / y))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -1.4e+145) || !(z <= 7e+216)) {
tmp = (x / y) * -z;
} else {
tmp = Math.abs(((x - -4.0) / y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -1.4e+145) or not (z <= 7e+216): tmp = (x / y) * -z else: tmp = math.fabs(((x - -4.0) / y)) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -1.4e+145) || !(z <= 7e+216)) tmp = Float64(Float64(x / y) * Float64(-z)); else tmp = abs(Float64(Float64(x - -4.0) / y)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -1.4e+145) || ~((z <= 7e+216))) tmp = (x / y) * -z; else tmp = abs(((x - -4.0) / y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -1.4e+145], N[Not[LessEqual[z, 7e+216]], $MachinePrecision]], N[(N[(x / y), $MachinePrecision] * (-z)), $MachinePrecision], N[Abs[N[(N[(x - -4.0), $MachinePrecision] / y), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.4 \cdot 10^{+145} \lor \neg \left(z \leq 7 \cdot 10^{+216}\right):\\
\;\;\;\;\frac{x}{y} \cdot \left(-z\right)\\
\mathbf{else}:\\
\;\;\;\;\left|\frac{x - -4}{y}\right|\\
\end{array}
\end{array}
if z < -1.3999999999999999e145 or 6.99999999999999984e216 < z Initial program 90.6%
Taylor expanded in x around inf
distribute-lft-out--N/A
associate-*r/N/A
*-rgt-identityN/A
associate-/l*N/A
div-subN/A
fp-cancel-sub-sign-invN/A
distribute-lft-neg-inN/A
mul-1-negN/A
*-commutativeN/A
associate-*r*N/A
distribute-rgt1-inN/A
associate-/l*N/A
lower-*.f64N/A
+-commutativeN/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f64N/A
lower-/.f6483.3
Applied rewrites83.3%
lift-fabs.f64N/A
rem-sqrt-square-revN/A
sqrt-prodN/A
rem-square-sqrt29.4
Applied rewrites29.4%
Taylor expanded in z around inf
Applied rewrites29.4%
if -1.3999999999999999e145 < z < 6.99999999999999984e216Initial program 93.7%
Taylor expanded in x around 0
+-commutativeN/A
distribute-lft-out--N/A
associate-*r/N/A
*-rgt-identityN/A
associate-/l*N/A
associate--l+N/A
associate-*r/N/A
metadata-evalN/A
div-addN/A
div-subN/A
lower-/.f64N/A
Applied rewrites98.0%
Taylor expanded in z around 0
associate-*r/N/A
metadata-evalN/A
div-addN/A
lower-/.f64N/A
Applied rewrites82.0%
Final simplification70.9%
(FPCore (x y z) :precision binary64 (if (<= x -1.52) (fabs (/ x y)) (if (<= x 4.0) (fabs (/ 4.0 y)) (/ x y))))
double code(double x, double y, double z) {
double tmp;
if (x <= -1.52) {
tmp = fabs((x / y));
} else if (x <= 4.0) {
tmp = fabs((4.0 / y));
} else {
tmp = x / y;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (x <= (-1.52d0)) then
tmp = abs((x / y))
else if (x <= 4.0d0) then
tmp = abs((4.0d0 / y))
else
tmp = x / y
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (x <= -1.52) {
tmp = Math.abs((x / y));
} else if (x <= 4.0) {
tmp = Math.abs((4.0 / y));
} else {
tmp = x / y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -1.52: tmp = math.fabs((x / y)) elif x <= 4.0: tmp = math.fabs((4.0 / y)) else: tmp = x / y return tmp
function code(x, y, z) tmp = 0.0 if (x <= -1.52) tmp = abs(Float64(x / y)); elseif (x <= 4.0) tmp = abs(Float64(4.0 / y)); else tmp = Float64(x / y); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= -1.52) tmp = abs((x / y)); elseif (x <= 4.0) tmp = abs((4.0 / y)); else tmp = x / y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -1.52], N[Abs[N[(x / y), $MachinePrecision]], $MachinePrecision], If[LessEqual[x, 4.0], N[Abs[N[(4.0 / y), $MachinePrecision]], $MachinePrecision], N[(x / y), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.52:\\
\;\;\;\;\left|\frac{x}{y}\right|\\
\mathbf{elif}\;x \leq 4:\\
\;\;\;\;\left|\frac{4}{y}\right|\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y}\\
\end{array}
\end{array}
if x < -1.52Initial program 90.2%
Taylor expanded in x around inf
distribute-lft-out--N/A
associate-*r/N/A
*-rgt-identityN/A
associate-/l*N/A
div-subN/A
fp-cancel-sub-sign-invN/A
distribute-lft-neg-inN/A
mul-1-negN/A
*-commutativeN/A
associate-*r*N/A
distribute-rgt1-inN/A
associate-/l*N/A
lower-*.f64N/A
+-commutativeN/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f64N/A
lower-/.f6498.8
Applied rewrites98.8%
Taylor expanded in z around 0
Applied rewrites65.4%
if -1.52 < x < 4Initial program 96.3%
Taylor expanded in x around 0
lower-/.f6469.1
Applied rewrites69.1%
if 4 < x Initial program 89.6%
Taylor expanded in x around inf
distribute-lft-out--N/A
associate-*r/N/A
*-rgt-identityN/A
associate-/l*N/A
div-subN/A
fp-cancel-sub-sign-invN/A
distribute-lft-neg-inN/A
mul-1-negN/A
*-commutativeN/A
associate-*r*N/A
distribute-rgt1-inN/A
associate-/l*N/A
lower-*.f64N/A
+-commutativeN/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f64N/A
lower-/.f6499.9
Applied rewrites99.9%
Taylor expanded in z around 0
Applied rewrites70.4%
lift-fabs.f64N/A
rem-sqrt-square-revN/A
sqrt-prodN/A
rem-square-sqrt47.9
Applied rewrites47.9%
(FPCore (x y z) :precision binary64 (fabs (/ (- x -4.0) y)))
double code(double x, double y, double z) {
return fabs(((x - -4.0) / y));
}
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))
end function
public static double code(double x, double y, double z) {
return Math.abs(((x - -4.0) / y));
}
def code(x, y, z): return math.fabs(((x - -4.0) / y))
function code(x, y, z) return abs(Float64(Float64(x - -4.0) / y)) end
function tmp = code(x, y, z) tmp = abs(((x - -4.0) / y)); end
code[x_, y_, z_] := N[Abs[N[(N[(x - -4.0), $MachinePrecision] / y), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|\frac{x - -4}{y}\right|
\end{array}
Initial program 93.0%
Taylor expanded in x around 0
+-commutativeN/A
distribute-lft-out--N/A
associate-*r/N/A
*-rgt-identityN/A
associate-/l*N/A
associate--l+N/A
associate-*r/N/A
metadata-evalN/A
div-addN/A
div-subN/A
lower-/.f64N/A
Applied rewrites95.5%
Taylor expanded in z around 0
associate-*r/N/A
metadata-evalN/A
div-addN/A
lower-/.f64N/A
Applied rewrites69.0%
(FPCore (x y z) :precision binary64 (fabs (/ x y)))
double code(double x, double y, double z) {
return fabs((x / y));
}
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 / y))
end function
public static double code(double x, double y, double z) {
return Math.abs((x / y));
}
def code(x, y, z): return math.fabs((x / y))
function code(x, y, z) return abs(Float64(x / y)) end
function tmp = code(x, y, z) tmp = abs((x / y)); end
code[x_, y_, z_] := N[Abs[N[(x / y), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|\frac{x}{y}\right|
\end{array}
Initial program 93.0%
Taylor expanded in x around inf
distribute-lft-out--N/A
associate-*r/N/A
*-rgt-identityN/A
associate-/l*N/A
div-subN/A
fp-cancel-sub-sign-invN/A
distribute-lft-neg-inN/A
mul-1-negN/A
*-commutativeN/A
associate-*r*N/A
distribute-rgt1-inN/A
associate-/l*N/A
lower-*.f64N/A
+-commutativeN/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f64N/A
lower-/.f6465.0
Applied rewrites65.0%
Taylor expanded in z around 0
Applied rewrites36.9%
(FPCore (x y z) :precision binary64 (/ x y))
double code(double x, double y, double z) {
return x / y;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = x / y
end function
public static double code(double x, double y, double z) {
return x / y;
}
def code(x, y, z): return x / y
function code(x, y, z) return Float64(x / y) end
function tmp = code(x, y, z) tmp = x / y; end
code[x_, y_, z_] := N[(x / y), $MachinePrecision]
\begin{array}{l}
\\
\frac{x}{y}
\end{array}
Initial program 93.0%
Taylor expanded in x around inf
distribute-lft-out--N/A
associate-*r/N/A
*-rgt-identityN/A
associate-/l*N/A
div-subN/A
fp-cancel-sub-sign-invN/A
distribute-lft-neg-inN/A
mul-1-negN/A
*-commutativeN/A
associate-*r*N/A
distribute-rgt1-inN/A
associate-/l*N/A
lower-*.f64N/A
+-commutativeN/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f64N/A
lower-/.f6465.0
Applied rewrites65.0%
Taylor expanded in z around 0
Applied rewrites36.9%
lift-fabs.f64N/A
rem-sqrt-square-revN/A
sqrt-prodN/A
rem-square-sqrt21.2
Applied rewrites21.2%
herbie shell --seed 2024333
(FPCore (x y z)
:name "fabs fraction 1"
:precision binary64
(fabs (- (/ (+ x 4.0) y) (* (/ x y) z))))