
(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
(let* ((t_0 (fabs (- (/ (+ x 4.0) y) (* z (/ x y))))))
(if (or (<= t_0 4e-65) (not (<= t_0 5e+299)))
(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 <= 4e-65) || !(t_0 <= 5e+299)) {
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 <= 4d-65) .or. (.not. (t_0 <= 5d+299))) 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 <= 4e-65) || !(t_0 <= 5e+299)) {
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 <= 4e-65) or not (t_0 <= 5e+299): 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 <= 4e-65) || !(t_0 <= 5e+299)) 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 <= 4e-65) || ~((t_0 <= 5e+299))) 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, 4e-65], N[Not[LessEqual[t$95$0, 5e+299]], $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 4 \cdot 10^{-65} \lor \neg \left(t\_0 \leq 5 \cdot 10^{+299}\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 4) y) (*.f64 (/.f64 x y) z))) < 3.99999999999999969e-65 or 5.0000000000000003e299 < (fabs.f64 (-.f64 (/.f64 (+.f64 x 4) y) (*.f64 (/.f64 x y) z))) Initial program 83.3%
associate-*l/90.9%
sub-div100.0%
Applied egg-rr100.0%
if 3.99999999999999969e-65 < (fabs.f64 (-.f64 (/.f64 (+.f64 x 4) y) (*.f64 (/.f64 x y) z))) < 5.0000000000000003e299Initial program 99.9%
Final simplification99.9%
(FPCore (x y z)
:precision binary64
(if (<= x -15000000000.0)
(fabs (* (/ x y) (- 1.0 z)))
(if (<= x 3.7)
(fabs (- (/ 4.0 y) (* x (/ z y))))
(fabs (/ x (/ y (- 1.0 z)))))))
double code(double x, double y, double z) {
double tmp;
if (x <= -15000000000.0) {
tmp = fabs(((x / y) * (1.0 - z)));
} else if (x <= 3.7) {
tmp = fabs(((4.0 / y) - (x * (z / y))));
} else {
tmp = fabs((x / (y / (1.0 - z))));
}
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 <= (-15000000000.0d0)) then
tmp = abs(((x / y) * (1.0d0 - z)))
else if (x <= 3.7d0) then
tmp = abs(((4.0d0 / y) - (x * (z / y))))
else
tmp = abs((x / (y / (1.0d0 - z))))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (x <= -15000000000.0) {
tmp = Math.abs(((x / y) * (1.0 - z)));
} else if (x <= 3.7) {
tmp = Math.abs(((4.0 / y) - (x * (z / y))));
} else {
tmp = Math.abs((x / (y / (1.0 - z))));
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -15000000000.0: tmp = math.fabs(((x / y) * (1.0 - z))) elif x <= 3.7: tmp = math.fabs(((4.0 / y) - (x * (z / y)))) else: tmp = math.fabs((x / (y / (1.0 - z)))) return tmp
function code(x, y, z) tmp = 0.0 if (x <= -15000000000.0) tmp = abs(Float64(Float64(x / y) * Float64(1.0 - z))); elseif (x <= 3.7) tmp = abs(Float64(Float64(4.0 / y) - Float64(x * Float64(z / y)))); else tmp = abs(Float64(x / Float64(y / Float64(1.0 - z)))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= -15000000000.0) tmp = abs(((x / y) * (1.0 - z))); elseif (x <= 3.7) tmp = abs(((4.0 / y) - (x * (z / y)))); else tmp = abs((x / (y / (1.0 - z)))); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -15000000000.0], N[Abs[N[(N[(x / y), $MachinePrecision] * N[(1.0 - z), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[x, 3.7], N[Abs[N[(N[(4.0 / y), $MachinePrecision] - N[(x * N[(z / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(x / N[(y / N[(1.0 - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -15000000000:\\
\;\;\;\;\left|\frac{x}{y} \cdot \left(1 - z\right)\right|\\
\mathbf{elif}\;x \leq 3.7:\\
\;\;\;\;\left|\frac{4}{y} - x \cdot \frac{z}{y}\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\frac{x}{\frac{y}{1 - z}}\right|\\
\end{array}
\end{array}
if x < -1.5e10Initial program 89.8%
Simplified87.5%
Taylor expanded in x around inf 87.5%
mul-1-neg87.5%
*-commutative87.5%
associate-/l*99.8%
distribute-lft-neg-in99.8%
neg-sub099.8%
associate-+l-99.8%
neg-sub099.8%
+-commutative99.8%
unsub-neg99.8%
Simplified99.8%
if -1.5e10 < x < 3.7000000000000002Initial program 96.2%
Simplified99.8%
Taylor expanded in z around -inf 83.4%
mul-1-neg83.4%
distribute-rgt-neg-in83.4%
*-lft-identity83.4%
metadata-eval83.4%
cancel-sign-sub-inv83.4%
distribute-lft-out--83.4%
mul-1-neg83.4%
remove-double-neg83.4%
Simplified82.7%
Taylor expanded in x around 0 82.6%
Taylor expanded in z around 0 99.8%
associate-*r/99.8%
metadata-eval99.8%
+-commutative99.8%
mul-1-neg99.8%
associate-/l*89.5%
distribute-lft-neg-in89.5%
cancel-sign-sub89.5%
remove-double-neg89.5%
Simplified89.5%
if 3.7000000000000002 < x Initial program 89.9%
Simplified91.8%
Taylor expanded in x around inf 90.9%
mul-1-neg90.9%
associate-/l*98.6%
distribute-rgt-neg-in98.6%
neg-sub098.6%
div098.6%
div-sub98.6%
associate-+l-98.6%
neg-sub098.6%
+-commutative98.6%
unsub-neg98.6%
Simplified98.6%
clear-num98.5%
un-div-inv98.8%
Applied egg-rr98.8%
Final simplification94.8%
(FPCore (x y z)
:precision binary64
(if (<= x -5e+110)
(fabs (* (/ x y) (- 1.0 z)))
(if (<= x 1.1e+20)
(fabs (/ (- (+ x 4.0) (* x z)) y))
(fabs (/ x (/ y (- 1.0 z)))))))
double code(double x, double y, double z) {
double tmp;
if (x <= -5e+110) {
tmp = fabs(((x / y) * (1.0 - z)));
} else if (x <= 1.1e+20) {
tmp = fabs((((x + 4.0) - (x * z)) / y));
} else {
tmp = fabs((x / (y / (1.0 - z))));
}
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 <= (-5d+110)) then
tmp = abs(((x / y) * (1.0d0 - z)))
else if (x <= 1.1d+20) then
tmp = abs((((x + 4.0d0) - (x * z)) / y))
else
tmp = abs((x / (y / (1.0d0 - z))))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (x <= -5e+110) {
tmp = Math.abs(((x / y) * (1.0 - z)));
} else if (x <= 1.1e+20) {
tmp = Math.abs((((x + 4.0) - (x * z)) / y));
} else {
tmp = Math.abs((x / (y / (1.0 - z))));
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -5e+110: tmp = math.fabs(((x / y) * (1.0 - z))) elif x <= 1.1e+20: tmp = math.fabs((((x + 4.0) - (x * z)) / y)) else: tmp = math.fabs((x / (y / (1.0 - z)))) return tmp
function code(x, y, z) tmp = 0.0 if (x <= -5e+110) tmp = abs(Float64(Float64(x / y) * Float64(1.0 - z))); elseif (x <= 1.1e+20) tmp = abs(Float64(Float64(Float64(x + 4.0) - Float64(x * z)) / y)); else tmp = abs(Float64(x / Float64(y / Float64(1.0 - z)))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= -5e+110) tmp = abs(((x / y) * (1.0 - z))); elseif (x <= 1.1e+20) tmp = abs((((x + 4.0) - (x * z)) / y)); else tmp = abs((x / (y / (1.0 - z)))); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -5e+110], N[Abs[N[(N[(x / y), $MachinePrecision] * N[(1.0 - z), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[x, 1.1e+20], N[Abs[N[(N[(N[(x + 4.0), $MachinePrecision] - N[(x * z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]], $MachinePrecision], N[Abs[N[(x / N[(y / N[(1.0 - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -5 \cdot 10^{+110}:\\
\;\;\;\;\left|\frac{x}{y} \cdot \left(1 - z\right)\right|\\
\mathbf{elif}\;x \leq 1.1 \cdot 10^{+20}:\\
\;\;\;\;\left|\frac{\left(x + 4\right) - x \cdot z}{y}\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\frac{x}{\frac{y}{1 - z}}\right|\\
\end{array}
\end{array}
if x < -4.99999999999999978e110Initial program 87.9%
Simplified82.8%
Taylor expanded in x around inf 82.9%
mul-1-neg82.9%
*-commutative82.9%
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 -4.99999999999999978e110 < x < 1.1e20Initial program 96.1%
associate-*l/99.9%
sub-div99.9%
Applied egg-rr99.9%
if 1.1e20 < x Initial program 89.2%
Simplified91.2%
Taylor expanded in x around inf 91.5%
mul-1-neg91.5%
associate-/l*99.7%
distribute-rgt-neg-in99.7%
neg-sub099.7%
div099.7%
div-sub99.7%
associate-+l-99.7%
neg-sub099.7%
+-commutative99.7%
unsub-neg99.7%
Simplified99.7%
clear-num99.7%
un-div-inv100.0%
Applied egg-rr100.0%
Final simplification99.9%
(FPCore (x y z) :precision binary64 (if (or (<= x -8.5e-24) (not (<= x 530000.0))) (fabs (* x (/ (- 1.0 z) y))) (fabs (/ (- -4.0 x) y))))
double code(double x, double y, double z) {
double tmp;
if ((x <= -8.5e-24) || !(x <= 530000.0)) {
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 ((x <= (-8.5d-24)) .or. (.not. (x <= 530000.0d0))) 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 ((x <= -8.5e-24) || !(x <= 530000.0)) {
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 (x <= -8.5e-24) or not (x <= 530000.0): 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 ((x <= -8.5e-24) || !(x <= 530000.0)) 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 ((x <= -8.5e-24) || ~((x <= 530000.0))) 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[x, -8.5e-24], N[Not[LessEqual[x, 530000.0]], $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}\;x \leq -8.5 \cdot 10^{-24} \lor \neg \left(x \leq 530000\right):\\
\;\;\;\;\left|x \cdot \frac{1 - z}{y}\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\frac{-4 - x}{y}\right|\\
\end{array}
\end{array}
if x < -8.5000000000000002e-24 or 5.3e5 < x Initial program 90.2%
Simplified90.0%
Taylor expanded in x around inf 89.3%
mul-1-neg89.3%
associate-/l*98.8%
distribute-rgt-neg-in98.8%
neg-sub098.8%
div098.8%
div-sub98.8%
associate-+l-98.8%
neg-sub098.8%
+-commutative98.8%
unsub-neg98.8%
Simplified98.8%
if -8.5000000000000002e-24 < x < 5.3e5Initial program 96.0%
fabs-sub96.0%
associate-*l/99.9%
associate-*r/89.2%
fma-neg89.2%
distribute-neg-frac89.2%
+-commutative89.2%
distribute-neg-in89.2%
unsub-neg89.2%
metadata-eval89.2%
Simplified89.2%
Taylor expanded in z around 0 78.6%
associate-*r/78.6%
distribute-lft-in78.6%
metadata-eval78.6%
neg-mul-178.6%
sub-neg78.6%
Simplified78.6%
Final simplification89.9%
(FPCore (x y z) :precision binary64 (if (or (<= x -1.6e-28) (not (<= x 41000.0))) (fabs (* (/ x y) (- 1.0 z))) (fabs (/ (- -4.0 x) y))))
double code(double x, double y, double z) {
double tmp;
if ((x <= -1.6e-28) || !(x <= 41000.0)) {
tmp = fabs(((x / y) * (1.0 - 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 ((x <= (-1.6d-28)) .or. (.not. (x <= 41000.0d0))) then
tmp = abs(((x / y) * (1.0d0 - 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 ((x <= -1.6e-28) || !(x <= 41000.0)) {
tmp = Math.abs(((x / y) * (1.0 - z)));
} else {
tmp = Math.abs(((-4.0 - x) / y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -1.6e-28) or not (x <= 41000.0): tmp = math.fabs(((x / y) * (1.0 - z))) else: tmp = math.fabs(((-4.0 - x) / y)) return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -1.6e-28) || !(x <= 41000.0)) tmp = abs(Float64(Float64(x / y) * Float64(1.0 - 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 ((x <= -1.6e-28) || ~((x <= 41000.0))) tmp = abs(((x / y) * (1.0 - z))); else tmp = abs(((-4.0 - x) / y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -1.6e-28], N[Not[LessEqual[x, 41000.0]], $MachinePrecision]], N[Abs[N[(N[(x / y), $MachinePrecision] * N[(1.0 - z), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[(-4.0 - x), $MachinePrecision] / y), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.6 \cdot 10^{-28} \lor \neg \left(x \leq 41000\right):\\
\;\;\;\;\left|\frac{x}{y} \cdot \left(1 - z\right)\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\frac{-4 - x}{y}\right|\\
\end{array}
\end{array}
if x < -1.59999999999999991e-28 or 41000 < x Initial program 90.2%
Simplified90.0%
Taylor expanded in x around inf 89.3%
mul-1-neg89.3%
*-commutative89.3%
associate-/l*99.0%
distribute-lft-neg-in99.0%
neg-sub099.0%
associate-+l-99.0%
neg-sub099.0%
+-commutative99.0%
unsub-neg99.0%
Simplified99.0%
if -1.59999999999999991e-28 < x < 41000Initial program 96.0%
fabs-sub96.0%
associate-*l/99.9%
associate-*r/89.2%
fma-neg89.2%
distribute-neg-frac89.2%
+-commutative89.2%
distribute-neg-in89.2%
unsub-neg89.2%
metadata-eval89.2%
Simplified89.2%
Taylor expanded in z around 0 78.6%
associate-*r/78.6%
distribute-lft-in78.6%
metadata-eval78.6%
neg-mul-178.6%
sub-neg78.6%
Simplified78.6%
Final simplification90.0%
(FPCore (x y z) :precision binary64 (if (<= x -1.3e-24) (fabs (* (/ x y) (- 1.0 z))) (if (<= x 2250.0) (fabs (/ (- -4.0 x) y)) (fabs (/ x (/ y (- 1.0 z)))))))
double code(double x, double y, double z) {
double tmp;
if (x <= -1.3e-24) {
tmp = fabs(((x / y) * (1.0 - z)));
} else if (x <= 2250.0) {
tmp = fabs(((-4.0 - x) / y));
} else {
tmp = fabs((x / (y / (1.0 - z))));
}
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.3d-24)) then
tmp = abs(((x / y) * (1.0d0 - z)))
else if (x <= 2250.0d0) then
tmp = abs((((-4.0d0) - x) / y))
else
tmp = abs((x / (y / (1.0d0 - z))))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (x <= -1.3e-24) {
tmp = Math.abs(((x / y) * (1.0 - z)));
} else if (x <= 2250.0) {
tmp = Math.abs(((-4.0 - x) / y));
} else {
tmp = Math.abs((x / (y / (1.0 - z))));
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -1.3e-24: tmp = math.fabs(((x / y) * (1.0 - z))) elif x <= 2250.0: tmp = math.fabs(((-4.0 - x) / y)) else: tmp = math.fabs((x / (y / (1.0 - z)))) return tmp
function code(x, y, z) tmp = 0.0 if (x <= -1.3e-24) tmp = abs(Float64(Float64(x / y) * Float64(1.0 - z))); elseif (x <= 2250.0) tmp = abs(Float64(Float64(-4.0 - x) / y)); else tmp = abs(Float64(x / Float64(y / Float64(1.0 - z)))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= -1.3e-24) tmp = abs(((x / y) * (1.0 - z))); elseif (x <= 2250.0) tmp = abs(((-4.0 - x) / y)); else tmp = abs((x / (y / (1.0 - z)))); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -1.3e-24], N[Abs[N[(N[(x / y), $MachinePrecision] * N[(1.0 - z), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[x, 2250.0], N[Abs[N[(N[(-4.0 - x), $MachinePrecision] / y), $MachinePrecision]], $MachinePrecision], N[Abs[N[(x / N[(y / N[(1.0 - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.3 \cdot 10^{-24}:\\
\;\;\;\;\left|\frac{x}{y} \cdot \left(1 - z\right)\right|\\
\mathbf{elif}\;x \leq 2250:\\
\;\;\;\;\left|\frac{-4 - x}{y}\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\frac{x}{\frac{y}{1 - z}}\right|\\
\end{array}
\end{array}
if x < -1.3e-24Initial program 90.6%
Simplified88.5%
Taylor expanded in x around inf 86.9%
mul-1-neg86.9%
*-commutative86.9%
associate-/l*98.3%
distribute-lft-neg-in98.3%
neg-sub098.3%
associate-+l-98.3%
neg-sub098.3%
+-commutative98.3%
unsub-neg98.3%
Simplified98.3%
if -1.3e-24 < x < 2250Initial program 96.0%
fabs-sub96.0%
associate-*l/99.9%
associate-*r/89.2%
fma-neg89.2%
distribute-neg-frac89.2%
+-commutative89.2%
distribute-neg-in89.2%
unsub-neg89.2%
metadata-eval89.2%
Simplified89.2%
Taylor expanded in z around 0 78.6%
associate-*r/78.6%
distribute-lft-in78.6%
metadata-eval78.6%
neg-mul-178.6%
sub-neg78.6%
Simplified78.6%
if 2250 < x Initial program 89.8%
Simplified91.7%
Taylor expanded in x around inf 91.8%
mul-1-neg91.8%
associate-/l*99.5%
distribute-rgt-neg-in99.5%
neg-sub099.5%
div099.5%
div-sub99.5%
associate-+l-99.5%
neg-sub099.5%
+-commutative99.5%
unsub-neg99.5%
Simplified99.5%
clear-num99.5%
un-div-inv99.7%
Applied egg-rr99.7%
Final simplification90.0%
(FPCore (x y z) :precision binary64 (if (<= y 5e-31) (fabs (/ (- (+ x 4.0) (* x z)) y)) (fabs (- (/ (+ x 4.0) y) (/ x (/ y z))))))
double code(double x, double y, double z) {
double tmp;
if (y <= 5e-31) {
tmp = fabs((((x + 4.0) - (x * z)) / y));
} else {
tmp = fabs((((x + 4.0) / y) - (x / (y / z))));
}
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 (y <= 5d-31) then
tmp = abs((((x + 4.0d0) - (x * z)) / y))
else
tmp = abs((((x + 4.0d0) / y) - (x / (y / z))))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= 5e-31) {
tmp = Math.abs((((x + 4.0) - (x * z)) / y));
} else {
tmp = Math.abs((((x + 4.0) / y) - (x / (y / z))));
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 5e-31: tmp = math.fabs((((x + 4.0) - (x * z)) / y)) else: tmp = math.fabs((((x + 4.0) / y) - (x / (y / z)))) return tmp
function code(x, y, z) tmp = 0.0 if (y <= 5e-31) tmp = abs(Float64(Float64(Float64(x + 4.0) - Float64(x * z)) / y)); else tmp = abs(Float64(Float64(Float64(x + 4.0) / y) - Float64(x / Float64(y / z)))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 5e-31) tmp = abs((((x + 4.0) - (x * z)) / y)); else tmp = abs((((x + 4.0) / y) - (x / (y / z)))); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 5e-31], N[Abs[N[(N[(N[(x + 4.0), $MachinePrecision] - N[(x * z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[(N[(x + 4.0), $MachinePrecision] / y), $MachinePrecision] - N[(x / N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 5 \cdot 10^{-31}:\\
\;\;\;\;\left|\frac{\left(x + 4\right) - x \cdot z}{y}\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\frac{x + 4}{y} - \frac{x}{\frac{y}{z}}\right|\\
\end{array}
\end{array}
if y < 5e-31Initial program 91.4%
associate-*l/88.6%
sub-div93.9%
Applied egg-rr93.9%
if 5e-31 < y Initial program 96.3%
associate-*l/95.8%
associate-*r/99.9%
clear-num99.9%
un-div-inv99.9%
Applied egg-rr99.9%
Final simplification95.5%
(FPCore (x y z) :precision binary64 (if (<= z -1.2e+24) (fabs (/ x (/ y z))) (if (<= z 1.6e+50) (fabs (/ (- -4.0 x) y)) (fabs (* z (/ x y))))))
double code(double x, double y, double z) {
double tmp;
if (z <= -1.2e+24) {
tmp = fabs((x / (y / z)));
} else if (z <= 1.6e+50) {
tmp = fabs(((-4.0 - x) / y));
} else {
tmp = fabs((z * (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 <= (-1.2d+24)) then
tmp = abs((x / (y / z)))
else if (z <= 1.6d+50) then
tmp = abs((((-4.0d0) - x) / y))
else
tmp = abs((z * (x / y)))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -1.2e+24) {
tmp = Math.abs((x / (y / z)));
} else if (z <= 1.6e+50) {
tmp = Math.abs(((-4.0 - x) / y));
} else {
tmp = Math.abs((z * (x / y)));
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -1.2e+24: tmp = math.fabs((x / (y / z))) elif z <= 1.6e+50: tmp = math.fabs(((-4.0 - x) / y)) else: tmp = math.fabs((z * (x / y))) return tmp
function code(x, y, z) tmp = 0.0 if (z <= -1.2e+24) tmp = abs(Float64(x / Float64(y / z))); elseif (z <= 1.6e+50) tmp = abs(Float64(Float64(-4.0 - x) / y)); else tmp = abs(Float64(z * Float64(x / y))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -1.2e+24) tmp = abs((x / (y / z))); elseif (z <= 1.6e+50) tmp = abs(((-4.0 - x) / y)); else tmp = abs((z * (x / y))); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -1.2e+24], N[Abs[N[(x / N[(y / z), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[z, 1.6e+50], N[Abs[N[(N[(-4.0 - x), $MachinePrecision] / y), $MachinePrecision]], $MachinePrecision], N[Abs[N[(z * N[(x / y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.2 \cdot 10^{+24}:\\
\;\;\;\;\left|\frac{x}{\frac{y}{z}}\right|\\
\mathbf{elif}\;z \leq 1.6 \cdot 10^{+50}:\\
\;\;\;\;\left|\frac{-4 - x}{y}\right|\\
\mathbf{else}:\\
\;\;\;\;\left|z \cdot \frac{x}{y}\right|\\
\end{array}
\end{array}
if z < -1.2e24Initial program 94.3%
Simplified87.7%
Taylor expanded in z around inf 68.1%
mul-1-neg68.1%
distribute-frac-neg68.1%
distribute-lft-neg-in68.1%
*-commutative68.1%
associate-*r/75.2%
Simplified75.2%
*-commutative75.2%
div-inv75.1%
associate-*l*74.2%
add-sqr-sqrt40.9%
sqrt-unprod59.4%
sqr-neg59.4%
sqrt-unprod33.1%
add-sqr-sqrt74.2%
associate-/r/74.2%
div-inv75.4%
Applied egg-rr75.4%
if -1.2e24 < z < 1.59999999999999991e50Initial program 94.5%
fabs-sub94.5%
associate-*l/97.2%
associate-*r/97.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 98.1%
associate-*r/98.1%
distribute-lft-in98.1%
metadata-eval98.1%
neg-mul-198.1%
sub-neg98.1%
Simplified98.1%
if 1.59999999999999991e50 < z Initial program 85.7%
Simplified86.5%
Taylor expanded in z around inf 70.9%
mul-1-neg70.9%
distribute-frac-neg70.9%
distribute-lft-neg-in70.9%
*-commutative70.9%
associate-*r/82.5%
Simplified82.5%
clear-num82.5%
un-div-inv82.5%
add-sqr-sqrt45.1%
sqrt-unprod66.8%
sqr-neg66.8%
sqrt-unprod37.3%
add-sqr-sqrt82.5%
Applied egg-rr82.5%
clear-num82.5%
associate-/r/82.5%
clear-num82.5%
Applied egg-rr82.5%
Final simplification89.6%
(FPCore (x y z) :precision binary64 (if (or (<= x -7.3) (not (<= x 4.0))) (fabs (/ x y)) (fabs (/ 4.0 y))))
double code(double x, double y, double z) {
double tmp;
if ((x <= -7.3) || !(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 <= (-7.3d0)) .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 <= -7.3) || !(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 <= -7.3) 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 <= -7.3) || !(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 <= -7.3) || ~((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, -7.3], 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 -7.3 \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 < -7.29999999999999982 or 4 < x Initial program 89.9%
Simplified89.8%
Taylor expanded in x around inf 89.3%
mul-1-neg89.3%
associate-/l*99.0%
distribute-rgt-neg-in99.0%
neg-sub099.0%
div099.0%
div-sub99.0%
associate-+l-99.0%
neg-sub099.0%
+-commutative99.0%
unsub-neg99.0%
Simplified99.0%
Taylor expanded in z around 0 63.8%
if -7.29999999999999982 < x < 4Initial program 96.2%
Simplified99.8%
Taylor expanded in x around 0 75.9%
Final simplification69.3%
(FPCore (x y z) :precision binary64 (if (<= x -1.22e-26) (fabs (* z (/ x y))) (if (<= x 4.0) (fabs (/ 4.0 y)) (fabs (/ x y)))))
double code(double x, double y, double z) {
double tmp;
if (x <= -1.22e-26) {
tmp = fabs((z * (x / y)));
} 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 <= (-1.22d-26)) then
tmp = abs((z * (x / y)))
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 <= -1.22e-26) {
tmp = Math.abs((z * (x / y)));
} 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 <= -1.22e-26: tmp = math.fabs((z * (x / y))) 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 <= -1.22e-26) tmp = abs(Float64(z * Float64(x / y))); 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 <= -1.22e-26) tmp = abs((z * (x / y))); 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, -1.22e-26], N[Abs[N[(z * N[(x / y), $MachinePrecision]), $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 -1.22 \cdot 10^{-26}:\\
\;\;\;\;\left|z \cdot \frac{x}{y}\right|\\
\mathbf{elif}\;x \leq 4:\\
\;\;\;\;\left|\frac{4}{y}\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\frac{x}{y}\right|\\
\end{array}
\end{array}
if x < -1.22e-26Initial program 90.6%
Simplified88.5%
Taylor expanded in z around inf 49.7%
mul-1-neg49.7%
distribute-frac-neg49.7%
distribute-lft-neg-in49.7%
*-commutative49.7%
associate-*r/72.2%
Simplified72.2%
clear-num72.2%
un-div-inv68.5%
add-sqr-sqrt68.4%
sqrt-unprod53.9%
sqr-neg53.9%
sqrt-unprod0.0%
add-sqr-sqrt68.5%
Applied egg-rr68.5%
clear-num68.5%
associate-/r/72.2%
clear-num72.2%
Applied egg-rr72.2%
if -1.22e-26 < x < 4Initial program 96.0%
Simplified99.8%
Taylor expanded in x around 0 78.4%
if 4 < x Initial program 89.9%
Simplified91.8%
Taylor expanded in x around inf 90.9%
mul-1-neg90.9%
associate-/l*98.6%
distribute-rgt-neg-in98.6%
neg-sub098.6%
div098.6%
div-sub98.6%
associate-+l-98.6%
neg-sub098.6%
+-commutative98.6%
unsub-neg98.6%
Simplified98.6%
Taylor expanded in z around 0 70.8%
Final simplification74.5%
(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 92.8%
Simplified94.3%
Taylor expanded in x around 0 37.2%
Final simplification37.2%
herbie shell --seed 2024055
(FPCore (x y z)
:name "fabs fraction 1"
:precision binary64
(fabs (- (/ (+ x 4.0) y) (* (/ x y) z))))