
(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 3.1e-91) (- x_m (/ (* x_m z) y)) (- x_m (/ x_m (/ 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 <= 3.1e-91) {
tmp = x_m - ((x_m * z) / y);
} else {
tmp = x_m - (x_m / (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 <= 3.1d-91) then
tmp = x_m - ((x_m * z) / y)
else
tmp = x_m - (x_m / (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 <= 3.1e-91) {
tmp = x_m - ((x_m * z) / y);
} else {
tmp = x_m - (x_m / (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 <= 3.1e-91: tmp = x_m - ((x_m * z) / y) else: tmp = x_m - (x_m / (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 <= 3.1e-91) tmp = Float64(x_m - Float64(Float64(x_m * z) / y)); else tmp = Float64(x_m - Float64(x_m / 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 <= 3.1e-91) tmp = x_m - ((x_m * z) / y); else tmp = x_m - (x_m / (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, 3.1e-91], N[(x$95$m - N[(N[(x$95$m * z), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], N[(x$95$m - N[(x$95$m / 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 3.1 \cdot 10^{-91}:\\
\;\;\;\;x\_m - \frac{x\_m \cdot z}{y}\\
\mathbf{else}:\\
\;\;\;\;x\_m - \frac{x\_m}{\frac{y}{z}}\\
\end{array}
\end{array}
if x < 3.09999999999999981e-91Initial program 84.7%
remove-double-neg84.7%
distribute-frac-neg284.7%
distribute-frac-neg84.7%
distribute-rgt-neg-in84.7%
associate-/l*92.9%
distribute-frac-neg92.9%
distribute-frac-neg292.9%
remove-double-neg92.9%
div-sub92.9%
*-inverses92.9%
Simplified92.9%
Taylor expanded in z around 0 93.5%
associate-*r/93.5%
associate-*r*93.5%
mul-1-neg93.5%
Simplified93.5%
if 3.09999999999999981e-91 < x Initial program 82.2%
remove-double-neg82.2%
distribute-frac-neg282.2%
distribute-frac-neg82.2%
distribute-rgt-neg-in82.2%
associate-/l*99.9%
distribute-frac-neg99.9%
distribute-frac-neg299.9%
remove-double-neg99.9%
div-sub99.9%
*-inverses99.9%
Simplified99.9%
clear-num99.9%
associate-/r/99.9%
Applied egg-rr99.9%
sub-neg99.9%
associate-*l/99.9%
*-un-lft-identity99.9%
distribute-frac-neg299.9%
distribute-lft-in99.9%
*-commutative99.9%
*-un-lft-identity99.9%
distribute-frac-neg299.9%
*-un-lft-identity99.9%
associate-*l/99.9%
distribute-rgt-neg-out99.9%
distribute-lft-neg-out99.9%
add-sqr-sqrt99.8%
sqrt-unprod82.8%
sqr-neg82.8%
sqrt-unprod0.0%
add-sqr-sqrt49.8%
cancel-sign-sub-inv49.8%
distribute-lft-neg-out49.8%
distribute-rgt-neg-out49.8%
associate-*l/49.8%
Applied egg-rr99.9%
Final simplification95.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 (or (<= z -8e-40) (not (<= z 3.4e+54))) (* 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 <= -8e-40) || !(z <= 3.4e+54)) {
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 <= (-8d-40)) .or. (.not. (z <= 3.4d+54))) 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 <= -8e-40) || !(z <= 3.4e+54)) {
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 <= -8e-40) or not (z <= 3.4e+54): 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 <= -8e-40) || !(z <= 3.4e+54)) 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 <= -8e-40) || ~((z <= 3.4e+54))) 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, -8e-40], N[Not[LessEqual[z, 3.4e+54]], $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 -8 \cdot 10^{-40} \lor \neg \left(z \leq 3.4 \cdot 10^{+54}\right):\\
\;\;\;\;z \cdot \frac{x\_m}{-y}\\
\mathbf{else}:\\
\;\;\;\;x\_m\\
\end{array}
\end{array}
if z < -7.9999999999999994e-40 or 3.4000000000000001e54 < z Initial program 87.2%
remove-double-neg87.2%
distribute-frac-neg287.2%
distribute-frac-neg87.2%
distribute-rgt-neg-in87.2%
associate-/l*90.1%
distribute-frac-neg90.1%
distribute-frac-neg290.1%
remove-double-neg90.1%
div-sub90.1%
*-inverses90.1%
Simplified90.1%
Taylor expanded in z around inf 74.1%
mul-1-neg74.1%
distribute-frac-neg274.1%
*-commutative74.1%
associate-/l*72.4%
Simplified72.4%
if -7.9999999999999994e-40 < z < 3.4000000000000001e54Initial program 80.8%
remove-double-neg80.8%
distribute-frac-neg280.8%
distribute-frac-neg80.8%
distribute-rgt-neg-in80.8%
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 77.2%
Final simplification74.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 (if (or (<= z -3.45e-37) (not (<= z 2.65e+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 ((z <= -3.45e-37) || !(z <= 2.65e+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 ((z <= (-3.45d-37)) .or. (.not. (z <= 2.65d+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 ((z <= -3.45e-37) || !(z <= 2.65e+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 (z <= -3.45e-37) or not (z <= 2.65e+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 ((z <= -3.45e-37) || !(z <= 2.65e+54)) 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 <= -3.45e-37) || ~((z <= 2.65e+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[Or[LessEqual[z, -3.45e-37], N[Not[LessEqual[z, 2.65e+54]], $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 -3.45 \cdot 10^{-37} \lor \neg \left(z \leq 2.65 \cdot 10^{+54}\right):\\
\;\;\;\;x\_m \cdot \frac{z}{-y}\\
\mathbf{else}:\\
\;\;\;\;x\_m\\
\end{array}
\end{array}
if z < -3.4499999999999999e-37 or 2.65000000000000009e54 < z Initial program 87.2%
remove-double-neg87.2%
distribute-frac-neg287.2%
distribute-frac-neg87.2%
distribute-rgt-neg-in87.2%
associate-/l*90.1%
distribute-frac-neg90.1%
distribute-frac-neg290.1%
remove-double-neg90.1%
div-sub90.1%
*-inverses90.1%
Simplified90.1%
Taylor expanded in z around inf 74.1%
mul-1-neg74.1%
distribute-frac-neg274.1%
associate-*r/67.4%
Simplified67.4%
if -3.4499999999999999e-37 < z < 2.65000000000000009e54Initial program 80.8%
remove-double-neg80.8%
distribute-frac-neg280.8%
distribute-frac-neg80.8%
distribute-rgt-neg-in80.8%
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 77.2%
Final simplification72.4%
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 -2.7e-40)
(- (/ (* x_m z) y))
(if (<= z 1.12e+54) x_m (* z (/ x_m (- 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 <= -2.7e-40) {
tmp = -((x_m * z) / y);
} else if (z <= 1.12e+54) {
tmp = x_m;
} else {
tmp = z * (x_m / -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 <= (-2.7d-40)) then
tmp = -((x_m * z) / y)
else if (z <= 1.12d+54) then
tmp = x_m
else
tmp = z * (x_m / -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 <= -2.7e-40) {
tmp = -((x_m * z) / y);
} else if (z <= 1.12e+54) {
tmp = x_m;
} else {
tmp = z * (x_m / -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 <= -2.7e-40: tmp = -((x_m * z) / y) elif z <= 1.12e+54: tmp = x_m else: tmp = z * (x_m / -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 <= -2.7e-40) tmp = Float64(-Float64(Float64(x_m * z) / y)); elseif (z <= 1.12e+54) tmp = x_m; else tmp = Float64(z * Float64(x_m / 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 <= -2.7e-40) tmp = -((x_m * z) / y); elseif (z <= 1.12e+54) tmp = x_m; else tmp = z * (x_m / -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, -2.7e-40], (-N[(N[(x$95$m * z), $MachinePrecision] / y), $MachinePrecision]), If[LessEqual[z, 1.12e+54], x$95$m, N[(z * N[(x$95$m / (-y)), $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}\;z \leq -2.7 \cdot 10^{-40}:\\
\;\;\;\;-\frac{x\_m \cdot z}{y}\\
\mathbf{elif}\;z \leq 1.12 \cdot 10^{+54}:\\
\;\;\;\;x\_m\\
\mathbf{else}:\\
\;\;\;\;z \cdot \frac{x\_m}{-y}\\
\end{array}
\end{array}
if z < -2.7e-40Initial program 86.1%
remove-double-neg86.1%
distribute-frac-neg286.1%
distribute-frac-neg86.1%
distribute-rgt-neg-in86.1%
associate-/l*92.9%
distribute-frac-neg92.9%
distribute-frac-neg292.9%
remove-double-neg92.9%
div-sub92.9%
*-inverses92.9%
Simplified92.9%
Taylor expanded in z around inf 70.6%
associate-*r/70.6%
associate-*r*70.6%
mul-1-neg70.6%
Simplified70.6%
if -2.7e-40 < z < 1.12e54Initial program 80.8%
remove-double-neg80.8%
distribute-frac-neg280.8%
distribute-frac-neg80.8%
distribute-rgt-neg-in80.8%
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 77.2%
if 1.12e54 < z Initial program 88.6%
remove-double-neg88.6%
distribute-frac-neg288.6%
distribute-frac-neg88.6%
distribute-rgt-neg-in88.6%
associate-/l*86.8%
distribute-frac-neg86.8%
distribute-frac-neg286.8%
remove-double-neg86.8%
div-sub86.8%
*-inverses86.8%
Simplified86.8%
Taylor expanded in z around inf 78.2%
mul-1-neg78.2%
distribute-frac-neg278.2%
*-commutative78.2%
associate-/l*78.9%
Simplified78.9%
Final simplification75.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 (if (<= x_m 2e-64) (- x_m (/ z (/ y x_m))) (- x_m (/ x_m (/ 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 <= 2e-64) {
tmp = x_m - (z / (y / x_m));
} else {
tmp = x_m - (x_m / (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 <= 2d-64) then
tmp = x_m - (z / (y / x_m))
else
tmp = x_m - (x_m / (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 <= 2e-64) {
tmp = x_m - (z / (y / x_m));
} else {
tmp = x_m - (x_m / (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 <= 2e-64: tmp = x_m - (z / (y / x_m)) else: tmp = x_m - (x_m / (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 <= 2e-64) tmp = Float64(x_m - Float64(z / Float64(y / x_m))); else tmp = Float64(x_m - Float64(x_m / 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 <= 2e-64) tmp = x_m - (z / (y / x_m)); else tmp = x_m - (x_m / (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, 2e-64], N[(x$95$m - N[(z / N[(y / x$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x$95$m - N[(x$95$m / 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 2 \cdot 10^{-64}:\\
\;\;\;\;x\_m - \frac{z}{\frac{y}{x\_m}}\\
\mathbf{else}:\\
\;\;\;\;x\_m - \frac{x\_m}{\frac{y}{z}}\\
\end{array}
\end{array}
if x < 1.99999999999999993e-64Initial program 85.3%
remove-double-neg85.3%
distribute-frac-neg285.3%
distribute-frac-neg85.3%
distribute-rgt-neg-in85.3%
associate-/l*93.1%
distribute-frac-neg93.1%
distribute-frac-neg293.1%
remove-double-neg93.1%
div-sub93.2%
*-inverses93.2%
Simplified93.2%
clear-num93.1%
associate-/r/93.1%
Applied egg-rr93.1%
sub-neg93.1%
associate-*l/93.2%
*-un-lft-identity93.2%
distribute-frac-neg293.2%
distribute-lft-in93.1%
*-commutative93.1%
*-un-lft-identity93.1%
distribute-frac-neg293.1%
*-un-lft-identity93.1%
associate-*l/93.1%
distribute-rgt-neg-out93.1%
distribute-lft-neg-out93.1%
add-sqr-sqrt24.1%
sqrt-unprod46.0%
sqr-neg46.0%
sqrt-unprod35.4%
add-sqr-sqrt49.6%
cancel-sign-sub-inv49.6%
distribute-lft-neg-out49.6%
distribute-rgt-neg-out49.6%
associate-*l/49.6%
Applied egg-rr93.1%
Taylor expanded in x around 0 93.7%
*-commutative93.7%
associate-*l/93.1%
associate-/r/93.2%
Simplified93.2%
if 1.99999999999999993e-64 < x Initial program 80.6%
remove-double-neg80.6%
distribute-frac-neg280.6%
distribute-frac-neg80.6%
distribute-rgt-neg-in80.6%
associate-/l*99.9%
distribute-frac-neg99.9%
distribute-frac-neg299.9%
remove-double-neg99.9%
div-sub99.9%
*-inverses99.9%
Simplified99.9%
clear-num99.9%
associate-/r/99.9%
Applied egg-rr99.9%
sub-neg99.9%
associate-*l/99.9%
*-un-lft-identity99.9%
distribute-frac-neg299.9%
distribute-lft-in99.9%
*-commutative99.9%
*-un-lft-identity99.9%
distribute-frac-neg299.9%
*-un-lft-identity99.9%
associate-*l/99.9%
distribute-rgt-neg-out99.9%
distribute-lft-neg-out99.9%
add-sqr-sqrt99.8%
sqrt-unprod81.2%
sqr-neg81.2%
sqrt-unprod0.0%
add-sqr-sqrt46.4%
cancel-sign-sub-inv46.4%
distribute-lft-neg-out46.4%
distribute-rgt-neg-out46.4%
associate-*l/46.4%
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 (<= z 1.8e+214) (* x_m (- 1.0 (/ z y))) (- (/ (* 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 <= 1.8e+214) {
tmp = x_m * (1.0 - (z / y));
} 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 <= 1.8d+214) then
tmp = x_m * (1.0d0 - (z / y))
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 <= 1.8e+214) {
tmp = x_m * (1.0 - (z / y));
} 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 <= 1.8e+214: tmp = x_m * (1.0 - (z / y)) 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 <= 1.8e+214) tmp = Float64(x_m * Float64(1.0 - Float64(z / y))); else tmp = Float64(-Float64(Float64(x_m * 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 (z <= 1.8e+214) tmp = x_m * (1.0 - (z / y)); 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, 1.8e+214], N[(x$95$m * N[(1.0 - N[(z / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], (-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 1.8 \cdot 10^{+214}:\\
\;\;\;\;x\_m \cdot \left(1 - \frac{z}{y}\right)\\
\mathbf{else}:\\
\;\;\;\;-\frac{x\_m \cdot z}{y}\\
\end{array}
\end{array}
if z < 1.8000000000000001e214Initial program 83.0%
remove-double-neg83.0%
distribute-frac-neg283.0%
distribute-frac-neg83.0%
distribute-rgt-neg-in83.0%
associate-/l*97.0%
distribute-frac-neg97.0%
distribute-frac-neg297.0%
remove-double-neg97.0%
div-sub97.1%
*-inverses97.1%
Simplified97.1%
if 1.8000000000000001e214 < z Initial program 95.4%
remove-double-neg95.4%
distribute-frac-neg295.4%
distribute-frac-neg95.4%
distribute-rgt-neg-in95.4%
associate-/l*71.5%
distribute-frac-neg71.5%
distribute-frac-neg271.5%
remove-double-neg71.5%
div-sub71.5%
*-inverses71.5%
Simplified71.5%
Taylor expanded in z around inf 95.4%
associate-*r/95.4%
associate-*r*95.4%
mul-1-neg95.4%
Simplified95.4%
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 2e+57) x_m (* y (/ x_m 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 <= 2e+57) {
tmp = x_m;
} else {
tmp = y * (x_m / 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 <= 2d+57) then
tmp = x_m
else
tmp = y * (x_m / 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 <= 2e+57) {
tmp = x_m;
} else {
tmp = y * (x_m / 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 <= 2e+57: tmp = x_m else: tmp = y * (x_m / 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 <= 2e+57) tmp = x_m; else tmp = Float64(y * Float64(x_m / 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 <= 2e+57) tmp = x_m; else tmp = y * (x_m / 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, 2e+57], x$95$m, N[(y * N[(x$95$m / y), $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 2 \cdot 10^{+57}:\\
\;\;\;\;x\_m\\
\mathbf{else}:\\
\;\;\;\;y \cdot \frac{x\_m}{y}\\
\end{array}
\end{array}
if x < 2.0000000000000001e57Initial program 86.9%
remove-double-neg86.9%
distribute-frac-neg286.9%
distribute-frac-neg86.9%
distribute-rgt-neg-in86.9%
associate-/l*94.1%
distribute-frac-neg94.1%
distribute-frac-neg294.1%
remove-double-neg94.1%
div-sub94.1%
*-inverses94.1%
Simplified94.1%
Taylor expanded in z around 0 50.4%
if 2.0000000000000001e57 < x Initial program 69.5%
*-commutative69.5%
associate-/l*91.0%
Applied egg-rr91.0%
Taylor expanded in y around inf 60.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 84.0%
remove-double-neg84.0%
distribute-frac-neg284.0%
distribute-frac-neg84.0%
distribute-rgt-neg-in84.0%
associate-/l*95.0%
distribute-frac-neg95.0%
distribute-frac-neg295.0%
remove-double-neg95.0%
div-sub95.1%
*-inverses95.1%
Simplified95.1%
Taylor expanded in z around 0 50.2%
(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 2024150
(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))