
(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 2e+20) (- 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 <= 2e+20) {
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 <= 2d+20) 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 <= 2e+20) {
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 <= 2e+20: 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 <= 2e+20) 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 <= 2e+20) 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, 2e+20], 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 2 \cdot 10^{+20}:\\
\;\;\;\;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 < 2e20Initial program 82.7%
remove-double-neg82.7%
distribute-frac-neg282.7%
distribute-frac-neg82.7%
distribute-rgt-neg-in82.7%
associate-/l*95.2%
distribute-frac-neg95.2%
distribute-frac-neg295.2%
remove-double-neg95.2%
div-sub95.2%
*-inverses95.2%
Simplified95.2%
sub-neg95.2%
distribute-rgt-in95.2%
*-un-lft-identity95.2%
distribute-neg-frac295.2%
Applied egg-rr95.2%
*-commutative95.2%
add-sqr-sqrt28.8%
sqrt-unprod47.2%
sqr-neg47.2%
sqrt-unprod33.0%
add-sqr-sqrt51.8%
cancel-sign-sub-inv51.8%
*-commutative51.8%
associate-*l/50.4%
associate-/l*50.5%
add-sqr-sqrt25.6%
sqrt-unprod63.7%
sqr-neg63.7%
sqrt-unprod46.7%
add-sqr-sqrt95.1%
Applied egg-rr95.1%
if 2e20 < x Initial program 76.1%
remove-double-neg76.1%
distribute-frac-neg276.1%
distribute-frac-neg76.1%
distribute-rgt-neg-in76.1%
associate-/l*99.9%
distribute-frac-neg99.9%
distribute-frac-neg299.9%
remove-double-neg99.9%
div-sub99.9%
*-inverses99.9%
Simplified99.9%
Final simplification96.1%
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.26e+33)
(and (not (<= z -1.65e-6))
(or (<= z -5.6e-46) (not (<= z 7.2e-51)))))
(* 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.26e+33) || (!(z <= -1.65e-6) && ((z <= -5.6e-46) || !(z <= 7.2e-51)))) {
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.26d+33)) .or. (.not. (z <= (-1.65d-6))) .and. (z <= (-5.6d-46)) .or. (.not. (z <= 7.2d-51))) 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.26e+33) || (!(z <= -1.65e-6) && ((z <= -5.6e-46) || !(z <= 7.2e-51)))) {
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.26e+33) or (not (z <= -1.65e-6) and ((z <= -5.6e-46) or not (z <= 7.2e-51))): 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.26e+33) || (!(z <= -1.65e-6) && ((z <= -5.6e-46) || !(z <= 7.2e-51)))) 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.26e+33) || (~((z <= -1.65e-6)) && ((z <= -5.6e-46) || ~((z <= 7.2e-51))))) 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.26e+33], And[N[Not[LessEqual[z, -1.65e-6]], $MachinePrecision], Or[LessEqual[z, -5.6e-46], N[Not[LessEqual[z, 7.2e-51]], $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.26 \cdot 10^{+33} \lor \neg \left(z \leq -1.65 \cdot 10^{-6}\right) \land \left(z \leq -5.6 \cdot 10^{-46} \lor \neg \left(z \leq 7.2 \cdot 10^{-51}\right)\right):\\
\;\;\;\;x\_m \cdot \frac{z}{-y}\\
\mathbf{else}:\\
\;\;\;\;x\_m\\
\end{array}
\end{array}
if z < -1.26e33 or -1.65000000000000008e-6 < z < -5.5999999999999997e-46 or 7.2000000000000001e-51 < z Initial program 88.4%
remove-double-neg88.4%
distribute-frac-neg288.4%
distribute-frac-neg88.4%
distribute-rgt-neg-in88.4%
associate-/l*92.7%
distribute-frac-neg92.7%
distribute-frac-neg292.7%
remove-double-neg92.7%
div-sub92.8%
*-inverses92.8%
Simplified92.8%
Taylor expanded in z around inf 69.9%
mul-1-neg69.9%
distribute-frac-neg269.9%
Simplified69.9%
if -1.26e33 < z < -1.65000000000000008e-6 or -5.5999999999999997e-46 < z < 7.2000000000000001e-51Initial program 73.8%
remove-double-neg73.8%
distribute-frac-neg273.8%
distribute-frac-neg73.8%
distribute-rgt-neg-in73.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 83.9%
Final simplification76.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 (or (<= z -8.4e+30)
(not
(or (<= z -1.52e-6) (and (not (<= z -1.15e-44)) (<= z 1.05e-50)))))
(* 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 <= -8.4e+30) || !((z <= -1.52e-6) || (!(z <= -1.15e-44) && (z <= 1.05e-50)))) {
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 <= (-8.4d+30)) .or. (.not. (z <= (-1.52d-6)) .or. (.not. (z <= (-1.15d-44))) .and. (z <= 1.05d-50))) 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 <= -8.4e+30) || !((z <= -1.52e-6) || (!(z <= -1.15e-44) && (z <= 1.05e-50)))) {
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 <= -8.4e+30) or not ((z <= -1.52e-6) or (not (z <= -1.15e-44) and (z <= 1.05e-50))): 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 <= -8.4e+30) || !((z <= -1.52e-6) || (!(z <= -1.15e-44) && (z <= 1.05e-50)))) 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 <= -8.4e+30) || ~(((z <= -1.52e-6) || (~((z <= -1.15e-44)) && (z <= 1.05e-50))))) 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, -8.4e+30], N[Not[Or[LessEqual[z, -1.52e-6], And[N[Not[LessEqual[z, -1.15e-44]], $MachinePrecision], LessEqual[z, 1.05e-50]]]], $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.4 \cdot 10^{+30} \lor \neg \left(z \leq -1.52 \cdot 10^{-6} \lor \neg \left(z \leq -1.15 \cdot 10^{-44}\right) \land z \leq 1.05 \cdot 10^{-50}\right):\\
\;\;\;\;z \cdot \frac{x\_m}{-y}\\
\mathbf{else}:\\
\;\;\;\;x\_m\\
\end{array}
\end{array}
if z < -8.4000000000000001e30 or -1.52000000000000006e-6 < z < -1.14999999999999999e-44 or 1.05e-50 < z Initial program 88.4%
remove-double-neg88.4%
distribute-frac-neg288.4%
distribute-frac-neg88.4%
distribute-rgt-neg-in88.4%
associate-/l*92.7%
distribute-frac-neg92.7%
distribute-frac-neg292.7%
remove-double-neg92.7%
div-sub92.8%
*-inverses92.8%
Simplified92.8%
Taylor expanded in z around inf 75.6%
associate-*l/74.1%
associate-*l*74.1%
*-commutative74.1%
associate-*r/74.1%
mul-1-neg74.1%
Simplified74.1%
if -8.4000000000000001e30 < z < -1.52000000000000006e-6 or -1.14999999999999999e-44 < z < 1.05e-50Initial program 73.8%
remove-double-neg73.8%
distribute-frac-neg273.8%
distribute-frac-neg73.8%
distribute-rgt-neg-in73.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 83.9%
Final simplification78.8%
x\_m = (fabs.f64 x)
x\_s = (copysign.f64 #s(literal 1 binary64) x)
(FPCore (x_s x_m y z)
:precision binary64
(let* ((t_0 (* z (/ x_m (- y)))))
(*
x_s
(if (<= z -1.16e+36)
t_0
(if (<= z -9.5e-8)
x_m
(if (<= z -2e-45) (/ z (/ y (- x_m))) (if (<= z 3.9e-53) x_m t_0)))))))x\_m = fabs(x);
x\_s = copysign(1.0, x);
double code(double x_s, double x_m, double y, double z) {
double t_0 = z * (x_m / -y);
double tmp;
if (z <= -1.16e+36) {
tmp = t_0;
} else if (z <= -9.5e-8) {
tmp = x_m;
} else if (z <= -2e-45) {
tmp = z / (y / -x_m);
} else if (z <= 3.9e-53) {
tmp = x_m;
} else {
tmp = t_0;
}
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) :: t_0
real(8) :: tmp
t_0 = z * (x_m / -y)
if (z <= (-1.16d+36)) then
tmp = t_0
else if (z <= (-9.5d-8)) then
tmp = x_m
else if (z <= (-2d-45)) then
tmp = z / (y / -x_m)
else if (z <= 3.9d-53) then
tmp = x_m
else
tmp = t_0
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 t_0 = z * (x_m / -y);
double tmp;
if (z <= -1.16e+36) {
tmp = t_0;
} else if (z <= -9.5e-8) {
tmp = x_m;
} else if (z <= -2e-45) {
tmp = z / (y / -x_m);
} else if (z <= 3.9e-53) {
tmp = x_m;
} else {
tmp = t_0;
}
return x_s * tmp;
}
x\_m = math.fabs(x) x\_s = math.copysign(1.0, x) def code(x_s, x_m, y, z): t_0 = z * (x_m / -y) tmp = 0 if z <= -1.16e+36: tmp = t_0 elif z <= -9.5e-8: tmp = x_m elif z <= -2e-45: tmp = z / (y / -x_m) elif z <= 3.9e-53: tmp = x_m else: tmp = t_0 return x_s * tmp
x\_m = abs(x) x\_s = copysign(1.0, x) function code(x_s, x_m, y, z) t_0 = Float64(z * Float64(x_m / Float64(-y))) tmp = 0.0 if (z <= -1.16e+36) tmp = t_0; elseif (z <= -9.5e-8) tmp = x_m; elseif (z <= -2e-45) tmp = Float64(z / Float64(y / Float64(-x_m))); elseif (z <= 3.9e-53) tmp = x_m; else tmp = t_0; 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) t_0 = z * (x_m / -y); tmp = 0.0; if (z <= -1.16e+36) tmp = t_0; elseif (z <= -9.5e-8) tmp = x_m; elseif (z <= -2e-45) tmp = z / (y / -x_m); elseif (z <= 3.9e-53) tmp = x_m; else tmp = t_0; 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_] := Block[{t$95$0 = N[(z * N[(x$95$m / (-y)), $MachinePrecision]), $MachinePrecision]}, N[(x$95$s * If[LessEqual[z, -1.16e+36], t$95$0, If[LessEqual[z, -9.5e-8], x$95$m, If[LessEqual[z, -2e-45], N[(z / N[(y / (-x$95$m)), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 3.9e-53], x$95$m, t$95$0]]]]), $MachinePrecision]]
\begin{array}{l}
x\_m = \left|x\right|
\\
x\_s = \mathsf{copysign}\left(1, x\right)
\\
\begin{array}{l}
t_0 := z \cdot \frac{x\_m}{-y}\\
x\_s \cdot \begin{array}{l}
\mathbf{if}\;z \leq -1.16 \cdot 10^{+36}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq -9.5 \cdot 10^{-8}:\\
\;\;\;\;x\_m\\
\mathbf{elif}\;z \leq -2 \cdot 10^{-45}:\\
\;\;\;\;\frac{z}{\frac{y}{-x\_m}}\\
\mathbf{elif}\;z \leq 3.9 \cdot 10^{-53}:\\
\;\;\;\;x\_m\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
\end{array}
if z < -1.15999999999999998e36 or 3.9000000000000002e-53 < z Initial program 87.8%
remove-double-neg87.8%
distribute-frac-neg287.8%
distribute-frac-neg87.8%
distribute-rgt-neg-in87.8%
associate-/l*92.3%
distribute-frac-neg92.3%
distribute-frac-neg292.3%
remove-double-neg92.3%
div-sub92.4%
*-inverses92.4%
Simplified92.4%
Taylor expanded in z around inf 75.0%
associate-*l/73.4%
associate-*l*73.4%
*-commutative73.4%
associate-*r/73.4%
mul-1-neg73.4%
Simplified73.4%
if -1.15999999999999998e36 < z < -9.50000000000000036e-8 or -1.99999999999999997e-45 < z < 3.9000000000000002e-53Initial program 73.8%
remove-double-neg73.8%
distribute-frac-neg273.8%
distribute-frac-neg73.8%
distribute-rgt-neg-in73.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 83.9%
if -9.50000000000000036e-8 < z < -1.99999999999999997e-45Initial program 99.6%
Taylor expanded in y around 0 85.3%
associate-*r*85.3%
mul-1-neg85.3%
Simplified85.3%
*-commutative85.3%
associate-/l*85.6%
add-sqr-sqrt56.2%
sqrt-unprod29.8%
sqr-neg29.8%
sqrt-unprod0.8%
add-sqr-sqrt1.5%
Applied egg-rr1.5%
add-sqr-sqrt0.9%
sqrt-unprod57.7%
swap-sqr57.5%
sqr-neg57.5%
distribute-frac-neg57.5%
distribute-frac-neg57.5%
swap-sqr57.7%
sqrt-unprod57.1%
add-sqr-sqrt85.6%
distribute-frac-neg85.6%
distribute-rgt-neg-in85.6%
distribute-lft-neg-in85.6%
clear-num85.8%
un-div-inv85.8%
Applied egg-rr85.8%
Final simplification78.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 (<= z -6.5e+40)
(/ (* x_m (- z)) y)
(if (<= z -3.7e-7)
x_m
(if (<= z -1.15e-47)
(/ z (/ y (- x_m)))
(if (<= z 1.05e-50) 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 <= -6.5e+40) {
tmp = (x_m * -z) / y;
} else if (z <= -3.7e-7) {
tmp = x_m;
} else if (z <= -1.15e-47) {
tmp = z / (y / -x_m);
} else if (z <= 1.05e-50) {
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 <= (-6.5d+40)) then
tmp = (x_m * -z) / y
else if (z <= (-3.7d-7)) then
tmp = x_m
else if (z <= (-1.15d-47)) then
tmp = z / (y / -x_m)
else if (z <= 1.05d-50) 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 <= -6.5e+40) {
tmp = (x_m * -z) / y;
} else if (z <= -3.7e-7) {
tmp = x_m;
} else if (z <= -1.15e-47) {
tmp = z / (y / -x_m);
} else if (z <= 1.05e-50) {
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 <= -6.5e+40: tmp = (x_m * -z) / y elif z <= -3.7e-7: tmp = x_m elif z <= -1.15e-47: tmp = z / (y / -x_m) elif z <= 1.05e-50: 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 <= -6.5e+40) tmp = Float64(Float64(x_m * Float64(-z)) / y); elseif (z <= -3.7e-7) tmp = x_m; elseif (z <= -1.15e-47) tmp = Float64(z / Float64(y / Float64(-x_m))); elseif (z <= 1.05e-50) 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 <= -6.5e+40) tmp = (x_m * -z) / y; elseif (z <= -3.7e-7) tmp = x_m; elseif (z <= -1.15e-47) tmp = z / (y / -x_m); elseif (z <= 1.05e-50) 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, -6.5e+40], N[(N[(x$95$m * (-z)), $MachinePrecision] / y), $MachinePrecision], If[LessEqual[z, -3.7e-7], x$95$m, If[LessEqual[z, -1.15e-47], N[(z / N[(y / (-x$95$m)), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 1.05e-50], 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 -6.5 \cdot 10^{+40}:\\
\;\;\;\;\frac{x\_m \cdot \left(-z\right)}{y}\\
\mathbf{elif}\;z \leq -3.7 \cdot 10^{-7}:\\
\;\;\;\;x\_m\\
\mathbf{elif}\;z \leq -1.15 \cdot 10^{-47}:\\
\;\;\;\;\frac{z}{\frac{y}{-x\_m}}\\
\mathbf{elif}\;z \leq 1.05 \cdot 10^{-50}:\\
\;\;\;\;x\_m\\
\mathbf{else}:\\
\;\;\;\;z \cdot \frac{x\_m}{-y}\\
\end{array}
\end{array}
if z < -6.5000000000000001e40Initial program 90.6%
Taylor expanded in y around 0 77.4%
associate-*r*77.4%
mul-1-neg77.4%
Simplified77.4%
if -6.5000000000000001e40 < z < -3.70000000000000004e-7 or -1.14999999999999991e-47 < z < 1.05e-50Initial program 73.8%
remove-double-neg73.8%
distribute-frac-neg273.8%
distribute-frac-neg73.8%
distribute-rgt-neg-in73.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 83.9%
if -3.70000000000000004e-7 < z < -1.14999999999999991e-47Initial program 99.6%
Taylor expanded in y around 0 85.3%
associate-*r*85.3%
mul-1-neg85.3%
Simplified85.3%
*-commutative85.3%
associate-/l*85.6%
add-sqr-sqrt56.2%
sqrt-unprod29.8%
sqr-neg29.8%
sqrt-unprod0.8%
add-sqr-sqrt1.5%
Applied egg-rr1.5%
add-sqr-sqrt0.9%
sqrt-unprod57.7%
swap-sqr57.5%
sqr-neg57.5%
distribute-frac-neg57.5%
distribute-frac-neg57.5%
swap-sqr57.7%
sqrt-unprod57.1%
add-sqr-sqrt85.6%
distribute-frac-neg85.6%
distribute-rgt-neg-in85.6%
distribute-lft-neg-in85.6%
clear-num85.8%
un-div-inv85.8%
Applied egg-rr85.8%
if 1.05e-50 < z Initial program 85.8%
remove-double-neg85.8%
distribute-frac-neg285.8%
distribute-frac-neg85.8%
distribute-rgt-neg-in85.8%
associate-/l*93.6%
distribute-frac-neg93.6%
distribute-frac-neg293.6%
remove-double-neg93.6%
div-sub93.6%
*-inverses93.6%
Simplified93.6%
Taylor expanded in z around inf 73.4%
associate-*l/74.6%
associate-*l*74.6%
*-commutative74.6%
associate-*r/74.6%
mul-1-neg74.6%
Simplified74.6%
Final simplification79.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 5e+24) 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 <= 5e+24) {
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 <= 5d+24) 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 <= 5e+24) {
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 <= 5e+24: 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 <= 5e+24) 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 <= 5e+24) 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, 5e+24], 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 5 \cdot 10^{+24}:\\
\;\;\;\;x\_m\\
\mathbf{else}:\\
\;\;\;\;y \cdot \frac{x\_m}{y}\\
\end{array}
\end{array}
if x < 5.00000000000000045e24Initial program 82.7%
remove-double-neg82.7%
distribute-frac-neg282.7%
distribute-frac-neg82.7%
distribute-rgt-neg-in82.7%
associate-/l*95.2%
distribute-frac-neg95.2%
distribute-frac-neg295.2%
remove-double-neg95.2%
div-sub95.2%
*-inverses95.2%
Simplified95.2%
Taylor expanded in z around 0 53.0%
if 5.00000000000000045e24 < x Initial program 76.1%
Taylor expanded in y around inf 28.4%
*-commutative28.4%
associate-/l*63.7%
Applied egg-rr63.7%
Final simplification55.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 (- 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 81.3%
remove-double-neg81.3%
distribute-frac-neg281.3%
distribute-frac-neg81.3%
distribute-rgt-neg-in81.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 (/ y z)))))
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 / (y / z)));
}
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 / (y / z)))
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 / (y / z)));
}
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 / (y / z)))
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(y / z)))) 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 / (y / z))); 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[(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 \left(x\_m - \frac{x\_m}{\frac{y}{z}}\right)
\end{array}
Initial program 81.3%
remove-double-neg81.3%
distribute-frac-neg281.3%
distribute-frac-neg81.3%
distribute-rgt-neg-in81.3%
associate-/l*96.2%
distribute-frac-neg96.2%
distribute-frac-neg296.2%
remove-double-neg96.2%
div-sub96.2%
*-inverses96.2%
Simplified96.2%
sub-neg96.2%
distribute-rgt-in96.2%
*-un-lft-identity96.2%
distribute-neg-frac296.2%
Applied egg-rr96.2%
*-commutative96.2%
distribute-frac-neg296.2%
distribute-rgt-neg-out96.2%
distribute-lft-neg-out96.2%
associate-/l*95.6%
clear-num95.6%
frac-2neg95.6%
metadata-eval95.6%
frac-2neg95.6%
add-sqr-sqrt50.3%
sqrt-unprod61.7%
sqr-neg61.7%
sqrt-unprod23.0%
add-sqr-sqrt49.3%
distribute-lft-neg-out49.3%
remove-double-neg49.3%
distribute-frac-neg249.3%
distribute-lft-neg-out49.3%
frac-2neg49.3%
add-sqr-sqrt26.2%
sqrt-unprod60.7%
sqr-neg60.7%
sqrt-unprod45.2%
add-sqr-sqrt95.6%
distribute-lft-neg-out95.6%
remove-double-neg95.6%
*-commutative95.6%
Applied egg-rr95.6%
Taylor expanded in y around 0 95.6%
associate-*r/95.6%
associate-*r*95.6%
neg-mul-195.6%
associate-*l/92.7%
associate-/r/97.0%
Simplified97.0%
Final simplification97.0%
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 81.3%
remove-double-neg81.3%
distribute-frac-neg281.3%
distribute-frac-neg81.3%
distribute-rgt-neg-in81.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.9%
Final simplification52.9%
(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 2024059
(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))