
(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 8 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 -1.2e+44) (not (<= x 3.5e+89))) (fabs (/ (+ z -1.0) (/ y x))) (fabs (/ (+ 4.0 (* x (- 1.0 z))) y))))
double code(double x, double y, double z) {
double tmp;
if ((x <= -1.2e+44) || !(x <= 3.5e+89)) {
tmp = fabs(((z + -1.0) / (y / x)));
} else {
tmp = fabs(((4.0 + (x * (1.0 - z))) / 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.2d+44)) .or. (.not. (x <= 3.5d+89))) then
tmp = abs(((z + (-1.0d0)) / (y / x)))
else
tmp = abs(((4.0d0 + (x * (1.0d0 - z))) / y))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((x <= -1.2e+44) || !(x <= 3.5e+89)) {
tmp = Math.abs(((z + -1.0) / (y / x)));
} else {
tmp = Math.abs(((4.0 + (x * (1.0 - z))) / y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -1.2e+44) or not (x <= 3.5e+89): tmp = math.fabs(((z + -1.0) / (y / x))) else: tmp = math.fabs(((4.0 + (x * (1.0 - z))) / y)) return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -1.2e+44) || !(x <= 3.5e+89)) tmp = abs(Float64(Float64(z + -1.0) / Float64(y / x))); else tmp = abs(Float64(Float64(4.0 + Float64(x * Float64(1.0 - z))) / y)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -1.2e+44) || ~((x <= 3.5e+89))) tmp = abs(((z + -1.0) / (y / x))); else tmp = abs(((4.0 + (x * (1.0 - z))) / y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -1.2e+44], N[Not[LessEqual[x, 3.5e+89]], $MachinePrecision]], N[Abs[N[(N[(z + -1.0), $MachinePrecision] / N[(y / x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[(4.0 + N[(x * N[(1.0 - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.2 \cdot 10^{+44} \lor \neg \left(x \leq 3.5 \cdot 10^{+89}\right):\\
\;\;\;\;\left|\frac{z + -1}{\frac{y}{x}}\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\frac{4 + x \cdot \left(1 - z\right)}{y}\right|\\
\end{array}
\end{array}
if x < -1.20000000000000007e44 or 3.5000000000000001e89 < x Initial program 80.8%
*-rgt-identity80.8%
fabs-sub80.8%
metadata-eval80.8%
metadata-eval80.8%
fabs-mul80.8%
metadata-eval80.8%
*-rgt-identity80.8%
associate-*l/77.9%
div-sub87.4%
sub-neg87.4%
+-commutative87.4%
remove-double-neg87.4%
distribute-neg-in87.4%
sub-neg87.4%
neg-mul-187.4%
associate-*l/87.3%
remove-double-neg87.3%
distribute-lft-neg-in87.3%
distribute-rgt-neg-in87.3%
Simplified87.3%
Taylor expanded in x around inf 87.4%
associate-/l*99.7%
sub-neg99.7%
metadata-eval99.7%
Simplified99.7%
if -1.20000000000000007e44 < x < 3.5000000000000001e89Initial program 98.0%
fabs-neg98.0%
sub-neg98.0%
distribute-neg-in98.0%
sub-neg98.0%
distribute-neg-frac98.0%
associate-*l/99.2%
distribute-neg-frac99.2%
neg-mul-199.2%
associate-*l/99.2%
neg-mul-199.2%
associate-*l/99.1%
distribute-lft-out--99.8%
fabs-mul99.8%
fabs-sub99.8%
fabs-mul99.8%
associate-*l/99.9%
Simplified99.9%
Taylor expanded in x around 0 99.9%
Final simplification99.8%
(FPCore (x y z) :precision binary64 (let* ((t_0 (fabs (- (/ (+ x 4.0) y) (* (/ x y) z))))) (if (<= t_0 1e+301) t_0 (fabs (/ (* x (+ z -1.0)) y)))))
double code(double x, double y, double z) {
double t_0 = fabs((((x + 4.0) / y) - ((x / y) * z)));
double tmp;
if (t_0 <= 1e+301) {
tmp = t_0;
} else {
tmp = fabs(((x * (z + -1.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 = abs((((x + 4.0d0) / y) - ((x / y) * z)))
if (t_0 <= 1d+301) then
tmp = t_0
else
tmp = abs(((x * (z + (-1.0d0))) / y))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = Math.abs((((x + 4.0) / y) - ((x / y) * z)));
double tmp;
if (t_0 <= 1e+301) {
tmp = t_0;
} else {
tmp = Math.abs(((x * (z + -1.0)) / y));
}
return tmp;
}
def code(x, y, z): t_0 = math.fabs((((x + 4.0) / y) - ((x / y) * z))) tmp = 0 if t_0 <= 1e+301: tmp = t_0 else: tmp = math.fabs(((x * (z + -1.0)) / y)) return tmp
function code(x, y, z) t_0 = abs(Float64(Float64(Float64(x + 4.0) / y) - Float64(Float64(x / y) * z))) tmp = 0.0 if (t_0 <= 1e+301) tmp = t_0; else tmp = abs(Float64(Float64(x * Float64(z + -1.0)) / y)); end return tmp end
function tmp_2 = code(x, y, z) t_0 = abs((((x + 4.0) / y) - ((x / y) * z))); tmp = 0.0; if (t_0 <= 1e+301) tmp = t_0; else tmp = abs(((x * (z + -1.0)) / y)); end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[Abs[N[(N[(N[(x + 4.0), $MachinePrecision] / y), $MachinePrecision] - N[(N[(x / y), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[t$95$0, 1e+301], t$95$0, N[Abs[N[(N[(x * N[(z + -1.0), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right|\\
\mathbf{if}\;t_0 \leq 10^{+301}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\left|\frac{x \cdot \left(z + -1\right)}{y}\right|\\
\end{array}
\end{array}
if (fabs.f64 (-.f64 (/.f64 (+.f64 x 4) y) (*.f64 (/.f64 x y) z))) < 1.00000000000000005e301Initial program 99.0%
if 1.00000000000000005e301 < (fabs.f64 (-.f64 (/.f64 (+.f64 x 4) y) (*.f64 (/.f64 x y) z))) Initial program 61.8%
*-rgt-identity61.8%
fabs-sub61.8%
metadata-eval61.8%
metadata-eval61.8%
fabs-mul61.8%
metadata-eval61.8%
*-rgt-identity61.8%
associate-*l/80.0%
div-sub100.0%
sub-neg100.0%
+-commutative100.0%
remove-double-neg100.0%
distribute-neg-in100.0%
sub-neg100.0%
neg-mul-1100.0%
associate-*l/100.0%
remove-double-neg100.0%
distribute-lft-neg-in100.0%
distribute-rgt-neg-in100.0%
Simplified100.0%
Taylor expanded in x around inf 100.0%
Final simplification99.2%
(FPCore (x y z) :precision binary64 (if (or (<= x -155000000000.0) (not (<= x 2.25e-10))) (fabs (/ (+ z -1.0) (/ y x))) (fabs (/ (- 4.0 (* x z)) y))))
double code(double x, double y, double z) {
double tmp;
if ((x <= -155000000000.0) || !(x <= 2.25e-10)) {
tmp = fabs(((z + -1.0) / (y / x)));
} else {
tmp = fabs(((4.0 - (x * z)) / 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 <= (-155000000000.0d0)) .or. (.not. (x <= 2.25d-10))) then
tmp = abs(((z + (-1.0d0)) / (y / x)))
else
tmp = abs(((4.0d0 - (x * z)) / y))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((x <= -155000000000.0) || !(x <= 2.25e-10)) {
tmp = Math.abs(((z + -1.0) / (y / x)));
} else {
tmp = Math.abs(((4.0 - (x * z)) / y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -155000000000.0) or not (x <= 2.25e-10): tmp = math.fabs(((z + -1.0) / (y / x))) else: tmp = math.fabs(((4.0 - (x * z)) / y)) return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -155000000000.0) || !(x <= 2.25e-10)) tmp = abs(Float64(Float64(z + -1.0) / Float64(y / x))); else tmp = abs(Float64(Float64(4.0 - Float64(x * z)) / y)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -155000000000.0) || ~((x <= 2.25e-10))) tmp = abs(((z + -1.0) / (y / x))); else tmp = abs(((4.0 - (x * z)) / y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -155000000000.0], N[Not[LessEqual[x, 2.25e-10]], $MachinePrecision]], N[Abs[N[(N[(z + -1.0), $MachinePrecision] / N[(y / x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[(4.0 - N[(x * z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -155000000000 \lor \neg \left(x \leq 2.25 \cdot 10^{-10}\right):\\
\;\;\;\;\left|\frac{z + -1}{\frac{y}{x}}\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\frac{4 - x \cdot z}{y}\right|\\
\end{array}
\end{array}
if x < -1.55e11 or 2.25e-10 < x Initial program 83.6%
*-rgt-identity83.6%
fabs-sub83.6%
metadata-eval83.6%
metadata-eval83.6%
fabs-mul83.6%
metadata-eval83.6%
*-rgt-identity83.6%
associate-*l/81.2%
div-sub89.7%
sub-neg89.7%
+-commutative89.7%
remove-double-neg89.7%
distribute-neg-in89.7%
sub-neg89.7%
neg-mul-189.7%
associate-*l/89.6%
remove-double-neg89.6%
distribute-lft-neg-in89.6%
distribute-rgt-neg-in89.6%
Simplified89.6%
Taylor expanded in x around inf 88.1%
associate-/l*98.1%
sub-neg98.1%
metadata-eval98.1%
Simplified98.1%
if -1.55e11 < x < 2.25e-10Initial program 98.4%
fabs-neg98.4%
sub-neg98.4%
distribute-neg-in98.4%
sub-neg98.4%
distribute-neg-frac98.4%
associate-*l/99.9%
distribute-neg-frac99.9%
neg-mul-199.9%
associate-*l/99.9%
neg-mul-199.9%
associate-*l/99.8%
distribute-lft-out--99.8%
fabs-mul99.8%
fabs-sub99.8%
fabs-mul99.8%
associate-*l/99.9%
Simplified99.9%
Taylor expanded in x around 0 99.9%
Taylor expanded in z around inf 98.8%
neg-mul-198.8%
distribute-lft-neg-in98.8%
*-commutative98.8%
Simplified98.8%
Taylor expanded in x around 0 98.8%
associate-*l/92.3%
*-commutative92.3%
neg-mul-192.3%
unsub-neg92.3%
associate-*r/92.3%
metadata-eval92.3%
*-commutative92.3%
associate-*l/98.8%
div-sub98.8%
Simplified98.8%
Final simplification98.5%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (fabs (/ x y))))
(if (<= x -1.2e+209)
t_0
(if (<= x -2.9e-6)
(fabs (* x (/ z y)))
(if (<= x 4.0) (fabs (/ 4.0 y)) t_0)))))
double code(double x, double y, double z) {
double t_0 = fabs((x / y));
double tmp;
if (x <= -1.2e+209) {
tmp = t_0;
} else if (x <= -2.9e-6) {
tmp = fabs((x * (z / y)));
} else if (x <= 4.0) {
tmp = fabs((4.0 / y));
} else {
tmp = t_0;
}
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 = abs((x / y))
if (x <= (-1.2d+209)) then
tmp = t_0
else if (x <= (-2.9d-6)) then
tmp = abs((x * (z / y)))
else if (x <= 4.0d0) then
tmp = abs((4.0d0 / y))
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = Math.abs((x / y));
double tmp;
if (x <= -1.2e+209) {
tmp = t_0;
} else if (x <= -2.9e-6) {
tmp = Math.abs((x * (z / y)));
} else if (x <= 4.0) {
tmp = Math.abs((4.0 / y));
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = math.fabs((x / y)) tmp = 0 if x <= -1.2e+209: tmp = t_0 elif x <= -2.9e-6: tmp = math.fabs((x * (z / y))) elif x <= 4.0: tmp = math.fabs((4.0 / y)) else: tmp = t_0 return tmp
function code(x, y, z) t_0 = abs(Float64(x / y)) tmp = 0.0 if (x <= -1.2e+209) tmp = t_0; elseif (x <= -2.9e-6) tmp = abs(Float64(x * Float64(z / y))); elseif (x <= 4.0) tmp = abs(Float64(4.0 / y)); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = abs((x / y)); tmp = 0.0; if (x <= -1.2e+209) tmp = t_0; elseif (x <= -2.9e-6) tmp = abs((x * (z / y))); elseif (x <= 4.0) tmp = abs((4.0 / y)); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[Abs[N[(x / y), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[x, -1.2e+209], t$95$0, If[LessEqual[x, -2.9e-6], N[Abs[N[(x * N[(z / y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[x, 4.0], N[Abs[N[(4.0 / y), $MachinePrecision]], $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left|\frac{x}{y}\right|\\
\mathbf{if}\;x \leq -1.2 \cdot 10^{+209}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq -2.9 \cdot 10^{-6}:\\
\;\;\;\;\left|x \cdot \frac{z}{y}\right|\\
\mathbf{elif}\;x \leq 4:\\
\;\;\;\;\left|\frac{4}{y}\right|\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if x < -1.19999999999999998e209 or 4 < x Initial program 82.9%
Taylor expanded in z around 0 74.5%
associate-*r/74.5%
metadata-eval74.5%
Simplified74.5%
Taylor expanded in x around inf 72.4%
if -1.19999999999999998e209 < x < -2.9000000000000002e-6Initial program 84.9%
*-rgt-identity84.9%
fabs-sub84.9%
metadata-eval84.9%
metadata-eval84.9%
fabs-mul84.9%
metadata-eval84.9%
*-rgt-identity84.9%
associate-*l/83.0%
div-sub90.5%
sub-neg90.5%
+-commutative90.5%
remove-double-neg90.5%
distribute-neg-in90.5%
sub-neg90.5%
neg-mul-190.5%
associate-*l/90.3%
remove-double-neg90.3%
distribute-lft-neg-in90.3%
distribute-rgt-neg-in90.3%
Simplified90.3%
Taylor expanded in z around inf 51.5%
associate-*l/61.0%
*-commutative61.0%
Simplified61.0%
if -2.9000000000000002e-6 < x < 4Initial program 98.4%
Taylor expanded in x around 0 76.6%
Final simplification72.7%
(FPCore (x y z) :precision binary64 (if (or (<= z -3.8e+95) (not (<= z 8.2e+36))) (fabs (* (/ x y) z)) (fabs (/ (- -4.0 x) y))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -3.8e+95) || !(z <= 8.2e+36)) {
tmp = fabs(((x / y) * z));
} else {
tmp = fabs(((-4.0 - 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 ((z <= (-3.8d+95)) .or. (.not. (z <= 8.2d+36))) then
tmp = abs(((x / y) * z))
else
tmp = abs((((-4.0d0) - x) / y))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -3.8e+95) || !(z <= 8.2e+36)) {
tmp = Math.abs(((x / y) * z));
} else {
tmp = Math.abs(((-4.0 - x) / y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -3.8e+95) or not (z <= 8.2e+36): tmp = math.fabs(((x / y) * z)) else: tmp = math.fabs(((-4.0 - x) / y)) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -3.8e+95) || !(z <= 8.2e+36)) tmp = abs(Float64(Float64(x / y) * z)); else tmp = abs(Float64(Float64(-4.0 - x) / y)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -3.8e+95) || ~((z <= 8.2e+36))) tmp = abs(((x / y) * z)); else tmp = abs(((-4.0 - x) / y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -3.8e+95], N[Not[LessEqual[z, 8.2e+36]], $MachinePrecision]], N[Abs[N[(N[(x / y), $MachinePrecision] * z), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[(-4.0 - x), $MachinePrecision] / y), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -3.8 \cdot 10^{+95} \lor \neg \left(z \leq 8.2 \cdot 10^{+36}\right):\\
\;\;\;\;\left|\frac{x}{y} \cdot z\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\frac{-4 - x}{y}\right|\\
\end{array}
\end{array}
if z < -3.7999999999999999e95 or 8.20000000000000026e36 < z Initial program 87.4%
*-rgt-identity87.4%
fabs-sub87.4%
metadata-eval87.4%
metadata-eval87.4%
fabs-mul87.4%
metadata-eval87.4%
*-rgt-identity87.4%
associate-*l/75.5%
div-sub86.0%
sub-neg86.0%
+-commutative86.0%
remove-double-neg86.0%
distribute-neg-in86.0%
sub-neg86.0%
neg-mul-186.0%
associate-*l/85.9%
remove-double-neg85.9%
distribute-lft-neg-in85.9%
distribute-rgt-neg-in85.9%
Simplified85.9%
Taylor expanded in z around inf 71.2%
*-commutative71.2%
associate-*l/83.0%
*-commutative83.0%
Simplified83.0%
if -3.7999999999999999e95 < z < 8.20000000000000026e36Initial program 93.1%
*-rgt-identity93.1%
fabs-sub93.1%
metadata-eval93.1%
metadata-eval93.1%
fabs-mul93.1%
metadata-eval93.1%
*-rgt-identity93.1%
associate-*l/99.3%
div-sub99.9%
sub-neg99.9%
+-commutative99.9%
remove-double-neg99.9%
distribute-neg-in99.9%
sub-neg99.9%
neg-mul-199.9%
associate-*l/99.8%
remove-double-neg99.8%
distribute-lft-neg-in99.8%
distribute-rgt-neg-in99.8%
Simplified99.8%
Taylor expanded in z around 0 95.0%
associate-*r/95.0%
distribute-lft-in95.0%
metadata-eval95.0%
neg-mul-195.0%
sub-neg95.0%
Simplified95.0%
Final simplification90.6%
(FPCore (x y z) :precision binary64 (if (or (<= x -10.5) (not (<= x 4.0))) (fabs (/ x y)) (fabs (/ 4.0 y))))
double code(double x, double y, double z) {
double tmp;
if ((x <= -10.5) || !(x <= 4.0)) {
tmp = fabs((x / y));
} else {
tmp = fabs((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 <= (-10.5d0)) .or. (.not. (x <= 4.0d0))) then
tmp = abs((x / y))
else
tmp = abs((4.0d0 / y))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((x <= -10.5) || !(x <= 4.0)) {
tmp = Math.abs((x / y));
} else {
tmp = Math.abs((4.0 / y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -10.5) or not (x <= 4.0): tmp = math.fabs((x / y)) else: tmp = math.fabs((4.0 / y)) return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -10.5) || !(x <= 4.0)) tmp = abs(Float64(x / y)); else tmp = abs(Float64(4.0 / y)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -10.5) || ~((x <= 4.0))) tmp = abs((x / y)); else tmp = abs((4.0 / y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -10.5], N[Not[LessEqual[x, 4.0]], $MachinePrecision]], N[Abs[N[(x / y), $MachinePrecision]], $MachinePrecision], N[Abs[N[(4.0 / y), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -10.5 \lor \neg \left(x \leq 4\right):\\
\;\;\;\;\left|\frac{x}{y}\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\frac{4}{y}\right|\\
\end{array}
\end{array}
if x < -10.5 or 4 < x Initial program 83.4%
Taylor expanded in z around 0 66.6%
associate-*r/66.6%
metadata-eval66.6%
Simplified66.6%
Taylor expanded in x around inf 65.8%
if -10.5 < x < 4Initial program 98.5%
Taylor expanded in x around 0 76.1%
Final simplification71.0%
(FPCore (x y z) :precision binary64 (if (<= x -2.7e-6) (fabs (* (/ x y) z)) (if (<= x 4.0) (fabs (/ 4.0 y)) (fabs (/ x y)))))
double code(double x, double y, double z) {
double tmp;
if (x <= -2.7e-6) {
tmp = fabs(((x / y) * z));
} else if (x <= 4.0) {
tmp = fabs((4.0 / y));
} else {
tmp = fabs((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 <= (-2.7d-6)) then
tmp = abs(((x / y) * z))
else if (x <= 4.0d0) then
tmp = abs((4.0d0 / y))
else
tmp = abs((x / y))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (x <= -2.7e-6) {
tmp = Math.abs(((x / y) * z));
} else if (x <= 4.0) {
tmp = Math.abs((4.0 / y));
} else {
tmp = Math.abs((x / y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -2.7e-6: tmp = math.fabs(((x / y) * z)) elif x <= 4.0: tmp = math.fabs((4.0 / y)) else: tmp = math.fabs((x / y)) return tmp
function code(x, y, z) tmp = 0.0 if (x <= -2.7e-6) tmp = abs(Float64(Float64(x / y) * z)); elseif (x <= 4.0) tmp = abs(Float64(4.0 / y)); else tmp = abs(Float64(x / y)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= -2.7e-6) tmp = abs(((x / y) * z)); elseif (x <= 4.0) tmp = abs((4.0 / y)); else tmp = abs((x / y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -2.7e-6], N[Abs[N[(N[(x / y), $MachinePrecision] * z), $MachinePrecision]], $MachinePrecision], If[LessEqual[x, 4.0], N[Abs[N[(4.0 / y), $MachinePrecision]], $MachinePrecision], N[Abs[N[(x / y), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.7 \cdot 10^{-6}:\\
\;\;\;\;\left|\frac{x}{y} \cdot z\right|\\
\mathbf{elif}\;x \leq 4:\\
\;\;\;\;\left|\frac{4}{y}\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\frac{x}{y}\right|\\
\end{array}
\end{array}
if x < -2.69999999999999998e-6Initial program 81.3%
*-rgt-identity81.3%
fabs-sub81.3%
metadata-eval81.3%
metadata-eval81.3%
fabs-mul81.3%
metadata-eval81.3%
*-rgt-identity81.3%
associate-*l/83.5%
div-sub92.0%
sub-neg92.0%
+-commutative92.0%
remove-double-neg92.0%
distribute-neg-in92.0%
sub-neg92.0%
neg-mul-192.0%
associate-*l/91.9%
remove-double-neg91.9%
distribute-lft-neg-in91.9%
distribute-rgt-neg-in91.9%
Simplified91.9%
Taylor expanded in z around inf 47.1%
*-commutative47.1%
associate-*l/69.2%
*-commutative69.2%
Simplified69.2%
if -2.69999999999999998e-6 < x < 4Initial program 98.4%
Taylor expanded in x around 0 76.6%
if 4 < x Initial program 85.4%
Taylor expanded in z around 0 72.7%
associate-*r/72.7%
metadata-eval72.7%
Simplified72.7%
Taylor expanded in x around inf 70.1%
Final simplification73.2%
(FPCore (x y z) :precision binary64 (fabs (/ 4.0 y)))
double code(double x, double y, double z) {
return fabs((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((4.0d0 / y))
end function
public static double code(double x, double y, double z) {
return Math.abs((4.0 / y));
}
def code(x, y, z): return math.fabs((4.0 / y))
function code(x, y, z) return abs(Float64(4.0 / y)) end
function tmp = code(x, y, z) tmp = abs((4.0 / y)); end
code[x_, y_, z_] := N[Abs[N[(4.0 / y), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|\frac{4}{y}\right|
\end{array}
Initial program 91.0%
Taylor expanded in x around 0 41.3%
Final simplification41.3%
herbie shell --seed 2023174
(FPCore (x y z)
:name "fabs fraction 1"
:precision binary64
(fabs (- (/ (+ x 4.0) y) (* (/ x y) z))))