
(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}
y_m = (fabs.f64 y) (FPCore (x y_m z) :precision binary64 (if (<= y_m 3e+34) (fabs (/ (fma x z (- -4.0 x)) y_m)) (fabs (fma x (/ z y_m) (/ (- -4.0 x) y_m)))))
y_m = fabs(y);
double code(double x, double y_m, double z) {
double tmp;
if (y_m <= 3e+34) {
tmp = fabs((fma(x, z, (-4.0 - x)) / y_m));
} else {
tmp = fabs(fma(x, (z / y_m), ((-4.0 - x) / y_m)));
}
return tmp;
}
y_m = abs(y) function code(x, y_m, z) tmp = 0.0 if (y_m <= 3e+34) tmp = abs(Float64(fma(x, z, Float64(-4.0 - x)) / y_m)); else tmp = abs(fma(x, Float64(z / y_m), Float64(Float64(-4.0 - x) / y_m))); end return tmp end
y_m = N[Abs[y], $MachinePrecision] code[x_, y$95$m_, z_] := If[LessEqual[y$95$m, 3e+34], N[Abs[N[(N[(x * z + N[(-4.0 - x), $MachinePrecision]), $MachinePrecision] / y$95$m), $MachinePrecision]], $MachinePrecision], N[Abs[N[(x * N[(z / y$95$m), $MachinePrecision] + N[(N[(-4.0 - x), $MachinePrecision] / y$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
y_m = \left|y\right|
\\
\begin{array}{l}
\mathbf{if}\;y_m \leq 3 \cdot 10^{+34}:\\
\;\;\;\;\left|\frac{\mathsf{fma}\left(x, z, -4 - x\right)}{y_m}\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\mathsf{fma}\left(x, \frac{z}{y_m}, \frac{-4 - x}{y_m}\right)\right|\\
\end{array}
\end{array}
if y < 3.00000000000000018e34Initial program 89.3%
Simplified90.5%
Taylor expanded in x around -inf 94.6%
Simplified96.5%
if 3.00000000000000018e34 < y Initial program 94.7%
Simplified99.9%
Final simplification97.3%
y_m = (fabs.f64 y)
(FPCore (x y_m z)
:precision binary64
(let* ((t_0 (/ (+ x 4.0) y_m)) (t_1 (* z (/ x y_m))))
(if (<= (- t_0 t_1) 5e+292)
(fabs (- t_1 t_0))
(fabs (/ (- (+ x 4.0) (* x z)) y_m)))))y_m = fabs(y);
double code(double x, double y_m, double z) {
double t_0 = (x + 4.0) / y_m;
double t_1 = z * (x / y_m);
double tmp;
if ((t_0 - t_1) <= 5e+292) {
tmp = fabs((t_1 - t_0));
} else {
tmp = fabs((((x + 4.0) - (x * z)) / y_m));
}
return tmp;
}
y_m = abs(y)
real(8) function code(x, y_m, z)
real(8), intent (in) :: x
real(8), intent (in) :: y_m
real(8), intent (in) :: z
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = (x + 4.0d0) / y_m
t_1 = z * (x / y_m)
if ((t_0 - t_1) <= 5d+292) then
tmp = abs((t_1 - t_0))
else
tmp = abs((((x + 4.0d0) - (x * z)) / y_m))
end if
code = tmp
end function
y_m = Math.abs(y);
public static double code(double x, double y_m, double z) {
double t_0 = (x + 4.0) / y_m;
double t_1 = z * (x / y_m);
double tmp;
if ((t_0 - t_1) <= 5e+292) {
tmp = Math.abs((t_1 - t_0));
} else {
tmp = Math.abs((((x + 4.0) - (x * z)) / y_m));
}
return tmp;
}
y_m = math.fabs(y) def code(x, y_m, z): t_0 = (x + 4.0) / y_m t_1 = z * (x / y_m) tmp = 0 if (t_0 - t_1) <= 5e+292: tmp = math.fabs((t_1 - t_0)) else: tmp = math.fabs((((x + 4.0) - (x * z)) / y_m)) return tmp
y_m = abs(y) function code(x, y_m, z) t_0 = Float64(Float64(x + 4.0) / y_m) t_1 = Float64(z * Float64(x / y_m)) tmp = 0.0 if (Float64(t_0 - t_1) <= 5e+292) tmp = abs(Float64(t_1 - t_0)); else tmp = abs(Float64(Float64(Float64(x + 4.0) - Float64(x * z)) / y_m)); end return tmp end
y_m = abs(y); function tmp_2 = code(x, y_m, z) t_0 = (x + 4.0) / y_m; t_1 = z * (x / y_m); tmp = 0.0; if ((t_0 - t_1) <= 5e+292) tmp = abs((t_1 - t_0)); else tmp = abs((((x + 4.0) - (x * z)) / y_m)); end tmp_2 = tmp; end
y_m = N[Abs[y], $MachinePrecision]
code[x_, y$95$m_, z_] := Block[{t$95$0 = N[(N[(x + 4.0), $MachinePrecision] / y$95$m), $MachinePrecision]}, Block[{t$95$1 = N[(z * N[(x / y$95$m), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(t$95$0 - t$95$1), $MachinePrecision], 5e+292], N[Abs[N[(t$95$1 - t$95$0), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[(N[(x + 4.0), $MachinePrecision] - N[(x * z), $MachinePrecision]), $MachinePrecision] / y$95$m), $MachinePrecision]], $MachinePrecision]]]]
\begin{array}{l}
y_m = \left|y\right|
\\
\begin{array}{l}
t_0 := \frac{x + 4}{y_m}\\
t_1 := z \cdot \frac{x}{y_m}\\
\mathbf{if}\;t_0 - t_1 \leq 5 \cdot 10^{+292}:\\
\;\;\;\;\left|t_1 - t_0\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\frac{\left(x + 4\right) - x \cdot z}{y_m}\right|\\
\end{array}
\end{array}
if (-.f64 (/.f64 (+.f64 x 4) y) (*.f64 (/.f64 x y) z)) < 4.9999999999999996e292Initial program 98.2%
if 4.9999999999999996e292 < (-.f64 (/.f64 (+.f64 x 4) y) (*.f64 (/.f64 x y) z)) Initial program 52.4%
Taylor expanded in y around 0 100.0%
Final simplification98.5%
y_m = (fabs.f64 y)
(FPCore (x y_m z)
:precision binary64
(let* ((t_0 (fabs (/ x y_m))) (t_1 (fabs (* x (/ z y_m)))))
(if (<= x -1.95e+127)
t_0
(if (<= x -1.1e-7)
t_1
(if (<= x 4.2e-111)
(fabs (/ 4.0 y_m))
(if (or (<= x 185000000.0) (not (<= x 1.46e+164))) t_1 t_0))))))y_m = fabs(y);
double code(double x, double y_m, double z) {
double t_0 = fabs((x / y_m));
double t_1 = fabs((x * (z / y_m)));
double tmp;
if (x <= -1.95e+127) {
tmp = t_0;
} else if (x <= -1.1e-7) {
tmp = t_1;
} else if (x <= 4.2e-111) {
tmp = fabs((4.0 / y_m));
} else if ((x <= 185000000.0) || !(x <= 1.46e+164)) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
y_m = abs(y)
real(8) function code(x, y_m, z)
real(8), intent (in) :: x
real(8), intent (in) :: y_m
real(8), intent (in) :: z
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = abs((x / y_m))
t_1 = abs((x * (z / y_m)))
if (x <= (-1.95d+127)) then
tmp = t_0
else if (x <= (-1.1d-7)) then
tmp = t_1
else if (x <= 4.2d-111) then
tmp = abs((4.0d0 / y_m))
else if ((x <= 185000000.0d0) .or. (.not. (x <= 1.46d+164))) then
tmp = t_1
else
tmp = t_0
end if
code = tmp
end function
y_m = Math.abs(y);
public static double code(double x, double y_m, double z) {
double t_0 = Math.abs((x / y_m));
double t_1 = Math.abs((x * (z / y_m)));
double tmp;
if (x <= -1.95e+127) {
tmp = t_0;
} else if (x <= -1.1e-7) {
tmp = t_1;
} else if (x <= 4.2e-111) {
tmp = Math.abs((4.0 / y_m));
} else if ((x <= 185000000.0) || !(x <= 1.46e+164)) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
y_m = math.fabs(y) def code(x, y_m, z): t_0 = math.fabs((x / y_m)) t_1 = math.fabs((x * (z / y_m))) tmp = 0 if x <= -1.95e+127: tmp = t_0 elif x <= -1.1e-7: tmp = t_1 elif x <= 4.2e-111: tmp = math.fabs((4.0 / y_m)) elif (x <= 185000000.0) or not (x <= 1.46e+164): tmp = t_1 else: tmp = t_0 return tmp
y_m = abs(y) function code(x, y_m, z) t_0 = abs(Float64(x / y_m)) t_1 = abs(Float64(x * Float64(z / y_m))) tmp = 0.0 if (x <= -1.95e+127) tmp = t_0; elseif (x <= -1.1e-7) tmp = t_1; elseif (x <= 4.2e-111) tmp = abs(Float64(4.0 / y_m)); elseif ((x <= 185000000.0) || !(x <= 1.46e+164)) tmp = t_1; else tmp = t_0; end return tmp end
y_m = abs(y); function tmp_2 = code(x, y_m, z) t_0 = abs((x / y_m)); t_1 = abs((x * (z / y_m))); tmp = 0.0; if (x <= -1.95e+127) tmp = t_0; elseif (x <= -1.1e-7) tmp = t_1; elseif (x <= 4.2e-111) tmp = abs((4.0 / y_m)); elseif ((x <= 185000000.0) || ~((x <= 1.46e+164))) tmp = t_1; else tmp = t_0; end tmp_2 = tmp; end
y_m = N[Abs[y], $MachinePrecision]
code[x_, y$95$m_, z_] := Block[{t$95$0 = N[Abs[N[(x / y$95$m), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Abs[N[(x * N[(z / y$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[x, -1.95e+127], t$95$0, If[LessEqual[x, -1.1e-7], t$95$1, If[LessEqual[x, 4.2e-111], N[Abs[N[(4.0 / y$95$m), $MachinePrecision]], $MachinePrecision], If[Or[LessEqual[x, 185000000.0], N[Not[LessEqual[x, 1.46e+164]], $MachinePrecision]], t$95$1, t$95$0]]]]]]
\begin{array}{l}
y_m = \left|y\right|
\\
\begin{array}{l}
t_0 := \left|\frac{x}{y_m}\right|\\
t_1 := \left|x \cdot \frac{z}{y_m}\right|\\
\mathbf{if}\;x \leq -1.95 \cdot 10^{+127}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq -1.1 \cdot 10^{-7}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;x \leq 4.2 \cdot 10^{-111}:\\
\;\;\;\;\left|\frac{4}{y_m}\right|\\
\mathbf{elif}\;x \leq 185000000 \lor \neg \left(x \leq 1.46 \cdot 10^{+164}\right):\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if x < -1.94999999999999991e127 or 1.85e8 < x < 1.45999999999999994e164Initial program 81.9%
Simplified91.6%
Taylor expanded in x around inf 98.4%
Taylor expanded in z around 0 77.1%
associate-*r/77.1%
neg-mul-177.1%
Simplified77.1%
if -1.94999999999999991e127 < x < -1.1000000000000001e-7 or 4.1999999999999997e-111 < x < 1.85e8 or 1.45999999999999994e164 < x Initial program 90.8%
Simplified96.4%
Taylor expanded in x around -inf 98.8%
Simplified90.6%
Taylor expanded in z around inf 61.7%
associate-*r/69.9%
Simplified69.9%
if -1.1000000000000001e-7 < x < 4.1999999999999997e-111Initial program 96.8%
Taylor expanded in x around 0 81.9%
Final simplification76.7%
y_m = (fabs.f64 y)
(FPCore (x y_m z)
:precision binary64
(let* ((t_0 (fabs (/ x y_m))) (t_1 (fabs (* z (/ x y_m)))))
(if (<= x -6.5e+127)
t_0
(if (<= x -1.85e-7)
t_1
(if (<= x 4.2e-111)
(fabs (/ 4.0 y_m))
(if (or (<= x 180000000.0) (not (<= x 3.6e+166))) t_1 t_0))))))y_m = fabs(y);
double code(double x, double y_m, double z) {
double t_0 = fabs((x / y_m));
double t_1 = fabs((z * (x / y_m)));
double tmp;
if (x <= -6.5e+127) {
tmp = t_0;
} else if (x <= -1.85e-7) {
tmp = t_1;
} else if (x <= 4.2e-111) {
tmp = fabs((4.0 / y_m));
} else if ((x <= 180000000.0) || !(x <= 3.6e+166)) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
y_m = abs(y)
real(8) function code(x, y_m, z)
real(8), intent (in) :: x
real(8), intent (in) :: y_m
real(8), intent (in) :: z
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = abs((x / y_m))
t_1 = abs((z * (x / y_m)))
if (x <= (-6.5d+127)) then
tmp = t_0
else if (x <= (-1.85d-7)) then
tmp = t_1
else if (x <= 4.2d-111) then
tmp = abs((4.0d0 / y_m))
else if ((x <= 180000000.0d0) .or. (.not. (x <= 3.6d+166))) then
tmp = t_1
else
tmp = t_0
end if
code = tmp
end function
y_m = Math.abs(y);
public static double code(double x, double y_m, double z) {
double t_0 = Math.abs((x / y_m));
double t_1 = Math.abs((z * (x / y_m)));
double tmp;
if (x <= -6.5e+127) {
tmp = t_0;
} else if (x <= -1.85e-7) {
tmp = t_1;
} else if (x <= 4.2e-111) {
tmp = Math.abs((4.0 / y_m));
} else if ((x <= 180000000.0) || !(x <= 3.6e+166)) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
y_m = math.fabs(y) def code(x, y_m, z): t_0 = math.fabs((x / y_m)) t_1 = math.fabs((z * (x / y_m))) tmp = 0 if x <= -6.5e+127: tmp = t_0 elif x <= -1.85e-7: tmp = t_1 elif x <= 4.2e-111: tmp = math.fabs((4.0 / y_m)) elif (x <= 180000000.0) or not (x <= 3.6e+166): tmp = t_1 else: tmp = t_0 return tmp
y_m = abs(y) function code(x, y_m, z) t_0 = abs(Float64(x / y_m)) t_1 = abs(Float64(z * Float64(x / y_m))) tmp = 0.0 if (x <= -6.5e+127) tmp = t_0; elseif (x <= -1.85e-7) tmp = t_1; elseif (x <= 4.2e-111) tmp = abs(Float64(4.0 / y_m)); elseif ((x <= 180000000.0) || !(x <= 3.6e+166)) tmp = t_1; else tmp = t_0; end return tmp end
y_m = abs(y); function tmp_2 = code(x, y_m, z) t_0 = abs((x / y_m)); t_1 = abs((z * (x / y_m))); tmp = 0.0; if (x <= -6.5e+127) tmp = t_0; elseif (x <= -1.85e-7) tmp = t_1; elseif (x <= 4.2e-111) tmp = abs((4.0 / y_m)); elseif ((x <= 180000000.0) || ~((x <= 3.6e+166))) tmp = t_1; else tmp = t_0; end tmp_2 = tmp; end
y_m = N[Abs[y], $MachinePrecision]
code[x_, y$95$m_, z_] := Block[{t$95$0 = N[Abs[N[(x / y$95$m), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Abs[N[(z * N[(x / y$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[x, -6.5e+127], t$95$0, If[LessEqual[x, -1.85e-7], t$95$1, If[LessEqual[x, 4.2e-111], N[Abs[N[(4.0 / y$95$m), $MachinePrecision]], $MachinePrecision], If[Or[LessEqual[x, 180000000.0], N[Not[LessEqual[x, 3.6e+166]], $MachinePrecision]], t$95$1, t$95$0]]]]]]
\begin{array}{l}
y_m = \left|y\right|
\\
\begin{array}{l}
t_0 := \left|\frac{x}{y_m}\right|\\
t_1 := \left|z \cdot \frac{x}{y_m}\right|\\
\mathbf{if}\;x \leq -6.5 \cdot 10^{+127}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq -1.85 \cdot 10^{-7}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;x \leq 4.2 \cdot 10^{-111}:\\
\;\;\;\;\left|\frac{4}{y_m}\right|\\
\mathbf{elif}\;x \leq 180000000 \lor \neg \left(x \leq 3.6 \cdot 10^{+166}\right):\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if x < -6.5e127 or 1.8e8 < x < 3.5999999999999997e166Initial program 81.9%
Simplified91.6%
Taylor expanded in x around inf 98.4%
Taylor expanded in z around 0 77.1%
associate-*r/77.1%
neg-mul-177.1%
Simplified77.1%
if -6.5e127 < x < -1.85000000000000002e-7 or 4.1999999999999997e-111 < x < 1.8e8 or 3.5999999999999997e166 < x Initial program 90.8%
Simplified96.4%
Taylor expanded in x around -inf 98.8%
Simplified90.6%
Taylor expanded in z around inf 61.7%
associate-*l/75.1%
Applied egg-rr75.1%
if -1.85000000000000002e-7 < x < 4.1999999999999997e-111Initial program 96.8%
Taylor expanded in x around 0 81.9%
Final simplification78.4%
y_m = (fabs.f64 y)
(FPCore (x y_m z)
:precision binary64
(let* ((t_0 (fabs (/ x y_m))) (t_1 (fabs (* z (/ x y_m)))))
(if (<= x -7e+127)
t_0
(if (<= x -1.85e-7)
t_1
(if (<= x 3.8e-112)
(fabs (/ 4.0 y_m))
(if (<= x 5000000.0)
(fabs (/ (* x z) y_m))
(if (<= x 6.5e+166) t_0 t_1)))))))y_m = fabs(y);
double code(double x, double y_m, double z) {
double t_0 = fabs((x / y_m));
double t_1 = fabs((z * (x / y_m)));
double tmp;
if (x <= -7e+127) {
tmp = t_0;
} else if (x <= -1.85e-7) {
tmp = t_1;
} else if (x <= 3.8e-112) {
tmp = fabs((4.0 / y_m));
} else if (x <= 5000000.0) {
tmp = fabs(((x * z) / y_m));
} else if (x <= 6.5e+166) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
y_m = abs(y)
real(8) function code(x, y_m, z)
real(8), intent (in) :: x
real(8), intent (in) :: y_m
real(8), intent (in) :: z
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = abs((x / y_m))
t_1 = abs((z * (x / y_m)))
if (x <= (-7d+127)) then
tmp = t_0
else if (x <= (-1.85d-7)) then
tmp = t_1
else if (x <= 3.8d-112) then
tmp = abs((4.0d0 / y_m))
else if (x <= 5000000.0d0) then
tmp = abs(((x * z) / y_m))
else if (x <= 6.5d+166) then
tmp = t_0
else
tmp = t_1
end if
code = tmp
end function
y_m = Math.abs(y);
public static double code(double x, double y_m, double z) {
double t_0 = Math.abs((x / y_m));
double t_1 = Math.abs((z * (x / y_m)));
double tmp;
if (x <= -7e+127) {
tmp = t_0;
} else if (x <= -1.85e-7) {
tmp = t_1;
} else if (x <= 3.8e-112) {
tmp = Math.abs((4.0 / y_m));
} else if (x <= 5000000.0) {
tmp = Math.abs(((x * z) / y_m));
} else if (x <= 6.5e+166) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
y_m = math.fabs(y) def code(x, y_m, z): t_0 = math.fabs((x / y_m)) t_1 = math.fabs((z * (x / y_m))) tmp = 0 if x <= -7e+127: tmp = t_0 elif x <= -1.85e-7: tmp = t_1 elif x <= 3.8e-112: tmp = math.fabs((4.0 / y_m)) elif x <= 5000000.0: tmp = math.fabs(((x * z) / y_m)) elif x <= 6.5e+166: tmp = t_0 else: tmp = t_1 return tmp
y_m = abs(y) function code(x, y_m, z) t_0 = abs(Float64(x / y_m)) t_1 = abs(Float64(z * Float64(x / y_m))) tmp = 0.0 if (x <= -7e+127) tmp = t_0; elseif (x <= -1.85e-7) tmp = t_1; elseif (x <= 3.8e-112) tmp = abs(Float64(4.0 / y_m)); elseif (x <= 5000000.0) tmp = abs(Float64(Float64(x * z) / y_m)); elseif (x <= 6.5e+166) tmp = t_0; else tmp = t_1; end return tmp end
y_m = abs(y); function tmp_2 = code(x, y_m, z) t_0 = abs((x / y_m)); t_1 = abs((z * (x / y_m))); tmp = 0.0; if (x <= -7e+127) tmp = t_0; elseif (x <= -1.85e-7) tmp = t_1; elseif (x <= 3.8e-112) tmp = abs((4.0 / y_m)); elseif (x <= 5000000.0) tmp = abs(((x * z) / y_m)); elseif (x <= 6.5e+166) tmp = t_0; else tmp = t_1; end tmp_2 = tmp; end
y_m = N[Abs[y], $MachinePrecision]
code[x_, y$95$m_, z_] := Block[{t$95$0 = N[Abs[N[(x / y$95$m), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Abs[N[(z * N[(x / y$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[x, -7e+127], t$95$0, If[LessEqual[x, -1.85e-7], t$95$1, If[LessEqual[x, 3.8e-112], N[Abs[N[(4.0 / y$95$m), $MachinePrecision]], $MachinePrecision], If[LessEqual[x, 5000000.0], N[Abs[N[(N[(x * z), $MachinePrecision] / y$95$m), $MachinePrecision]], $MachinePrecision], If[LessEqual[x, 6.5e+166], t$95$0, t$95$1]]]]]]]
\begin{array}{l}
y_m = \left|y\right|
\\
\begin{array}{l}
t_0 := \left|\frac{x}{y_m}\right|\\
t_1 := \left|z \cdot \frac{x}{y_m}\right|\\
\mathbf{if}\;x \leq -7 \cdot 10^{+127}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq -1.85 \cdot 10^{-7}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;x \leq 3.8 \cdot 10^{-112}:\\
\;\;\;\;\left|\frac{4}{y_m}\right|\\
\mathbf{elif}\;x \leq 5000000:\\
\;\;\;\;\left|\frac{x \cdot z}{y_m}\right|\\
\mathbf{elif}\;x \leq 6.5 \cdot 10^{+166}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if x < -6.99999999999999956e127 or 5e6 < x < 6.5000000000000005e166Initial program 81.9%
Simplified91.6%
Taylor expanded in x around inf 98.4%
Taylor expanded in z around 0 77.1%
associate-*r/77.1%
neg-mul-177.1%
Simplified77.1%
if -6.99999999999999956e127 < x < -1.85000000000000002e-7 or 6.5000000000000005e166 < x Initial program 88.0%
Simplified96.5%
Taylor expanded in x around -inf 99.8%
Simplified87.0%
Taylor expanded in z around inf 58.4%
associate-*l/77.8%
Applied egg-rr77.8%
if -1.85000000000000002e-7 < x < 3.79999999999999995e-112Initial program 96.8%
Taylor expanded in x around 0 81.9%
if 3.79999999999999995e-112 < x < 5e6Initial program 97.9%
Simplified96.2%
Taylor expanded in x around -inf 96.1%
Simplified99.8%
Taylor expanded in z around inf 70.2%
Final simplification78.6%
y_m = (fabs.f64 y) (FPCore (x y_m z) :precision binary64 (if (or (<= x -1.75e-7) (not (<= x 4.2e-111))) (fabs (* x (+ (/ z y_m) (/ -1.0 y_m)))) (fabs (/ (- x -4.0) y_m))))
y_m = fabs(y);
double code(double x, double y_m, double z) {
double tmp;
if ((x <= -1.75e-7) || !(x <= 4.2e-111)) {
tmp = fabs((x * ((z / y_m) + (-1.0 / y_m))));
} else {
tmp = fabs(((x - -4.0) / y_m));
}
return tmp;
}
y_m = abs(y)
real(8) function code(x, y_m, z)
real(8), intent (in) :: x
real(8), intent (in) :: y_m
real(8), intent (in) :: z
real(8) :: tmp
if ((x <= (-1.75d-7)) .or. (.not. (x <= 4.2d-111))) then
tmp = abs((x * ((z / y_m) + ((-1.0d0) / y_m))))
else
tmp = abs(((x - (-4.0d0)) / y_m))
end if
code = tmp
end function
y_m = Math.abs(y);
public static double code(double x, double y_m, double z) {
double tmp;
if ((x <= -1.75e-7) || !(x <= 4.2e-111)) {
tmp = Math.abs((x * ((z / y_m) + (-1.0 / y_m))));
} else {
tmp = Math.abs(((x - -4.0) / y_m));
}
return tmp;
}
y_m = math.fabs(y) def code(x, y_m, z): tmp = 0 if (x <= -1.75e-7) or not (x <= 4.2e-111): tmp = math.fabs((x * ((z / y_m) + (-1.0 / y_m)))) else: tmp = math.fabs(((x - -4.0) / y_m)) return tmp
y_m = abs(y) function code(x, y_m, z) tmp = 0.0 if ((x <= -1.75e-7) || !(x <= 4.2e-111)) tmp = abs(Float64(x * Float64(Float64(z / y_m) + Float64(-1.0 / y_m)))); else tmp = abs(Float64(Float64(x - -4.0) / y_m)); end return tmp end
y_m = abs(y); function tmp_2 = code(x, y_m, z) tmp = 0.0; if ((x <= -1.75e-7) || ~((x <= 4.2e-111))) tmp = abs((x * ((z / y_m) + (-1.0 / y_m)))); else tmp = abs(((x - -4.0) / y_m)); end tmp_2 = tmp; end
y_m = N[Abs[y], $MachinePrecision] code[x_, y$95$m_, z_] := If[Or[LessEqual[x, -1.75e-7], N[Not[LessEqual[x, 4.2e-111]], $MachinePrecision]], N[Abs[N[(x * N[(N[(z / y$95$m), $MachinePrecision] + N[(-1.0 / y$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[(x - -4.0), $MachinePrecision] / y$95$m), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
y_m = \left|y\right|
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.75 \cdot 10^{-7} \lor \neg \left(x \leq 4.2 \cdot 10^{-111}\right):\\
\;\;\;\;\left|x \cdot \left(\frac{z}{y_m} + \frac{-1}{y_m}\right)\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\frac{x - -4}{y_m}\right|\\
\end{array}
\end{array}
if x < -1.74999999999999992e-7 or 4.1999999999999997e-111 < x Initial program 86.6%
Simplified94.2%
Taylor expanded in x around inf 94.1%
if -1.74999999999999992e-7 < x < 4.1999999999999997e-111Initial program 96.8%
Simplified90.7%
Taylor expanded in z around 0 83.2%
associate-*r/83.2%
distribute-lft-in83.2%
metadata-eval83.2%
neg-mul-183.2%
sub-neg83.2%
Simplified83.2%
Final simplification89.8%
y_m = (fabs.f64 y) (FPCore (x y_m z) :precision binary64 (if (or (<= x -1e+40) (not (<= x 75000000000000.0))) (fabs (* x (+ (/ z y_m) (/ -1.0 y_m)))) (fabs (/ (- (+ x 4.0) (* x z)) y_m))))
y_m = fabs(y);
double code(double x, double y_m, double z) {
double tmp;
if ((x <= -1e+40) || !(x <= 75000000000000.0)) {
tmp = fabs((x * ((z / y_m) + (-1.0 / y_m))));
} else {
tmp = fabs((((x + 4.0) - (x * z)) / y_m));
}
return tmp;
}
y_m = abs(y)
real(8) function code(x, y_m, z)
real(8), intent (in) :: x
real(8), intent (in) :: y_m
real(8), intent (in) :: z
real(8) :: tmp
if ((x <= (-1d+40)) .or. (.not. (x <= 75000000000000.0d0))) then
tmp = abs((x * ((z / y_m) + ((-1.0d0) / y_m))))
else
tmp = abs((((x + 4.0d0) - (x * z)) / y_m))
end if
code = tmp
end function
y_m = Math.abs(y);
public static double code(double x, double y_m, double z) {
double tmp;
if ((x <= -1e+40) || !(x <= 75000000000000.0)) {
tmp = Math.abs((x * ((z / y_m) + (-1.0 / y_m))));
} else {
tmp = Math.abs((((x + 4.0) - (x * z)) / y_m));
}
return tmp;
}
y_m = math.fabs(y) def code(x, y_m, z): tmp = 0 if (x <= -1e+40) or not (x <= 75000000000000.0): tmp = math.fabs((x * ((z / y_m) + (-1.0 / y_m)))) else: tmp = math.fabs((((x + 4.0) - (x * z)) / y_m)) return tmp
y_m = abs(y) function code(x, y_m, z) tmp = 0.0 if ((x <= -1e+40) || !(x <= 75000000000000.0)) tmp = abs(Float64(x * Float64(Float64(z / y_m) + Float64(-1.0 / y_m)))); else tmp = abs(Float64(Float64(Float64(x + 4.0) - Float64(x * z)) / y_m)); end return tmp end
y_m = abs(y); function tmp_2 = code(x, y_m, z) tmp = 0.0; if ((x <= -1e+40) || ~((x <= 75000000000000.0))) tmp = abs((x * ((z / y_m) + (-1.0 / y_m)))); else tmp = abs((((x + 4.0) - (x * z)) / y_m)); end tmp_2 = tmp; end
y_m = N[Abs[y], $MachinePrecision] code[x_, y$95$m_, z_] := If[Or[LessEqual[x, -1e+40], N[Not[LessEqual[x, 75000000000000.0]], $MachinePrecision]], N[Abs[N[(x * N[(N[(z / y$95$m), $MachinePrecision] + N[(-1.0 / y$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[(N[(x + 4.0), $MachinePrecision] - N[(x * z), $MachinePrecision]), $MachinePrecision] / y$95$m), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
y_m = \left|y\right|
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1 \cdot 10^{+40} \lor \neg \left(x \leq 75000000000000\right):\\
\;\;\;\;\left|x \cdot \left(\frac{z}{y_m} + \frac{-1}{y_m}\right)\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\frac{\left(x + 4\right) - x \cdot z}{y_m}\right|\\
\end{array}
\end{array}
if x < -1.00000000000000003e40 or 7.5e13 < x Initial program 83.2%
Simplified93.3%
Taylor expanded in x around inf 99.9%
if -1.00000000000000003e40 < x < 7.5e13Initial program 97.2%
Taylor expanded in y around 0 99.9%
Final simplification99.9%
y_m = (fabs.f64 y) (FPCore (x y_m z) :precision binary64 (if (or (<= x -1.14e-7) (not (<= x 4.2e-111))) (fabs (/ (+ z -1.0) (/ y_m x))) (fabs (/ (- x -4.0) y_m))))
y_m = fabs(y);
double code(double x, double y_m, double z) {
double tmp;
if ((x <= -1.14e-7) || !(x <= 4.2e-111)) {
tmp = fabs(((z + -1.0) / (y_m / x)));
} else {
tmp = fabs(((x - -4.0) / y_m));
}
return tmp;
}
y_m = abs(y)
real(8) function code(x, y_m, z)
real(8), intent (in) :: x
real(8), intent (in) :: y_m
real(8), intent (in) :: z
real(8) :: tmp
if ((x <= (-1.14d-7)) .or. (.not. (x <= 4.2d-111))) then
tmp = abs(((z + (-1.0d0)) / (y_m / x)))
else
tmp = abs(((x - (-4.0d0)) / y_m))
end if
code = tmp
end function
y_m = Math.abs(y);
public static double code(double x, double y_m, double z) {
double tmp;
if ((x <= -1.14e-7) || !(x <= 4.2e-111)) {
tmp = Math.abs(((z + -1.0) / (y_m / x)));
} else {
tmp = Math.abs(((x - -4.0) / y_m));
}
return tmp;
}
y_m = math.fabs(y) def code(x, y_m, z): tmp = 0 if (x <= -1.14e-7) or not (x <= 4.2e-111): tmp = math.fabs(((z + -1.0) / (y_m / x))) else: tmp = math.fabs(((x - -4.0) / y_m)) return tmp
y_m = abs(y) function code(x, y_m, z) tmp = 0.0 if ((x <= -1.14e-7) || !(x <= 4.2e-111)) tmp = abs(Float64(Float64(z + -1.0) / Float64(y_m / x))); else tmp = abs(Float64(Float64(x - -4.0) / y_m)); end return tmp end
y_m = abs(y); function tmp_2 = code(x, y_m, z) tmp = 0.0; if ((x <= -1.14e-7) || ~((x <= 4.2e-111))) tmp = abs(((z + -1.0) / (y_m / x))); else tmp = abs(((x - -4.0) / y_m)); end tmp_2 = tmp; end
y_m = N[Abs[y], $MachinePrecision] code[x_, y$95$m_, z_] := If[Or[LessEqual[x, -1.14e-7], N[Not[LessEqual[x, 4.2e-111]], $MachinePrecision]], N[Abs[N[(N[(z + -1.0), $MachinePrecision] / N[(y$95$m / x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[(x - -4.0), $MachinePrecision] / y$95$m), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
y_m = \left|y\right|
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.14 \cdot 10^{-7} \lor \neg \left(x \leq 4.2 \cdot 10^{-111}\right):\\
\;\;\;\;\left|\frac{z + -1}{\frac{y_m}{x}}\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\frac{x - -4}{y_m}\right|\\
\end{array}
\end{array}
if x < -1.14000000000000002e-7 or 4.1999999999999997e-111 < x Initial program 86.6%
Simplified94.2%
Taylor expanded in x around -inf 99.3%
Simplified90.7%
Taylor expanded in x around inf 85.6%
sub-neg85.6%
metadata-eval85.6%
*-commutative85.6%
associate-/l*93.9%
Simplified93.9%
if -1.14000000000000002e-7 < x < 4.1999999999999997e-111Initial program 96.8%
Simplified90.7%
Taylor expanded in z around 0 83.2%
associate-*r/83.2%
distribute-lft-in83.2%
metadata-eval83.2%
neg-mul-183.2%
sub-neg83.2%
Simplified83.2%
Final simplification89.6%
y_m = (fabs.f64 y) (FPCore (x y_m z) :precision binary64 (if (<= z -180000000000.0) (fabs (* x (/ z y_m))) (if (<= z 1.8e+30) (fabs (/ (- x -4.0) y_m)) (fabs (* z (/ x y_m))))))
y_m = fabs(y);
double code(double x, double y_m, double z) {
double tmp;
if (z <= -180000000000.0) {
tmp = fabs((x * (z / y_m)));
} else if (z <= 1.8e+30) {
tmp = fabs(((x - -4.0) / y_m));
} else {
tmp = fabs((z * (x / y_m)));
}
return tmp;
}
y_m = abs(y)
real(8) function code(x, y_m, z)
real(8), intent (in) :: x
real(8), intent (in) :: y_m
real(8), intent (in) :: z
real(8) :: tmp
if (z <= (-180000000000.0d0)) then
tmp = abs((x * (z / y_m)))
else if (z <= 1.8d+30) then
tmp = abs(((x - (-4.0d0)) / y_m))
else
tmp = abs((z * (x / y_m)))
end if
code = tmp
end function
y_m = Math.abs(y);
public static double code(double x, double y_m, double z) {
double tmp;
if (z <= -180000000000.0) {
tmp = Math.abs((x * (z / y_m)));
} else if (z <= 1.8e+30) {
tmp = Math.abs(((x - -4.0) / y_m));
} else {
tmp = Math.abs((z * (x / y_m)));
}
return tmp;
}
y_m = math.fabs(y) def code(x, y_m, z): tmp = 0 if z <= -180000000000.0: tmp = math.fabs((x * (z / y_m))) elif z <= 1.8e+30: tmp = math.fabs(((x - -4.0) / y_m)) else: tmp = math.fabs((z * (x / y_m))) return tmp
y_m = abs(y) function code(x, y_m, z) tmp = 0.0 if (z <= -180000000000.0) tmp = abs(Float64(x * Float64(z / y_m))); elseif (z <= 1.8e+30) tmp = abs(Float64(Float64(x - -4.0) / y_m)); else tmp = abs(Float64(z * Float64(x / y_m))); end return tmp end
y_m = abs(y); function tmp_2 = code(x, y_m, z) tmp = 0.0; if (z <= -180000000000.0) tmp = abs((x * (z / y_m))); elseif (z <= 1.8e+30) tmp = abs(((x - -4.0) / y_m)); else tmp = abs((z * (x / y_m))); end tmp_2 = tmp; end
y_m = N[Abs[y], $MachinePrecision] code[x_, y$95$m_, z_] := If[LessEqual[z, -180000000000.0], N[Abs[N[(x * N[(z / y$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[z, 1.8e+30], N[Abs[N[(N[(x - -4.0), $MachinePrecision] / y$95$m), $MachinePrecision]], $MachinePrecision], N[Abs[N[(z * N[(x / y$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
y_m = \left|y\right|
\\
\begin{array}{l}
\mathbf{if}\;z \leq -180000000000:\\
\;\;\;\;\left|x \cdot \frac{z}{y_m}\right|\\
\mathbf{elif}\;z \leq 1.8 \cdot 10^{+30}:\\
\;\;\;\;\left|\frac{x - -4}{y_m}\right|\\
\mathbf{else}:\\
\;\;\;\;\left|z \cdot \frac{x}{y_m}\right|\\
\end{array}
\end{array}
if z < -1.8e11Initial program 96.0%
Simplified96.7%
Taylor expanded in x around -inf 96.7%
Simplified88.7%
Taylor expanded in z around inf 67.8%
associate-*r/78.9%
Simplified78.9%
if -1.8e11 < z < 1.8000000000000001e30Initial program 91.8%
Simplified100.0%
Taylor expanded in z around 0 97.9%
associate-*r/97.9%
distribute-lft-in97.9%
metadata-eval97.9%
neg-mul-197.9%
sub-neg97.9%
Simplified97.9%
if 1.8000000000000001e30 < z Initial program 83.3%
Simplified73.8%
Taylor expanded in x around -inf 86.5%
Simplified87.8%
Taylor expanded in z around inf 66.1%
associate-*l/76.4%
Applied egg-rr76.4%
Final simplification88.3%
y_m = (fabs.f64 y) (FPCore (x y_m z) :precision binary64 (if (or (<= x -10.2) (not (<= x 4.0))) (fabs (/ x y_m)) (fabs (/ 4.0 y_m))))
y_m = fabs(y);
double code(double x, double y_m, double z) {
double tmp;
if ((x <= -10.2) || !(x <= 4.0)) {
tmp = fabs((x / y_m));
} else {
tmp = fabs((4.0 / y_m));
}
return tmp;
}
y_m = abs(y)
real(8) function code(x, y_m, z)
real(8), intent (in) :: x
real(8), intent (in) :: y_m
real(8), intent (in) :: z
real(8) :: tmp
if ((x <= (-10.2d0)) .or. (.not. (x <= 4.0d0))) then
tmp = abs((x / y_m))
else
tmp = abs((4.0d0 / y_m))
end if
code = tmp
end function
y_m = Math.abs(y);
public static double code(double x, double y_m, double z) {
double tmp;
if ((x <= -10.2) || !(x <= 4.0)) {
tmp = Math.abs((x / y_m));
} else {
tmp = Math.abs((4.0 / y_m));
}
return tmp;
}
y_m = math.fabs(y) def code(x, y_m, z): tmp = 0 if (x <= -10.2) or not (x <= 4.0): tmp = math.fabs((x / y_m)) else: tmp = math.fabs((4.0 / y_m)) return tmp
y_m = abs(y) function code(x, y_m, z) tmp = 0.0 if ((x <= -10.2) || !(x <= 4.0)) tmp = abs(Float64(x / y_m)); else tmp = abs(Float64(4.0 / y_m)); end return tmp end
y_m = abs(y); function tmp_2 = code(x, y_m, z) tmp = 0.0; if ((x <= -10.2) || ~((x <= 4.0))) tmp = abs((x / y_m)); else tmp = abs((4.0 / y_m)); end tmp_2 = tmp; end
y_m = N[Abs[y], $MachinePrecision] code[x_, y$95$m_, z_] := If[Or[LessEqual[x, -10.2], N[Not[LessEqual[x, 4.0]], $MachinePrecision]], N[Abs[N[(x / y$95$m), $MachinePrecision]], $MachinePrecision], N[Abs[N[(4.0 / y$95$m), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
y_m = \left|y\right|
\\
\begin{array}{l}
\mathbf{if}\;x \leq -10.2 \lor \neg \left(x \leq 4\right):\\
\;\;\;\;\left|\frac{x}{y_m}\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\frac{4}{y_m}\right|\\
\end{array}
\end{array}
if x < -10.199999999999999 or 4 < x Initial program 84.7%
Simplified93.9%
Taylor expanded in x around inf 98.8%
Taylor expanded in z around 0 61.2%
associate-*r/61.2%
neg-mul-161.2%
Simplified61.2%
if -10.199999999999999 < x < 4Initial program 96.9%
Taylor expanded in x around 0 73.4%
Final simplification67.1%
y_m = (fabs.f64 y) (FPCore (x y_m z) :precision binary64 (fabs (/ 4.0 y_m)))
y_m = fabs(y);
double code(double x, double y_m, double z) {
return fabs((4.0 / y_m));
}
y_m = abs(y)
real(8) function code(x, y_m, z)
real(8), intent (in) :: x
real(8), intent (in) :: y_m
real(8), intent (in) :: z
code = abs((4.0d0 / y_m))
end function
y_m = Math.abs(y);
public static double code(double x, double y_m, double z) {
return Math.abs((4.0 / y_m));
}
y_m = math.fabs(y) def code(x, y_m, z): return math.fabs((4.0 / y_m))
y_m = abs(y) function code(x, y_m, z) return abs(Float64(4.0 / y_m)) end
y_m = abs(y); function tmp = code(x, y_m, z) tmp = abs((4.0 / y_m)); end
y_m = N[Abs[y], $MachinePrecision] code[x_, y$95$m_, z_] := N[Abs[N[(4.0 / y$95$m), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
y_m = \left|y\right|
\\
\left|\frac{4}{y_m}\right|
\end{array}
Initial program 90.7%
Taylor expanded in x around 0 38.2%
Final simplification38.2%
herbie shell --seed 2024013
(FPCore (x y z)
:name "fabs fraction 1"
:precision binary64
(fabs (- (/ (+ x 4.0) y) (* (/ x y) z))))