
(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}
y_m = (fabs.f64 y) (FPCore (x y_m z) :precision binary64 (if (<= y_m 2e-26) (fabs (/ (- (+ x 4.0) (* x z)) y_m)) (fabs (- (* x (/ z y_m)) (/ (+ x 4.0) y_m)))))
y_m = fabs(y);
double code(double x, double y_m, double z) {
double tmp;
if (y_m <= 2e-26) {
tmp = fabs((((x + 4.0) - (x * z)) / y_m));
} else {
tmp = fabs(((x * (z / y_m)) - ((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 (y_m <= 2d-26) then
tmp = abs((((x + 4.0d0) - (x * z)) / y_m))
else
tmp = abs(((x * (z / y_m)) - ((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 (y_m <= 2e-26) {
tmp = Math.abs((((x + 4.0) - (x * z)) / y_m));
} else {
tmp = Math.abs(((x * (z / y_m)) - ((x + 4.0) / y_m)));
}
return tmp;
}
y_m = math.fabs(y) def code(x, y_m, z): tmp = 0 if y_m <= 2e-26: tmp = math.fabs((((x + 4.0) - (x * z)) / y_m)) else: tmp = math.fabs(((x * (z / y_m)) - ((x + 4.0) / y_m))) return tmp
y_m = abs(y) function code(x, y_m, z) tmp = 0.0 if (y_m <= 2e-26) tmp = abs(Float64(Float64(Float64(x + 4.0) - Float64(x * z)) / y_m)); else tmp = abs(Float64(Float64(x * Float64(z / y_m)) - 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 (y_m <= 2e-26) tmp = abs((((x + 4.0) - (x * z)) / y_m)); else tmp = abs(((x * (z / y_m)) - ((x + 4.0) / y_m))); end tmp_2 = tmp; end
y_m = N[Abs[y], $MachinePrecision] code[x_, y$95$m_, z_] := If[LessEqual[y$95$m, 2e-26], N[Abs[N[(N[(N[(x + 4.0), $MachinePrecision] - N[(x * z), $MachinePrecision]), $MachinePrecision] / y$95$m), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[(x * N[(z / y$95$m), $MachinePrecision]), $MachinePrecision] - N[(N[(x + 4.0), $MachinePrecision] / y$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
y_m = \left|y\right|
\\
\begin{array}{l}
\mathbf{if}\;y\_m \leq 2 \cdot 10^{-26}:\\
\;\;\;\;\left|\frac{\left(x + 4\right) - x \cdot z}{y\_m}\right|\\
\mathbf{else}:\\
\;\;\;\;\left|x \cdot \frac{z}{y\_m} - \frac{x + 4}{y\_m}\right|\\
\end{array}
\end{array}
if y < 2.0000000000000001e-26Initial program 88.7%
associate-*l/90.7%
sub-div96.4%
Applied egg-rr96.4%
if 2.0000000000000001e-26 < y Initial program 95.7%
Taylor expanded in x around 0 94.1%
associate-*r/99.9%
Simplified99.9%
Final simplification97.3%
y_m = (fabs.f64 y) (FPCore (x y_m z) :precision binary64 (if (or (<= x -530000000.0) (not (<= x 1.75e-26))) (fabs (* x (/ (- 1.0 z) y_m))) (fabs (/ (- -4.0 x) y_m))))
y_m = fabs(y);
double code(double x, double y_m, double z) {
double tmp;
if ((x <= -530000000.0) || !(x <= 1.75e-26)) {
tmp = fabs((x * ((1.0 - z) / y_m)));
} else {
tmp = fabs(((-4.0 - 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 ((x <= (-530000000.0d0)) .or. (.not. (x <= 1.75d-26))) then
tmp = abs((x * ((1.0d0 - z) / y_m)))
else
tmp = abs((((-4.0d0) - 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 ((x <= -530000000.0) || !(x <= 1.75e-26)) {
tmp = Math.abs((x * ((1.0 - z) / y_m)));
} else {
tmp = Math.abs(((-4.0 - x) / y_m));
}
return tmp;
}
y_m = math.fabs(y) def code(x, y_m, z): tmp = 0 if (x <= -530000000.0) or not (x <= 1.75e-26): tmp = math.fabs((x * ((1.0 - z) / y_m))) else: tmp = math.fabs(((-4.0 - x) / y_m)) return tmp
y_m = abs(y) function code(x, y_m, z) tmp = 0.0 if ((x <= -530000000.0) || !(x <= 1.75e-26)) tmp = abs(Float64(x * Float64(Float64(1.0 - z) / y_m))); else tmp = abs(Float64(Float64(-4.0 - x) / y_m)); end return tmp end
y_m = abs(y); function tmp_2 = code(x, y_m, z) tmp = 0.0; if ((x <= -530000000.0) || ~((x <= 1.75e-26))) tmp = abs((x * ((1.0 - z) / y_m))); else tmp = abs(((-4.0 - x) / y_m)); end tmp_2 = tmp; end
y_m = N[Abs[y], $MachinePrecision] code[x_, y$95$m_, z_] := If[Or[LessEqual[x, -530000000.0], N[Not[LessEqual[x, 1.75e-26]], $MachinePrecision]], N[Abs[N[(x * N[(N[(1.0 - z), $MachinePrecision] / y$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[(-4.0 - x), $MachinePrecision] / y$95$m), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
y_m = \left|y\right|
\\
\begin{array}{l}
\mathbf{if}\;x \leq -530000000 \lor \neg \left(x \leq 1.75 \cdot 10^{-26}\right):\\
\;\;\;\;\left|x \cdot \frac{1 - z}{y\_m}\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\frac{-4 - x}{y\_m}\right|\\
\end{array}
\end{array}
if x < -5.3e8 or 1.74999999999999992e-26 < x Initial program 85.6%
Simplified90.5%
Taylor expanded in x around inf 89.1%
mul-1-neg89.1%
associate-/l*98.3%
distribute-rgt-neg-in98.3%
mul-1-neg98.3%
associate-*r/98.3%
sub-neg98.3%
metadata-eval98.3%
distribute-lft-in98.3%
neg-mul-198.3%
metadata-eval98.3%
+-commutative98.3%
unsub-neg98.3%
Simplified98.3%
if -5.3e8 < x < 1.74999999999999992e-26Initial program 94.3%
Simplified99.8%
Taylor expanded in z around 0 78.9%
+-commutative78.9%
rem-square-sqrt36.6%
fabs-sqr36.6%
rem-square-sqrt78.9%
fabs-neg78.9%
distribute-neg-frac78.9%
distribute-neg-in78.9%
metadata-eval78.9%
+-commutative78.9%
sub-neg78.9%
rem-square-sqrt41.8%
fabs-sqr41.8%
rem-square-sqrt78.9%
Simplified78.9%
Final simplification87.4%
y_m = (fabs.f64 y)
(FPCore (x y_m z)
:precision binary64
(if (<= x -530000000.0)
(fabs (* (- 1.0 z) (/ x y_m)))
(if (<= x 2.6e-24)
(fabs (- (/ -4.0 y_m) (/ x y_m)))
(fabs (* x (/ (- 1.0 z) y_m))))))y_m = fabs(y);
double code(double x, double y_m, double z) {
double tmp;
if (x <= -530000000.0) {
tmp = fabs(((1.0 - z) * (x / y_m)));
} else if (x <= 2.6e-24) {
tmp = fabs(((-4.0 / y_m) - (x / y_m)));
} else {
tmp = fabs((x * ((1.0 - 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 <= (-530000000.0d0)) then
tmp = abs(((1.0d0 - z) * (x / y_m)))
else if (x <= 2.6d-24) then
tmp = abs((((-4.0d0) / y_m) - (x / y_m)))
else
tmp = abs((x * ((1.0d0 - 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 <= -530000000.0) {
tmp = Math.abs(((1.0 - z) * (x / y_m)));
} else if (x <= 2.6e-24) {
tmp = Math.abs(((-4.0 / y_m) - (x / y_m)));
} else {
tmp = Math.abs((x * ((1.0 - z) / y_m)));
}
return tmp;
}
y_m = math.fabs(y) def code(x, y_m, z): tmp = 0 if x <= -530000000.0: tmp = math.fabs(((1.0 - z) * (x / y_m))) elif x <= 2.6e-24: tmp = math.fabs(((-4.0 / y_m) - (x / y_m))) else: tmp = math.fabs((x * ((1.0 - z) / y_m))) return tmp
y_m = abs(y) function code(x, y_m, z) tmp = 0.0 if (x <= -530000000.0) tmp = abs(Float64(Float64(1.0 - z) * Float64(x / y_m))); elseif (x <= 2.6e-24) tmp = abs(Float64(Float64(-4.0 / y_m) - Float64(x / y_m))); else tmp = abs(Float64(x * Float64(Float64(1.0 - z) / y_m))); end return tmp end
y_m = abs(y); function tmp_2 = code(x, y_m, z) tmp = 0.0; if (x <= -530000000.0) tmp = abs(((1.0 - z) * (x / y_m))); elseif (x <= 2.6e-24) tmp = abs(((-4.0 / y_m) - (x / y_m))); else tmp = abs((x * ((1.0 - z) / y_m))); end tmp_2 = tmp; end
y_m = N[Abs[y], $MachinePrecision] code[x_, y$95$m_, z_] := If[LessEqual[x, -530000000.0], N[Abs[N[(N[(1.0 - z), $MachinePrecision] * N[(x / y$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[x, 2.6e-24], N[Abs[N[(N[(-4.0 / y$95$m), $MachinePrecision] - N[(x / y$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(x * N[(N[(1.0 - z), $MachinePrecision] / y$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
y_m = \left|y\right|
\\
\begin{array}{l}
\mathbf{if}\;x \leq -530000000:\\
\;\;\;\;\left|\left(1 - z\right) \cdot \frac{x}{y\_m}\right|\\
\mathbf{elif}\;x \leq 2.6 \cdot 10^{-24}:\\
\;\;\;\;\left|\frac{-4}{y\_m} - \frac{x}{y\_m}\right|\\
\mathbf{else}:\\
\;\;\;\;\left|x \cdot \frac{1 - z}{y\_m}\right|\\
\end{array}
\end{array}
if x < -5.3e8Initial program 84.8%
Simplified92.6%
Taylor expanded in x around inf 92.8%
associate-*r/92.8%
*-commutative92.8%
associate-*r*92.8%
sub-neg92.8%
metadata-eval92.8%
distribute-lft-in92.8%
neg-mul-192.8%
metadata-eval92.8%
+-commutative92.8%
neg-mul-192.8%
associate-/l*99.9%
neg-mul-199.9%
unsub-neg99.9%
Simplified99.9%
if -5.3e8 < x < 2.6e-24Initial program 94.3%
Simplified99.8%
Taylor expanded in z around 0 78.9%
+-commutative78.9%
rem-square-sqrt36.6%
fabs-sqr36.6%
rem-square-sqrt78.9%
fabs-neg78.9%
distribute-neg-frac78.9%
distribute-neg-in78.9%
metadata-eval78.9%
+-commutative78.9%
sub-neg78.9%
rem-square-sqrt41.8%
fabs-sqr41.8%
rem-square-sqrt78.9%
Simplified78.9%
div-sub78.9%
Applied egg-rr78.9%
if 2.6e-24 < x Initial program 86.2%
Simplified88.6%
Taylor expanded in x around inf 85.8%
mul-1-neg85.8%
associate-/l*96.9%
distribute-rgt-neg-in96.9%
mul-1-neg96.9%
associate-*r/96.9%
sub-neg96.9%
metadata-eval96.9%
distribute-lft-in96.9%
neg-mul-196.9%
metadata-eval96.9%
+-commutative96.9%
unsub-neg96.9%
Simplified96.9%
y_m = (fabs.f64 y)
(FPCore (x y_m z)
:precision binary64
(if (<= x -530000000.0)
(fabs (* (- 1.0 z) (/ x y_m)))
(if (<= x 4.3e-26)
(fabs (/ (- -4.0 x) y_m))
(fabs (* x (/ (- 1.0 z) y_m))))))y_m = fabs(y);
double code(double x, double y_m, double z) {
double tmp;
if (x <= -530000000.0) {
tmp = fabs(((1.0 - z) * (x / y_m)));
} else if (x <= 4.3e-26) {
tmp = fabs(((-4.0 - x) / y_m));
} else {
tmp = fabs((x * ((1.0 - 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 <= (-530000000.0d0)) then
tmp = abs(((1.0d0 - z) * (x / y_m)))
else if (x <= 4.3d-26) then
tmp = abs((((-4.0d0) - x) / y_m))
else
tmp = abs((x * ((1.0d0 - 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 <= -530000000.0) {
tmp = Math.abs(((1.0 - z) * (x / y_m)));
} else if (x <= 4.3e-26) {
tmp = Math.abs(((-4.0 - x) / y_m));
} else {
tmp = Math.abs((x * ((1.0 - z) / y_m)));
}
return tmp;
}
y_m = math.fabs(y) def code(x, y_m, z): tmp = 0 if x <= -530000000.0: tmp = math.fabs(((1.0 - z) * (x / y_m))) elif x <= 4.3e-26: tmp = math.fabs(((-4.0 - x) / y_m)) else: tmp = math.fabs((x * ((1.0 - z) / y_m))) return tmp
y_m = abs(y) function code(x, y_m, z) tmp = 0.0 if (x <= -530000000.0) tmp = abs(Float64(Float64(1.0 - z) * Float64(x / y_m))); elseif (x <= 4.3e-26) tmp = abs(Float64(Float64(-4.0 - x) / y_m)); else tmp = abs(Float64(x * Float64(Float64(1.0 - z) / y_m))); end return tmp end
y_m = abs(y); function tmp_2 = code(x, y_m, z) tmp = 0.0; if (x <= -530000000.0) tmp = abs(((1.0 - z) * (x / y_m))); elseif (x <= 4.3e-26) tmp = abs(((-4.0 - x) / y_m)); else tmp = abs((x * ((1.0 - z) / y_m))); end tmp_2 = tmp; end
y_m = N[Abs[y], $MachinePrecision] code[x_, y$95$m_, z_] := If[LessEqual[x, -530000000.0], N[Abs[N[(N[(1.0 - z), $MachinePrecision] * N[(x / y$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[x, 4.3e-26], N[Abs[N[(N[(-4.0 - x), $MachinePrecision] / y$95$m), $MachinePrecision]], $MachinePrecision], N[Abs[N[(x * N[(N[(1.0 - z), $MachinePrecision] / y$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
y_m = \left|y\right|
\\
\begin{array}{l}
\mathbf{if}\;x \leq -530000000:\\
\;\;\;\;\left|\left(1 - z\right) \cdot \frac{x}{y\_m}\right|\\
\mathbf{elif}\;x \leq 4.3 \cdot 10^{-26}:\\
\;\;\;\;\left|\frac{-4 - x}{y\_m}\right|\\
\mathbf{else}:\\
\;\;\;\;\left|x \cdot \frac{1 - z}{y\_m}\right|\\
\end{array}
\end{array}
if x < -5.3e8Initial program 84.8%
Simplified92.6%
Taylor expanded in x around inf 92.8%
associate-*r/92.8%
*-commutative92.8%
associate-*r*92.8%
sub-neg92.8%
metadata-eval92.8%
distribute-lft-in92.8%
neg-mul-192.8%
metadata-eval92.8%
+-commutative92.8%
neg-mul-192.8%
associate-/l*99.9%
neg-mul-199.9%
unsub-neg99.9%
Simplified99.9%
if -5.3e8 < x < 4.29999999999999988e-26Initial program 94.3%
Simplified99.8%
Taylor expanded in z around 0 78.9%
+-commutative78.9%
rem-square-sqrt36.6%
fabs-sqr36.6%
rem-square-sqrt78.9%
fabs-neg78.9%
distribute-neg-frac78.9%
distribute-neg-in78.9%
metadata-eval78.9%
+-commutative78.9%
sub-neg78.9%
rem-square-sqrt41.8%
fabs-sqr41.8%
rem-square-sqrt78.9%
Simplified78.9%
if 4.29999999999999988e-26 < x Initial program 86.2%
Simplified88.6%
Taylor expanded in x around inf 85.8%
mul-1-neg85.8%
associate-/l*96.9%
distribute-rgt-neg-in96.9%
mul-1-neg96.9%
associate-*r/96.9%
sub-neg96.9%
metadata-eval96.9%
distribute-lft-in96.9%
neg-mul-196.9%
metadata-eval96.9%
+-commutative96.9%
unsub-neg96.9%
Simplified96.9%
y_m = (fabs.f64 y) (FPCore (x y_m z) :precision binary64 (if (or (<= x -3.1e-35) (not (<= x 3e-23))) (fabs (* z (/ 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 <= -3.1e-35) || !(x <= 3e-23)) {
tmp = fabs((z * (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 <= (-3.1d-35)) .or. (.not. (x <= 3d-23))) then
tmp = abs((z * (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 <= -3.1e-35) || !(x <= 3e-23)) {
tmp = Math.abs((z * (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 <= -3.1e-35) or not (x <= 3e-23): tmp = math.fabs((z * (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 <= -3.1e-35) || !(x <= 3e-23)) tmp = abs(Float64(z * 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 <= -3.1e-35) || ~((x <= 3e-23))) tmp = abs((z * (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, -3.1e-35], N[Not[LessEqual[x, 3e-23]], $MachinePrecision]], N[Abs[N[(z * N[(x / y$95$m), $MachinePrecision]), $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 -3.1 \cdot 10^{-35} \lor \neg \left(x \leq 3 \cdot 10^{-23}\right):\\
\;\;\;\;\left|z \cdot \frac{x}{y\_m}\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\frac{4}{y\_m}\right|\\
\end{array}
\end{array}
if x < -3.10000000000000012e-35 or 3.00000000000000003e-23 < x Initial program 86.4%
Simplified91.0%
Taylor expanded in z around inf 50.8%
mul-1-neg50.8%
associate-*r/59.5%
*-commutative59.5%
distribute-rgt-neg-in59.5%
Simplified59.5%
*-commutative59.5%
clear-num59.3%
un-div-inv59.5%
add-sqr-sqrt29.5%
sqrt-unprod56.3%
sqr-neg56.3%
sqrt-unprod29.9%
add-sqr-sqrt59.5%
Applied egg-rr59.5%
associate-/r/65.8%
*-commutative65.8%
Simplified65.8%
if -3.10000000000000012e-35 < x < 3.00000000000000003e-23Initial program 94.1%
Simplified99.9%
Taylor expanded in x around 0 79.9%
Final simplification73.4%
y_m = (fabs.f64 y) (FPCore (x y_m z) :precision binary64 (if (<= z -1.2e+52) (fabs (* x (/ z y_m))) (if (<= z 1.42e+75) (fabs (/ (- -4.0 x) y_m)) (fabs (/ z (/ y_m x))))))
y_m = fabs(y);
double code(double x, double y_m, double z) {
double tmp;
if (z <= -1.2e+52) {
tmp = fabs((x * (z / y_m)));
} else if (z <= 1.42e+75) {
tmp = fabs(((-4.0 - x) / y_m));
} else {
tmp = fabs((z / (y_m / x)));
}
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 <= (-1.2d+52)) then
tmp = abs((x * (z / y_m)))
else if (z <= 1.42d+75) then
tmp = abs((((-4.0d0) - x) / y_m))
else
tmp = abs((z / (y_m / x)))
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 <= -1.2e+52) {
tmp = Math.abs((x * (z / y_m)));
} else if (z <= 1.42e+75) {
tmp = Math.abs(((-4.0 - x) / y_m));
} else {
tmp = Math.abs((z / (y_m / x)));
}
return tmp;
}
y_m = math.fabs(y) def code(x, y_m, z): tmp = 0 if z <= -1.2e+52: tmp = math.fabs((x * (z / y_m))) elif z <= 1.42e+75: tmp = math.fabs(((-4.0 - x) / y_m)) else: tmp = math.fabs((z / (y_m / x))) return tmp
y_m = abs(y) function code(x, y_m, z) tmp = 0.0 if (z <= -1.2e+52) tmp = abs(Float64(x * Float64(z / y_m))); elseif (z <= 1.42e+75) tmp = abs(Float64(Float64(-4.0 - x) / y_m)); else tmp = abs(Float64(z / Float64(y_m / x))); end return tmp end
y_m = abs(y); function tmp_2 = code(x, y_m, z) tmp = 0.0; if (z <= -1.2e+52) tmp = abs((x * (z / y_m))); elseif (z <= 1.42e+75) tmp = abs(((-4.0 - x) / y_m)); else tmp = abs((z / (y_m / x))); end tmp_2 = tmp; end
y_m = N[Abs[y], $MachinePrecision] code[x_, y$95$m_, z_] := If[LessEqual[z, -1.2e+52], N[Abs[N[(x * N[(z / y$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[z, 1.42e+75], N[Abs[N[(N[(-4.0 - x), $MachinePrecision] / y$95$m), $MachinePrecision]], $MachinePrecision], N[Abs[N[(z / N[(y$95$m / x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
y_m = \left|y\right|
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.2 \cdot 10^{+52}:\\
\;\;\;\;\left|x \cdot \frac{z}{y\_m}\right|\\
\mathbf{elif}\;z \leq 1.42 \cdot 10^{+75}:\\
\;\;\;\;\left|\frac{-4 - x}{y\_m}\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\frac{z}{\frac{y\_m}{x}}\right|\\
\end{array}
\end{array}
if z < -1.2e52Initial program 90.3%
Simplified86.6%
Taylor expanded in z around inf 67.4%
associate-*r/67.4%
neg-mul-167.4%
distribute-rgt-neg-in67.4%
Simplified67.4%
distribute-rgt-neg-out67.4%
distribute-lft-neg-in67.4%
associate-*r/77.7%
*-commutative77.7%
add-sqr-sqrt35.5%
sqrt-unprod60.1%
sqr-neg60.1%
sqrt-unprod42.0%
add-sqr-sqrt77.7%
Applied egg-rr77.7%
if -1.2e52 < z < 1.42e75Initial program 93.3%
Simplified99.8%
Taylor expanded in z around 0 93.9%
+-commutative93.9%
rem-square-sqrt42.3%
fabs-sqr42.3%
rem-square-sqrt93.9%
fabs-neg93.9%
distribute-neg-frac93.9%
distribute-neg-in93.9%
metadata-eval93.9%
+-commutative93.9%
sub-neg93.9%
rem-square-sqrt51.1%
fabs-sqr51.1%
rem-square-sqrt93.9%
Simplified93.9%
if 1.42e75 < z Initial program 81.7%
Simplified93.8%
Taylor expanded in z around inf 70.3%
mul-1-neg70.3%
associate-*r/71.1%
*-commutative71.1%
distribute-rgt-neg-in71.1%
Simplified71.1%
*-commutative71.1%
clear-num71.0%
un-div-inv71.2%
add-sqr-sqrt32.5%
sqrt-unprod59.0%
sqr-neg59.0%
sqrt-unprod38.5%
add-sqr-sqrt71.2%
Applied egg-rr71.2%
associate-/r/72.1%
*-commutative72.1%
Simplified72.1%
clear-num72.0%
div-inv72.1%
Applied egg-rr72.1%
Final simplification86.2%
y_m = (fabs.f64 y) (FPCore (x y_m z) :precision binary64 (if (<= x 3.7e+39) (fabs (/ (- (+ x 4.0) (* x z)) y_m)) (fabs (* x (/ (- 1.0 z) y_m)))))
y_m = fabs(y);
double code(double x, double y_m, double z) {
double tmp;
if (x <= 3.7e+39) {
tmp = fabs((((x + 4.0) - (x * z)) / y_m));
} else {
tmp = fabs((x * ((1.0 - 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 <= 3.7d+39) then
tmp = abs((((x + 4.0d0) - (x * z)) / y_m))
else
tmp = abs((x * ((1.0d0 - 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 <= 3.7e+39) {
tmp = Math.abs((((x + 4.0) - (x * z)) / y_m));
} else {
tmp = Math.abs((x * ((1.0 - z) / y_m)));
}
return tmp;
}
y_m = math.fabs(y) def code(x, y_m, z): tmp = 0 if x <= 3.7e+39: tmp = math.fabs((((x + 4.0) - (x * z)) / y_m)) else: tmp = math.fabs((x * ((1.0 - z) / y_m))) return tmp
y_m = abs(y) function code(x, y_m, z) tmp = 0.0 if (x <= 3.7e+39) tmp = abs(Float64(Float64(Float64(x + 4.0) - Float64(x * z)) / y_m)); else tmp = abs(Float64(x * Float64(Float64(1.0 - z) / y_m))); end return tmp end
y_m = abs(y); function tmp_2 = code(x, y_m, z) tmp = 0.0; if (x <= 3.7e+39) tmp = abs((((x + 4.0) - (x * z)) / y_m)); else tmp = abs((x * ((1.0 - z) / y_m))); end tmp_2 = tmp; end
y_m = N[Abs[y], $MachinePrecision] code[x_, y$95$m_, z_] := If[LessEqual[x, 3.7e+39], N[Abs[N[(N[(N[(x + 4.0), $MachinePrecision] - N[(x * z), $MachinePrecision]), $MachinePrecision] / y$95$m), $MachinePrecision]], $MachinePrecision], N[Abs[N[(x * N[(N[(1.0 - z), $MachinePrecision] / y$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
y_m = \left|y\right|
\\
\begin{array}{l}
\mathbf{if}\;x \leq 3.7 \cdot 10^{+39}:\\
\;\;\;\;\left|\frac{\left(x + 4\right) - x \cdot z}{y\_m}\right|\\
\mathbf{else}:\\
\;\;\;\;\left|x \cdot \frac{1 - z}{y\_m}\right|\\
\end{array}
\end{array}
if x < 3.70000000000000012e39Initial program 92.0%
associate-*l/95.6%
sub-div98.0%
Applied egg-rr98.0%
if 3.70000000000000012e39 < x Initial program 84.4%
Simplified87.1%
Taylor expanded in x around inf 87.2%
mul-1-neg87.2%
associate-/l*99.8%
distribute-rgt-neg-in99.8%
mul-1-neg99.8%
associate-*r/99.8%
sub-neg99.8%
metadata-eval99.8%
distribute-lft-in99.8%
neg-mul-199.8%
metadata-eval99.8%
+-commutative99.8%
unsub-neg99.8%
Simplified99.8%
y_m = (fabs.f64 y) (FPCore (x y_m z) :precision binary64 (if (or (<= x -1.55) (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 <= -1.55) || !(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 <= (-1.55d0)) .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 <= -1.55) || !(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 <= -1.55) 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 <= -1.55) || !(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 <= -1.55) || ~((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, -1.55], 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 -1.55 \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 < -1.55000000000000004 or 4 < x Initial program 85.4%
Simplified90.4%
Taylor expanded in x around inf 88.8%
associate-*r/88.8%
*-commutative88.8%
associate-*r*88.8%
sub-neg88.8%
metadata-eval88.8%
distribute-lft-in88.8%
neg-mul-188.8%
metadata-eval88.8%
+-commutative88.8%
neg-mul-188.8%
associate-/l*98.0%
neg-mul-198.0%
unsub-neg98.0%
Simplified98.0%
Taylor expanded in z around 0 61.7%
if -1.55000000000000004 < x < 4Initial program 94.4%
Simplified99.9%
Taylor expanded in x around 0 77.3%
Final simplification70.6%
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.5%
Simplified95.8%
Taylor expanded in x around 0 46.1%
herbie shell --seed 2024106
(FPCore (x y z)
:name "fabs fraction 1"
:precision binary64
(fabs (- (/ (+ x 4.0) y) (* (/ x y) z))))