
(FPCore (x y z) :precision binary64 (/ (* x (- y z)) y))
double code(double x, double y, double z) {
return (x * (y - z)) / y;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (x * (y - z)) / y
end function
public static double code(double x, double y, double z) {
return (x * (y - z)) / y;
}
def code(x, y, z): return (x * (y - z)) / y
function code(x, y, z) return Float64(Float64(x * Float64(y - z)) / y) end
function tmp = code(x, y, z) tmp = (x * (y - z)) / y; end
code[x_, y_, z_] := N[(N[(x * N[(y - z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]
\begin{array}{l}
\\
\frac{x \cdot \left(y - z\right)}{y}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 9 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 (/ (* x (- y z)) y))
double code(double x, double y, double z) {
return (x * (y - z)) / y;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (x * (y - z)) / y
end function
public static double code(double x, double y, double z) {
return (x * (y - z)) / y;
}
def code(x, y, z): return (x * (y - z)) / y
function code(x, y, z) return Float64(Float64(x * Float64(y - z)) / y) end
function tmp = code(x, y, z) tmp = (x * (y - z)) / y; end
code[x_, y_, z_] := N[(N[(x * N[(y - z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]
\begin{array}{l}
\\
\frac{x \cdot \left(y - z\right)}{y}
\end{array}
x\_m = (fabs.f64 x) x\_s = (copysign.f64 #s(literal 1 binary64) x) (FPCore (x_s x_m y z) :precision binary64 (* x_s (if (<= x_m 1e-55) (- x_m (* z (/ x_m y))) (- x_m (* x_m (/ z y))))))
x\_m = fabs(x);
x\_s = copysign(1.0, x);
double code(double x_s, double x_m, double y, double z) {
double tmp;
if (x_m <= 1e-55) {
tmp = x_m - (z * (x_m / y));
} else {
tmp = x_m - (x_m * (z / y));
}
return x_s * tmp;
}
x\_m = abs(x)
x\_s = copysign(1.0d0, x)
real(8) function code(x_s, x_m, y, z)
real(8), intent (in) :: x_s
real(8), intent (in) :: x_m
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (x_m <= 1d-55) then
tmp = x_m - (z * (x_m / y))
else
tmp = x_m - (x_m * (z / y))
end if
code = x_s * tmp
end function
x\_m = Math.abs(x);
x\_s = Math.copySign(1.0, x);
public static double code(double x_s, double x_m, double y, double z) {
double tmp;
if (x_m <= 1e-55) {
tmp = x_m - (z * (x_m / y));
} else {
tmp = x_m - (x_m * (z / y));
}
return x_s * tmp;
}
x\_m = math.fabs(x) x\_s = math.copysign(1.0, x) def code(x_s, x_m, y, z): tmp = 0 if x_m <= 1e-55: tmp = x_m - (z * (x_m / y)) else: tmp = x_m - (x_m * (z / y)) return x_s * tmp
x\_m = abs(x) x\_s = copysign(1.0, x) function code(x_s, x_m, y, z) tmp = 0.0 if (x_m <= 1e-55) tmp = Float64(x_m - Float64(z * Float64(x_m / y))); else tmp = Float64(x_m - Float64(x_m * Float64(z / y))); end return Float64(x_s * tmp) end
x\_m = abs(x); x\_s = sign(x) * abs(1.0); function tmp_2 = code(x_s, x_m, y, z) tmp = 0.0; if (x_m <= 1e-55) tmp = x_m - (z * (x_m / y)); else tmp = x_m - (x_m * (z / y)); end tmp_2 = x_s * tmp; end
x\_m = N[Abs[x], $MachinePrecision]
x\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[x$95$s_, x$95$m_, y_, z_] := N[(x$95$s * If[LessEqual[x$95$m, 1e-55], N[(x$95$m - N[(z * N[(x$95$m / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x$95$m - N[(x$95$m * N[(z / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
x\_m = \left|x\right|
\\
x\_s = \mathsf{copysign}\left(1, x\right)
\\
x\_s \cdot \begin{array}{l}
\mathbf{if}\;x\_m \leq 10^{-55}:\\
\;\;\;\;x\_m - z \cdot \frac{x\_m}{y}\\
\mathbf{else}:\\
\;\;\;\;x\_m - x\_m \cdot \frac{z}{y}\\
\end{array}
\end{array}
if x < 9.99999999999999995e-56Initial program 82.2%
remove-double-neg82.2%
distribute-frac-neg282.2%
distribute-frac-neg82.2%
distribute-rgt-neg-in82.2%
associate-/l*94.9%
distribute-frac-neg94.9%
distribute-frac-neg294.9%
remove-double-neg94.9%
div-sub94.9%
*-inverses94.9%
Simplified94.9%
sub-neg94.9%
distribute-rgt-in94.9%
*-un-lft-identity94.9%
distribute-neg-frac294.9%
Applied egg-rr94.9%
*-commutative94.9%
add-sqr-sqrt26.4%
sqrt-unprod43.6%
sqr-neg43.6%
sqrt-unprod39.2%
add-sqr-sqrt52.6%
cancel-sign-sub-inv52.6%
*-commutative52.6%
associate-*l/48.4%
associate-/l*52.1%
add-sqr-sqrt22.0%
sqrt-unprod63.6%
sqr-neg63.6%
sqrt-unprod50.0%
add-sqr-sqrt95.8%
Applied egg-rr95.8%
if 9.99999999999999995e-56 < x Initial program 82.5%
remove-double-neg82.5%
distribute-frac-neg282.5%
distribute-frac-neg82.5%
distribute-rgt-neg-in82.5%
associate-/l*99.8%
distribute-frac-neg99.8%
distribute-frac-neg299.8%
remove-double-neg99.8%
div-sub99.9%
*-inverses99.9%
Simplified99.9%
sub-neg99.9%
distribute-rgt-in99.9%
*-un-lft-identity99.9%
distribute-neg-frac299.9%
Applied egg-rr99.9%
Final simplification96.9%
x\_m = (fabs.f64 x) x\_s = (copysign.f64 #s(literal 1 binary64) x) (FPCore (x_s x_m y z) :precision binary64 (* x_s (if (<= y -7e+27) x_m (if (<= y 4.2e-54) (- (* x_m (/ z y))) x_m))))
x\_m = fabs(x);
x\_s = copysign(1.0, x);
double code(double x_s, double x_m, double y, double z) {
double tmp;
if (y <= -7e+27) {
tmp = x_m;
} else if (y <= 4.2e-54) {
tmp = -(x_m * (z / y));
} else {
tmp = x_m;
}
return x_s * tmp;
}
x\_m = abs(x)
x\_s = copysign(1.0d0, x)
real(8) function code(x_s, x_m, y, z)
real(8), intent (in) :: x_s
real(8), intent (in) :: x_m
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (y <= (-7d+27)) then
tmp = x_m
else if (y <= 4.2d-54) then
tmp = -(x_m * (z / y))
else
tmp = x_m
end if
code = x_s * tmp
end function
x\_m = Math.abs(x);
x\_s = Math.copySign(1.0, x);
public static double code(double x_s, double x_m, double y, double z) {
double tmp;
if (y <= -7e+27) {
tmp = x_m;
} else if (y <= 4.2e-54) {
tmp = -(x_m * (z / y));
} else {
tmp = x_m;
}
return x_s * tmp;
}
x\_m = math.fabs(x) x\_s = math.copysign(1.0, x) def code(x_s, x_m, y, z): tmp = 0 if y <= -7e+27: tmp = x_m elif y <= 4.2e-54: tmp = -(x_m * (z / y)) else: tmp = x_m return x_s * tmp
x\_m = abs(x) x\_s = copysign(1.0, x) function code(x_s, x_m, y, z) tmp = 0.0 if (y <= -7e+27) tmp = x_m; elseif (y <= 4.2e-54) tmp = Float64(-Float64(x_m * Float64(z / y))); else tmp = x_m; end return Float64(x_s * tmp) end
x\_m = abs(x); x\_s = sign(x) * abs(1.0); function tmp_2 = code(x_s, x_m, y, z) tmp = 0.0; if (y <= -7e+27) tmp = x_m; elseif (y <= 4.2e-54) tmp = -(x_m * (z / y)); else tmp = x_m; end tmp_2 = x_s * tmp; end
x\_m = N[Abs[x], $MachinePrecision]
x\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[x$95$s_, x$95$m_, y_, z_] := N[(x$95$s * If[LessEqual[y, -7e+27], x$95$m, If[LessEqual[y, 4.2e-54], (-N[(x$95$m * N[(z / y), $MachinePrecision]), $MachinePrecision]), x$95$m]]), $MachinePrecision]
\begin{array}{l}
x\_m = \left|x\right|
\\
x\_s = \mathsf{copysign}\left(1, x\right)
\\
x\_s \cdot \begin{array}{l}
\mathbf{if}\;y \leq -7 \cdot 10^{+27}:\\
\;\;\;\;x\_m\\
\mathbf{elif}\;y \leq 4.2 \cdot 10^{-54}:\\
\;\;\;\;-x\_m \cdot \frac{z}{y}\\
\mathbf{else}:\\
\;\;\;\;x\_m\\
\end{array}
\end{array}
if y < -7.0000000000000004e27 or 4.2e-54 < y Initial program 71.6%
remove-double-neg71.6%
distribute-frac-neg271.6%
distribute-frac-neg71.6%
distribute-rgt-neg-in71.6%
associate-/l*99.9%
distribute-frac-neg99.9%
distribute-frac-neg299.9%
remove-double-neg99.9%
div-sub99.9%
*-inverses99.9%
Simplified99.9%
Taylor expanded in z around 0 78.4%
if -7.0000000000000004e27 < y < 4.2e-54Initial program 93.6%
associate-/l*92.4%
Simplified92.4%
Taylor expanded in y around 0 67.9%
mul-1-neg67.9%
distribute-frac-neg267.9%
Simplified67.9%
Final simplification73.3%
x\_m = (fabs.f64 x) x\_s = (copysign.f64 #s(literal 1 binary64) x) (FPCore (x_s x_m y z) :precision binary64 (* x_s (if (<= y -5.4e+27) x_m (if (<= y 3.6e-54) (* (/ x_m y) (- z)) x_m))))
x\_m = fabs(x);
x\_s = copysign(1.0, x);
double code(double x_s, double x_m, double y, double z) {
double tmp;
if (y <= -5.4e+27) {
tmp = x_m;
} else if (y <= 3.6e-54) {
tmp = (x_m / y) * -z;
} else {
tmp = x_m;
}
return x_s * tmp;
}
x\_m = abs(x)
x\_s = copysign(1.0d0, x)
real(8) function code(x_s, x_m, y, z)
real(8), intent (in) :: x_s
real(8), intent (in) :: x_m
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (y <= (-5.4d+27)) then
tmp = x_m
else if (y <= 3.6d-54) then
tmp = (x_m / y) * -z
else
tmp = x_m
end if
code = x_s * tmp
end function
x\_m = Math.abs(x);
x\_s = Math.copySign(1.0, x);
public static double code(double x_s, double x_m, double y, double z) {
double tmp;
if (y <= -5.4e+27) {
tmp = x_m;
} else if (y <= 3.6e-54) {
tmp = (x_m / y) * -z;
} else {
tmp = x_m;
}
return x_s * tmp;
}
x\_m = math.fabs(x) x\_s = math.copysign(1.0, x) def code(x_s, x_m, y, z): tmp = 0 if y <= -5.4e+27: tmp = x_m elif y <= 3.6e-54: tmp = (x_m / y) * -z else: tmp = x_m return x_s * tmp
x\_m = abs(x) x\_s = copysign(1.0, x) function code(x_s, x_m, y, z) tmp = 0.0 if (y <= -5.4e+27) tmp = x_m; elseif (y <= 3.6e-54) tmp = Float64(Float64(x_m / y) * Float64(-z)); else tmp = x_m; end return Float64(x_s * tmp) end
x\_m = abs(x); x\_s = sign(x) * abs(1.0); function tmp_2 = code(x_s, x_m, y, z) tmp = 0.0; if (y <= -5.4e+27) tmp = x_m; elseif (y <= 3.6e-54) tmp = (x_m / y) * -z; else tmp = x_m; end tmp_2 = x_s * tmp; end
x\_m = N[Abs[x], $MachinePrecision]
x\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[x$95$s_, x$95$m_, y_, z_] := N[(x$95$s * If[LessEqual[y, -5.4e+27], x$95$m, If[LessEqual[y, 3.6e-54], N[(N[(x$95$m / y), $MachinePrecision] * (-z)), $MachinePrecision], x$95$m]]), $MachinePrecision]
\begin{array}{l}
x\_m = \left|x\right|
\\
x\_s = \mathsf{copysign}\left(1, x\right)
\\
x\_s \cdot \begin{array}{l}
\mathbf{if}\;y \leq -5.4 \cdot 10^{+27}:\\
\;\;\;\;x\_m\\
\mathbf{elif}\;y \leq 3.6 \cdot 10^{-54}:\\
\;\;\;\;\frac{x\_m}{y} \cdot \left(-z\right)\\
\mathbf{else}:\\
\;\;\;\;x\_m\\
\end{array}
\end{array}
if y < -5.3999999999999995e27 or 3.59999999999999976e-54 < y Initial program 71.6%
remove-double-neg71.6%
distribute-frac-neg271.6%
distribute-frac-neg71.6%
distribute-rgt-neg-in71.6%
associate-/l*99.9%
distribute-frac-neg99.9%
distribute-frac-neg299.9%
remove-double-neg99.9%
div-sub99.9%
*-inverses99.9%
Simplified99.9%
Taylor expanded in z around 0 78.4%
if -5.3999999999999995e27 < y < 3.59999999999999976e-54Initial program 93.6%
remove-double-neg93.6%
distribute-frac-neg293.6%
distribute-frac-neg93.6%
distribute-rgt-neg-in93.6%
associate-/l*92.4%
distribute-frac-neg92.4%
distribute-frac-neg292.4%
remove-double-neg92.4%
div-sub92.4%
*-inverses92.4%
Simplified92.4%
Taylor expanded in z around inf 74.0%
associate-*l/70.5%
associate-*l*70.5%
*-commutative70.5%
associate-*r/70.5%
mul-1-neg70.5%
Simplified70.5%
Final simplification74.5%
x\_m = (fabs.f64 x) x\_s = (copysign.f64 #s(literal 1 binary64) x) (FPCore (x_s x_m y z) :precision binary64 (* x_s (if (<= y -6.2e+27) x_m (if (<= y 1.16e-54) (/ (- z) (/ y x_m)) x_m))))
x\_m = fabs(x);
x\_s = copysign(1.0, x);
double code(double x_s, double x_m, double y, double z) {
double tmp;
if (y <= -6.2e+27) {
tmp = x_m;
} else if (y <= 1.16e-54) {
tmp = -z / (y / x_m);
} else {
tmp = x_m;
}
return x_s * tmp;
}
x\_m = abs(x)
x\_s = copysign(1.0d0, x)
real(8) function code(x_s, x_m, y, z)
real(8), intent (in) :: x_s
real(8), intent (in) :: x_m
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (y <= (-6.2d+27)) then
tmp = x_m
else if (y <= 1.16d-54) then
tmp = -z / (y / x_m)
else
tmp = x_m
end if
code = x_s * tmp
end function
x\_m = Math.abs(x);
x\_s = Math.copySign(1.0, x);
public static double code(double x_s, double x_m, double y, double z) {
double tmp;
if (y <= -6.2e+27) {
tmp = x_m;
} else if (y <= 1.16e-54) {
tmp = -z / (y / x_m);
} else {
tmp = x_m;
}
return x_s * tmp;
}
x\_m = math.fabs(x) x\_s = math.copysign(1.0, x) def code(x_s, x_m, y, z): tmp = 0 if y <= -6.2e+27: tmp = x_m elif y <= 1.16e-54: tmp = -z / (y / x_m) else: tmp = x_m return x_s * tmp
x\_m = abs(x) x\_s = copysign(1.0, x) function code(x_s, x_m, y, z) tmp = 0.0 if (y <= -6.2e+27) tmp = x_m; elseif (y <= 1.16e-54) tmp = Float64(Float64(-z) / Float64(y / x_m)); else tmp = x_m; end return Float64(x_s * tmp) end
x\_m = abs(x); x\_s = sign(x) * abs(1.0); function tmp_2 = code(x_s, x_m, y, z) tmp = 0.0; if (y <= -6.2e+27) tmp = x_m; elseif (y <= 1.16e-54) tmp = -z / (y / x_m); else tmp = x_m; end tmp_2 = x_s * tmp; end
x\_m = N[Abs[x], $MachinePrecision]
x\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[x$95$s_, x$95$m_, y_, z_] := N[(x$95$s * If[LessEqual[y, -6.2e+27], x$95$m, If[LessEqual[y, 1.16e-54], N[((-z) / N[(y / x$95$m), $MachinePrecision]), $MachinePrecision], x$95$m]]), $MachinePrecision]
\begin{array}{l}
x\_m = \left|x\right|
\\
x\_s = \mathsf{copysign}\left(1, x\right)
\\
x\_s \cdot \begin{array}{l}
\mathbf{if}\;y \leq -6.2 \cdot 10^{+27}:\\
\;\;\;\;x\_m\\
\mathbf{elif}\;y \leq 1.16 \cdot 10^{-54}:\\
\;\;\;\;\frac{-z}{\frac{y}{x\_m}}\\
\mathbf{else}:\\
\;\;\;\;x\_m\\
\end{array}
\end{array}
if y < -6.19999999999999992e27 or 1.16e-54 < y Initial program 71.6%
remove-double-neg71.6%
distribute-frac-neg271.6%
distribute-frac-neg71.6%
distribute-rgt-neg-in71.6%
associate-/l*99.9%
distribute-frac-neg99.9%
distribute-frac-neg299.9%
remove-double-neg99.9%
div-sub99.9%
*-inverses99.9%
Simplified99.9%
Taylor expanded in z around 0 78.4%
if -6.19999999999999992e27 < y < 1.16e-54Initial program 93.6%
remove-double-neg93.6%
distribute-frac-neg293.6%
distribute-frac-neg93.6%
distribute-rgt-neg-in93.6%
associate-/l*92.4%
distribute-frac-neg92.4%
distribute-frac-neg292.4%
remove-double-neg92.4%
div-sub92.4%
*-inverses92.4%
Simplified92.4%
sub-neg92.4%
distribute-rgt-in92.4%
*-un-lft-identity92.4%
distribute-neg-frac292.4%
Applied egg-rr92.4%
*-commutative92.4%
add-sqr-sqrt46.0%
sqrt-unprod46.3%
sqr-neg46.3%
sqrt-unprod11.6%
add-sqr-sqrt22.7%
cancel-sign-sub-inv22.7%
*-commutative22.7%
associate-*l/22.9%
associate-/l*19.0%
add-sqr-sqrt12.2%
sqrt-unprod35.1%
sqr-neg35.1%
sqrt-unprod34.9%
add-sqr-sqrt90.5%
Applied egg-rr90.5%
Taylor expanded in z around inf 74.0%
associate-*r/74.0%
*-commutative74.0%
neg-mul-174.0%
distribute-lft-neg-out74.0%
associate-*l/67.9%
associate-/r/70.8%
Simplified70.8%
Final simplification74.7%
x\_m = (fabs.f64 x) x\_s = (copysign.f64 #s(literal 1 binary64) x) (FPCore (x_s x_m y z) :precision binary64 (* x_s (if (<= y -5.4e+27) x_m (if (<= y 1.28e-54) (/ (* x_m (- z)) y) x_m))))
x\_m = fabs(x);
x\_s = copysign(1.0, x);
double code(double x_s, double x_m, double y, double z) {
double tmp;
if (y <= -5.4e+27) {
tmp = x_m;
} else if (y <= 1.28e-54) {
tmp = (x_m * -z) / y;
} else {
tmp = x_m;
}
return x_s * tmp;
}
x\_m = abs(x)
x\_s = copysign(1.0d0, x)
real(8) function code(x_s, x_m, y, z)
real(8), intent (in) :: x_s
real(8), intent (in) :: x_m
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (y <= (-5.4d+27)) then
tmp = x_m
else if (y <= 1.28d-54) then
tmp = (x_m * -z) / y
else
tmp = x_m
end if
code = x_s * tmp
end function
x\_m = Math.abs(x);
x\_s = Math.copySign(1.0, x);
public static double code(double x_s, double x_m, double y, double z) {
double tmp;
if (y <= -5.4e+27) {
tmp = x_m;
} else if (y <= 1.28e-54) {
tmp = (x_m * -z) / y;
} else {
tmp = x_m;
}
return x_s * tmp;
}
x\_m = math.fabs(x) x\_s = math.copysign(1.0, x) def code(x_s, x_m, y, z): tmp = 0 if y <= -5.4e+27: tmp = x_m elif y <= 1.28e-54: tmp = (x_m * -z) / y else: tmp = x_m return x_s * tmp
x\_m = abs(x) x\_s = copysign(1.0, x) function code(x_s, x_m, y, z) tmp = 0.0 if (y <= -5.4e+27) tmp = x_m; elseif (y <= 1.28e-54) tmp = Float64(Float64(x_m * Float64(-z)) / y); else tmp = x_m; end return Float64(x_s * tmp) end
x\_m = abs(x); x\_s = sign(x) * abs(1.0); function tmp_2 = code(x_s, x_m, y, z) tmp = 0.0; if (y <= -5.4e+27) tmp = x_m; elseif (y <= 1.28e-54) tmp = (x_m * -z) / y; else tmp = x_m; end tmp_2 = x_s * tmp; end
x\_m = N[Abs[x], $MachinePrecision]
x\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[x$95$s_, x$95$m_, y_, z_] := N[(x$95$s * If[LessEqual[y, -5.4e+27], x$95$m, If[LessEqual[y, 1.28e-54], N[(N[(x$95$m * (-z)), $MachinePrecision] / y), $MachinePrecision], x$95$m]]), $MachinePrecision]
\begin{array}{l}
x\_m = \left|x\right|
\\
x\_s = \mathsf{copysign}\left(1, x\right)
\\
x\_s \cdot \begin{array}{l}
\mathbf{if}\;y \leq -5.4 \cdot 10^{+27}:\\
\;\;\;\;x\_m\\
\mathbf{elif}\;y \leq 1.28 \cdot 10^{-54}:\\
\;\;\;\;\frac{x\_m \cdot \left(-z\right)}{y}\\
\mathbf{else}:\\
\;\;\;\;x\_m\\
\end{array}
\end{array}
if y < -5.3999999999999995e27 or 1.2800000000000001e-54 < y Initial program 71.6%
remove-double-neg71.6%
distribute-frac-neg271.6%
distribute-frac-neg71.6%
distribute-rgt-neg-in71.6%
associate-/l*99.9%
distribute-frac-neg99.9%
distribute-frac-neg299.9%
remove-double-neg99.9%
div-sub99.9%
*-inverses99.9%
Simplified99.9%
Taylor expanded in z around 0 78.4%
if -5.3999999999999995e27 < y < 1.2800000000000001e-54Initial program 93.6%
Taylor expanded in y around 0 74.0%
associate-*r*74.0%
*-commutative74.0%
mul-1-neg74.0%
Simplified74.0%
Final simplification76.3%
x\_m = (fabs.f64 x) x\_s = (copysign.f64 #s(literal 1 binary64) x) (FPCore (x_s x_m y z) :precision binary64 (* x_s (if (<= x_m 3.1e-52) (- x_m (* z (/ x_m y))) (* x_m (- 1.0 (/ z y))))))
x\_m = fabs(x);
x\_s = copysign(1.0, x);
double code(double x_s, double x_m, double y, double z) {
double tmp;
if (x_m <= 3.1e-52) {
tmp = x_m - (z * (x_m / y));
} else {
tmp = x_m * (1.0 - (z / y));
}
return x_s * tmp;
}
x\_m = abs(x)
x\_s = copysign(1.0d0, x)
real(8) function code(x_s, x_m, y, z)
real(8), intent (in) :: x_s
real(8), intent (in) :: x_m
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (x_m <= 3.1d-52) then
tmp = x_m - (z * (x_m / y))
else
tmp = x_m * (1.0d0 - (z / y))
end if
code = x_s * tmp
end function
x\_m = Math.abs(x);
x\_s = Math.copySign(1.0, x);
public static double code(double x_s, double x_m, double y, double z) {
double tmp;
if (x_m <= 3.1e-52) {
tmp = x_m - (z * (x_m / y));
} else {
tmp = x_m * (1.0 - (z / y));
}
return x_s * tmp;
}
x\_m = math.fabs(x) x\_s = math.copysign(1.0, x) def code(x_s, x_m, y, z): tmp = 0 if x_m <= 3.1e-52: tmp = x_m - (z * (x_m / y)) else: tmp = x_m * (1.0 - (z / y)) return x_s * tmp
x\_m = abs(x) x\_s = copysign(1.0, x) function code(x_s, x_m, y, z) tmp = 0.0 if (x_m <= 3.1e-52) tmp = Float64(x_m - Float64(z * Float64(x_m / y))); else tmp = Float64(x_m * Float64(1.0 - Float64(z / y))); end return Float64(x_s * tmp) end
x\_m = abs(x); x\_s = sign(x) * abs(1.0); function tmp_2 = code(x_s, x_m, y, z) tmp = 0.0; if (x_m <= 3.1e-52) tmp = x_m - (z * (x_m / y)); else tmp = x_m * (1.0 - (z / y)); end tmp_2 = x_s * tmp; end
x\_m = N[Abs[x], $MachinePrecision]
x\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[x$95$s_, x$95$m_, y_, z_] := N[(x$95$s * If[LessEqual[x$95$m, 3.1e-52], N[(x$95$m - N[(z * N[(x$95$m / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x$95$m * N[(1.0 - N[(z / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
x\_m = \left|x\right|
\\
x\_s = \mathsf{copysign}\left(1, x\right)
\\
x\_s \cdot \begin{array}{l}
\mathbf{if}\;x\_m \leq 3.1 \cdot 10^{-52}:\\
\;\;\;\;x\_m - z \cdot \frac{x\_m}{y}\\
\mathbf{else}:\\
\;\;\;\;x\_m \cdot \left(1 - \frac{z}{y}\right)\\
\end{array}
\end{array}
if x < 3.0999999999999999e-52Initial program 82.2%
remove-double-neg82.2%
distribute-frac-neg282.2%
distribute-frac-neg82.2%
distribute-rgt-neg-in82.2%
associate-/l*94.9%
distribute-frac-neg94.9%
distribute-frac-neg294.9%
remove-double-neg94.9%
div-sub94.9%
*-inverses94.9%
Simplified94.9%
sub-neg94.9%
distribute-rgt-in94.9%
*-un-lft-identity94.9%
distribute-neg-frac294.9%
Applied egg-rr94.9%
*-commutative94.9%
add-sqr-sqrt26.4%
sqrt-unprod43.6%
sqr-neg43.6%
sqrt-unprod39.2%
add-sqr-sqrt52.6%
cancel-sign-sub-inv52.6%
*-commutative52.6%
associate-*l/48.4%
associate-/l*52.1%
add-sqr-sqrt22.0%
sqrt-unprod63.6%
sqr-neg63.6%
sqrt-unprod50.0%
add-sqr-sqrt95.8%
Applied egg-rr95.8%
if 3.0999999999999999e-52 < x Initial program 82.5%
remove-double-neg82.5%
distribute-frac-neg282.5%
distribute-frac-neg82.5%
distribute-rgt-neg-in82.5%
associate-/l*99.8%
distribute-frac-neg99.8%
distribute-frac-neg299.8%
remove-double-neg99.8%
div-sub99.9%
*-inverses99.9%
Simplified99.9%
Final simplification96.9%
x\_m = (fabs.f64 x) x\_s = (copysign.f64 #s(literal 1 binary64) x) (FPCore (x_s x_m y z) :precision binary64 (* x_s (if (<= x_m 6e+33) (- x_m (* z (/ x_m y))) (/ x_m (/ y (- y z))))))
x\_m = fabs(x);
x\_s = copysign(1.0, x);
double code(double x_s, double x_m, double y, double z) {
double tmp;
if (x_m <= 6e+33) {
tmp = x_m - (z * (x_m / y));
} else {
tmp = x_m / (y / (y - z));
}
return x_s * tmp;
}
x\_m = abs(x)
x\_s = copysign(1.0d0, x)
real(8) function code(x_s, x_m, y, z)
real(8), intent (in) :: x_s
real(8), intent (in) :: x_m
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (x_m <= 6d+33) then
tmp = x_m - (z * (x_m / y))
else
tmp = x_m / (y / (y - z))
end if
code = x_s * tmp
end function
x\_m = Math.abs(x);
x\_s = Math.copySign(1.0, x);
public static double code(double x_s, double x_m, double y, double z) {
double tmp;
if (x_m <= 6e+33) {
tmp = x_m - (z * (x_m / y));
} else {
tmp = x_m / (y / (y - z));
}
return x_s * tmp;
}
x\_m = math.fabs(x) x\_s = math.copysign(1.0, x) def code(x_s, x_m, y, z): tmp = 0 if x_m <= 6e+33: tmp = x_m - (z * (x_m / y)) else: tmp = x_m / (y / (y - z)) return x_s * tmp
x\_m = abs(x) x\_s = copysign(1.0, x) function code(x_s, x_m, y, z) tmp = 0.0 if (x_m <= 6e+33) tmp = Float64(x_m - Float64(z * Float64(x_m / y))); else tmp = Float64(x_m / Float64(y / Float64(y - z))); end return Float64(x_s * tmp) end
x\_m = abs(x); x\_s = sign(x) * abs(1.0); function tmp_2 = code(x_s, x_m, y, z) tmp = 0.0; if (x_m <= 6e+33) tmp = x_m - (z * (x_m / y)); else tmp = x_m / (y / (y - z)); end tmp_2 = x_s * tmp; end
x\_m = N[Abs[x], $MachinePrecision]
x\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[x$95$s_, x$95$m_, y_, z_] := N[(x$95$s * If[LessEqual[x$95$m, 6e+33], N[(x$95$m - N[(z * N[(x$95$m / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x$95$m / N[(y / N[(y - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
x\_m = \left|x\right|
\\
x\_s = \mathsf{copysign}\left(1, x\right)
\\
x\_s \cdot \begin{array}{l}
\mathbf{if}\;x\_m \leq 6 \cdot 10^{+33}:\\
\;\;\;\;x\_m - z \cdot \frac{x\_m}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{x\_m}{\frac{y}{y - z}}\\
\end{array}
\end{array}
if x < 5.99999999999999967e33Initial program 83.5%
remove-double-neg83.5%
distribute-frac-neg283.5%
distribute-frac-neg83.5%
distribute-rgt-neg-in83.5%
associate-/l*95.3%
distribute-frac-neg95.3%
distribute-frac-neg295.3%
remove-double-neg95.3%
div-sub95.3%
*-inverses95.3%
Simplified95.3%
sub-neg95.3%
distribute-rgt-in95.3%
*-un-lft-identity95.3%
distribute-neg-frac295.3%
Applied egg-rr95.3%
*-commutative95.3%
add-sqr-sqrt31.9%
sqrt-unprod47.8%
sqr-neg47.8%
sqrt-unprod36.2%
add-sqr-sqrt51.4%
cancel-sign-sub-inv51.4%
*-commutative51.4%
associate-*l/47.5%
associate-/l*51.0%
add-sqr-sqrt20.6%
sqrt-unprod63.5%
sqr-neg63.5%
sqrt-unprod50.8%
add-sqr-sqrt96.1%
Applied egg-rr96.1%
if 5.99999999999999967e33 < x Initial program 77.8%
remove-double-neg77.8%
distribute-frac-neg277.8%
distribute-frac-neg77.8%
distribute-rgt-neg-in77.8%
associate-/l*99.8%
distribute-frac-neg99.8%
distribute-frac-neg299.8%
remove-double-neg99.8%
div-sub99.8%
*-inverses99.8%
Simplified99.8%
*-inverses99.8%
div-sub99.8%
clear-num99.8%
un-div-inv99.8%
Applied egg-rr99.8%
Final simplification96.9%
x\_m = (fabs.f64 x) x\_s = (copysign.f64 #s(literal 1 binary64) x) (FPCore (x_s x_m y z) :precision binary64 (* x_s (* x_m (- 1.0 (/ z y)))))
x\_m = fabs(x);
x\_s = copysign(1.0, x);
double code(double x_s, double x_m, double y, double z) {
return x_s * (x_m * (1.0 - (z / y)));
}
x\_m = abs(x)
x\_s = copysign(1.0d0, x)
real(8) function code(x_s, x_m, y, z)
real(8), intent (in) :: x_s
real(8), intent (in) :: x_m
real(8), intent (in) :: y
real(8), intent (in) :: z
code = x_s * (x_m * (1.0d0 - (z / y)))
end function
x\_m = Math.abs(x);
x\_s = Math.copySign(1.0, x);
public static double code(double x_s, double x_m, double y, double z) {
return x_s * (x_m * (1.0 - (z / y)));
}
x\_m = math.fabs(x) x\_s = math.copysign(1.0, x) def code(x_s, x_m, y, z): return x_s * (x_m * (1.0 - (z / y)))
x\_m = abs(x) x\_s = copysign(1.0, x) function code(x_s, x_m, y, z) return Float64(x_s * Float64(x_m * Float64(1.0 - Float64(z / y)))) end
x\_m = abs(x); x\_s = sign(x) * abs(1.0); function tmp = code(x_s, x_m, y, z) tmp = x_s * (x_m * (1.0 - (z / y))); end
x\_m = N[Abs[x], $MachinePrecision]
x\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[x$95$s_, x$95$m_, y_, z_] := N[(x$95$s * N[(x$95$m * N[(1.0 - N[(z / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
x\_m = \left|x\right|
\\
x\_s = \mathsf{copysign}\left(1, x\right)
\\
x\_s \cdot \left(x\_m \cdot \left(1 - \frac{z}{y}\right)\right)
\end{array}
Initial program 82.3%
remove-double-neg82.3%
distribute-frac-neg282.3%
distribute-frac-neg82.3%
distribute-rgt-neg-in82.3%
associate-/l*96.2%
distribute-frac-neg96.2%
distribute-frac-neg296.2%
remove-double-neg96.2%
div-sub96.2%
*-inverses96.2%
Simplified96.2%
Final simplification96.2%
x\_m = (fabs.f64 x) x\_s = (copysign.f64 #s(literal 1 binary64) x) (FPCore (x_s x_m y z) :precision binary64 (* x_s x_m))
x\_m = fabs(x);
x\_s = copysign(1.0, x);
double code(double x_s, double x_m, double y, double z) {
return x_s * x_m;
}
x\_m = abs(x)
x\_s = copysign(1.0d0, x)
real(8) function code(x_s, x_m, y, z)
real(8), intent (in) :: x_s
real(8), intent (in) :: x_m
real(8), intent (in) :: y
real(8), intent (in) :: z
code = x_s * x_m
end function
x\_m = Math.abs(x);
x\_s = Math.copySign(1.0, x);
public static double code(double x_s, double x_m, double y, double z) {
return x_s * x_m;
}
x\_m = math.fabs(x) x\_s = math.copysign(1.0, x) def code(x_s, x_m, y, z): return x_s * x_m
x\_m = abs(x) x\_s = copysign(1.0, x) function code(x_s, x_m, y, z) return Float64(x_s * x_m) end
x\_m = abs(x); x\_s = sign(x) * abs(1.0); function tmp = code(x_s, x_m, y, z) tmp = x_s * x_m; end
x\_m = N[Abs[x], $MachinePrecision]
x\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[x$95$s_, x$95$m_, y_, z_] := N[(x$95$s * x$95$m), $MachinePrecision]
\begin{array}{l}
x\_m = \left|x\right|
\\
x\_s = \mathsf{copysign}\left(1, x\right)
\\
x\_s \cdot x\_m
\end{array}
Initial program 82.3%
remove-double-neg82.3%
distribute-frac-neg282.3%
distribute-frac-neg82.3%
distribute-rgt-neg-in82.3%
associate-/l*96.2%
distribute-frac-neg96.2%
distribute-frac-neg296.2%
remove-double-neg96.2%
div-sub96.2%
*-inverses96.2%
Simplified96.2%
Taylor expanded in z around 0 52.5%
Final simplification52.5%
(FPCore (x y z) :precision binary64 (if (< z -2.060202331921739e+104) (- x (/ (* z x) y)) (if (< z 1.6939766013828526e+213) (/ x (/ y (- y z))) (* (- y z) (/ x y)))))
double code(double x, double y, double z) {
double tmp;
if (z < -2.060202331921739e+104) {
tmp = x - ((z * x) / y);
} else if (z < 1.6939766013828526e+213) {
tmp = x / (y / (y - z));
} else {
tmp = (y - z) * (x / y);
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (z < (-2.060202331921739d+104)) then
tmp = x - ((z * x) / y)
else if (z < 1.6939766013828526d+213) then
tmp = x / (y / (y - z))
else
tmp = (y - z) * (x / y)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z < -2.060202331921739e+104) {
tmp = x - ((z * x) / y);
} else if (z < 1.6939766013828526e+213) {
tmp = x / (y / (y - z));
} else {
tmp = (y - z) * (x / y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if z < -2.060202331921739e+104: tmp = x - ((z * x) / y) elif z < 1.6939766013828526e+213: tmp = x / (y / (y - z)) else: tmp = (y - z) * (x / y) return tmp
function code(x, y, z) tmp = 0.0 if (z < -2.060202331921739e+104) tmp = Float64(x - Float64(Float64(z * x) / y)); elseif (z < 1.6939766013828526e+213) tmp = Float64(x / Float64(y / Float64(y - z))); else tmp = Float64(Float64(y - z) * Float64(x / y)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z < -2.060202331921739e+104) tmp = x - ((z * x) / y); elseif (z < 1.6939766013828526e+213) tmp = x / (y / (y - z)); else tmp = (y - z) * (x / y); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Less[z, -2.060202331921739e+104], N[(x - N[(N[(z * x), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], If[Less[z, 1.6939766013828526e+213], N[(x / N[(y / N[(y - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(y - z), $MachinePrecision] * N[(x / y), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z < -2.060202331921739 \cdot 10^{+104}:\\
\;\;\;\;x - \frac{z \cdot x}{y}\\
\mathbf{elif}\;z < 1.6939766013828526 \cdot 10^{+213}:\\
\;\;\;\;\frac{x}{\frac{y}{y - z}}\\
\mathbf{else}:\\
\;\;\;\;\left(y - z\right) \cdot \frac{x}{y}\\
\end{array}
\end{array}
herbie shell --seed 2024115
(FPCore (x y z)
:name "Diagrams.Backend.Cairo.Internal:setTexture from diagrams-cairo-1.3.0.3"
:precision binary64
:alt
(if (< z -2.060202331921739e+104) (- x (/ (* z x) y)) (if (< z 1.6939766013828526e+213) (/ x (/ y (- y z))) (* (- y z) (/ x y))))
(/ (* x (- y z)) y))