
(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 (<= y -2e+58) (fabs (fma x (/ z y) (/ (- -4.0 x) y))) (fabs (/ (+ 4.0 (* x (- 1.0 z))) y))))
double code(double x, double y, double z) {
double tmp;
if (y <= -2e+58) {
tmp = fabs(fma(x, (z / y), ((-4.0 - x) / y)));
} else {
tmp = fabs(((4.0 + (x * (1.0 - z))) / y));
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (y <= -2e+58) tmp = abs(fma(x, Float64(z / y), Float64(Float64(-4.0 - x) / y))); else tmp = abs(Float64(Float64(4.0 + Float64(x * Float64(1.0 - z))) / y)); end return tmp end
code[x_, y_, z_] := If[LessEqual[y, -2e+58], N[Abs[N[(x * N[(z / y), $MachinePrecision] + N[(N[(-4.0 - x), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[(4.0 + N[(x * N[(1.0 - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2 \cdot 10^{+58}:\\
\;\;\;\;\left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\frac{4 + x \cdot \left(1 - z\right)}{y}\right|\\
\end{array}
\end{array}
if y < -1.99999999999999989e58Initial program 96.2%
fabs-sub96.2%
associate-*l/91.6%
*-commutative91.6%
associate-*l/99.8%
*-commutative99.8%
fma-neg99.8%
distribute-neg-frac99.8%
+-commutative99.8%
distribute-neg-in99.8%
unsub-neg99.8%
metadata-eval99.8%
Simplified99.8%
if -1.99999999999999989e58 < y Initial program 92.4%
fabs-neg92.4%
sub-neg92.4%
distribute-neg-in92.4%
sub-neg92.4%
distribute-neg-frac92.4%
associate-*l/95.0%
distribute-neg-frac95.0%
neg-mul-195.0%
associate-*l/94.9%
neg-mul-194.9%
associate-*l/94.9%
distribute-lft-out--98.9%
fabs-mul98.9%
fabs-sub98.9%
fabs-mul98.9%
associate-*l/99.0%
Simplified99.0%
Taylor expanded in x around 0 99.0%
Final simplification99.2%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (fabs (/ x y))) (t_1 (fabs (* x (/ z y)))))
(if (<= x -2.15e+76)
t_0
(if (<= x -1.52e-21)
t_1
(if (<= x 3.3e-43)
(fabs (/ 4.0 y))
(if (or (<= x 1.7e+120) (not (<= x 4.2e+190))) t_1 t_0))))))
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.15e+76) {
tmp = t_0;
} else if (x <= -1.52e-21) {
tmp = t_1;
} else if (x <= 3.3e-43) {
tmp = fabs((4.0 / y));
} else if ((x <= 1.7e+120) || !(x <= 4.2e+190)) {
tmp = t_1;
} 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) :: t_1
real(8) :: tmp
t_0 = abs((x / y))
t_1 = abs((x * (z / y)))
if (x <= (-2.15d+76)) then
tmp = t_0
else if (x <= (-1.52d-21)) then
tmp = t_1
else if (x <= 3.3d-43) then
tmp = abs((4.0d0 / y))
else if ((x <= 1.7d+120) .or. (.not. (x <= 4.2d+190))) then
tmp = t_1
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 t_1 = Math.abs((x * (z / y)));
double tmp;
if (x <= -2.15e+76) {
tmp = t_0;
} else if (x <= -1.52e-21) {
tmp = t_1;
} else if (x <= 3.3e-43) {
tmp = Math.abs((4.0 / y));
} else if ((x <= 1.7e+120) || !(x <= 4.2e+190)) {
tmp = t_1;
} else {
tmp = t_0;
}
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.15e+76: tmp = t_0 elif x <= -1.52e-21: tmp = t_1 elif x <= 3.3e-43: tmp = math.fabs((4.0 / y)) elif (x <= 1.7e+120) or not (x <= 4.2e+190): tmp = t_1 else: tmp = t_0 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.15e+76) tmp = t_0; elseif (x <= -1.52e-21) tmp = t_1; elseif (x <= 3.3e-43) tmp = abs(Float64(4.0 / y)); elseif ((x <= 1.7e+120) || !(x <= 4.2e+190)) tmp = t_1; else tmp = t_0; 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.15e+76) tmp = t_0; elseif (x <= -1.52e-21) tmp = t_1; elseif (x <= 3.3e-43) tmp = abs((4.0 / y)); elseif ((x <= 1.7e+120) || ~((x <= 4.2e+190))) tmp = t_1; else tmp = t_0; 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.15e+76], t$95$0, If[LessEqual[x, -1.52e-21], t$95$1, If[LessEqual[x, 3.3e-43], N[Abs[N[(4.0 / y), $MachinePrecision]], $MachinePrecision], If[Or[LessEqual[x, 1.7e+120], N[Not[LessEqual[x, 4.2e+190]], $MachinePrecision]], t$95$1, t$95$0]]]]]]
\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.15 \cdot 10^{+76}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq -1.52 \cdot 10^{-21}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;x \leq 3.3 \cdot 10^{-43}:\\
\;\;\;\;\left|\frac{4}{y}\right|\\
\mathbf{elif}\;x \leq 1.7 \cdot 10^{+120} \lor \neg \left(x \leq 4.2 \cdot 10^{+190}\right):\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if x < -2.14999999999999989e76 or 1.69999999999999999e120 < x < 4.2000000000000001e190Initial program 86.9%
fabs-neg86.9%
sub-neg86.9%
distribute-neg-in86.9%
sub-neg86.9%
distribute-neg-frac86.9%
associate-*l/82.1%
distribute-neg-frac82.1%
neg-mul-182.1%
associate-*l/81.8%
neg-mul-181.8%
associate-*l/81.7%
distribute-lft-out--91.0%
fabs-mul91.0%
fabs-sub91.0%
fabs-mul91.0%
associate-*l/91.3%
Simplified91.3%
Taylor expanded in x around inf 91.3%
Taylor expanded in z around 0 78.7%
if -2.14999999999999989e76 < x < -1.52000000000000009e-21 or 3.30000000000000016e-43 < x < 1.69999999999999999e120 or 4.2000000000000001e190 < x Initial program 92.6%
Taylor expanded in z around inf 68.6%
associate-*r/68.6%
associate-*r*68.6%
neg-mul-168.6%
associate-*r/74.1%
*-commutative74.1%
Simplified74.1%
expm1-log1p-u43.4%
expm1-udef34.9%
add-sqr-sqrt18.7%
sqrt-unprod27.9%
sqr-neg27.9%
sqrt-unprod14.8%
add-sqr-sqrt30.8%
clear-num30.8%
associate-*l/30.8%
*-un-lft-identity30.8%
Applied egg-rr30.8%
expm1-def39.2%
expm1-log1p74.2%
associate-/r/69.8%
*-commutative69.8%
Simplified69.8%
if -1.52000000000000009e-21 < x < 3.30000000000000016e-43Initial program 96.7%
Taylor expanded in x around 0 79.6%
Final simplification76.2%
(FPCore (x y z)
:precision binary64
(if (<= x -1.8e+79)
(fabs (/ x y))
(if (or (<= x -1.05e-20) (not (<= x 4e-42)))
(fabs (* z (/ x y)))
(fabs (/ 4.0 y)))))
double code(double x, double y, double z) {
double tmp;
if (x <= -1.8e+79) {
tmp = fabs((x / y));
} else if ((x <= -1.05e-20) || !(x <= 4e-42)) {
tmp = fabs((z * (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.8d+79)) then
tmp = abs((x / y))
else if ((x <= (-1.05d-20)) .or. (.not. (x <= 4d-42))) then
tmp = abs((z * (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.8e+79) {
tmp = Math.abs((x / y));
} else if ((x <= -1.05e-20) || !(x <= 4e-42)) {
tmp = Math.abs((z * (x / y)));
} else {
tmp = Math.abs((4.0 / y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -1.8e+79: tmp = math.fabs((x / y)) elif (x <= -1.05e-20) or not (x <= 4e-42): tmp = math.fabs((z * (x / y))) else: tmp = math.fabs((4.0 / y)) return tmp
function code(x, y, z) tmp = 0.0 if (x <= -1.8e+79) tmp = abs(Float64(x / y)); elseif ((x <= -1.05e-20) || !(x <= 4e-42)) tmp = abs(Float64(z * 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.8e+79) tmp = abs((x / y)); elseif ((x <= -1.05e-20) || ~((x <= 4e-42))) tmp = abs((z * (x / y))); else tmp = abs((4.0 / y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -1.8e+79], N[Abs[N[(x / y), $MachinePrecision]], $MachinePrecision], If[Or[LessEqual[x, -1.05e-20], N[Not[LessEqual[x, 4e-42]], $MachinePrecision]], N[Abs[N[(z * N[(x / y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(4.0 / y), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.8 \cdot 10^{+79}:\\
\;\;\;\;\left|\frac{x}{y}\right|\\
\mathbf{elif}\;x \leq -1.05 \cdot 10^{-20} \lor \neg \left(x \leq 4 \cdot 10^{-42}\right):\\
\;\;\;\;\left|z \cdot \frac{x}{y}\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\frac{4}{y}\right|\\
\end{array}
\end{array}
if x < -1.8e79Initial program 84.5%
fabs-neg84.5%
sub-neg84.5%
distribute-neg-in84.5%
sub-neg84.5%
distribute-neg-frac84.5%
associate-*l/77.6%
distribute-neg-frac77.6%
neg-mul-177.6%
associate-*l/77.3%
neg-mul-177.3%
associate-*l/77.3%
distribute-lft-out--90.1%
fabs-mul90.1%
fabs-sub90.1%
fabs-mul90.1%
associate-*l/90.4%
Simplified90.4%
Taylor expanded in x around inf 90.4%
Taylor expanded in z around 0 80.2%
if -1.8e79 < x < -1.0499999999999999e-20 or 4.00000000000000015e-42 < x Initial program 92.7%
Taylor expanded in z around inf 63.8%
associate-*r/63.8%
associate-*r*63.8%
neg-mul-163.8%
associate-*r/71.3%
*-commutative71.3%
Simplified71.3%
associate-*l/63.8%
associate-/l*66.1%
add-sqr-sqrt36.6%
sqrt-unprod53.4%
sqr-neg53.4%
sqrt-unprod29.3%
add-sqr-sqrt66.1%
Applied egg-rr66.1%
associate-/r/71.3%
Applied egg-rr71.3%
if -1.0499999999999999e-20 < x < 4.00000000000000015e-42Initial program 96.7%
Taylor expanded in x around 0 79.6%
Final simplification76.5%
(FPCore (x y z)
:precision binary64
(if (<= x -5.5e+74)
(fabs (/ x y))
(if (or (<= x -1.3e-20) (not (<= x 1.36e-41)))
(fabs (/ z (/ y x)))
(fabs (/ 4.0 y)))))
double code(double x, double y, double z) {
double tmp;
if (x <= -5.5e+74) {
tmp = fabs((x / y));
} else if ((x <= -1.3e-20) || !(x <= 1.36e-41)) {
tmp = fabs((z / (y / x)));
} 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 <= (-5.5d+74)) then
tmp = abs((x / y))
else if ((x <= (-1.3d-20)) .or. (.not. (x <= 1.36d-41))) then
tmp = abs((z / (y / x)))
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 <= -5.5e+74) {
tmp = Math.abs((x / y));
} else if ((x <= -1.3e-20) || !(x <= 1.36e-41)) {
tmp = Math.abs((z / (y / x)));
} else {
tmp = Math.abs((4.0 / y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -5.5e+74: tmp = math.fabs((x / y)) elif (x <= -1.3e-20) or not (x <= 1.36e-41): tmp = math.fabs((z / (y / x))) else: tmp = math.fabs((4.0 / y)) return tmp
function code(x, y, z) tmp = 0.0 if (x <= -5.5e+74) tmp = abs(Float64(x / y)); elseif ((x <= -1.3e-20) || !(x <= 1.36e-41)) tmp = abs(Float64(z / Float64(y / x))); else tmp = abs(Float64(4.0 / y)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= -5.5e+74) tmp = abs((x / y)); elseif ((x <= -1.3e-20) || ~((x <= 1.36e-41))) tmp = abs((z / (y / x))); else tmp = abs((4.0 / y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -5.5e+74], N[Abs[N[(x / y), $MachinePrecision]], $MachinePrecision], If[Or[LessEqual[x, -1.3e-20], N[Not[LessEqual[x, 1.36e-41]], $MachinePrecision]], N[Abs[N[(z / N[(y / x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(4.0 / y), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -5.5 \cdot 10^{+74}:\\
\;\;\;\;\left|\frac{x}{y}\right|\\
\mathbf{elif}\;x \leq -1.3 \cdot 10^{-20} \lor \neg \left(x \leq 1.36 \cdot 10^{-41}\right):\\
\;\;\;\;\left|\frac{z}{\frac{y}{x}}\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\frac{4}{y}\right|\\
\end{array}
\end{array}
if x < -5.5000000000000003e74Initial program 84.5%
fabs-neg84.5%
sub-neg84.5%
distribute-neg-in84.5%
sub-neg84.5%
distribute-neg-frac84.5%
associate-*l/77.6%
distribute-neg-frac77.6%
neg-mul-177.6%
associate-*l/77.3%
neg-mul-177.3%
associate-*l/77.3%
distribute-lft-out--90.1%
fabs-mul90.1%
fabs-sub90.1%
fabs-mul90.1%
associate-*l/90.4%
Simplified90.4%
Taylor expanded in x around inf 90.4%
Taylor expanded in z around 0 80.2%
if -5.5000000000000003e74 < x < -1.29999999999999997e-20 or 1.36000000000000009e-41 < x Initial program 92.7%
Taylor expanded in z around inf 63.8%
associate-*r/63.8%
associate-*r*63.8%
neg-mul-163.8%
associate-*r/71.3%
*-commutative71.3%
Simplified71.3%
clear-num71.3%
associate-*l/71.4%
*-un-lft-identity71.4%
add-sqr-sqrt38.1%
sqrt-unprod55.8%
sqr-neg55.8%
sqrt-unprod33.0%
add-sqr-sqrt71.4%
Applied egg-rr71.4%
if -1.29999999999999997e-20 < x < 1.36000000000000009e-41Initial program 96.7%
Taylor expanded in x around 0 79.6%
Final simplification76.5%
(FPCore (x y z) :precision binary64 (if (or (<= x -0.0001) (not (<= x 1.42e-42))) (fabs (/ (- 1.0 z) (/ y x))) (fabs (+ (/ 4.0 y) (/ x y)))))
double code(double x, double y, double z) {
double tmp;
if ((x <= -0.0001) || !(x <= 1.42e-42)) {
tmp = fabs(((1.0 - z) / (y / x)));
} else {
tmp = fabs(((4.0 / y) + (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 <= (-0.0001d0)) .or. (.not. (x <= 1.42d-42))) then
tmp = abs(((1.0d0 - z) / (y / x)))
else
tmp = abs(((4.0d0 / y) + (x / y)))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((x <= -0.0001) || !(x <= 1.42e-42)) {
tmp = Math.abs(((1.0 - z) / (y / x)));
} else {
tmp = Math.abs(((4.0 / y) + (x / y)));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -0.0001) or not (x <= 1.42e-42): tmp = math.fabs(((1.0 - z) / (y / x))) else: tmp = math.fabs(((4.0 / y) + (x / y))) return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -0.0001) || !(x <= 1.42e-42)) tmp = abs(Float64(Float64(1.0 - z) / Float64(y / x))); else tmp = abs(Float64(Float64(4.0 / y) + Float64(x / y))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -0.0001) || ~((x <= 1.42e-42))) tmp = abs(((1.0 - z) / (y / x))); else tmp = abs(((4.0 / y) + (x / y))); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -0.0001], N[Not[LessEqual[x, 1.42e-42]], $MachinePrecision]], N[Abs[N[(N[(1.0 - z), $MachinePrecision] / N[(y / x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[(4.0 / y), $MachinePrecision] + N[(x / y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -0.0001 \lor \neg \left(x \leq 1.42 \cdot 10^{-42}\right):\\
\;\;\;\;\left|\frac{1 - z}{\frac{y}{x}}\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\frac{4}{y} + \frac{x}{y}\right|\\
\end{array}
\end{array}
if x < -1.00000000000000005e-4 or 1.42000000000000005e-42 < x Initial program 90.0%
fabs-neg90.0%
sub-neg90.0%
distribute-neg-in90.0%
sub-neg90.0%
distribute-neg-frac90.0%
associate-*l/88.9%
distribute-neg-frac88.9%
neg-mul-188.9%
associate-*l/88.8%
neg-mul-188.8%
associate-*l/88.7%
distribute-lft-out--94.8%
fabs-mul94.8%
fabs-sub94.8%
fabs-mul94.8%
associate-*l/95.0%
Simplified95.0%
Taylor expanded in x around inf 90.8%
associate-/l*95.6%
Simplified95.6%
if -1.00000000000000005e-4 < x < 1.42000000000000005e-42Initial program 96.8%
Taylor expanded in z around 0 78.7%
associate-*r/78.7%
metadata-eval78.7%
Simplified78.7%
Final simplification87.5%
(FPCore (x y z)
:precision binary64
(if (<= x -7800.0)
(fabs (/ (- 1.0 z) (/ y x)))
(if (<= x 40000000.0)
(fabs (/ (- 4.0 (* x z)) y))
(fabs (* x (/ (- 1.0 z) y))))))
double code(double x, double y, double z) {
double tmp;
if (x <= -7800.0) {
tmp = fabs(((1.0 - z) / (y / x)));
} else if (x <= 40000000.0) {
tmp = fabs(((4.0 - (x * z)) / 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 (x <= (-7800.0d0)) then
tmp = abs(((1.0d0 - z) / (y / x)))
else if (x <= 40000000.0d0) then
tmp = abs(((4.0d0 - (x * z)) / 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 (x <= -7800.0) {
tmp = Math.abs(((1.0 - z) / (y / x)));
} else if (x <= 40000000.0) {
tmp = Math.abs(((4.0 - (x * z)) / y));
} else {
tmp = Math.abs((x * ((1.0 - z) / y)));
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -7800.0: tmp = math.fabs(((1.0 - z) / (y / x))) elif x <= 40000000.0: tmp = math.fabs(((4.0 - (x * z)) / y)) else: tmp = math.fabs((x * ((1.0 - z) / y))) return tmp
function code(x, y, z) tmp = 0.0 if (x <= -7800.0) tmp = abs(Float64(Float64(1.0 - z) / Float64(y / x))); elseif (x <= 40000000.0) tmp = abs(Float64(Float64(4.0 - Float64(x * z)) / 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 (x <= -7800.0) tmp = abs(((1.0 - z) / (y / x))); elseif (x <= 40000000.0) tmp = abs(((4.0 - (x * z)) / y)); else tmp = abs((x * ((1.0 - z) / y))); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -7800.0], N[Abs[N[(N[(1.0 - z), $MachinePrecision] / N[(y / x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[x, 40000000.0], N[Abs[N[(N[(4.0 - N[(x * z), $MachinePrecision]), $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}\;x \leq -7800:\\
\;\;\;\;\left|\frac{1 - z}{\frac{y}{x}}\right|\\
\mathbf{elif}\;x \leq 40000000:\\
\;\;\;\;\left|\frac{4 - x \cdot z}{y}\right|\\
\mathbf{else}:\\
\;\;\;\;\left|x \cdot \frac{1 - z}{y}\right|\\
\end{array}
\end{array}
if x < -7800Initial program 87.1%
fabs-neg87.1%
sub-neg87.1%
distribute-neg-in87.1%
sub-neg87.1%
distribute-neg-frac87.1%
associate-*l/84.1%
distribute-neg-frac84.1%
neg-mul-184.1%
associate-*l/83.9%
neg-mul-183.9%
associate-*l/83.8%
distribute-lft-out--92.9%
fabs-mul92.9%
fabs-sub92.9%
fabs-mul92.9%
associate-*l/93.2%
Simplified93.2%
Taylor expanded in x around inf 92.1%
associate-/l*98.7%
Simplified98.7%
if -7800 < x < 4e7Initial program 97.2%
fabs-neg97.2%
sub-neg97.2%
distribute-neg-in97.2%
sub-neg97.2%
distribute-neg-frac97.2%
associate-*l/99.9%
distribute-neg-frac99.9%
neg-mul-199.9%
associate-*l/99.9%
neg-mul-199.9%
associate-*l/99.8%
distribute-lft-out--99.8%
fabs-mul99.8%
fabs-sub99.8%
fabs-mul99.8%
associate-*l/99.9%
Simplified99.9%
Taylor expanded in x around 0 99.9%
Taylor expanded in z around inf 97.9%
mul-1-neg97.9%
distribute-rgt-neg-out97.9%
Simplified97.9%
if 4e7 < x Initial program 89.6%
fabs-neg89.6%
sub-neg89.6%
distribute-neg-in89.6%
sub-neg89.6%
distribute-neg-frac89.6%
associate-*l/89.9%
distribute-neg-frac89.9%
neg-mul-189.9%
associate-*l/89.8%
neg-mul-189.8%
associate-*l/89.8%
distribute-lft-out--94.9%
fabs-mul94.9%
fabs-sub94.9%
fabs-mul94.9%
associate-*l/95.0%
Simplified95.0%
Taylor expanded in x around inf 94.6%
associate-/l*99.2%
associate-/r/99.3%
Simplified99.3%
Final simplification98.4%
(FPCore (x y z) :precision binary64 (if (<= z -1.15e+66) (fabs (/ z (/ y x))) (if (<= z 1.82e+84) (fabs (/ (- -4.0 x) y)) (fabs (/ (* x z) y)))))
double code(double x, double y, double z) {
double tmp;
if (z <= -1.15e+66) {
tmp = fabs((z / (y / x)));
} else if (z <= 1.82e+84) {
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 <= (-1.15d+66)) then
tmp = abs((z / (y / x)))
else if (z <= 1.82d+84) 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 <= -1.15e+66) {
tmp = Math.abs((z / (y / x)));
} else if (z <= 1.82e+84) {
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 <= -1.15e+66: tmp = math.fabs((z / (y / x))) elif z <= 1.82e+84: 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 <= -1.15e+66) tmp = abs(Float64(z / Float64(y / x))); elseif (z <= 1.82e+84) tmp = abs(Float64(Float64(-4.0 - x) / y)); else tmp = abs(Float64(Float64(x * z) / y)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -1.15e+66) tmp = abs((z / (y / x))); elseif (z <= 1.82e+84) tmp = abs(((-4.0 - x) / y)); else tmp = abs(((x * z) / y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -1.15e+66], N[Abs[N[(z / N[(y / x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[z, 1.82e+84], N[Abs[N[(N[(-4.0 - x), $MachinePrecision] / y), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[(x * z), $MachinePrecision] / y), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.15 \cdot 10^{+66}:\\
\;\;\;\;\left|\frac{z}{\frac{y}{x}}\right|\\
\mathbf{elif}\;z \leq 1.82 \cdot 10^{+84}:\\
\;\;\;\;\left|\frac{-4 - x}{y}\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\frac{x \cdot z}{y}\right|\\
\end{array}
\end{array}
if z < -1.15e66Initial program 97.0%
Taylor expanded in z around inf 71.4%
associate-*r/71.4%
associate-*r*71.4%
neg-mul-171.4%
associate-*r/76.5%
*-commutative76.5%
Simplified76.5%
clear-num76.5%
associate-*l/76.5%
*-un-lft-identity76.5%
add-sqr-sqrt76.1%
sqrt-unprod46.8%
sqr-neg46.8%
sqrt-unprod0.0%
add-sqr-sqrt76.5%
Applied egg-rr76.5%
if -1.15e66 < z < 1.8200000000000001e84Initial program 93.5%
fabs-sub93.5%
associate-*l/96.1%
*-commutative96.1%
associate-*l/95.6%
*-commutative95.6%
fma-neg98.2%
distribute-neg-frac98.2%
+-commutative98.2%
distribute-neg-in98.2%
unsub-neg98.2%
metadata-eval98.2%
Simplified98.2%
Taylor expanded in z around 0 91.5%
associate-*r/91.5%
distribute-lft-in91.5%
metadata-eval91.5%
neg-mul-191.5%
sub-neg91.5%
Simplified91.5%
if 1.8200000000000001e84 < z Initial program 88.4%
Taylor expanded in z around inf 78.8%
associate-*r/78.8%
associate-*r*78.8%
neg-mul-178.8%
associate-*r/78.5%
*-commutative78.5%
Simplified78.5%
add-sqr-sqrt0.0%
sqrt-unprod54.4%
sqr-neg54.4%
sqrt-unprod78.3%
add-sqr-sqrt78.5%
associate-*l/78.8%
Applied egg-rr78.8%
Final simplification86.1%
(FPCore (x y z) :precision binary64 (fabs (/ (+ 4.0 (* x (- 1.0 z))) y)))
double code(double x, double y, double z) {
return fabs(((4.0 + (x * (1.0 - 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(((4.0d0 + (x * (1.0d0 - z))) / y))
end function
public static double code(double x, double y, double z) {
return Math.abs(((4.0 + (x * (1.0 - z))) / y));
}
def code(x, y, z): return math.fabs(((4.0 + (x * (1.0 - z))) / y))
function code(x, y, z) return abs(Float64(Float64(4.0 + Float64(x * Float64(1.0 - z))) / y)) end
function tmp = code(x, y, z) tmp = abs(((4.0 + (x * (1.0 - z))) / y)); end
code[x_, y_, z_] := N[Abs[N[(N[(4.0 + N[(x * N[(1.0 - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|\frac{4 + x \cdot \left(1 - z\right)}{y}\right|
\end{array}
Initial program 93.3%
fabs-neg93.3%
sub-neg93.3%
distribute-neg-in93.3%
sub-neg93.3%
distribute-neg-frac93.3%
associate-*l/94.2%
distribute-neg-frac94.2%
neg-mul-194.2%
associate-*l/94.1%
neg-mul-194.1%
associate-*l/94.1%
distribute-lft-out--97.2%
fabs-mul97.2%
fabs-sub97.2%
fabs-mul97.2%
associate-*l/97.3%
Simplified97.3%
Taylor expanded in x around 0 97.3%
Final simplification97.3%
(FPCore (x y z) :precision binary64 (if (or (<= x -1.45) (not (<= x 4.0))) (fabs (/ x y)) (fabs (/ 4.0 y))))
double code(double x, double y, double z) {
double tmp;
if ((x <= -1.45) || !(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.45d0)) .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.45) || !(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.45) 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.45) || !(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.45) || ~((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.45], 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.45 \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.44999999999999996 or 4 < x Initial program 89.1%
fabs-neg89.1%
sub-neg89.1%
distribute-neg-in89.1%
sub-neg89.1%
distribute-neg-frac89.1%
associate-*l/87.8%
distribute-neg-frac87.8%
neg-mul-187.8%
associate-*l/87.7%
neg-mul-187.7%
associate-*l/87.7%
distribute-lft-out--94.3%
fabs-mul94.3%
fabs-sub94.3%
fabs-mul94.3%
associate-*l/94.5%
Simplified94.5%
Taylor expanded in x around inf 93.8%
Taylor expanded in z around 0 57.1%
if -1.44999999999999996 < x < 4Initial program 97.1%
Taylor expanded in x around 0 73.9%
Final simplification66.0%
(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.3%
Taylor expanded in x around 0 41.4%
Final simplification41.4%
herbie shell --seed 2023178
(FPCore (x y z)
:name "fabs fraction 1"
:precision binary64
(fabs (- (/ (+ x 4.0) y) (* (/ x y) z))))