
(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 8 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 1.36e-126) (- x_m (/ z (/ y x_m))) (- 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 <= 1.36e-126) {
tmp = x_m - (z / (y / x_m));
} 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 <= 1.36d-126) then
tmp = x_m - (z / (y / x_m))
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 <= 1.36e-126) {
tmp = x_m - (z / (y / x_m));
} 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 <= 1.36e-126: tmp = x_m - (z / (y / x_m)) 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 <= 1.36e-126) tmp = Float64(x_m - Float64(z / Float64(y / x_m))); 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 <= 1.36e-126) tmp = x_m - (z / (y / x_m)); 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, 1.36e-126], N[(x$95$m - N[(z / N[(y / x$95$m), $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 1.36 \cdot 10^{-126}:\\
\;\;\;\;x\_m - \frac{z}{\frac{y}{x\_m}}\\
\mathbf{else}:\\
\;\;\;\;x\_m - x\_m \cdot \frac{z}{y}\\
\end{array}
\end{array}
if x < 1.3599999999999999e-126Initial program 83.8%
remove-double-neg83.8%
distribute-frac-neg283.8%
distribute-frac-neg83.8%
distribute-rgt-neg-in83.8%
associate-/l*93.7%
distribute-frac-neg93.7%
distribute-frac-neg293.7%
remove-double-neg93.7%
div-sub93.8%
*-inverses93.8%
Simplified93.8%
sub-neg93.8%
distribute-rgt-in93.8%
*-un-lft-identity93.8%
distribute-neg-frac293.8%
Applied egg-rr93.8%
*-commutative93.8%
add-sqr-sqrt17.1%
sqrt-unprod35.6%
sqr-neg35.6%
sqrt-unprod37.0%
add-sqr-sqrt46.4%
cancel-sign-sub-inv46.4%
distribute-frac-neg246.4%
distribute-rgt-neg-out46.4%
distribute-lft-neg-out46.4%
add-sqr-sqrt37.0%
sqrt-unprod35.6%
sqr-neg35.6%
sqrt-unprod17.1%
add-sqr-sqrt93.8%
Applied egg-rr93.8%
associate-*r/95.4%
add-sqr-sqrt43.7%
sqrt-unprod63.4%
sqr-neg63.4%
sqrt-unprod27.8%
add-sqr-sqrt46.5%
associate-*l/43.4%
clear-num43.4%
associate-*l/43.4%
*-un-lft-identity43.4%
add-sqr-sqrt25.2%
sqrt-unprod60.7%
sqr-neg60.7%
sqrt-unprod43.6%
add-sqr-sqrt91.3%
Applied egg-rr91.3%
if 1.3599999999999999e-126 < x Initial program 82.7%
remove-double-neg82.7%
distribute-frac-neg282.7%
distribute-frac-neg82.7%
distribute-rgt-neg-in82.7%
associate-/l*99.9%
distribute-frac-neg99.9%
distribute-frac-neg299.9%
remove-double-neg99.9%
div-sub100.0%
*-inverses100.0%
Simplified100.0%
sub-neg100.0%
distribute-rgt-in99.9%
*-un-lft-identity99.9%
distribute-neg-frac299.9%
Applied egg-rr99.9%
*-commutative99.9%
add-sqr-sqrt99.8%
sqrt-unprod81.0%
sqr-neg81.0%
sqrt-unprod0.0%
add-sqr-sqrt53.4%
cancel-sign-sub-inv53.4%
distribute-frac-neg253.4%
distribute-rgt-neg-out53.4%
distribute-lft-neg-out53.4%
add-sqr-sqrt0.0%
sqrt-unprod81.0%
sqr-neg81.0%
sqrt-unprod99.8%
add-sqr-sqrt99.9%
Applied egg-rr99.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 (or (<= z -7e-19) (not (<= z 540000.0))) (* z (/ x_m (- 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 ((z <= -7e-19) || !(z <= 540000.0)) {
tmp = z * (x_m / -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 ((z <= (-7d-19)) .or. (.not. (z <= 540000.0d0))) then
tmp = z * (x_m / -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 ((z <= -7e-19) || !(z <= 540000.0)) {
tmp = z * (x_m / -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 (z <= -7e-19) or not (z <= 540000.0): tmp = z * (x_m / -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 ((z <= -7e-19) || !(z <= 540000.0)) tmp = Float64(z * Float64(x_m / Float64(-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 ((z <= -7e-19) || ~((z <= 540000.0))) tmp = z * (x_m / -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[Or[LessEqual[z, -7e-19], N[Not[LessEqual[z, 540000.0]], $MachinePrecision]], N[(z * N[(x$95$m / (-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}\;z \leq -7 \cdot 10^{-19} \lor \neg \left(z \leq 540000\right):\\
\;\;\;\;z \cdot \frac{x\_m}{-y}\\
\mathbf{else}:\\
\;\;\;\;x\_m\\
\end{array}
\end{array}
if z < -7.00000000000000031e-19 or 5.4e5 < z Initial program 91.3%
remove-double-neg91.3%
distribute-frac-neg291.3%
distribute-frac-neg91.3%
distribute-rgt-neg-in91.3%
associate-/l*92.0%
distribute-frac-neg92.0%
distribute-frac-neg292.0%
remove-double-neg92.0%
div-sub92.1%
*-inverses92.1%
Simplified92.1%
Taylor expanded in z around inf 75.6%
mul-1-neg75.6%
distribute-frac-neg275.6%
*-commutative75.6%
associate-/l*73.8%
Simplified73.8%
if -7.00000000000000031e-19 < z < 5.4e5Initial program 74.9%
remove-double-neg74.9%
distribute-frac-neg274.9%
distribute-frac-neg74.9%
distribute-rgt-neg-in74.9%
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.3%
Final simplification75.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 (or (<= z -1.6e-21) (not (<= z 360000.0))) (* 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 ((z <= -1.6e-21) || !(z <= 360000.0)) {
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 ((z <= (-1.6d-21)) .or. (.not. (z <= 360000.0d0))) 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 ((z <= -1.6e-21) || !(z <= 360000.0)) {
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 (z <= -1.6e-21) or not (z <= 360000.0): 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 ((z <= -1.6e-21) || !(z <= 360000.0)) tmp = Float64(x_m * Float64(z / Float64(-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 ((z <= -1.6e-21) || ~((z <= 360000.0))) 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[Or[LessEqual[z, -1.6e-21], N[Not[LessEqual[z, 360000.0]], $MachinePrecision]], 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}\;z \leq -1.6 \cdot 10^{-21} \lor \neg \left(z \leq 360000\right):\\
\;\;\;\;x\_m \cdot \frac{z}{-y}\\
\mathbf{else}:\\
\;\;\;\;x\_m\\
\end{array}
\end{array}
if z < -1.6000000000000001e-21 or 3.6e5 < z Initial program 91.3%
remove-double-neg91.3%
distribute-frac-neg291.3%
distribute-frac-neg91.3%
distribute-rgt-neg-in91.3%
associate-/l*92.0%
distribute-frac-neg92.0%
distribute-frac-neg292.0%
remove-double-neg92.0%
div-sub92.1%
*-inverses92.1%
Simplified92.1%
Taylor expanded in z around inf 75.6%
mul-1-neg75.6%
distribute-frac-neg275.6%
associate-*r/69.9%
Simplified69.9%
if -1.6000000000000001e-21 < z < 3.6e5Initial program 74.9%
remove-double-neg74.9%
distribute-frac-neg274.9%
distribute-frac-neg74.9%
distribute-rgt-neg-in74.9%
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.3%
Final simplification73.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 (<= z -6e-18)
(* z (/ x_m (- y)))
(if (<= z 750000.0) 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 (z <= -6e-18) {
tmp = z * (x_m / -y);
} else if (z <= 750000.0) {
tmp = x_m;
} else {
tmp = (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 (z <= (-6d-18)) then
tmp = z * (x_m / -y)
else if (z <= 750000.0d0) then
tmp = x_m
else
tmp = (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 (z <= -6e-18) {
tmp = z * (x_m / -y);
} else if (z <= 750000.0) {
tmp = x_m;
} else {
tmp = (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 z <= -6e-18: tmp = z * (x_m / -y) elif z <= 750000.0: tmp = x_m else: tmp = (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 (z <= -6e-18) tmp = Float64(z * Float64(x_m / Float64(-y))); elseif (z <= 750000.0) tmp = x_m; else tmp = Float64(Float64(x_m * z) / Float64(-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 (z <= -6e-18) tmp = z * (x_m / -y); elseif (z <= 750000.0) tmp = x_m; else tmp = (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[z, -6e-18], N[(z * N[(x$95$m / (-y)), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 750000.0], x$95$m, N[(N[(x$95$m * z), $MachinePrecision] / (-y)), $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}\;z \leq -6 \cdot 10^{-18}:\\
\;\;\;\;z \cdot \frac{x\_m}{-y}\\
\mathbf{elif}\;z \leq 750000:\\
\;\;\;\;x\_m\\
\mathbf{else}:\\
\;\;\;\;\frac{x\_m \cdot z}{-y}\\
\end{array}
\end{array}
if z < -5.99999999999999966e-18Initial program 92.3%
remove-double-neg92.3%
distribute-frac-neg292.3%
distribute-frac-neg92.3%
distribute-rgt-neg-in92.3%
associate-/l*96.8%
distribute-frac-neg96.8%
distribute-frac-neg296.8%
remove-double-neg96.8%
div-sub96.8%
*-inverses96.8%
Simplified96.8%
Taylor expanded in z around inf 76.6%
mul-1-neg76.6%
distribute-frac-neg276.6%
*-commutative76.6%
associate-/l*80.2%
Simplified80.2%
if -5.99999999999999966e-18 < z < 7.5e5Initial program 74.9%
remove-double-neg74.9%
distribute-frac-neg274.9%
distribute-frac-neg74.9%
distribute-rgt-neg-in74.9%
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.3%
if 7.5e5 < z Initial program 90.5%
remove-double-neg90.5%
distribute-frac-neg290.5%
distribute-frac-neg90.5%
distribute-rgt-neg-in90.5%
associate-/l*88.0%
distribute-frac-neg88.0%
distribute-frac-neg288.0%
remove-double-neg88.0%
div-sub88.0%
*-inverses88.0%
Simplified88.0%
Taylor expanded in z around inf 74.7%
associate-*r/74.7%
associate-*r*74.7%
mul-1-neg74.7%
Simplified74.7%
Final simplification77.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 -2.6e-134) x_m (if (<= y 2e-76) (* y (/ x_m 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 <= -2.6e-134) {
tmp = x_m;
} else if (y <= 2e-76) {
tmp = y * (x_m / 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 <= (-2.6d-134)) then
tmp = x_m
else if (y <= 2d-76) then
tmp = y * (x_m / 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 <= -2.6e-134) {
tmp = x_m;
} else if (y <= 2e-76) {
tmp = y * (x_m / 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 <= -2.6e-134: tmp = x_m elif y <= 2e-76: tmp = y * (x_m / 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 <= -2.6e-134) tmp = x_m; elseif (y <= 2e-76) tmp = Float64(y * Float64(x_m / 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 <= -2.6e-134) tmp = x_m; elseif (y <= 2e-76) tmp = y * (x_m / 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, -2.6e-134], x$95$m, If[LessEqual[y, 2e-76], N[(y * N[(x$95$m / 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 -2.6 \cdot 10^{-134}:\\
\;\;\;\;x\_m\\
\mathbf{elif}\;y \leq 2 \cdot 10^{-76}:\\
\;\;\;\;y \cdot \frac{x\_m}{y}\\
\mathbf{else}:\\
\;\;\;\;x\_m\\
\end{array}
\end{array}
if y < -2.60000000000000023e-134 or 1.99999999999999985e-76 < y Initial program 81.0%
remove-double-neg81.0%
distribute-frac-neg281.0%
distribute-frac-neg81.0%
distribute-rgt-neg-in81.0%
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 66.9%
if -2.60000000000000023e-134 < y < 1.99999999999999985e-76Initial program 87.8%
Taylor expanded in y around inf 16.4%
*-commutative16.4%
associate-/l*39.3%
Applied egg-rr39.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 (- 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) {
return x_s * (x_m - (x_m * (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 - (x_m * (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 - (x_m * (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 - (x_m * (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(x_m * 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 - (x_m * (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[(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 \left(x\_m - x\_m \cdot \frac{z}{y}\right)
\end{array}
Initial program 83.5%
remove-double-neg83.5%
distribute-frac-neg283.5%
distribute-frac-neg83.5%
distribute-rgt-neg-in83.5%
associate-/l*95.8%
distribute-frac-neg95.8%
distribute-frac-neg295.8%
remove-double-neg95.8%
div-sub95.8%
*-inverses95.8%
Simplified95.8%
sub-neg95.8%
distribute-rgt-in95.9%
*-un-lft-identity95.9%
distribute-neg-frac295.9%
Applied egg-rr95.9%
*-commutative95.9%
add-sqr-sqrt44.9%
sqrt-unprod50.8%
sqr-neg50.8%
sqrt-unprod24.6%
add-sqr-sqrt48.7%
cancel-sign-sub-inv48.7%
distribute-frac-neg248.7%
distribute-rgt-neg-out48.7%
distribute-lft-neg-out48.7%
add-sqr-sqrt24.6%
sqrt-unprod50.8%
sqr-neg50.8%
sqrt-unprod44.9%
add-sqr-sqrt95.9%
Applied egg-rr95.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 83.5%
remove-double-neg83.5%
distribute-frac-neg283.5%
distribute-frac-neg83.5%
distribute-rgt-neg-in83.5%
associate-/l*95.8%
distribute-frac-neg95.8%
distribute-frac-neg295.8%
remove-double-neg95.8%
div-sub95.8%
*-inverses95.8%
Simplified95.8%
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 83.5%
remove-double-neg83.5%
distribute-frac-neg283.5%
distribute-frac-neg83.5%
distribute-rgt-neg-in83.5%
associate-/l*95.8%
distribute-frac-neg95.8%
distribute-frac-neg295.8%
remove-double-neg95.8%
div-sub95.8%
*-inverses95.8%
Simplified95.8%
Taylor expanded in z around 0 50.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 2024143
(FPCore (x y z)
:name "Diagrams.Backend.Cairo.Internal:setTexture from diagrams-cairo-1.3.0.3"
:precision binary64
:alt
(! :herbie-platform default (if (< z -206020233192173900000000000000000000000000000000000000000000000000000000000000000000000000000000000000000) (- x (/ (* z x) y)) (if (< z 1693976601382852600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000) (/ x (/ y (- y z))) (* (- y z) (/ x y)))))
(/ (* x (- y z)) y))