
(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 7 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 (<= x -1.6e+15) (fabs (/ (+ z -1.0) (/ y x))) (fabs (/ (- (* x z) (+ x 4.0)) y))))
double code(double x, double y, double z) {
double tmp;
if (x <= -1.6e+15) {
tmp = fabs(((z + -1.0) / (y / x)));
} else {
tmp = fabs((((x * z) - (x + 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.6d+15)) then
tmp = abs(((z + (-1.0d0)) / (y / x)))
else
tmp = abs((((x * z) - (x + 4.0d0)) / y))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (x <= -1.6e+15) {
tmp = Math.abs(((z + -1.0) / (y / x)));
} else {
tmp = Math.abs((((x * z) - (x + 4.0)) / y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -1.6e+15: tmp = math.fabs(((z + -1.0) / (y / x))) else: tmp = math.fabs((((x * z) - (x + 4.0)) / y)) return tmp
function code(x, y, z) tmp = 0.0 if (x <= -1.6e+15) tmp = abs(Float64(Float64(z + -1.0) / Float64(y / x))); else tmp = abs(Float64(Float64(Float64(x * z) - Float64(x + 4.0)) / y)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= -1.6e+15) tmp = abs(((z + -1.0) / (y / x))); else tmp = abs((((x * z) - (x + 4.0)) / y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -1.6e+15], N[Abs[N[(N[(z + -1.0), $MachinePrecision] / N[(y / x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[(N[(x * z), $MachinePrecision] - N[(x + 4.0), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.6 \cdot 10^{+15}:\\
\;\;\;\;\left|\frac{z + -1}{\frac{y}{x}}\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\frac{x \cdot z - \left(x + 4\right)}{y}\right|\\
\end{array}
\end{array}
if x < -1.6e15Initial program 80.5%
*-rgt-identity80.5%
fabs-sub80.5%
metadata-eval80.5%
metadata-eval80.5%
fabs-mul80.5%
metadata-eval80.5%
*-rgt-identity80.5%
associate-*l/79.5%
div-sub91.5%
sub-neg91.5%
+-commutative91.5%
remove-double-neg91.5%
distribute-neg-in91.5%
sub-neg91.5%
neg-mul-191.5%
associate-*l/91.3%
remove-double-neg91.3%
distribute-lft-neg-in91.3%
distribute-rgt-neg-in91.3%
Simplified91.3%
Taylor expanded in x around inf 91.5%
associate-/l*99.8%
sub-neg99.8%
metadata-eval99.8%
Simplified99.8%
if -1.6e15 < x Initial program 93.4%
associate-*l/96.8%
sub-div98.4%
Applied egg-rr98.4%
Final simplification98.8%
(FPCore (x y z) :precision binary64 (if (<= z -5.5e+27) (fabs (/ (* x z) y)) (if (<= z 400000.0) (fabs (/ (- -4.0 x) y)) (* (fabs (/ x y)) (fabs z)))))
double code(double x, double y, double z) {
double tmp;
if (z <= -5.5e+27) {
tmp = fabs(((x * z) / y));
} else if (z <= 400000.0) {
tmp = fabs(((-4.0 - x) / y));
} else {
tmp = fabs((x / y)) * fabs(z);
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (z <= (-5.5d+27)) then
tmp = abs(((x * z) / y))
else if (z <= 400000.0d0) then
tmp = abs((((-4.0d0) - x) / y))
else
tmp = abs((x / y)) * abs(z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -5.5e+27) {
tmp = Math.abs(((x * z) / y));
} else if (z <= 400000.0) {
tmp = Math.abs(((-4.0 - x) / y));
} else {
tmp = Math.abs((x / y)) * Math.abs(z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -5.5e+27: tmp = math.fabs(((x * z) / y)) elif z <= 400000.0: tmp = math.fabs(((-4.0 - x) / y)) else: tmp = math.fabs((x / y)) * math.fabs(z) return tmp
function code(x, y, z) tmp = 0.0 if (z <= -5.5e+27) tmp = abs(Float64(Float64(x * z) / y)); elseif (z <= 400000.0) tmp = abs(Float64(Float64(-4.0 - x) / y)); else tmp = Float64(abs(Float64(x / y)) * abs(z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -5.5e+27) tmp = abs(((x * z) / y)); elseif (z <= 400000.0) tmp = abs(((-4.0 - x) / y)); else tmp = abs((x / y)) * abs(z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -5.5e+27], N[Abs[N[(N[(x * z), $MachinePrecision] / y), $MachinePrecision]], $MachinePrecision], If[LessEqual[z, 400000.0], N[Abs[N[(N[(-4.0 - x), $MachinePrecision] / y), $MachinePrecision]], $MachinePrecision], N[(N[Abs[N[(x / y), $MachinePrecision]], $MachinePrecision] * N[Abs[z], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -5.5 \cdot 10^{+27}:\\
\;\;\;\;\left|\frac{x \cdot z}{y}\right|\\
\mathbf{elif}\;z \leq 400000:\\
\;\;\;\;\left|\frac{-4 - x}{y}\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\frac{x}{y}\right| \cdot \left|z\right|\\
\end{array}
\end{array}
if z < -5.49999999999999966e27Initial program 92.5%
*-rgt-identity92.5%
fabs-sub92.5%
metadata-eval92.5%
metadata-eval92.5%
fabs-mul92.5%
metadata-eval92.5%
*-rgt-identity92.5%
associate-*l/95.0%
div-sub94.9%
sub-neg94.9%
+-commutative94.9%
remove-double-neg94.9%
distribute-neg-in94.9%
sub-neg94.9%
neg-mul-194.9%
associate-*l/94.8%
remove-double-neg94.8%
distribute-lft-neg-in94.8%
distribute-rgt-neg-in94.8%
Simplified94.8%
Taylor expanded in z around inf 64.8%
if -5.49999999999999966e27 < z < 4e5Initial program 90.8%
*-rgt-identity90.8%
fabs-sub90.8%
metadata-eval90.8%
metadata-eval90.8%
fabs-mul90.8%
metadata-eval90.8%
*-rgt-identity90.8%
associate-*l/97.2%
div-sub100.0%
sub-neg100.0%
+-commutative100.0%
remove-double-neg100.0%
distribute-neg-in100.0%
sub-neg100.0%
neg-mul-1100.0%
associate-*l/99.8%
remove-double-neg99.8%
distribute-lft-neg-in99.8%
distribute-rgt-neg-in99.8%
Simplified99.8%
Taylor expanded in z around 0 99.4%
associate-*r/99.4%
distribute-lft-in99.4%
metadata-eval99.4%
neg-mul-199.4%
sub-neg99.4%
Simplified99.4%
if 4e5 < z Initial program 85.2%
Taylor expanded in z around inf 73.9%
associate-*r/73.9%
mul-1-neg73.9%
distribute-rgt-neg-out73.9%
associate-*r/83.1%
distribute-frac-neg83.1%
mul-1-neg83.1%
metadata-eval83.1%
times-frac83.1%
*-lft-identity83.1%
neg-mul-183.1%
Simplified83.1%
Final simplification88.0%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (fabs (/ x y))))
(if (<= x -10.5)
t_0
(if (<= x 4e-109)
(fabs (/ 4.0 y))
(if (<= x 3050000.0) (fabs (* x (/ z y))) t_0)))))
double code(double x, double y, double z) {
double t_0 = fabs((x / y));
double tmp;
if (x <= -10.5) {
tmp = t_0;
} else if (x <= 4e-109) {
tmp = fabs((4.0 / y));
} else if (x <= 3050000.0) {
tmp = fabs((x * (z / y)));
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: t_0
real(8) :: tmp
t_0 = abs((x / y))
if (x <= (-10.5d0)) then
tmp = t_0
else if (x <= 4d-109) then
tmp = abs((4.0d0 / y))
else if (x <= 3050000.0d0) then
tmp = abs((x * (z / y)))
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = Math.abs((x / y));
double tmp;
if (x <= -10.5) {
tmp = t_0;
} else if (x <= 4e-109) {
tmp = Math.abs((4.0 / y));
} else if (x <= 3050000.0) {
tmp = Math.abs((x * (z / y)));
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = math.fabs((x / y)) tmp = 0 if x <= -10.5: tmp = t_0 elif x <= 4e-109: tmp = math.fabs((4.0 / y)) elif x <= 3050000.0: tmp = math.fabs((x * (z / y))) else: tmp = t_0 return tmp
function code(x, y, z) t_0 = abs(Float64(x / y)) tmp = 0.0 if (x <= -10.5) tmp = t_0; elseif (x <= 4e-109) tmp = abs(Float64(4.0 / y)); elseif (x <= 3050000.0) tmp = abs(Float64(x * Float64(z / y))); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = abs((x / y)); tmp = 0.0; if (x <= -10.5) tmp = t_0; elseif (x <= 4e-109) tmp = abs((4.0 / y)); elseif (x <= 3050000.0) tmp = abs((x * (z / y))); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[Abs[N[(x / y), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[x, -10.5], t$95$0, If[LessEqual[x, 4e-109], N[Abs[N[(4.0 / y), $MachinePrecision]], $MachinePrecision], If[LessEqual[x, 3050000.0], N[Abs[N[(x * N[(z / y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left|\frac{x}{y}\right|\\
\mathbf{if}\;x \leq -10.5:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 4 \cdot 10^{-109}:\\
\;\;\;\;\left|\frac{4}{y}\right|\\
\mathbf{elif}\;x \leq 3050000:\\
\;\;\;\;\left|x \cdot \frac{z}{y}\right|\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if x < -10.5 or 3.05e6 < x Initial program 84.7%
*-rgt-identity84.7%
fabs-sub84.7%
metadata-eval84.7%
metadata-eval84.7%
fabs-mul84.7%
metadata-eval84.7%
*-rgt-identity84.7%
associate-*l/85.2%
div-sub93.5%
sub-neg93.5%
+-commutative93.5%
remove-double-neg93.5%
distribute-neg-in93.5%
sub-neg93.5%
neg-mul-193.5%
associate-*l/93.3%
remove-double-neg93.3%
distribute-lft-neg-in93.3%
distribute-rgt-neg-in93.3%
Simplified93.3%
Taylor expanded in x around inf 92.2%
associate-/l*98.4%
sub-neg98.4%
metadata-eval98.4%
Simplified98.4%
Taylor expanded in z around 0 69.6%
associate-*r/69.6%
neg-mul-169.6%
Simplified69.6%
if -10.5 < x < 4e-109Initial program 96.6%
Taylor expanded in x around 0 76.8%
if 4e-109 < x < 3.05e6Initial program 89.9%
*-rgt-identity89.9%
fabs-sub89.9%
metadata-eval89.9%
metadata-eval89.9%
fabs-mul89.9%
metadata-eval89.9%
*-rgt-identity89.9%
associate-*l/99.9%
div-sub99.9%
sub-neg99.9%
+-commutative99.9%
remove-double-neg99.9%
distribute-neg-in99.9%
sub-neg99.9%
neg-mul-199.9%
associate-*l/99.9%
remove-double-neg99.9%
distribute-lft-neg-in99.9%
distribute-rgt-neg-in99.9%
Simplified99.9%
Taylor expanded in z around inf 69.7%
associate-*l/65.0%
*-commutative65.0%
Simplified65.0%
Final simplification72.2%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (fabs (/ x y))))
(if (<= x -10.5)
t_0
(if (<= x 4e-109)
(fabs (/ 4.0 y))
(if (<= x 3200000.0) (fabs (/ (* x z) y)) t_0)))))
double code(double x, double y, double z) {
double t_0 = fabs((x / y));
double tmp;
if (x <= -10.5) {
tmp = t_0;
} else if (x <= 4e-109) {
tmp = fabs((4.0 / y));
} else if (x <= 3200000.0) {
tmp = fabs(((x * z) / y));
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: t_0
real(8) :: tmp
t_0 = abs((x / y))
if (x <= (-10.5d0)) then
tmp = t_0
else if (x <= 4d-109) then
tmp = abs((4.0d0 / y))
else if (x <= 3200000.0d0) then
tmp = abs(((x * z) / y))
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = Math.abs((x / y));
double tmp;
if (x <= -10.5) {
tmp = t_0;
} else if (x <= 4e-109) {
tmp = Math.abs((4.0 / y));
} else if (x <= 3200000.0) {
tmp = Math.abs(((x * z) / y));
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = math.fabs((x / y)) tmp = 0 if x <= -10.5: tmp = t_0 elif x <= 4e-109: tmp = math.fabs((4.0 / y)) elif x <= 3200000.0: tmp = math.fabs(((x * z) / y)) else: tmp = t_0 return tmp
function code(x, y, z) t_0 = abs(Float64(x / y)) tmp = 0.0 if (x <= -10.5) tmp = t_0; elseif (x <= 4e-109) tmp = abs(Float64(4.0 / y)); elseif (x <= 3200000.0) tmp = abs(Float64(Float64(x * z) / y)); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = abs((x / y)); tmp = 0.0; if (x <= -10.5) tmp = t_0; elseif (x <= 4e-109) tmp = abs((4.0 / y)); elseif (x <= 3200000.0) tmp = abs(((x * z) / y)); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[Abs[N[(x / y), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[x, -10.5], t$95$0, If[LessEqual[x, 4e-109], N[Abs[N[(4.0 / y), $MachinePrecision]], $MachinePrecision], If[LessEqual[x, 3200000.0], N[Abs[N[(N[(x * z), $MachinePrecision] / y), $MachinePrecision]], $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left|\frac{x}{y}\right|\\
\mathbf{if}\;x \leq -10.5:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 4 \cdot 10^{-109}:\\
\;\;\;\;\left|\frac{4}{y}\right|\\
\mathbf{elif}\;x \leq 3200000:\\
\;\;\;\;\left|\frac{x \cdot z}{y}\right|\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if x < -10.5 or 3.2e6 < x Initial program 84.7%
*-rgt-identity84.7%
fabs-sub84.7%
metadata-eval84.7%
metadata-eval84.7%
fabs-mul84.7%
metadata-eval84.7%
*-rgt-identity84.7%
associate-*l/85.2%
div-sub93.5%
sub-neg93.5%
+-commutative93.5%
remove-double-neg93.5%
distribute-neg-in93.5%
sub-neg93.5%
neg-mul-193.5%
associate-*l/93.3%
remove-double-neg93.3%
distribute-lft-neg-in93.3%
distribute-rgt-neg-in93.3%
Simplified93.3%
Taylor expanded in x around inf 92.2%
associate-/l*98.4%
sub-neg98.4%
metadata-eval98.4%
Simplified98.4%
Taylor expanded in z around 0 69.6%
associate-*r/69.6%
neg-mul-169.6%
Simplified69.6%
if -10.5 < x < 4e-109Initial program 96.6%
Taylor expanded in x around 0 76.8%
if 4e-109 < x < 3.2e6Initial program 89.9%
*-rgt-identity89.9%
fabs-sub89.9%
metadata-eval89.9%
metadata-eval89.9%
fabs-mul89.9%
metadata-eval89.9%
*-rgt-identity89.9%
associate-*l/99.9%
div-sub99.9%
sub-neg99.9%
+-commutative99.9%
remove-double-neg99.9%
distribute-neg-in99.9%
sub-neg99.9%
neg-mul-199.9%
associate-*l/99.9%
remove-double-neg99.9%
distribute-lft-neg-in99.9%
distribute-rgt-neg-in99.9%
Simplified99.9%
Taylor expanded in z around inf 69.7%
Final simplification72.6%
(FPCore (x y z) :precision binary64 (if (<= z -1.4e+25) (fabs (/ (* x z) y)) (if (<= z 3500000000.0) (fabs (/ (- -4.0 x) y)) (fabs (/ z (/ y x))))))
double code(double x, double y, double z) {
double tmp;
if (z <= -1.4e+25) {
tmp = fabs(((x * z) / y));
} else if (z <= 3500000000.0) {
tmp = fabs(((-4.0 - x) / y));
} else {
tmp = fabs((z / (y / x)));
}
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.4d+25)) then
tmp = abs(((x * z) / y))
else if (z <= 3500000000.0d0) then
tmp = abs((((-4.0d0) - x) / y))
else
tmp = abs((z / (y / x)))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -1.4e+25) {
tmp = Math.abs(((x * z) / y));
} else if (z <= 3500000000.0) {
tmp = Math.abs(((-4.0 - x) / y));
} else {
tmp = Math.abs((z / (y / x)));
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -1.4e+25: tmp = math.fabs(((x * z) / y)) elif z <= 3500000000.0: tmp = math.fabs(((-4.0 - x) / y)) else: tmp = math.fabs((z / (y / x))) return tmp
function code(x, y, z) tmp = 0.0 if (z <= -1.4e+25) tmp = abs(Float64(Float64(x * z) / y)); elseif (z <= 3500000000.0) tmp = abs(Float64(Float64(-4.0 - x) / y)); else tmp = abs(Float64(z / Float64(y / x))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -1.4e+25) tmp = abs(((x * z) / y)); elseif (z <= 3500000000.0) tmp = abs(((-4.0 - x) / y)); else tmp = abs((z / (y / x))); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -1.4e+25], N[Abs[N[(N[(x * z), $MachinePrecision] / y), $MachinePrecision]], $MachinePrecision], If[LessEqual[z, 3500000000.0], N[Abs[N[(N[(-4.0 - x), $MachinePrecision] / y), $MachinePrecision]], $MachinePrecision], N[Abs[N[(z / N[(y / x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.4 \cdot 10^{+25}:\\
\;\;\;\;\left|\frac{x \cdot z}{y}\right|\\
\mathbf{elif}\;z \leq 3500000000:\\
\;\;\;\;\left|\frac{-4 - x}{y}\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\frac{z}{\frac{y}{x}}\right|\\
\end{array}
\end{array}
if z < -1.4000000000000001e25Initial program 92.5%
*-rgt-identity92.5%
fabs-sub92.5%
metadata-eval92.5%
metadata-eval92.5%
fabs-mul92.5%
metadata-eval92.5%
*-rgt-identity92.5%
associate-*l/95.0%
div-sub94.9%
sub-neg94.9%
+-commutative94.9%
remove-double-neg94.9%
distribute-neg-in94.9%
sub-neg94.9%
neg-mul-194.9%
associate-*l/94.8%
remove-double-neg94.8%
distribute-lft-neg-in94.8%
distribute-rgt-neg-in94.8%
Simplified94.8%
Taylor expanded in z around inf 64.8%
if -1.4000000000000001e25 < z < 3.5e9Initial program 90.8%
*-rgt-identity90.8%
fabs-sub90.8%
metadata-eval90.8%
metadata-eval90.8%
fabs-mul90.8%
metadata-eval90.8%
*-rgt-identity90.8%
associate-*l/97.2%
div-sub100.0%
sub-neg100.0%
+-commutative100.0%
remove-double-neg100.0%
distribute-neg-in100.0%
sub-neg100.0%
neg-mul-1100.0%
associate-*l/99.8%
remove-double-neg99.8%
distribute-lft-neg-in99.8%
distribute-rgt-neg-in99.8%
Simplified99.8%
Taylor expanded in z around 0 99.4%
associate-*r/99.4%
distribute-lft-in99.4%
metadata-eval99.4%
neg-mul-199.4%
sub-neg99.4%
Simplified99.4%
if 3.5e9 < z Initial program 85.2%
Taylor expanded in z around inf 73.9%
associate-*r/73.9%
mul-1-neg73.9%
distribute-rgt-neg-out73.9%
associate-*r/83.1%
distribute-frac-neg83.1%
mul-1-neg83.1%
metadata-eval83.1%
times-frac83.1%
*-lft-identity83.1%
neg-mul-183.1%
Simplified83.1%
associate-*r/73.9%
add-sqr-sqrt27.0%
sqrt-unprod56.8%
sqr-neg56.8%
sqrt-unprod46.7%
add-sqr-sqrt73.9%
associate-/l*82.2%
Applied egg-rr82.2%
Final simplification87.8%
(FPCore (x y z) :precision binary64 (if (or (<= x -10.5) (not (<= x 4.0))) (fabs (/ x y)) (fabs (/ 4.0 y))))
double code(double x, double y, double z) {
double tmp;
if ((x <= -10.5) || !(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 <= (-10.5d0)) .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 <= -10.5) || !(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 <= -10.5) 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 <= -10.5) || !(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 <= -10.5) || ~((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, -10.5], 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 -10.5 \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 < -10.5 or 4 < x Initial program 84.8%
*-rgt-identity84.8%
fabs-sub84.8%
metadata-eval84.8%
metadata-eval84.8%
fabs-mul84.8%
metadata-eval84.8%
*-rgt-identity84.8%
associate-*l/85.3%
div-sub93.6%
sub-neg93.6%
+-commutative93.6%
remove-double-neg93.6%
distribute-neg-in93.6%
sub-neg93.6%
neg-mul-193.6%
associate-*l/93.4%
remove-double-neg93.4%
distribute-lft-neg-in93.4%
distribute-rgt-neg-in93.4%
Simplified93.4%
Taylor expanded in x around inf 92.3%
associate-/l*98.5%
sub-neg98.5%
metadata-eval98.5%
Simplified98.5%
Taylor expanded in z around 0 69.2%
associate-*r/69.2%
neg-mul-169.2%
Simplified69.2%
if -10.5 < x < 4Initial program 95.5%
Taylor expanded in x around 0 70.8%
Final simplification69.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 90.0%
Taylor expanded in x around 0 36.8%
Final simplification36.8%
herbie shell --seed 2023175
(FPCore (x y z)
:name "fabs fraction 1"
:precision binary64
(fabs (- (/ (+ x 4.0) y) (* (/ x y) z))))