
(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 (or (<= x -4e+98) (not (<= x 5e+37))) (fabs (/ x (/ y (- 1.0 z)))) (fabs (/ (- (+ x 4.0) (* x z)) y))))
double code(double x, double y, double z) {
double tmp;
if ((x <= -4e+98) || !(x <= 5e+37)) {
tmp = fabs((x / (y / (1.0 - z))));
} else {
tmp = fabs((((x + 4.0) - (x * z)) / y));
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if ((x <= (-4d+98)) .or. (.not. (x <= 5d+37))) then
tmp = abs((x / (y / (1.0d0 - z))))
else
tmp = abs((((x + 4.0d0) - (x * z)) / y))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((x <= -4e+98) || !(x <= 5e+37)) {
tmp = Math.abs((x / (y / (1.0 - z))));
} else {
tmp = Math.abs((((x + 4.0) - (x * z)) / y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -4e+98) or not (x <= 5e+37): tmp = math.fabs((x / (y / (1.0 - z)))) else: tmp = math.fabs((((x + 4.0) - (x * z)) / y)) return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -4e+98) || !(x <= 5e+37)) tmp = abs(Float64(x / Float64(y / Float64(1.0 - z)))); else tmp = abs(Float64(Float64(Float64(x + 4.0) - Float64(x * z)) / y)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -4e+98) || ~((x <= 5e+37))) tmp = abs((x / (y / (1.0 - z)))); else tmp = abs((((x + 4.0) - (x * z)) / y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -4e+98], N[Not[LessEqual[x, 5e+37]], $MachinePrecision]], N[Abs[N[(x / N[(y / N[(1.0 - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[(N[(x + 4.0), $MachinePrecision] - N[(x * z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -4 \cdot 10^{+98} \lor \neg \left(x \leq 5 \cdot 10^{+37}\right):\\
\;\;\;\;\left|\frac{x}{\frac{y}{1 - z}}\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\frac{\left(x + 4\right) - x \cdot z}{y}\right|\\
\end{array}
\end{array}
if x < -3.99999999999999999e98 or 4.99999999999999989e37 < x Initial program 86.4%
associate-*l/78.6%
sub-div88.2%
Applied egg-rr88.2%
Taylor expanded in x around inf 88.2%
associate-/l*100.0%
Simplified100.0%
if -3.99999999999999999e98 < x < 4.99999999999999989e37Initial program 95.9%
associate-*l/99.9%
sub-div99.9%
Applied egg-rr99.9%
Final simplification99.9%
(FPCore (x y z) :precision binary64 (if (<= y 4e-20) (fabs (/ (- (+ x 4.0) (* x z)) y)) (fabs (fma x (/ z y) (/ (- -4.0 x) y)))))
double code(double x, double y, double z) {
double tmp;
if (y <= 4e-20) {
tmp = fabs((((x + 4.0) - (x * z)) / y));
} else {
tmp = fabs(fma(x, (z / y), ((-4.0 - x) / y)));
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (y <= 4e-20) tmp = abs(Float64(Float64(Float64(x + 4.0) - Float64(x * z)) / y)); else tmp = abs(fma(x, Float64(z / y), Float64(Float64(-4.0 - x) / y))); end return tmp end
code[x_, y_, z_] := If[LessEqual[y, 4e-20], N[Abs[N[(N[(N[(x + 4.0), $MachinePrecision] - N[(x * z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]], $MachinePrecision], N[Abs[N[(x * N[(z / y), $MachinePrecision] + N[(N[(-4.0 - x), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 4 \cdot 10^{-20}:\\
\;\;\;\;\left|\frac{\left(x + 4\right) - x \cdot z}{y}\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)\right|\\
\end{array}
\end{array}
if y < 3.99999999999999978e-20Initial program 90.5%
associate-*l/91.4%
sub-div96.9%
Applied egg-rr96.9%
if 3.99999999999999978e-20 < y Initial program 96.0%
Simplified99.9%
Final simplification97.7%
(FPCore (x y z)
:precision binary64
(if (<= z -10.0)
(fabs (* (- 1.0 z) (/ x y)))
(if (<= z 8.2e+75)
(fabs (/ (- x -4.0) y))
(fabs (* x (+ (/ z y) (/ -1.0 y)))))))
double code(double x, double y, double z) {
double tmp;
if (z <= -10.0) {
tmp = fabs(((1.0 - z) * (x / y)));
} else if (z <= 8.2e+75) {
tmp = fabs(((x - -4.0) / y));
} else {
tmp = fabs((x * ((z / y) + (-1.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 (z <= (-10.0d0)) then
tmp = abs(((1.0d0 - z) * (x / y)))
else if (z <= 8.2d+75) then
tmp = abs(((x - (-4.0d0)) / y))
else
tmp = abs((x * ((z / y) + ((-1.0d0) / y))))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -10.0) {
tmp = Math.abs(((1.0 - z) * (x / y)));
} else if (z <= 8.2e+75) {
tmp = Math.abs(((x - -4.0) / y));
} else {
tmp = Math.abs((x * ((z / y) + (-1.0 / y))));
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -10.0: tmp = math.fabs(((1.0 - z) * (x / y))) elif z <= 8.2e+75: tmp = math.fabs(((x - -4.0) / y)) else: tmp = math.fabs((x * ((z / y) + (-1.0 / y)))) return tmp
function code(x, y, z) tmp = 0.0 if (z <= -10.0) tmp = abs(Float64(Float64(1.0 - z) * Float64(x / y))); elseif (z <= 8.2e+75) tmp = abs(Float64(Float64(x - -4.0) / y)); else tmp = abs(Float64(x * Float64(Float64(z / y) + Float64(-1.0 / y)))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -10.0) tmp = abs(((1.0 - z) * (x / y))); elseif (z <= 8.2e+75) tmp = abs(((x - -4.0) / y)); else tmp = abs((x * ((z / y) + (-1.0 / y)))); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -10.0], N[Abs[N[(N[(1.0 - z), $MachinePrecision] * N[(x / y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[z, 8.2e+75], N[Abs[N[(N[(x - -4.0), $MachinePrecision] / y), $MachinePrecision]], $MachinePrecision], N[Abs[N[(x * N[(N[(z / y), $MachinePrecision] + N[(-1.0 / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -10:\\
\;\;\;\;\left|\left(1 - z\right) \cdot \frac{x}{y}\right|\\
\mathbf{elif}\;z \leq 8.2 \cdot 10^{+75}:\\
\;\;\;\;\left|\frac{x - -4}{y}\right|\\
\mathbf{else}:\\
\;\;\;\;\left|x \cdot \left(\frac{z}{y} + \frac{-1}{y}\right)\right|\\
\end{array}
\end{array}
if z < -10Initial program 94.6%
associate-*l/86.2%
sub-div86.1%
Applied egg-rr86.1%
Taylor expanded in x around inf 73.3%
associate-/l*80.2%
associate-/r/81.7%
Applied egg-rr81.7%
if -10 < z < 8.1999999999999997e75Initial program 95.5%
Simplified100.0%
Taylor expanded in z around 0 98.3%
associate-*r/98.3%
distribute-lft-in98.3%
metadata-eval98.3%
neg-mul-198.3%
sub-neg98.3%
Simplified98.3%
if 8.1999999999999997e75 < z Initial program 76.4%
Simplified84.5%
Taylor expanded in x around inf 85.5%
Final simplification92.5%
(FPCore (x y z) :precision binary64 (if (<= y 5e-20) (fabs (/ (- (+ x 4.0) (* x z)) y)) (fabs (- (/ (+ x 4.0) y) (/ x (/ y z))))))
double code(double x, double y, double z) {
double tmp;
if (y <= 5e-20) {
tmp = fabs((((x + 4.0) - (x * z)) / y));
} else {
tmp = fabs((((x + 4.0) / y) - (x / (y / 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 (y <= 5d-20) then
tmp = abs((((x + 4.0d0) - (x * z)) / y))
else
tmp = abs((((x + 4.0d0) / y) - (x / (y / z))))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= 5e-20) {
tmp = Math.abs((((x + 4.0) - (x * z)) / y));
} else {
tmp = Math.abs((((x + 4.0) / y) - (x / (y / z))));
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 5e-20: tmp = math.fabs((((x + 4.0) - (x * z)) / y)) else: tmp = math.fabs((((x + 4.0) / y) - (x / (y / z)))) return tmp
function code(x, y, z) tmp = 0.0 if (y <= 5e-20) tmp = abs(Float64(Float64(Float64(x + 4.0) - Float64(x * z)) / y)); else tmp = abs(Float64(Float64(Float64(x + 4.0) / y) - Float64(x / Float64(y / z)))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 5e-20) tmp = abs((((x + 4.0) - (x * z)) / y)); else tmp = abs((((x + 4.0) / y) - (x / (y / z)))); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 5e-20], N[Abs[N[(N[(N[(x + 4.0), $MachinePrecision] - N[(x * z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[(N[(x + 4.0), $MachinePrecision] / y), $MachinePrecision] - N[(x / N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 5 \cdot 10^{-20}:\\
\;\;\;\;\left|\frac{\left(x + 4\right) - x \cdot z}{y}\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\frac{x + 4}{y} - \frac{x}{\frac{y}{z}}\right|\\
\end{array}
\end{array}
if y < 4.9999999999999999e-20Initial program 90.5%
associate-*l/91.4%
sub-div96.9%
Applied egg-rr96.9%
if 4.9999999999999999e-20 < y Initial program 96.0%
Simplified99.8%
Final simplification97.7%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (fabs (/ x y))))
(if (<= x -9200000000000.0)
t_0
(if (<= x -6.4e-43)
(fabs (* z (/ x y)))
(if (<= x 4.0) (fabs (/ 4.0 y)) t_0)))))
double code(double x, double y, double z) {
double t_0 = fabs((x / y));
double tmp;
if (x <= -9200000000000.0) {
tmp = t_0;
} else if (x <= -6.4e-43) {
tmp = fabs((z * (x / y)));
} else if (x <= 4.0) {
tmp = fabs((4.0 / 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 <= (-9200000000000.0d0)) then
tmp = t_0
else if (x <= (-6.4d-43)) then
tmp = abs((z * (x / y)))
else if (x <= 4.0d0) then
tmp = abs((4.0d0 / 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 <= -9200000000000.0) {
tmp = t_0;
} else if (x <= -6.4e-43) {
tmp = Math.abs((z * (x / y)));
} else if (x <= 4.0) {
tmp = Math.abs((4.0 / y));
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = math.fabs((x / y)) tmp = 0 if x <= -9200000000000.0: tmp = t_0 elif x <= -6.4e-43: tmp = math.fabs((z * (x / y))) elif x <= 4.0: tmp = math.fabs((4.0 / y)) else: tmp = t_0 return tmp
function code(x, y, z) t_0 = abs(Float64(x / y)) tmp = 0.0 if (x <= -9200000000000.0) tmp = t_0; elseif (x <= -6.4e-43) tmp = abs(Float64(z * Float64(x / y))); elseif (x <= 4.0) tmp = abs(Float64(4.0 / 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 <= -9200000000000.0) tmp = t_0; elseif (x <= -6.4e-43) tmp = abs((z * (x / y))); elseif (x <= 4.0) tmp = abs((4.0 / 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, -9200000000000.0], t$95$0, If[LessEqual[x, -6.4e-43], N[Abs[N[(z * N[(x / y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[x, 4.0], N[Abs[N[(4.0 / y), $MachinePrecision]], $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left|\frac{x}{y}\right|\\
\mathbf{if}\;x \leq -9200000000000:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq -6.4 \cdot 10^{-43}:\\
\;\;\;\;\left|z \cdot \frac{x}{y}\right|\\
\mathbf{elif}\;x \leq 4:\\
\;\;\;\;\left|\frac{4}{y}\right|\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if x < -9.2e12 or 4 < x Initial program 89.3%
associate-*l/83.1%
sub-div90.7%
Applied egg-rr90.7%
Taylor expanded in x around inf 89.8%
Taylor expanded in z around 0 72.0%
if -9.2e12 < x < -6.3999999999999997e-43Initial program 99.9%
Taylor expanded in z around inf 87.6%
mul-1-neg87.6%
associate-*r/87.3%
distribute-rgt-neg-out87.3%
distribute-neg-frac87.3%
Simplified87.3%
expm1-log1p-u65.7%
expm1-udef56.9%
add-sqr-sqrt31.2%
sqrt-unprod16.0%
sqr-neg16.0%
sqrt-unprod0.3%
add-sqr-sqrt18.5%
Applied egg-rr18.5%
expm1-def27.3%
expm1-log1p87.3%
associate-*r/87.6%
associate-*l/87.6%
*-commutative87.6%
Simplified87.6%
if -6.3999999999999997e-43 < x < 4Initial program 94.5%
Taylor expanded in x around 0 78.2%
Final simplification75.4%
(FPCore (x y z) :precision binary64 (if (<= z -320000.0) (fabs (/ z (/ y x))) (if (<= z 1.3e+76) (fabs (/ (- x -4.0) y)) (fabs (/ x (/ y z))))))
double code(double x, double y, double z) {
double tmp;
if (z <= -320000.0) {
tmp = fabs((z / (y / x)));
} else if (z <= 1.3e+76) {
tmp = fabs(((x - -4.0) / y));
} else {
tmp = fabs((x / (y / 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 <= (-320000.0d0)) then
tmp = abs((z / (y / x)))
else if (z <= 1.3d+76) then
tmp = abs(((x - (-4.0d0)) / y))
else
tmp = abs((x / (y / z)))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -320000.0) {
tmp = Math.abs((z / (y / x)));
} else if (z <= 1.3e+76) {
tmp = Math.abs(((x - -4.0) / y));
} else {
tmp = Math.abs((x / (y / z)));
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -320000.0: tmp = math.fabs((z / (y / x))) elif z <= 1.3e+76: tmp = math.fabs(((x - -4.0) / y)) else: tmp = math.fabs((x / (y / z))) return tmp
function code(x, y, z) tmp = 0.0 if (z <= -320000.0) tmp = abs(Float64(z / Float64(y / x))); elseif (z <= 1.3e+76) tmp = abs(Float64(Float64(x - -4.0) / y)); else tmp = abs(Float64(x / Float64(y / z))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -320000.0) tmp = abs((z / (y / x))); elseif (z <= 1.3e+76) tmp = abs(((x - -4.0) / y)); else tmp = abs((x / (y / z))); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -320000.0], N[Abs[N[(z / N[(y / x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[z, 1.3e+76], N[Abs[N[(N[(x - -4.0), $MachinePrecision] / y), $MachinePrecision]], $MachinePrecision], N[Abs[N[(x / N[(y / z), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -320000:\\
\;\;\;\;\left|\frac{z}{\frac{y}{x}}\right|\\
\mathbf{elif}\;z \leq 1.3 \cdot 10^{+76}:\\
\;\;\;\;\left|\frac{x - -4}{y}\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\frac{x}{\frac{y}{z}}\right|\\
\end{array}
\end{array}
if z < -3.2e5Initial program 94.6%
Taylor expanded in z around inf 71.5%
mul-1-neg71.5%
associate-*r/78.4%
distribute-rgt-neg-out78.4%
distribute-neg-frac78.4%
Simplified78.4%
associate-*r/71.5%
add-cube-cbrt70.9%
times-frac79.3%
add-sqr-sqrt79.3%
sqrt-unprod57.5%
sqr-neg57.5%
sqrt-unprod0.0%
add-sqr-sqrt79.3%
times-frac70.9%
*-commutative70.9%
add-cube-cbrt71.5%
associate-/l*79.9%
Applied egg-rr79.9%
if -3.2e5 < z < 1.3e76Initial program 95.5%
Simplified100.0%
Taylor expanded in z around 0 98.3%
associate-*r/98.3%
distribute-lft-in98.3%
metadata-eval98.3%
neg-mul-198.3%
sub-neg98.3%
Simplified98.3%
if 1.3e76 < z Initial program 76.4%
Taylor expanded in z around inf 78.8%
mul-1-neg78.8%
associate-*r/85.5%
distribute-rgt-neg-out85.5%
distribute-neg-frac85.5%
Simplified85.5%
associate-*r/78.8%
add-sqr-sqrt0.0%
sqrt-unprod48.2%
sqr-neg48.2%
sqrt-unprod78.6%
add-sqr-sqrt78.8%
associate-/l*85.5%
Applied egg-rr85.5%
Final simplification92.1%
(FPCore (x y z) :precision binary64 (if (<= z -320000.0) (fabs (/ z (/ y x))) (if (<= z 3.05e+76) (fabs (/ (- x -4.0) y)) (fabs (* x (/ z y))))))
double code(double x, double y, double z) {
double tmp;
if (z <= -320000.0) {
tmp = fabs((z / (y / x)));
} else if (z <= 3.05e+76) {
tmp = fabs(((x - -4.0) / 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 <= (-320000.0d0)) then
tmp = abs((z / (y / x)))
else if (z <= 3.05d+76) then
tmp = abs(((x - (-4.0d0)) / 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 <= -320000.0) {
tmp = Math.abs((z / (y / x)));
} else if (z <= 3.05e+76) {
tmp = Math.abs(((x - -4.0) / y));
} else {
tmp = Math.abs((x * (z / y)));
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -320000.0: tmp = math.fabs((z / (y / x))) elif z <= 3.05e+76: tmp = math.fabs(((x - -4.0) / y)) else: tmp = math.fabs((x * (z / y))) return tmp
function code(x, y, z) tmp = 0.0 if (z <= -320000.0) tmp = abs(Float64(z / Float64(y / x))); elseif (z <= 3.05e+76) tmp = abs(Float64(Float64(x - -4.0) / y)); else tmp = abs(Float64(x * Float64(z / y))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -320000.0) tmp = abs((z / (y / x))); elseif (z <= 3.05e+76) tmp = abs(((x - -4.0) / y)); else tmp = abs((x * (z / y))); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -320000.0], N[Abs[N[(z / N[(y / x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[z, 3.05e+76], N[Abs[N[(N[(x - -4.0), $MachinePrecision] / y), $MachinePrecision]], $MachinePrecision], N[Abs[N[(x * N[(z / y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -320000:\\
\;\;\;\;\left|\frac{z}{\frac{y}{x}}\right|\\
\mathbf{elif}\;z \leq 3.05 \cdot 10^{+76}:\\
\;\;\;\;\left|\frac{x - -4}{y}\right|\\
\mathbf{else}:\\
\;\;\;\;\left|x \cdot \frac{z}{y}\right|\\
\end{array}
\end{array}
if z < -3.2e5Initial program 94.6%
Taylor expanded in z around inf 71.5%
mul-1-neg71.5%
associate-*r/78.4%
distribute-rgt-neg-out78.4%
distribute-neg-frac78.4%
Simplified78.4%
associate-*r/71.5%
add-cube-cbrt70.9%
times-frac79.3%
add-sqr-sqrt79.3%
sqrt-unprod57.5%
sqr-neg57.5%
sqrt-unprod0.0%
add-sqr-sqrt79.3%
times-frac70.9%
*-commutative70.9%
add-cube-cbrt71.5%
associate-/l*79.9%
Applied egg-rr79.9%
if -3.2e5 < z < 3.05000000000000029e76Initial program 95.5%
Simplified100.0%
Taylor expanded in z around 0 98.3%
associate-*r/98.3%
distribute-lft-in98.3%
metadata-eval98.3%
neg-mul-198.3%
sub-neg98.3%
Simplified98.3%
if 3.05000000000000029e76 < z Initial program 76.4%
Taylor expanded in z around inf 78.8%
mul-1-neg78.8%
associate-*r/85.5%
distribute-rgt-neg-out85.5%
distribute-neg-frac85.5%
Simplified85.5%
Final simplification92.2%
(FPCore (x y z) :precision binary64 (if (<= z -0.0045) (fabs (* (- 1.0 z) (/ x y))) (if (<= z 3.15e+77) (fabs (/ (- x -4.0) y)) (fabs (* x (/ z y))))))
double code(double x, double y, double z) {
double tmp;
if (z <= -0.0045) {
tmp = fabs(((1.0 - z) * (x / y)));
} else if (z <= 3.15e+77) {
tmp = fabs(((x - -4.0) / 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 <= (-0.0045d0)) then
tmp = abs(((1.0d0 - z) * (x / y)))
else if (z <= 3.15d+77) then
tmp = abs(((x - (-4.0d0)) / 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 <= -0.0045) {
tmp = Math.abs(((1.0 - z) * (x / y)));
} else if (z <= 3.15e+77) {
tmp = Math.abs(((x - -4.0) / y));
} else {
tmp = Math.abs((x * (z / y)));
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -0.0045: tmp = math.fabs(((1.0 - z) * (x / y))) elif z <= 3.15e+77: tmp = math.fabs(((x - -4.0) / y)) else: tmp = math.fabs((x * (z / y))) return tmp
function code(x, y, z) tmp = 0.0 if (z <= -0.0045) tmp = abs(Float64(Float64(1.0 - z) * Float64(x / y))); elseif (z <= 3.15e+77) tmp = abs(Float64(Float64(x - -4.0) / y)); else tmp = abs(Float64(x * Float64(z / y))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -0.0045) tmp = abs(((1.0 - z) * (x / y))); elseif (z <= 3.15e+77) tmp = abs(((x - -4.0) / y)); else tmp = abs((x * (z / y))); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -0.0045], N[Abs[N[(N[(1.0 - z), $MachinePrecision] * N[(x / y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[z, 3.15e+77], N[Abs[N[(N[(x - -4.0), $MachinePrecision] / y), $MachinePrecision]], $MachinePrecision], N[Abs[N[(x * N[(z / y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -0.0045:\\
\;\;\;\;\left|\left(1 - z\right) \cdot \frac{x}{y}\right|\\
\mathbf{elif}\;z \leq 3.15 \cdot 10^{+77}:\\
\;\;\;\;\left|\frac{x - -4}{y}\right|\\
\mathbf{else}:\\
\;\;\;\;\left|x \cdot \frac{z}{y}\right|\\
\end{array}
\end{array}
if z < -0.00449999999999999966Initial program 94.6%
associate-*l/86.2%
sub-div86.1%
Applied egg-rr86.1%
Taylor expanded in x around inf 73.3%
associate-/l*80.2%
associate-/r/81.7%
Applied egg-rr81.7%
if -0.00449999999999999966 < z < 3.14999999999999981e77Initial program 95.5%
Simplified100.0%
Taylor expanded in z around 0 98.3%
associate-*r/98.3%
distribute-lft-in98.3%
metadata-eval98.3%
neg-mul-198.3%
sub-neg98.3%
Simplified98.3%
if 3.14999999999999981e77 < z Initial program 76.4%
Taylor expanded in z around inf 78.8%
mul-1-neg78.8%
associate-*r/85.5%
distribute-rgt-neg-out85.5%
distribute-neg-frac85.5%
Simplified85.5%
Final simplification92.5%
(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 89.4%
associate-*l/83.3%
sub-div90.8%
Applied egg-rr90.8%
Taylor expanded in x around inf 89.5%
Taylor expanded in z around 0 71.3%
if -10.5 < x < 4Initial program 94.9%
Taylor expanded in x around 0 72.9%
Final simplification72.1%
(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 92.0%
Taylor expanded in x around 0 37.6%
Final simplification37.6%
herbie shell --seed 2023320
(FPCore (x y z)
:name "fabs fraction 1"
:precision binary64
(fabs (- (/ (+ x 4.0) y) (* (/ x y) z))))