
(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 (if (or (<= x -5e+17) (not (<= x 46000000000000.0))) (fabs (* (/ x y) (+ z -1.0))) (fabs (- (/ (+ 4.0 x) y) (/ (* x z) y)))))
double code(double x, double y, double z) {
double tmp;
if ((x <= -5e+17) || !(x <= 46000000000000.0)) {
tmp = fabs(((x / y) * (z + -1.0)));
} else {
tmp = fabs((((4.0 + x) / y) - ((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 <= (-5d+17)) .or. (.not. (x <= 46000000000000.0d0))) then
tmp = abs(((x / y) * (z + (-1.0d0))))
else
tmp = abs((((4.0d0 + x) / y) - ((x * z) / y)))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((x <= -5e+17) || !(x <= 46000000000000.0)) {
tmp = Math.abs(((x / y) * (z + -1.0)));
} else {
tmp = Math.abs((((4.0 + x) / y) - ((x * z) / y)));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -5e+17) or not (x <= 46000000000000.0): tmp = math.fabs(((x / y) * (z + -1.0))) else: tmp = math.fabs((((4.0 + x) / y) - ((x * z) / y))) return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -5e+17) || !(x <= 46000000000000.0)) tmp = abs(Float64(Float64(x / y) * Float64(z + -1.0))); else tmp = abs(Float64(Float64(Float64(4.0 + x) / y) - Float64(Float64(x * z) / y))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -5e+17) || ~((x <= 46000000000000.0))) tmp = abs(((x / y) * (z + -1.0))); else tmp = abs((((4.0 + x) / y) - ((x * z) / y))); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -5e+17], N[Not[LessEqual[x, 46000000000000.0]], $MachinePrecision]], N[Abs[N[(N[(x / y), $MachinePrecision] * N[(z + -1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[(N[(4.0 + x), $MachinePrecision] / y), $MachinePrecision] - N[(N[(x * z), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -5 \cdot 10^{+17} \lor \neg \left(x \leq 46000000000000\right):\\
\;\;\;\;\left|\frac{x}{y} \cdot \left(z + -1\right)\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\frac{4 + x}{y} - \frac{x \cdot z}{y}\right|\\
\end{array}
\end{array}
if x < -5e17 or 4.6e13 < x Initial program 89.7%
Simplified95.2%
Taylor expanded in x around inf 99.7%
Taylor expanded in z around 0 83.1%
associate-*l/89.7%
*-commutative89.7%
distribute-rgt-out100.0%
+-commutative100.0%
Simplified100.0%
if -5e17 < x < 4.6e13Initial program 96.7%
Simplified99.9%
Final simplification100.0%
(FPCore (x y z) :precision binary64 (if (<= y 1.9e+69) (fabs (/ (- (+ 4.0 x) (* x z)) y)) (fabs (fma x (/ z y) (/ (- -4.0 x) y)))))
double code(double x, double y, double z) {
double tmp;
if (y <= 1.9e+69) {
tmp = fabs((((4.0 + x) - (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 <= 1.9e+69) tmp = abs(Float64(Float64(Float64(4.0 + x) - 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, 1.9e+69], N[Abs[N[(N[(N[(4.0 + x), $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 1.9 \cdot 10^{+69}:\\
\;\;\;\;\left|\frac{\left(4 + x\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 < 1.90000000000000014e69Initial program 91.6%
Taylor expanded in y around 0 97.5%
if 1.90000000000000014e69 < y Initial program 98.0%
Simplified99.9%
Final simplification98.1%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (fabs (/ x y))) (t_1 (fabs (* x (/ z y)))))
(if (<= x -2.55e+73)
t_0
(if (<= x -5.2e-44)
t_1
(if (<= x 4.0)
(fabs (/ 4.0 y))
(if (or (<= x 2.3e+186) (not (<= x 1.75e+277))) t_0 t_1))))))
double code(double x, double y, double z) {
double t_0 = fabs((x / y));
double t_1 = fabs((x * (z / y)));
double tmp;
if (x <= -2.55e+73) {
tmp = t_0;
} else if (x <= -5.2e-44) {
tmp = t_1;
} else if (x <= 4.0) {
tmp = fabs((4.0 / y));
} else if ((x <= 2.3e+186) || !(x <= 1.75e+277)) {
tmp = t_0;
} else {
tmp = t_1;
}
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) :: t_1
real(8) :: tmp
t_0 = abs((x / y))
t_1 = abs((x * (z / y)))
if (x <= (-2.55d+73)) then
tmp = t_0
else if (x <= (-5.2d-44)) then
tmp = t_1
else if (x <= 4.0d0) then
tmp = abs((4.0d0 / y))
else if ((x <= 2.3d+186) .or. (.not. (x <= 1.75d+277))) then
tmp = t_0
else
tmp = t_1
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = Math.abs((x / y));
double t_1 = Math.abs((x * (z / y)));
double tmp;
if (x <= -2.55e+73) {
tmp = t_0;
} else if (x <= -5.2e-44) {
tmp = t_1;
} else if (x <= 4.0) {
tmp = Math.abs((4.0 / y));
} else if ((x <= 2.3e+186) || !(x <= 1.75e+277)) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z): t_0 = math.fabs((x / y)) t_1 = math.fabs((x * (z / y))) tmp = 0 if x <= -2.55e+73: tmp = t_0 elif x <= -5.2e-44: tmp = t_1 elif x <= 4.0: tmp = math.fabs((4.0 / y)) elif (x <= 2.3e+186) or not (x <= 1.75e+277): tmp = t_0 else: tmp = t_1 return tmp
function code(x, y, z) t_0 = abs(Float64(x / y)) t_1 = abs(Float64(x * Float64(z / y))) tmp = 0.0 if (x <= -2.55e+73) tmp = t_0; elseif (x <= -5.2e-44) tmp = t_1; elseif (x <= 4.0) tmp = abs(Float64(4.0 / y)); elseif ((x <= 2.3e+186) || !(x <= 1.75e+277)) tmp = t_0; else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z) t_0 = abs((x / y)); t_1 = abs((x * (z / y))); tmp = 0.0; if (x <= -2.55e+73) tmp = t_0; elseif (x <= -5.2e-44) tmp = t_1; elseif (x <= 4.0) tmp = abs((4.0 / y)); elseif ((x <= 2.3e+186) || ~((x <= 1.75e+277))) tmp = t_0; else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[Abs[N[(x / y), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Abs[N[(x * N[(z / y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[x, -2.55e+73], t$95$0, If[LessEqual[x, -5.2e-44], t$95$1, If[LessEqual[x, 4.0], N[Abs[N[(4.0 / y), $MachinePrecision]], $MachinePrecision], If[Or[LessEqual[x, 2.3e+186], N[Not[LessEqual[x, 1.75e+277]], $MachinePrecision]], t$95$0, t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left|\frac{x}{y}\right|\\
t_1 := \left|x \cdot \frac{z}{y}\right|\\
\mathbf{if}\;x \leq -2.55 \cdot 10^{+73}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq -5.2 \cdot 10^{-44}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq 4:\\
\;\;\;\;\left|\frac{4}{y}\right|\\
\mathbf{elif}\;x \leq 2.3 \cdot 10^{+186} \lor \neg \left(x \leq 1.75 \cdot 10^{+277}\right):\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if x < -2.55000000000000012e73 or 4 < x < 2.30000000000000013e186 or 1.7500000000000001e277 < x Initial program 91.2%
Simplified95.5%
Taylor expanded in x around inf 98.5%
Taylor expanded in z around 0 68.8%
neg-mul-168.8%
distribute-neg-frac68.8%
Simplified68.8%
if -2.55000000000000012e73 < x < -5.1999999999999996e-44 or 2.30000000000000013e186 < x < 1.7500000000000001e277Initial program 90.6%
Simplified96.0%
Taylor expanded in x around inf 96.6%
Taylor expanded in z around inf 60.8%
associate-*r/71.5%
Simplified71.5%
if -5.1999999999999996e-44 < x < 4Initial program 96.2%
Taylor expanded in x around 0 76.8%
Final simplification72.8%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (fabs (/ x y))) (t_1 (fabs (* z (/ x y)))))
(if (<= x -3.4e+81)
t_0
(if (<= x -9e-41)
t_1
(if (<= x 4.0) (fabs (/ 4.0 y)) (if (<= x 2.2e+186) t_0 t_1))))))
double code(double x, double y, double z) {
double t_0 = fabs((x / y));
double t_1 = fabs((z * (x / y)));
double tmp;
if (x <= -3.4e+81) {
tmp = t_0;
} else if (x <= -9e-41) {
tmp = t_1;
} else if (x <= 4.0) {
tmp = fabs((4.0 / y));
} else if (x <= 2.2e+186) {
tmp = t_0;
} else {
tmp = t_1;
}
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) :: t_1
real(8) :: tmp
t_0 = abs((x / y))
t_1 = abs((z * (x / y)))
if (x <= (-3.4d+81)) then
tmp = t_0
else if (x <= (-9d-41)) then
tmp = t_1
else if (x <= 4.0d0) then
tmp = abs((4.0d0 / y))
else if (x <= 2.2d+186) then
tmp = t_0
else
tmp = t_1
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = Math.abs((x / y));
double t_1 = Math.abs((z * (x / y)));
double tmp;
if (x <= -3.4e+81) {
tmp = t_0;
} else if (x <= -9e-41) {
tmp = t_1;
} else if (x <= 4.0) {
tmp = Math.abs((4.0 / y));
} else if (x <= 2.2e+186) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z): t_0 = math.fabs((x / y)) t_1 = math.fabs((z * (x / y))) tmp = 0 if x <= -3.4e+81: tmp = t_0 elif x <= -9e-41: tmp = t_1 elif x <= 4.0: tmp = math.fabs((4.0 / y)) elif x <= 2.2e+186: tmp = t_0 else: tmp = t_1 return tmp
function code(x, y, z) t_0 = abs(Float64(x / y)) t_1 = abs(Float64(z * Float64(x / y))) tmp = 0.0 if (x <= -3.4e+81) tmp = t_0; elseif (x <= -9e-41) tmp = t_1; elseif (x <= 4.0) tmp = abs(Float64(4.0 / y)); elseif (x <= 2.2e+186) tmp = t_0; else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z) t_0 = abs((x / y)); t_1 = abs((z * (x / y))); tmp = 0.0; if (x <= -3.4e+81) tmp = t_0; elseif (x <= -9e-41) tmp = t_1; elseif (x <= 4.0) tmp = abs((4.0 / y)); elseif (x <= 2.2e+186) tmp = t_0; else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[Abs[N[(x / y), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Abs[N[(z * N[(x / y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[x, -3.4e+81], t$95$0, If[LessEqual[x, -9e-41], t$95$1, If[LessEqual[x, 4.0], N[Abs[N[(4.0 / y), $MachinePrecision]], $MachinePrecision], If[LessEqual[x, 2.2e+186], t$95$0, t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left|\frac{x}{y}\right|\\
t_1 := \left|z \cdot \frac{x}{y}\right|\\
\mathbf{if}\;x \leq -3.4 \cdot 10^{+81}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq -9 \cdot 10^{-41}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq 4:\\
\;\;\;\;\left|\frac{4}{y}\right|\\
\mathbf{elif}\;x \leq 2.2 \cdot 10^{+186}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if x < -3.40000000000000003e81 or 4 < x < 2.1999999999999998e186Initial program 93.8%
Simplified96.3%
Taylor expanded in x around inf 98.3%
Taylor expanded in z around 0 66.5%
neg-mul-166.5%
distribute-neg-frac66.5%
Simplified66.5%
if -3.40000000000000003e81 < x < -9e-41 or 2.1999999999999998e186 < x Initial program 87.1%
Taylor expanded in z around inf 58.9%
mul-1-neg58.9%
associate-*l/77.2%
distribute-rgt-neg-out77.2%
Simplified77.2%
add-sqr-sqrt36.2%
sqrt-unprod60.0%
sqr-neg60.0%
sqrt-unprod40.7%
add-sqr-sqrt77.2%
associate-*l/58.9%
associate-/l*69.5%
Applied egg-rr69.5%
associate-/r/77.2%
Applied egg-rr77.2%
if -9e-41 < x < 4Initial program 96.2%
Taylor expanded in x around 0 76.8%
Final simplification73.6%
(FPCore (x y z) :precision binary64 (if (or (<= x -8.5e+16) (not (<= x 3.8e+43))) (fabs (* (/ x y) (+ z -1.0))) (fabs (/ (- (+ 4.0 x) (* x z)) y))))
double code(double x, double y, double z) {
double tmp;
if ((x <= -8.5e+16) || !(x <= 3.8e+43)) {
tmp = fabs(((x / y) * (z + -1.0)));
} else {
tmp = fabs((((4.0 + x) - (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 <= (-8.5d+16)) .or. (.not. (x <= 3.8d+43))) then
tmp = abs(((x / y) * (z + (-1.0d0))))
else
tmp = abs((((4.0d0 + x) - (x * z)) / y))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((x <= -8.5e+16) || !(x <= 3.8e+43)) {
tmp = Math.abs(((x / y) * (z + -1.0)));
} else {
tmp = Math.abs((((4.0 + x) - (x * z)) / y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -8.5e+16) or not (x <= 3.8e+43): tmp = math.fabs(((x / y) * (z + -1.0))) else: tmp = math.fabs((((4.0 + x) - (x * z)) / y)) return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -8.5e+16) || !(x <= 3.8e+43)) tmp = abs(Float64(Float64(x / y) * Float64(z + -1.0))); else tmp = abs(Float64(Float64(Float64(4.0 + x) - Float64(x * z)) / y)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -8.5e+16) || ~((x <= 3.8e+43))) tmp = abs(((x / y) * (z + -1.0))); else tmp = abs((((4.0 + x) - (x * z)) / y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -8.5e+16], N[Not[LessEqual[x, 3.8e+43]], $MachinePrecision]], N[Abs[N[(N[(x / y), $MachinePrecision] * N[(z + -1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[(N[(4.0 + x), $MachinePrecision] - N[(x * z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -8.5 \cdot 10^{+16} \lor \neg \left(x \leq 3.8 \cdot 10^{+43}\right):\\
\;\;\;\;\left|\frac{x}{y} \cdot \left(z + -1\right)\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\frac{\left(4 + x\right) - x \cdot z}{y}\right|\\
\end{array}
\end{array}
if x < -8.5e16 or 3.80000000000000008e43 < x Initial program 89.8%
Simplified94.8%
Taylor expanded in x around inf 99.7%
Taylor expanded in z around 0 82.7%
associate-*l/89.8%
*-commutative89.8%
distribute-rgt-out100.0%
+-commutative100.0%
Simplified100.0%
if -8.5e16 < x < 3.80000000000000008e43Initial program 96.2%
Taylor expanded in y around 0 99.9%
Final simplification100.0%
(FPCore (x y z) :precision binary64 (if (<= z -2.3e+66) (fabs (* z (/ x y))) (if (<= z 1.7e+43) (fabs (/ (- -4.0 x) y)) (fabs (* (/ x y) (+ z -1.0))))))
double code(double x, double y, double z) {
double tmp;
if (z <= -2.3e+66) {
tmp = fabs((z * (x / y)));
} else if (z <= 1.7e+43) {
tmp = fabs(((-4.0 - x) / y));
} else {
tmp = fabs(((x / y) * (z + -1.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) :: tmp
if (z <= (-2.3d+66)) then
tmp = abs((z * (x / y)))
else if (z <= 1.7d+43) then
tmp = abs((((-4.0d0) - x) / y))
else
tmp = abs(((x / y) * (z + (-1.0d0))))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -2.3e+66) {
tmp = Math.abs((z * (x / y)));
} else if (z <= 1.7e+43) {
tmp = Math.abs(((-4.0 - x) / y));
} else {
tmp = Math.abs(((x / y) * (z + -1.0)));
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -2.3e+66: tmp = math.fabs((z * (x / y))) elif z <= 1.7e+43: tmp = math.fabs(((-4.0 - x) / y)) else: tmp = math.fabs(((x / y) * (z + -1.0))) return tmp
function code(x, y, z) tmp = 0.0 if (z <= -2.3e+66) tmp = abs(Float64(z * Float64(x / y))); elseif (z <= 1.7e+43) tmp = abs(Float64(Float64(-4.0 - x) / y)); else tmp = abs(Float64(Float64(x / y) * Float64(z + -1.0))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -2.3e+66) tmp = abs((z * (x / y))); elseif (z <= 1.7e+43) tmp = abs(((-4.0 - x) / y)); else tmp = abs(((x / y) * (z + -1.0))); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -2.3e+66], N[Abs[N[(z * N[(x / y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[z, 1.7e+43], N[Abs[N[(N[(-4.0 - x), $MachinePrecision] / y), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[(x / y), $MachinePrecision] * N[(z + -1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2.3 \cdot 10^{+66}:\\
\;\;\;\;\left|z \cdot \frac{x}{y}\right|\\
\mathbf{elif}\;z \leq 1.7 \cdot 10^{+43}:\\
\;\;\;\;\left|\frac{-4 - x}{y}\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\frac{x}{y} \cdot \left(z + -1\right)\right|\\
\end{array}
\end{array}
if z < -2.3e66Initial program 96.1%
Taylor expanded in z around inf 72.2%
mul-1-neg72.2%
associate-*l/82.4%
distribute-rgt-neg-out82.4%
Simplified82.4%
add-sqr-sqrt81.9%
sqrt-unprod52.4%
sqr-neg52.4%
sqrt-unprod0.0%
add-sqr-sqrt82.4%
associate-*l/72.2%
associate-/l*79.7%
Applied egg-rr79.7%
associate-/r/82.4%
Applied egg-rr82.4%
if -2.3e66 < z < 1.70000000000000006e43Initial program 96.0%
Simplified98.1%
Taylor expanded in z around 0 95.4%
associate-*r/95.4%
distribute-lft-in95.4%
metadata-eval95.4%
neg-mul-195.4%
sub-neg95.4%
Simplified95.4%
if 1.70000000000000006e43 < z Initial program 82.3%
Simplified76.0%
Taylor expanded in x around inf 76.9%
Taylor expanded in z around 0 66.8%
associate-*l/68.5%
*-commutative68.5%
distribute-rgt-out82.0%
+-commutative82.0%
Simplified82.0%
Final simplification89.9%
(FPCore (x y z) :precision binary64 (if (or (<= z -1.9e+61) (not (<= z 1.5e+39))) (fabs (* z (/ x y))) (fabs (/ (- -4.0 x) y))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -1.9e+61) || !(z <= 1.5e+39)) {
tmp = fabs((z * (x / 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 <= (-1.9d+61)) .or. (.not. (z <= 1.5d+39))) then
tmp = abs((z * (x / 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 <= -1.9e+61) || !(z <= 1.5e+39)) {
tmp = Math.abs((z * (x / y)));
} else {
tmp = Math.abs(((-4.0 - x) / y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -1.9e+61) or not (z <= 1.5e+39): tmp = math.fabs((z * (x / y))) else: tmp = math.fabs(((-4.0 - x) / y)) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -1.9e+61) || !(z <= 1.5e+39)) tmp = abs(Float64(z * Float64(x / 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 <= -1.9e+61) || ~((z <= 1.5e+39))) tmp = abs((z * (x / y))); else tmp = abs(((-4.0 - x) / y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -1.9e+61], N[Not[LessEqual[z, 1.5e+39]], $MachinePrecision]], N[Abs[N[(z * N[(x / 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 -1.9 \cdot 10^{+61} \lor \neg \left(z \leq 1.5 \cdot 10^{+39}\right):\\
\;\;\;\;\left|z \cdot \frac{x}{y}\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\frac{-4 - x}{y}\right|\\
\end{array}
\end{array}
if z < -1.89999999999999998e61 or 1.5e39 < z Initial program 89.3%
Taylor expanded in z around inf 76.1%
mul-1-neg76.1%
associate-*l/82.2%
distribute-rgt-neg-out82.2%
Simplified82.2%
add-sqr-sqrt41.7%
sqrt-unprod56.1%
sqr-neg56.1%
sqrt-unprod40.1%
add-sqr-sqrt82.2%
associate-*l/76.1%
associate-/l*78.9%
Applied egg-rr78.9%
associate-/r/82.2%
Applied egg-rr82.2%
if -1.89999999999999998e61 < z < 1.5e39Initial program 96.0%
Simplified98.1%
Taylor expanded in z around 0 95.4%
associate-*r/95.4%
distribute-lft-in95.4%
metadata-eval95.4%
neg-mul-195.4%
sub-neg95.4%
Simplified95.4%
Final simplification89.9%
(FPCore (x y z) :precision binary64 (if (or (<= x -1.55) (not (<= x 4.0))) (fabs (/ x y)) (fabs (/ 4.0 y))))
double code(double x, double y, double z) {
double tmp;
if ((x <= -1.55) || !(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 <= (-1.55d0)) .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 <= -1.55) || !(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 <= -1.55) 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 <= -1.55) || !(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 <= -1.55) || ~((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, -1.55], 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 -1.55 \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 < -1.55000000000000004 or 4 < x Initial program 90.4%
Simplified95.5%
Taylor expanded in x around inf 98.4%
Taylor expanded in z around 0 61.6%
neg-mul-161.6%
distribute-neg-frac61.6%
Simplified61.6%
if -1.55000000000000004 < x < 4Initial program 96.4%
Taylor expanded in x around 0 72.9%
Final simplification66.9%
(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 93.2%
Taylor expanded in x around 0 36.9%
Final simplification36.9%
herbie shell --seed 2024031
(FPCore (x y z)
:name "fabs fraction 1"
:precision binary64
(fabs (- (/ (+ x 4.0) y) (* (/ x y) z))))