
(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 10 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 (<= (fabs (- (/ (+ x 4.0) y) (* (/ x y) z))) 2e-69) (fabs (/ (- (+ x 4.0) (* x z)) y)) (fabs (+ (/ 4.0 y) (* (/ x y) (- 1.0 z))))))
double code(double x, double y, double z) {
double tmp;
if (fabs((((x + 4.0) / y) - ((x / y) * z))) <= 2e-69) {
tmp = fabs((((x + 4.0) - (x * z)) / y));
} else {
tmp = fabs(((4.0 / y) + ((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 (abs((((x + 4.0d0) / y) - ((x / y) * z))) <= 2d-69) then
tmp = abs((((x + 4.0d0) - (x * z)) / y))
else
tmp = abs(((4.0d0 / y) + ((x / y) * (1.0d0 - z))))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (Math.abs((((x + 4.0) / y) - ((x / y) * z))) <= 2e-69) {
tmp = Math.abs((((x + 4.0) - (x * z)) / y));
} else {
tmp = Math.abs(((4.0 / y) + ((x / y) * (1.0 - z))));
}
return tmp;
}
def code(x, y, z): tmp = 0 if math.fabs((((x + 4.0) / y) - ((x / y) * z))) <= 2e-69: tmp = math.fabs((((x + 4.0) - (x * z)) / y)) else: tmp = math.fabs(((4.0 / y) + ((x / y) * (1.0 - z)))) return tmp
function code(x, y, z) tmp = 0.0 if (abs(Float64(Float64(Float64(x + 4.0) / y) - Float64(Float64(x / y) * z))) <= 2e-69) tmp = abs(Float64(Float64(Float64(x + 4.0) - Float64(x * z)) / y)); else tmp = abs(Float64(Float64(4.0 / y) + Float64(Float64(x / y) * Float64(1.0 - z)))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (abs((((x + 4.0) / y) - ((x / y) * z))) <= 2e-69) tmp = abs((((x + 4.0) - (x * z)) / y)); else tmp = abs(((4.0 / y) + ((x / y) * (1.0 - z)))); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[N[Abs[N[(N[(N[(x + 4.0), $MachinePrecision] / y), $MachinePrecision] - N[(N[(x / y), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2e-69], N[Abs[N[(N[(N[(x + 4.0), $MachinePrecision] - N[(x * z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[(4.0 / y), $MachinePrecision] + N[(N[(x / y), $MachinePrecision] * N[(1.0 - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \leq 2 \cdot 10^{-69}:\\
\;\;\;\;\left|\frac{\left(x + 4\right) - x \cdot z}{y}\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\frac{4}{y} + \frac{x}{y} \cdot \left(1 - z\right)\right|\\
\end{array}
\end{array}
if (fabs.f64 (-.f64 (/.f64 (+.f64 x #s(literal 4 binary64)) y) (*.f64 (/.f64 x y) z))) < 1.9999999999999999e-69Initial program 91.1%
fabs-lowering-fabs.f64N/A
associate-*l/N/A
sub-divN/A
flip3-+N/A
div-invN/A
fmm-defN/A
*-commutativeN/A
/-lowering-/.f64N/A
Applied egg-rr99.8%
if 1.9999999999999999e-69 < (fabs.f64 (-.f64 (/.f64 (+.f64 x #s(literal 4 binary64)) y) (*.f64 (/.f64 x y) z))) Initial program 93.2%
fabs-lowering-fabs.f64N/A
sub-negN/A
+-commutativeN/A
neg-sub0N/A
associate-+l-N/A
sub0-negN/A
neg-mul-1N/A
distribute-rgt-out--N/A
*-commutativeN/A
neg-mul-1N/A
associate-*l/N/A
*-commutativeN/A
neg-mul-1N/A
distribute-neg-inN/A
sub-negN/A
div-subN/A
distribute-neg-fracN/A
associate--r-N/A
+-commutativeN/A
+-lowering-+.f64N/A
/-lowering-/.f64N/A
sub-negN/A
Simplified99.9%
Final simplification99.9%
(FPCore (x y z) :precision binary64 (let* ((t_0 (fabs (* (/ x y) (- 1.0 z))))) (if (<= x -1.5) t_0 (if (<= x 0.07) (fabs (/ (- (* x z) 4.0) y)) t_0))))
double code(double x, double y, double z) {
double t_0 = fabs(((x / y) * (1.0 - z)));
double tmp;
if (x <= -1.5) {
tmp = t_0;
} else if (x <= 0.07) {
tmp = fabs((((x * z) - 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) * (1.0d0 - z)))
if (x <= (-1.5d0)) then
tmp = t_0
else if (x <= 0.07d0) then
tmp = abs((((x * z) - 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) * (1.0 - z)));
double tmp;
if (x <= -1.5) {
tmp = t_0;
} else if (x <= 0.07) {
tmp = Math.abs((((x * z) - 4.0) / y));
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = math.fabs(((x / y) * (1.0 - z))) tmp = 0 if x <= -1.5: tmp = t_0 elif x <= 0.07: tmp = math.fabs((((x * z) - 4.0) / y)) else: tmp = t_0 return tmp
function code(x, y, z) t_0 = abs(Float64(Float64(x / y) * Float64(1.0 - z))) tmp = 0.0 if (x <= -1.5) tmp = t_0; elseif (x <= 0.07) tmp = abs(Float64(Float64(Float64(x * z) - 4.0) / y)); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = abs(((x / y) * (1.0 - z))); tmp = 0.0; if (x <= -1.5) tmp = t_0; elseif (x <= 0.07) tmp = abs((((x * z) - 4.0) / y)); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[Abs[N[(N[(x / y), $MachinePrecision] * N[(1.0 - z), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[x, -1.5], t$95$0, If[LessEqual[x, 0.07], N[Abs[N[(N[(N[(x * z), $MachinePrecision] - 4.0), $MachinePrecision] / y), $MachinePrecision]], $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left|\frac{x}{y} \cdot \left(1 - z\right)\right|\\
\mathbf{if}\;x \leq -1.5:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 0.07:\\
\;\;\;\;\left|\frac{x \cdot z - 4}{y}\right|\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -1.5 or 0.070000000000000007 < x Initial program 89.7%
fabs-lowering-fabs.f64N/A
sub-negN/A
+-commutativeN/A
neg-sub0N/A
associate-+l-N/A
sub0-negN/A
neg-mul-1N/A
distribute-rgt-out--N/A
*-commutativeN/A
neg-mul-1N/A
associate-*l/N/A
*-commutativeN/A
neg-mul-1N/A
distribute-neg-inN/A
sub-negN/A
div-subN/A
distribute-neg-fracN/A
associate--r-N/A
+-commutativeN/A
+-lowering-+.f64N/A
/-lowering-/.f64N/A
sub-negN/A
Simplified99.9%
Taylor expanded in x around inf
div-subN/A
associate-/l*N/A
/-lowering-/.f64N/A
*-lowering-*.f64N/A
--lowering--.f6492.7%
Simplified92.7%
*-commutativeN/A
associate-/l*N/A
*-lowering-*.f64N/A
--lowering--.f64N/A
/-lowering-/.f6497.5%
Applied egg-rr97.5%
if -1.5 < x < 0.070000000000000007Initial program 96.4%
Taylor expanded in x around 0
/-lowering-/.f6495.9%
Simplified95.9%
fabs-subN/A
fabs-lowering-fabs.f64N/A
associate-*l/N/A
sub-divN/A
/-lowering-/.f64N/A
--lowering--.f64N/A
*-commutativeN/A
*-lowering-*.f6499.4%
Applied egg-rr99.4%
Final simplification98.4%
(FPCore (x y z) :precision binary64 (if (<= z -1.45e+77) (fabs (* (/ x y) z)) (if (<= z 4.2e-8) (fabs (/ (+ x 4.0) y)) (fabs (* x (/ (- 1.0 z) y))))))
double code(double x, double y, double z) {
double tmp;
if (z <= -1.45e+77) {
tmp = fabs(((x / y) * z));
} else if (z <= 4.2e-8) {
tmp = fabs(((x + 4.0) / 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 <= (-1.45d+77)) then
tmp = abs(((x / y) * z))
else if (z <= 4.2d-8) then
tmp = abs(((x + 4.0d0) / 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 <= -1.45e+77) {
tmp = Math.abs(((x / y) * z));
} else if (z <= 4.2e-8) {
tmp = Math.abs(((x + 4.0) / y));
} else {
tmp = Math.abs((x * ((1.0 - z) / y)));
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -1.45e+77: tmp = math.fabs(((x / y) * z)) elif z <= 4.2e-8: tmp = math.fabs(((x + 4.0) / y)) else: tmp = math.fabs((x * ((1.0 - z) / y))) return tmp
function code(x, y, z) tmp = 0.0 if (z <= -1.45e+77) tmp = abs(Float64(Float64(x / y) * z)); elseif (z <= 4.2e-8) tmp = abs(Float64(Float64(x + 4.0) / 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 <= -1.45e+77) tmp = abs(((x / y) * z)); elseif (z <= 4.2e-8) tmp = abs(((x + 4.0) / y)); else tmp = abs((x * ((1.0 - z) / y))); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -1.45e+77], N[Abs[N[(N[(x / y), $MachinePrecision] * z), $MachinePrecision]], $MachinePrecision], If[LessEqual[z, 4.2e-8], N[Abs[N[(N[(x + 4.0), $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 -1.45 \cdot 10^{+77}:\\
\;\;\;\;\left|\frac{x}{y} \cdot z\right|\\
\mathbf{elif}\;z \leq 4.2 \cdot 10^{-8}:\\
\;\;\;\;\left|\frac{x + 4}{y}\right|\\
\mathbf{else}:\\
\;\;\;\;\left|x \cdot \frac{1 - z}{y}\right|\\
\end{array}
\end{array}
if z < -1.4500000000000001e77Initial program 98.9%
Taylor expanded in x around 0
/-lowering-/.f6498.9%
Simplified98.9%
fabs-subN/A
fabs-lowering-fabs.f64N/A
associate-*l/N/A
sub-divN/A
/-lowering-/.f64N/A
--lowering--.f64N/A
*-commutativeN/A
*-lowering-*.f6496.5%
Applied egg-rr96.5%
Taylor expanded in z around inf
/-lowering-/.f64N/A
*-lowering-*.f6485.3%
Simplified85.3%
clear-numN/A
associate-/r/N/A
associate-*r*N/A
*-lowering-*.f64N/A
*-commutativeN/A
div-invN/A
/-lowering-/.f6487.8%
Applied egg-rr87.8%
if -1.4500000000000001e77 < z < 4.19999999999999989e-8Initial program 96.2%
fabs-lowering-fabs.f64N/A
sub-negN/A
+-commutativeN/A
neg-sub0N/A
associate-+l-N/A
sub0-negN/A
neg-mul-1N/A
distribute-rgt-out--N/A
*-commutativeN/A
neg-mul-1N/A
associate-*l/N/A
*-commutativeN/A
neg-mul-1N/A
distribute-neg-inN/A
sub-negN/A
div-subN/A
distribute-neg-fracN/A
associate--r-N/A
+-commutativeN/A
+-lowering-+.f64N/A
/-lowering-/.f64N/A
sub-negN/A
Simplified100.0%
Taylor expanded in z around 0
*-rgt-identityN/A
associate-*r/N/A
distribute-rgt-outN/A
associate-*l/N/A
metadata-evalN/A
distribute-lft-neg-inN/A
distribute-frac-negN/A
mul-1-negN/A
distribute-frac-negN/A
remove-double-negN/A
/-lowering-/.f64N/A
+-lowering-+.f6495.2%
Simplified95.2%
if 4.19999999999999989e-8 < z Initial program 80.7%
fabs-lowering-fabs.f64N/A
sub-negN/A
+-commutativeN/A
neg-sub0N/A
associate-+l-N/A
sub0-negN/A
neg-mul-1N/A
distribute-rgt-out--N/A
*-commutativeN/A
neg-mul-1N/A
associate-*l/N/A
*-commutativeN/A
neg-mul-1N/A
distribute-neg-inN/A
sub-negN/A
div-subN/A
distribute-neg-fracN/A
associate--r-N/A
+-commutativeN/A
+-lowering-+.f64N/A
/-lowering-/.f64N/A
sub-negN/A
Simplified94.3%
Taylor expanded in x around inf
div-subN/A
associate-/l*N/A
/-lowering-/.f64N/A
*-lowering-*.f64N/A
--lowering--.f6472.1%
Simplified72.1%
associate-/l*N/A
*-commutativeN/A
*-lowering-*.f64N/A
/-lowering-/.f64N/A
--lowering--.f6476.5%
Applied egg-rr76.5%
Final simplification88.7%
(FPCore (x y z) :precision binary64 (if (<= z -4.4e+76) (fabs (* (/ x y) z)) (if (<= z 2.2e-7) (fabs (/ (+ x 4.0) y)) (fabs (* (/ x y) (- 1.0 z))))))
double code(double x, double y, double z) {
double tmp;
if (z <= -4.4e+76) {
tmp = fabs(((x / y) * z));
} else if (z <= 2.2e-7) {
tmp = fabs(((x + 4.0) / 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 (z <= (-4.4d+76)) then
tmp = abs(((x / y) * z))
else if (z <= 2.2d-7) then
tmp = abs(((x + 4.0d0) / 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 (z <= -4.4e+76) {
tmp = Math.abs(((x / y) * z));
} else if (z <= 2.2e-7) {
tmp = Math.abs(((x + 4.0) / y));
} else {
tmp = Math.abs(((x / y) * (1.0 - z)));
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -4.4e+76: tmp = math.fabs(((x / y) * z)) elif z <= 2.2e-7: tmp = math.fabs(((x + 4.0) / y)) else: tmp = math.fabs(((x / y) * (1.0 - z))) return tmp
function code(x, y, z) tmp = 0.0 if (z <= -4.4e+76) tmp = abs(Float64(Float64(x / y) * z)); elseif (z <= 2.2e-7) tmp = abs(Float64(Float64(x + 4.0) / y)); else tmp = abs(Float64(Float64(x / y) * Float64(1.0 - z))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -4.4e+76) tmp = abs(((x / y) * z)); elseif (z <= 2.2e-7) tmp = abs(((x + 4.0) / y)); else tmp = abs(((x / y) * (1.0 - z))); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -4.4e+76], N[Abs[N[(N[(x / y), $MachinePrecision] * z), $MachinePrecision]], $MachinePrecision], If[LessEqual[z, 2.2e-7], N[Abs[N[(N[(x + 4.0), $MachinePrecision] / y), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[(x / y), $MachinePrecision] * N[(1.0 - z), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -4.4 \cdot 10^{+76}:\\
\;\;\;\;\left|\frac{x}{y} \cdot z\right|\\
\mathbf{elif}\;z \leq 2.2 \cdot 10^{-7}:\\
\;\;\;\;\left|\frac{x + 4}{y}\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\frac{x}{y} \cdot \left(1 - z\right)\right|\\
\end{array}
\end{array}
if z < -4.4000000000000001e76Initial program 98.9%
Taylor expanded in x around 0
/-lowering-/.f6498.9%
Simplified98.9%
fabs-subN/A
fabs-lowering-fabs.f64N/A
associate-*l/N/A
sub-divN/A
/-lowering-/.f64N/A
--lowering--.f64N/A
*-commutativeN/A
*-lowering-*.f6496.5%
Applied egg-rr96.5%
Taylor expanded in z around inf
/-lowering-/.f64N/A
*-lowering-*.f6485.3%
Simplified85.3%
clear-numN/A
associate-/r/N/A
associate-*r*N/A
*-lowering-*.f64N/A
*-commutativeN/A
div-invN/A
/-lowering-/.f6487.8%
Applied egg-rr87.8%
if -4.4000000000000001e76 < z < 2.2000000000000001e-7Initial program 96.2%
fabs-lowering-fabs.f64N/A
sub-negN/A
+-commutativeN/A
neg-sub0N/A
associate-+l-N/A
sub0-negN/A
neg-mul-1N/A
distribute-rgt-out--N/A
*-commutativeN/A
neg-mul-1N/A
associate-*l/N/A
*-commutativeN/A
neg-mul-1N/A
distribute-neg-inN/A
sub-negN/A
div-subN/A
distribute-neg-fracN/A
associate--r-N/A
+-commutativeN/A
+-lowering-+.f64N/A
/-lowering-/.f64N/A
sub-negN/A
Simplified100.0%
Taylor expanded in z around 0
*-rgt-identityN/A
associate-*r/N/A
distribute-rgt-outN/A
associate-*l/N/A
metadata-evalN/A
distribute-lft-neg-inN/A
distribute-frac-negN/A
mul-1-negN/A
distribute-frac-negN/A
remove-double-negN/A
/-lowering-/.f64N/A
+-lowering-+.f6495.2%
Simplified95.2%
if 2.2000000000000001e-7 < z Initial program 80.7%
fabs-lowering-fabs.f64N/A
sub-negN/A
+-commutativeN/A
neg-sub0N/A
associate-+l-N/A
sub0-negN/A
neg-mul-1N/A
distribute-rgt-out--N/A
*-commutativeN/A
neg-mul-1N/A
associate-*l/N/A
*-commutativeN/A
neg-mul-1N/A
distribute-neg-inN/A
sub-negN/A
div-subN/A
distribute-neg-fracN/A
associate--r-N/A
+-commutativeN/A
+-lowering-+.f64N/A
/-lowering-/.f64N/A
sub-negN/A
Simplified94.3%
Taylor expanded in x around inf
div-subN/A
associate-/l*N/A
/-lowering-/.f64N/A
*-lowering-*.f64N/A
--lowering--.f6472.1%
Simplified72.1%
*-commutativeN/A
associate-/l*N/A
*-lowering-*.f64N/A
--lowering--.f64N/A
/-lowering-/.f6475.4%
Applied egg-rr75.4%
Final simplification88.4%
(FPCore (x y z) :precision binary64 (if (<= y 3.3e+78) (fabs (/ (- (+ x 4.0) (* x z)) y)) (fabs (+ (/ 4.0 y) (* x (/ (- 1.0 z) y))))))
double code(double x, double y, double z) {
double tmp;
if (y <= 3.3e+78) {
tmp = fabs((((x + 4.0) - (x * z)) / y));
} else {
tmp = fabs(((4.0 / y) + (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 (y <= 3.3d+78) then
tmp = abs((((x + 4.0d0) - (x * z)) / y))
else
tmp = abs(((4.0d0 / y) + (x * ((1.0d0 - z) / y))))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= 3.3e+78) {
tmp = Math.abs((((x + 4.0) - (x * z)) / y));
} else {
tmp = Math.abs(((4.0 / y) + (x * ((1.0 - z) / y))));
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 3.3e+78: tmp = math.fabs((((x + 4.0) - (x * z)) / y)) else: tmp = math.fabs(((4.0 / y) + (x * ((1.0 - z) / y)))) return tmp
function code(x, y, z) tmp = 0.0 if (y <= 3.3e+78) tmp = abs(Float64(Float64(Float64(x + 4.0) - Float64(x * z)) / y)); else tmp = abs(Float64(Float64(4.0 / y) + Float64(x * Float64(Float64(1.0 - z) / y)))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 3.3e+78) tmp = abs((((x + 4.0) - (x * z)) / y)); else tmp = abs(((4.0 / y) + (x * ((1.0 - z) / y)))); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 3.3e+78], N[Abs[N[(N[(N[(x + 4.0), $MachinePrecision] - N[(x * z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[(4.0 / y), $MachinePrecision] + N[(x * N[(N[(1.0 - z), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 3.3 \cdot 10^{+78}:\\
\;\;\;\;\left|\frac{\left(x + 4\right) - x \cdot z}{y}\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\frac{4}{y} + x \cdot \frac{1 - z}{y}\right|\\
\end{array}
\end{array}
if y < 3.3e78Initial program 92.9%
fabs-lowering-fabs.f64N/A
associate-*l/N/A
sub-divN/A
flip3-+N/A
div-invN/A
fmm-defN/A
*-commutativeN/A
/-lowering-/.f64N/A
Applied egg-rr98.6%
if 3.3e78 < y Initial program 92.1%
fabs-lowering-fabs.f64N/A
sub-negN/A
+-commutativeN/A
neg-sub0N/A
associate-+l-N/A
sub0-negN/A
neg-mul-1N/A
distribute-rgt-out--N/A
*-commutativeN/A
neg-mul-1N/A
associate-*l/N/A
*-commutativeN/A
neg-mul-1N/A
distribute-neg-inN/A
sub-negN/A
div-subN/A
distribute-neg-fracN/A
associate--r-N/A
+-commutativeN/A
+-lowering-+.f64N/A
/-lowering-/.f64N/A
sub-negN/A
Simplified92.1%
associate-*l/N/A
associate-/l*N/A
*-lowering-*.f64N/A
/-lowering-/.f64N/A
--lowering--.f6499.8%
Applied egg-rr99.8%
Final simplification98.7%
(FPCore (x y z) :precision binary64 (if (<= z -3e+78) (fabs (* (/ x y) z)) (if (<= z 2.5e+72) (fabs (/ (+ x 4.0) y)) (fabs (/ x (/ y z))))))
double code(double x, double y, double z) {
double tmp;
if (z <= -3e+78) {
tmp = fabs(((x / y) * z));
} else if (z <= 2.5e+72) {
tmp = fabs(((x + 4.0) / y));
} else {
tmp = fabs((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 (z <= (-3d+78)) then
tmp = abs(((x / y) * z))
else if (z <= 2.5d+72) then
tmp = abs(((x + 4.0d0) / y))
else
tmp = abs((x / (y / z)))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -3e+78) {
tmp = Math.abs(((x / y) * z));
} else if (z <= 2.5e+72) {
tmp = Math.abs(((x + 4.0) / y));
} else {
tmp = Math.abs((x / (y / z)));
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -3e+78: tmp = math.fabs(((x / y) * z)) elif z <= 2.5e+72: tmp = math.fabs(((x + 4.0) / y)) else: tmp = math.fabs((x / (y / z))) return tmp
function code(x, y, z) tmp = 0.0 if (z <= -3e+78) tmp = abs(Float64(Float64(x / y) * z)); elseif (z <= 2.5e+72) tmp = abs(Float64(Float64(x + 4.0) / y)); else tmp = abs(Float64(x / Float64(y / z))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -3e+78) tmp = abs(((x / y) * z)); elseif (z <= 2.5e+72) tmp = abs(((x + 4.0) / y)); else tmp = abs((x / (y / z))); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -3e+78], N[Abs[N[(N[(x / y), $MachinePrecision] * z), $MachinePrecision]], $MachinePrecision], If[LessEqual[z, 2.5e+72], N[Abs[N[(N[(x + 4.0), $MachinePrecision] / y), $MachinePrecision]], $MachinePrecision], N[Abs[N[(x / N[(y / z), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -3 \cdot 10^{+78}:\\
\;\;\;\;\left|\frac{x}{y} \cdot z\right|\\
\mathbf{elif}\;z \leq 2.5 \cdot 10^{+72}:\\
\;\;\;\;\left|\frac{x + 4}{y}\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\frac{x}{\frac{y}{z}}\right|\\
\end{array}
\end{array}
if z < -2.99999999999999982e78Initial program 98.9%
Taylor expanded in x around 0
/-lowering-/.f6498.9%
Simplified98.9%
fabs-subN/A
fabs-lowering-fabs.f64N/A
associate-*l/N/A
sub-divN/A
/-lowering-/.f64N/A
--lowering--.f64N/A
*-commutativeN/A
*-lowering-*.f6496.5%
Applied egg-rr96.5%
Taylor expanded in z around inf
/-lowering-/.f64N/A
*-lowering-*.f6485.3%
Simplified85.3%
clear-numN/A
associate-/r/N/A
associate-*r*N/A
*-lowering-*.f64N/A
*-commutativeN/A
div-invN/A
/-lowering-/.f6487.8%
Applied egg-rr87.8%
if -2.99999999999999982e78 < z < 2.49999999999999996e72Initial program 95.8%
fabs-lowering-fabs.f64N/A
sub-negN/A
+-commutativeN/A
neg-sub0N/A
associate-+l-N/A
sub0-negN/A
neg-mul-1N/A
distribute-rgt-out--N/A
*-commutativeN/A
neg-mul-1N/A
associate-*l/N/A
*-commutativeN/A
neg-mul-1N/A
distribute-neg-inN/A
sub-negN/A
div-subN/A
distribute-neg-fracN/A
associate--r-N/A
+-commutativeN/A
+-lowering-+.f64N/A
/-lowering-/.f64N/A
sub-negN/A
Simplified99.9%
Taylor expanded in z around 0
*-rgt-identityN/A
associate-*r/N/A
distribute-rgt-outN/A
associate-*l/N/A
metadata-evalN/A
distribute-lft-neg-inN/A
distribute-frac-negN/A
mul-1-negN/A
distribute-frac-negN/A
remove-double-negN/A
/-lowering-/.f64N/A
+-lowering-+.f6492.2%
Simplified92.2%
if 2.49999999999999996e72 < z Initial program 78.7%
Taylor expanded in x around 0
/-lowering-/.f6493.3%
Simplified93.3%
fabs-subN/A
fabs-lowering-fabs.f64N/A
associate-*l/N/A
sub-divN/A
/-lowering-/.f64N/A
--lowering--.f64N/A
*-commutativeN/A
*-lowering-*.f6491.3%
Applied egg-rr91.3%
Taylor expanded in z around inf
/-lowering-/.f64N/A
*-lowering-*.f6473.6%
Simplified73.6%
associate-/l*N/A
clear-numN/A
un-div-invN/A
/-lowering-/.f64N/A
/-lowering-/.f6478.9%
Applied egg-rr78.9%
Final simplification88.4%
(FPCore (x y z) :precision binary64 (if (<= x -1.5) (fabs (/ x y)) (if (<= x 2.05e-113) (fabs (/ 4.0 y)) (fabs (* (/ x y) z)))))
double code(double x, double y, double z) {
double tmp;
if (x <= -1.5) {
tmp = fabs((x / y));
} else if (x <= 2.05e-113) {
tmp = fabs((4.0 / y));
} else {
tmp = fabs(((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 (x <= (-1.5d0)) then
tmp = abs((x / y))
else if (x <= 2.05d-113) then
tmp = abs((4.0d0 / y))
else
tmp = abs(((x / y) * z))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (x <= -1.5) {
tmp = Math.abs((x / y));
} else if (x <= 2.05e-113) {
tmp = Math.abs((4.0 / y));
} else {
tmp = Math.abs(((x / y) * z));
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -1.5: tmp = math.fabs((x / y)) elif x <= 2.05e-113: tmp = math.fabs((4.0 / y)) else: tmp = math.fabs(((x / y) * z)) return tmp
function code(x, y, z) tmp = 0.0 if (x <= -1.5) tmp = abs(Float64(x / y)); elseif (x <= 2.05e-113) tmp = abs(Float64(4.0 / y)); else tmp = abs(Float64(Float64(x / y) * z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= -1.5) tmp = abs((x / y)); elseif (x <= 2.05e-113) tmp = abs((4.0 / y)); else tmp = abs(((x / y) * z)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -1.5], N[Abs[N[(x / y), $MachinePrecision]], $MachinePrecision], If[LessEqual[x, 2.05e-113], N[Abs[N[(4.0 / y), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[(x / y), $MachinePrecision] * z), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.5:\\
\;\;\;\;\left|\frac{x}{y}\right|\\
\mathbf{elif}\;x \leq 2.05 \cdot 10^{-113}:\\
\;\;\;\;\left|\frac{4}{y}\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\frac{x}{y} \cdot z\right|\\
\end{array}
\end{array}
if x < -1.5Initial program 87.2%
fabs-lowering-fabs.f64N/A
sub-negN/A
+-commutativeN/A
neg-sub0N/A
associate-+l-N/A
sub0-negN/A
neg-mul-1N/A
distribute-rgt-out--N/A
*-commutativeN/A
neg-mul-1N/A
associate-*l/N/A
*-commutativeN/A
neg-mul-1N/A
distribute-neg-inN/A
sub-negN/A
div-subN/A
distribute-neg-fracN/A
associate--r-N/A
+-commutativeN/A
+-lowering-+.f64N/A
/-lowering-/.f64N/A
sub-negN/A
Simplified99.9%
Taylor expanded in z around 0
/-lowering-/.f6467.5%
Simplified67.5%
Taylor expanded in x around inf
/-lowering-/.f6464.8%
Simplified64.8%
if -1.5 < x < 2.05e-113Initial program 96.1%
fabs-lowering-fabs.f64N/A
sub-negN/A
+-commutativeN/A
neg-sub0N/A
associate-+l-N/A
sub0-negN/A
neg-mul-1N/A
distribute-rgt-out--N/A
*-commutativeN/A
neg-mul-1N/A
associate-*l/N/A
*-commutativeN/A
neg-mul-1N/A
distribute-neg-inN/A
sub-negN/A
div-subN/A
distribute-neg-fracN/A
associate--r-N/A
+-commutativeN/A
+-lowering-+.f64N/A
/-lowering-/.f64N/A
sub-negN/A
Simplified96.1%
Taylor expanded in x around 0
/-lowering-/.f6478.1%
Simplified78.1%
if 2.05e-113 < x Initial program 93.8%
Taylor expanded in x around 0
/-lowering-/.f6476.3%
Simplified76.3%
fabs-subN/A
fabs-lowering-fabs.f64N/A
associate-*l/N/A
sub-divN/A
/-lowering-/.f64N/A
--lowering--.f64N/A
*-commutativeN/A
*-lowering-*.f6468.5%
Applied egg-rr68.5%
Taylor expanded in z around inf
/-lowering-/.f64N/A
*-lowering-*.f6456.0%
Simplified56.0%
clear-numN/A
associate-/r/N/A
associate-*r*N/A
*-lowering-*.f64N/A
*-commutativeN/A
div-invN/A
/-lowering-/.f6463.7%
Applied egg-rr63.7%
(FPCore (x y z) :precision binary64 (let* ((t_0 (fabs (/ x y)))) (if (<= x -1.55) t_0 (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.55) {
tmp = t_0;
} 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.55d0)) then
tmp = t_0
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.55) {
tmp = t_0;
} 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.55: tmp = t_0 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.55) tmp = t_0; 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.55) tmp = t_0; 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.55], t$95$0, 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.55:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 4:\\
\;\;\;\;\left|\frac{4}{y}\right|\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -1.55000000000000004 or 4 < x Initial program 89.6%
fabs-lowering-fabs.f64N/A
sub-negN/A
+-commutativeN/A
neg-sub0N/A
associate-+l-N/A
sub0-negN/A
neg-mul-1N/A
distribute-rgt-out--N/A
*-commutativeN/A
neg-mul-1N/A
associate-*l/N/A
*-commutativeN/A
neg-mul-1N/A
distribute-neg-inN/A
sub-negN/A
div-subN/A
distribute-neg-fracN/A
associate--r-N/A
+-commutativeN/A
+-lowering-+.f64N/A
/-lowering-/.f64N/A
sub-negN/A
Simplified99.9%
Taylor expanded in z around 0
/-lowering-/.f6462.2%
Simplified62.2%
Taylor expanded in x around inf
/-lowering-/.f6459.8%
Simplified59.8%
if -1.55000000000000004 < x < 4Initial program 96.4%
fabs-lowering-fabs.f64N/A
sub-negN/A
+-commutativeN/A
neg-sub0N/A
associate-+l-N/A
sub0-negN/A
neg-mul-1N/A
distribute-rgt-out--N/A
*-commutativeN/A
neg-mul-1N/A
associate-*l/N/A
*-commutativeN/A
neg-mul-1N/A
distribute-neg-inN/A
sub-negN/A
div-subN/A
distribute-neg-fracN/A
associate--r-N/A
+-commutativeN/A
+-lowering-+.f64N/A
/-lowering-/.f64N/A
sub-negN/A
Simplified96.4%
Taylor expanded in x around 0
/-lowering-/.f6471.5%
Simplified71.5%
(FPCore (x y z) :precision binary64 (fabs (/ (- (+ x 4.0) (* x z)) y)))
double code(double x, double y, double z) {
return fabs((((x + 4.0) - (x * z)) / 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) - (x * z)) / y))
end function
public static double code(double x, double y, double z) {
return Math.abs((((x + 4.0) - (x * z)) / y));
}
def code(x, y, z): return math.fabs((((x + 4.0) - (x * z)) / y))
function code(x, y, z) return abs(Float64(Float64(Float64(x + 4.0) - Float64(x * z)) / y)) end
function tmp = code(x, y, z) tmp = abs((((x + 4.0) - (x * z)) / y)); end
code[x_, y_, z_] := N[Abs[N[(N[(N[(x + 4.0), $MachinePrecision] - N[(x * z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|\frac{\left(x + 4\right) - x \cdot z}{y}\right|
\end{array}
Initial program 92.8%
fabs-lowering-fabs.f64N/A
associate-*l/N/A
sub-divN/A
flip3-+N/A
div-invN/A
fmm-defN/A
*-commutativeN/A
/-lowering-/.f64N/A
Applied egg-rr97.3%
Final simplification97.3%
(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%
fabs-lowering-fabs.f64N/A
sub-negN/A
+-commutativeN/A
neg-sub0N/A
associate-+l-N/A
sub0-negN/A
neg-mul-1N/A
distribute-rgt-out--N/A
*-commutativeN/A
neg-mul-1N/A
associate-*l/N/A
*-commutativeN/A
neg-mul-1N/A
distribute-neg-inN/A
sub-negN/A
div-subN/A
distribute-neg-fracN/A
associate--r-N/A
+-commutativeN/A
+-lowering-+.f64N/A
/-lowering-/.f64N/A
sub-negN/A
Simplified98.3%
Taylor expanded in x around 0
/-lowering-/.f6436.4%
Simplified36.4%
herbie shell --seed 2024161
(FPCore (x y z)
:name "fabs fraction 1"
:precision binary64
(fabs (- (/ (+ x 4.0) y) (* (/ x y) z))))