
(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}
(FPCore (x y z)
:precision binary64
(let* ((t_0 (fabs (- (/ (+ x 4.0) y) (* z (/ x y))))))
(if (or (<= t_0 2e-41) (not (<= t_0 1e+290)))
(fabs (/ (- (+ x 4.0) (* x z)) y))
t_0)))
double code(double x, double y, double z) {
double t_0 = fabs((((x + 4.0) / y) - (z * (x / y))));
double tmp;
if ((t_0 <= 2e-41) || !(t_0 <= 1e+290)) {
tmp = fabs((((x + 4.0) - (x * z)) / 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 + 4.0d0) / y) - (z * (x / y))))
if ((t_0 <= 2d-41) .or. (.not. (t_0 <= 1d+290))) then
tmp = abs((((x + 4.0d0) - (x * z)) / 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 + 4.0) / y) - (z * (x / y))));
double tmp;
if ((t_0 <= 2e-41) || !(t_0 <= 1e+290)) {
tmp = Math.abs((((x + 4.0) - (x * z)) / y));
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = math.fabs((((x + 4.0) / y) - (z * (x / y)))) tmp = 0 if (t_0 <= 2e-41) or not (t_0 <= 1e+290): tmp = math.fabs((((x + 4.0) - (x * z)) / y)) else: tmp = t_0 return tmp
function code(x, y, z) t_0 = abs(Float64(Float64(Float64(x + 4.0) / y) - Float64(z * Float64(x / y)))) tmp = 0.0 if ((t_0 <= 2e-41) || !(t_0 <= 1e+290)) tmp = abs(Float64(Float64(Float64(x + 4.0) - Float64(x * z)) / y)); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = abs((((x + 4.0) / y) - (z * (x / y)))); tmp = 0.0; if ((t_0 <= 2e-41) || ~((t_0 <= 1e+290))) tmp = abs((((x + 4.0) - (x * z)) / y)); else tmp = t_0; 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[(z * N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[Or[LessEqual[t$95$0, 2e-41], N[Not[LessEqual[t$95$0, 1e+290]], $MachinePrecision]], N[Abs[N[(N[(N[(x + 4.0), $MachinePrecision] - N[(x * z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]], $MachinePrecision], t$95$0]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left|\frac{x + 4}{y} - z \cdot \frac{x}{y}\right|\\
\mathbf{if}\;t\_0 \leq 2 \cdot 10^{-41} \lor \neg \left(t\_0 \leq 10^{+290}\right):\\
\;\;\;\;\left|\frac{\left(x + 4\right) - x \cdot z}{y}\right|\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if (fabs.f64 (-.f64 (/.f64 (+.f64 x #s(literal 4 binary64)) y) (*.f64 (/.f64 x y) z))) < 2.00000000000000001e-41 or 1.00000000000000006e290 < (fabs.f64 (-.f64 (/.f64 (+.f64 x #s(literal 4 binary64)) y) (*.f64 (/.f64 x y) z))) Initial program 78.2%
associate-*l/88.4%
sub-div100.0%
Applied egg-rr100.0%
if 2.00000000000000001e-41 < (fabs.f64 (-.f64 (/.f64 (+.f64 x #s(literal 4 binary64)) y) (*.f64 (/.f64 x y) z))) < 1.00000000000000006e290Initial program 99.9%
Final simplification99.9%
(FPCore (x y z) :precision binary64 (if (<= y 8e-75) (fabs (/ (- (+ x 4.0) (* x z)) y)) (fabs (fma x (/ z y) (/ (- -4.0 x) y)))))
double code(double x, double y, double z) {
double tmp;
if (y <= 8e-75) {
tmp = fabs((((x + 4.0) - (x * z)) / y));
} else {
tmp = fabs(fma(x, (z / y), ((-4.0 - x) / y)));
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (y <= 8e-75) tmp = abs(Float64(Float64(Float64(x + 4.0) - Float64(x * z)) / y)); else tmp = abs(fma(x, Float64(z / y), Float64(Float64(-4.0 - x) / y))); end return tmp end
code[x_, y_, z_] := If[LessEqual[y, 8e-75], N[Abs[N[(N[(N[(x + 4.0), $MachinePrecision] - N[(x * z), $MachinePrecision]), $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 8 \cdot 10^{-75}:\\
\;\;\;\;\left|\frac{\left(x + 4\right) - x \cdot z}{y}\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)\right|\\
\end{array}
\end{array}
if y < 7.9999999999999997e-75Initial program 86.3%
associate-*l/87.5%
sub-div95.8%
Applied egg-rr95.8%
if 7.9999999999999997e-75 < y Initial program 95.0%
fabs-sub95.0%
associate-*l/86.0%
associate-*r/99.8%
fma-neg99.9%
distribute-neg-frac99.9%
+-commutative99.9%
distribute-neg-in99.9%
unsub-neg99.9%
metadata-eval99.9%
Simplified99.9%
Final simplification97.0%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (fabs (* z (/ x y)))))
(if (<= x -1.7e-33)
t_0
(if (<= x 4.0) (fabs (/ 4.0 y)) (if (<= x 1.6e+55) (fabs (/ x y)) t_0)))))
double code(double x, double y, double z) {
double t_0 = fabs((z * (x / y)));
double tmp;
if (x <= -1.7e-33) {
tmp = t_0;
} else if (x <= 4.0) {
tmp = fabs((4.0 / y));
} else if (x <= 1.6e+55) {
tmp = fabs((x / 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((z * (x / y)))
if (x <= (-1.7d-33)) then
tmp = t_0
else if (x <= 4.0d0) then
tmp = abs((4.0d0 / y))
else if (x <= 1.6d+55) then
tmp = abs((x / 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((z * (x / y)));
double tmp;
if (x <= -1.7e-33) {
tmp = t_0;
} else if (x <= 4.0) {
tmp = Math.abs((4.0 / y));
} else if (x <= 1.6e+55) {
tmp = Math.abs((x / y));
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = math.fabs((z * (x / y))) tmp = 0 if x <= -1.7e-33: tmp = t_0 elif x <= 4.0: tmp = math.fabs((4.0 / y)) elif x <= 1.6e+55: tmp = math.fabs((x / y)) else: tmp = t_0 return tmp
function code(x, y, z) t_0 = abs(Float64(z * Float64(x / y))) tmp = 0.0 if (x <= -1.7e-33) tmp = t_0; elseif (x <= 4.0) tmp = abs(Float64(4.0 / y)); elseif (x <= 1.6e+55) tmp = abs(Float64(x / y)); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = abs((z * (x / y))); tmp = 0.0; if (x <= -1.7e-33) tmp = t_0; elseif (x <= 4.0) tmp = abs((4.0 / y)); elseif (x <= 1.6e+55) tmp = abs((x / y)); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[Abs[N[(z * N[(x / y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[x, -1.7e-33], t$95$0, If[LessEqual[x, 4.0], N[Abs[N[(4.0 / y), $MachinePrecision]], $MachinePrecision], If[LessEqual[x, 1.6e+55], N[Abs[N[(x / y), $MachinePrecision]], $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left|z \cdot \frac{x}{y}\right|\\
\mathbf{if}\;x \leq -1.7 \cdot 10^{-33}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 4:\\
\;\;\;\;\left|\frac{4}{y}\right|\\
\mathbf{elif}\;x \leq 1.6 \cdot 10^{+55}:\\
\;\;\;\;\left|\frac{x}{y}\right|\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -1.7e-33 or 1.6000000000000001e55 < x Initial program 83.7%
associate-*l/75.7%
sub-div86.7%
Applied egg-rr86.7%
Taylor expanded in z around inf 51.0%
mul-1-neg51.0%
associate-*r/63.7%
distribute-rgt-neg-in63.7%
distribute-neg-frac63.7%
Simplified63.7%
clear-num63.6%
un-div-inv63.6%
add-sqr-sqrt34.0%
sqrt-unprod51.5%
sqr-neg51.5%
sqrt-unprod29.5%
add-sqr-sqrt63.6%
Applied egg-rr63.6%
associate-/r/71.8%
Simplified71.8%
if -1.7e-33 < x < 4Initial program 94.0%
Simplified99.9%
Taylor expanded in x around 0 74.4%
if 4 < x < 1.6000000000000001e55Initial program 100.0%
Simplified99.6%
Taylor expanded in x around inf 94.3%
mul-1-neg94.3%
associate-/l*94.1%
distribute-rgt-neg-in94.1%
neg-sub094.1%
div094.1%
div-sub94.1%
associate-+l-94.1%
neg-sub094.1%
+-commutative94.1%
unsub-neg94.1%
Simplified94.1%
Taylor expanded in z around 0 72.8%
Final simplification73.0%
(FPCore (x y z) :precision binary64 (if (or (<= x -110000000.0) (not (<= x 5e+16))) (fabs (* (/ x y) (- 1.0 z))) (fabs (/ (- (+ x 4.0) (* x z)) y))))
double code(double x, double y, double z) {
double tmp;
if ((x <= -110000000.0) || !(x <= 5e+16)) {
tmp = fabs(((x / y) * (1.0 - z)));
} else {
tmp = fabs((((x + 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 <= (-110000000.0d0)) .or. (.not. (x <= 5d+16))) then
tmp = abs(((x / y) * (1.0d0 - z)))
else
tmp = abs((((x + 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 <= -110000000.0) || !(x <= 5e+16)) {
tmp = Math.abs(((x / y) * (1.0 - z)));
} else {
tmp = Math.abs((((x + 4.0) - (x * z)) / y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -110000000.0) or not (x <= 5e+16): tmp = math.fabs(((x / y) * (1.0 - z))) else: tmp = math.fabs((((x + 4.0) - (x * z)) / y)) return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -110000000.0) || !(x <= 5e+16)) tmp = abs(Float64(Float64(x / y) * Float64(1.0 - z))); else tmp = abs(Float64(Float64(Float64(x + 4.0) - Float64(x * z)) / y)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -110000000.0) || ~((x <= 5e+16))) tmp = abs(((x / y) * (1.0 - z))); else tmp = abs((((x + 4.0) - (x * z)) / y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -110000000.0], N[Not[LessEqual[x, 5e+16]], $MachinePrecision]], N[Abs[N[(N[(x / y), $MachinePrecision] * N[(1.0 - z), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[(N[(x + 4.0), $MachinePrecision] - N[(x * z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -110000000 \lor \neg \left(x \leq 5 \cdot 10^{+16}\right):\\
\;\;\;\;\left|\frac{x}{y} \cdot \left(1 - z\right)\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\frac{\left(x + 4\right) - x \cdot z}{y}\right|\\
\end{array}
\end{array}
if x < -1.1e8 or 5e16 < x Initial program 83.8%
Simplified86.6%
Taylor expanded in x around inf 86.8%
mul-1-neg86.8%
*-commutative86.8%
associate-/l*99.9%
distribute-lft-neg-in99.9%
neg-sub099.9%
associate-+l-99.9%
neg-sub099.9%
+-commutative99.9%
unsub-neg99.9%
Simplified99.9%
if -1.1e8 < x < 5e16Initial program 94.6%
associate-*l/99.9%
sub-div99.9%
Applied egg-rr99.9%
Final simplification99.9%
(FPCore (x y z) :precision binary64 (if (or (<= z -5.5e-6) (not (<= z 7e+87))) (fabs (* x (/ (- 1.0 z) y))) (fabs (/ (- -4.0 x) y))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -5.5e-6) || !(z <= 7e+87)) {
tmp = fabs((x * ((1.0 - z) / y)));
} 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 <= (-5.5d-6)) .or. (.not. (z <= 7d+87))) then
tmp = abs((x * ((1.0d0 - z) / y)))
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 <= -5.5e-6) || !(z <= 7e+87)) {
tmp = Math.abs((x * ((1.0 - z) / y)));
} else {
tmp = Math.abs(((-4.0 - x) / y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -5.5e-6) or not (z <= 7e+87): tmp = math.fabs((x * ((1.0 - z) / y))) else: tmp = math.fabs(((-4.0 - x) / y)) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -5.5e-6) || !(z <= 7e+87)) tmp = abs(Float64(x * Float64(Float64(1.0 - z) / y))); 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 <= -5.5e-6) || ~((z <= 7e+87))) tmp = abs((x * ((1.0 - z) / y))); else tmp = abs(((-4.0 - x) / y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -5.5e-6], N[Not[LessEqual[z, 7e+87]], $MachinePrecision]], N[Abs[N[(x * N[(N[(1.0 - z), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[(-4.0 - x), $MachinePrecision] / y), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -5.5 \cdot 10^{-6} \lor \neg \left(z \leq 7 \cdot 10^{+87}\right):\\
\;\;\;\;\left|x \cdot \frac{1 - z}{y}\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\frac{-4 - x}{y}\right|\\
\end{array}
\end{array}
if z < -5.4999999999999999e-6 or 6.99999999999999972e87 < z Initial program 86.5%
Simplified85.8%
Taylor expanded in x around inf 73.6%
mul-1-neg73.6%
associate-/l*84.6%
distribute-rgt-neg-in84.6%
neg-sub084.6%
div084.6%
div-sub84.6%
associate-+l-84.6%
neg-sub084.6%
+-commutative84.6%
unsub-neg84.6%
Simplified84.6%
if -5.4999999999999999e-6 < z < 6.99999999999999972e87Initial program 91.0%
fabs-sub91.0%
associate-*l/95.5%
associate-*r/96.2%
fma-neg100.0%
distribute-neg-frac100.0%
+-commutative100.0%
distribute-neg-in100.0%
unsub-neg100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in z around 0 95.3%
associate-*r/95.3%
distribute-lft-in95.3%
metadata-eval95.3%
neg-mul-195.3%
sub-neg95.3%
Simplified95.3%
Final simplification90.2%
(FPCore (x y z) :precision binary64 (if (<= z -6.7e-6) (fabs (* (/ x y) (- 1.0 z))) (if (<= z 4.1e+89) (fabs (/ (- -4.0 x) y)) (fabs (* x (/ (- 1.0 z) y))))))
double code(double x, double y, double z) {
double tmp;
if (z <= -6.7e-6) {
tmp = fabs(((x / y) * (1.0 - z)));
} else if (z <= 4.1e+89) {
tmp = fabs(((-4.0 - x) / y));
} else {
tmp = fabs((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 (z <= (-6.7d-6)) then
tmp = abs(((x / y) * (1.0d0 - z)))
else if (z <= 4.1d+89) then
tmp = abs((((-4.0d0) - x) / y))
else
tmp = abs((x * ((1.0d0 - z) / y)))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -6.7e-6) {
tmp = Math.abs(((x / y) * (1.0 - z)));
} else if (z <= 4.1e+89) {
tmp = Math.abs(((-4.0 - x) / y));
} else {
tmp = Math.abs((x * ((1.0 - z) / y)));
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -6.7e-6: tmp = math.fabs(((x / y) * (1.0 - z))) elif z <= 4.1e+89: tmp = math.fabs(((-4.0 - x) / y)) else: tmp = math.fabs((x * ((1.0 - z) / y))) return tmp
function code(x, y, z) tmp = 0.0 if (z <= -6.7e-6) tmp = abs(Float64(Float64(x / y) * Float64(1.0 - z))); elseif (z <= 4.1e+89) tmp = abs(Float64(Float64(-4.0 - x) / y)); else tmp = abs(Float64(x * Float64(Float64(1.0 - z) / y))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -6.7e-6) tmp = abs(((x / y) * (1.0 - z))); elseif (z <= 4.1e+89) tmp = abs(((-4.0 - x) / y)); else tmp = abs((x * ((1.0 - z) / y))); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -6.7e-6], N[Abs[N[(N[(x / y), $MachinePrecision] * N[(1.0 - z), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[z, 4.1e+89], N[Abs[N[(N[(-4.0 - x), $MachinePrecision] / y), $MachinePrecision]], $MachinePrecision], N[Abs[N[(x * N[(N[(1.0 - z), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -6.7 \cdot 10^{-6}:\\
\;\;\;\;\left|\frac{x}{y} \cdot \left(1 - z\right)\right|\\
\mathbf{elif}\;z \leq 4.1 \cdot 10^{+89}:\\
\;\;\;\;\left|\frac{-4 - x}{y}\right|\\
\mathbf{else}:\\
\;\;\;\;\left|x \cdot \frac{1 - z}{y}\right|\\
\end{array}
\end{array}
if z < -6.7e-6Initial program 97.3%
Simplified86.8%
Taylor expanded in x around inf 72.0%
mul-1-neg72.0%
*-commutative72.0%
associate-/l*82.6%
distribute-lft-neg-in82.6%
neg-sub082.6%
associate-+l-82.6%
neg-sub082.6%
+-commutative82.6%
unsub-neg82.6%
Simplified82.6%
if -6.7e-6 < z < 4.09999999999999985e89Initial program 91.0%
fabs-sub91.0%
associate-*l/95.5%
associate-*r/96.2%
fma-neg100.0%
distribute-neg-frac100.0%
+-commutative100.0%
distribute-neg-in100.0%
unsub-neg100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in z around 0 95.3%
associate-*r/95.3%
distribute-lft-in95.3%
metadata-eval95.3%
neg-mul-195.3%
sub-neg95.3%
Simplified95.3%
if 4.09999999999999985e89 < z Initial program 70.3%
Simplified84.3%
Taylor expanded in x around inf 75.9%
mul-1-neg75.9%
associate-/l*91.3%
distribute-rgt-neg-in91.3%
neg-sub091.3%
div091.3%
div-sub91.3%
associate-+l-91.3%
neg-sub091.3%
+-commutative91.3%
unsub-neg91.3%
Simplified91.3%
Final simplification90.9%
(FPCore (x y z) :precision binary64 (if (<= z -3800000.0) (fabs (* z (/ x y))) (if (<= z 1.45e+79) (fabs (/ (- -4.0 x) y)) (fabs (* x (/ z y))))))
double code(double x, double y, double z) {
double tmp;
if (z <= -3800000.0) {
tmp = fabs((z * (x / y)));
} else if (z <= 1.45e+79) {
tmp = fabs(((-4.0 - x) / y));
} else {
tmp = fabs((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 (z <= (-3800000.0d0)) then
tmp = abs((z * (x / y)))
else if (z <= 1.45d+79) then
tmp = abs((((-4.0d0) - x) / y))
else
tmp = abs((x * (z / y)))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -3800000.0) {
tmp = Math.abs((z * (x / y)));
} else if (z <= 1.45e+79) {
tmp = Math.abs(((-4.0 - x) / y));
} else {
tmp = Math.abs((x * (z / y)));
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -3800000.0: tmp = math.fabs((z * (x / y))) elif z <= 1.45e+79: tmp = math.fabs(((-4.0 - x) / y)) else: tmp = math.fabs((x * (z / y))) return tmp
function code(x, y, z) tmp = 0.0 if (z <= -3800000.0) tmp = abs(Float64(z * Float64(x / y))); elseif (z <= 1.45e+79) tmp = abs(Float64(Float64(-4.0 - x) / y)); else tmp = abs(Float64(x * Float64(z / y))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -3800000.0) tmp = abs((z * (x / y))); elseif (z <= 1.45e+79) tmp = abs(((-4.0 - x) / y)); else tmp = abs((x * (z / y))); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -3800000.0], N[Abs[N[(z * N[(x / y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[z, 1.45e+79], N[Abs[N[(N[(-4.0 - x), $MachinePrecision] / y), $MachinePrecision]], $MachinePrecision], N[Abs[N[(x * N[(z / y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -3800000:\\
\;\;\;\;\left|z \cdot \frac{x}{y}\right|\\
\mathbf{elif}\;z \leq 1.45 \cdot 10^{+79}:\\
\;\;\;\;\left|\frac{-4 - x}{y}\right|\\
\mathbf{else}:\\
\;\;\;\;\left|x \cdot \frac{z}{y}\right|\\
\end{array}
\end{array}
if z < -3.8e6Initial program 97.2%
associate-*l/86.5%
sub-div86.5%
Applied egg-rr86.5%
Taylor expanded in z around inf 69.8%
mul-1-neg69.8%
associate-*r/78.1%
distribute-rgt-neg-in78.1%
distribute-neg-frac78.1%
Simplified78.1%
clear-num78.1%
un-div-inv78.1%
add-sqr-sqrt77.9%
sqrt-unprod56.1%
sqr-neg56.1%
sqrt-unprod0.0%
add-sqr-sqrt78.1%
Applied egg-rr78.1%
associate-/r/80.6%
Simplified80.6%
if -3.8e6 < z < 1.44999999999999996e79Initial program 91.1%
fabs-sub91.1%
associate-*l/95.6%
associate-*r/96.3%
fma-neg100.0%
distribute-neg-frac100.0%
+-commutative100.0%
distribute-neg-in100.0%
unsub-neg100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in z around 0 94.5%
associate-*r/94.5%
distribute-lft-in94.5%
metadata-eval94.5%
neg-mul-194.5%
sub-neg94.5%
Simplified94.5%
if 1.44999999999999996e79 < z Initial program 70.3%
Simplified84.3%
Taylor expanded in z around inf 75.9%
mul-1-neg75.9%
distribute-frac-neg75.9%
distribute-lft-neg-in75.9%
*-commutative75.9%
associate-*r/83.0%
Simplified83.0%
add-sqr-sqrt43.7%
sqrt-unprod66.9%
sqr-neg66.9%
sqrt-unprod39.0%
add-sqr-sqrt83.0%
clear-num80.7%
div-inv80.7%
Applied egg-rr80.7%
associate-/r/91.3%
Applied egg-rr91.3%
Final simplification90.1%
(FPCore (x y z) :precision binary64 (if (or (<= x -10.4) (not (<= x 4.0))) (fabs (/ x y)) (fabs (/ 4.0 y))))
double code(double x, double y, double z) {
double tmp;
if ((x <= -10.4) || !(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.4d0)) .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.4) || !(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.4) 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.4) || !(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.4) || ~((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.4], 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.4 \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.4000000000000004 or 4 < x Initial program 84.1%
Simplified86.8%
Taylor expanded in x around inf 86.4%
mul-1-neg86.4%
associate-/l*99.2%
distribute-rgt-neg-in99.2%
neg-sub099.2%
div099.2%
div-sub99.2%
associate-+l-99.2%
neg-sub099.2%
+-commutative99.2%
unsub-neg99.2%
Simplified99.2%
Taylor expanded in z around 0 59.3%
if -10.4000000000000004 < x < 4Initial program 94.5%
Simplified99.9%
Taylor expanded in x around 0 70.9%
Final simplification64.6%
(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 88.8%
Simplified92.8%
Taylor expanded in x around 0 35.1%
Final simplification35.1%
herbie shell --seed 2024073
(FPCore (x y z)
:name "fabs fraction 1"
:precision binary64
(fabs (- (/ (+ x 4.0) y) (* (/ x y) z))))