
(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 7 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 1 x) (FPCore (x_s x_m y z) :precision binary64 (let* ((t_0 (/ (* x_m (- y z)) y))) (* x_s (if (<= t_0 -5e-189) t_0 (- 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 t_0 = (x_m * (y - z)) / y;
double tmp;
if (t_0 <= -5e-189) {
tmp = t_0;
} 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) :: t_0
real(8) :: tmp
t_0 = (x_m * (y - z)) / y
if (t_0 <= (-5d-189)) then
tmp = t_0
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 t_0 = (x_m * (y - z)) / y;
double tmp;
if (t_0 <= -5e-189) {
tmp = t_0;
} 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): t_0 = (x_m * (y - z)) / y tmp = 0 if t_0 <= -5e-189: tmp = t_0 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) t_0 = Float64(Float64(x_m * Float64(y - z)) / y) tmp = 0.0 if (t_0 <= -5e-189) tmp = t_0; 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) t_0 = (x_m * (y - z)) / y; tmp = 0.0; if (t_0 <= -5e-189) tmp = t_0; 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_] := Block[{t$95$0 = N[(N[(x$95$m * N[(y - z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]}, N[(x$95$s * If[LessEqual[t$95$0, -5e-189], t$95$0, 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)
\\
\begin{array}{l}
t_0 := \frac{x\_m \cdot \left(y - z\right)}{y}\\
x\_s \cdot \begin{array}{l}
\mathbf{if}\;t\_0 \leq -5 \cdot 10^{-189}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;x\_m - \frac{x\_m}{\frac{y}{z}}\\
\end{array}
\end{array}
\end{array}
if (/.f64 (*.f64 x (-.f64 y z)) y) < -4.9999999999999997e-189Initial program 80.0%
if -4.9999999999999997e-189 < (/.f64 (*.f64 x (-.f64 y z)) y) Initial program 79.8%
remove-double-neg79.8%
distribute-frac-neg279.8%
distribute-frac-neg79.8%
distribute-rgt-neg-in79.8%
associate-/l*94.5%
distribute-frac-neg94.5%
distribute-frac-neg294.5%
remove-double-neg94.5%
div-sub94.5%
*-inverses94.5%
Simplified94.5%
Taylor expanded in z around 0 92.4%
associate-*r/92.4%
mul-1-neg92.4%
distribute-rgt-neg-out92.4%
Simplified92.4%
associate-*l/95.8%
add-sqr-sqrt38.1%
sqrt-unprod61.5%
sqr-neg61.5%
sqrt-unprod28.8%
add-sqr-sqrt49.5%
*-commutative49.5%
cancel-sign-sub49.5%
associate-*r/48.8%
*-commutative48.8%
associate-/l*49.5%
add-sqr-sqrt20.7%
sqrt-unprod70.5%
sqr-neg70.5%
sqrt-unprod58.3%
add-sqr-sqrt94.5%
Applied egg-rr94.5%
Taylor expanded in x around 0 92.4%
associate-*l/95.8%
associate-/r/95.1%
Simplified95.1%
Final simplification88.2%
x_m = (fabs.f64 x)
x_s = (copysign.f64 1 x)
(FPCore (x_s x_m y z)
:precision binary64
(*
x_s
(if (<= y -6.4e+19)
x_m
(if (or (<= y 2e-110) (and (not (<= y 8e-80)) (<= y 9.5e+36)))
(* 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 <= -6.4e+19) {
tmp = x_m;
} else if ((y <= 2e-110) || (!(y <= 8e-80) && (y <= 9.5e+36))) {
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 <= (-6.4d+19)) then
tmp = x_m
else if ((y <= 2d-110) .or. (.not. (y <= 8d-80)) .and. (y <= 9.5d+36)) 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 <= -6.4e+19) {
tmp = x_m;
} else if ((y <= 2e-110) || (!(y <= 8e-80) && (y <= 9.5e+36))) {
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 <= -6.4e+19: tmp = x_m elif (y <= 2e-110) or (not (y <= 8e-80) and (y <= 9.5e+36)): 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 <= -6.4e+19) tmp = x_m; elseif ((y <= 2e-110) || (!(y <= 8e-80) && (y <= 9.5e+36))) 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 (y <= -6.4e+19) tmp = x_m; elseif ((y <= 2e-110) || (~((y <= 8e-80)) && (y <= 9.5e+36))) 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, -6.4e+19], x$95$m, If[Or[LessEqual[y, 2e-110], And[N[Not[LessEqual[y, 8e-80]], $MachinePrecision], LessEqual[y, 9.5e+36]]], 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 -6.4 \cdot 10^{+19}:\\
\;\;\;\;x\_m\\
\mathbf{elif}\;y \leq 2 \cdot 10^{-110} \lor \neg \left(y \leq 8 \cdot 10^{-80}\right) \land y \leq 9.5 \cdot 10^{+36}:\\
\;\;\;\;x\_m \cdot \frac{z}{-y}\\
\mathbf{else}:\\
\;\;\;\;x\_m\\
\end{array}
\end{array}
if y < -6.4e19 or 2.0000000000000001e-110 < y < 7.99999999999999969e-80 or 9.49999999999999974e36 < y Initial program 64.4%
remove-double-neg64.4%
distribute-frac-neg264.4%
distribute-frac-neg64.4%
distribute-rgt-neg-in64.4%
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 84.5%
if -6.4e19 < y < 2.0000000000000001e-110 or 7.99999999999999969e-80 < y < 9.49999999999999974e36Initial program 93.1%
associate-/l*90.9%
add-sqr-sqrt43.2%
associate-*l*43.2%
Applied egg-rr43.2%
Taylor expanded in y around 0 76.6%
mul-1-neg76.6%
distribute-frac-neg276.6%
associate-/l*71.9%
Simplified71.9%
Final simplification77.7%
x_m = (fabs.f64 x)
x_s = (copysign.f64 1 x)
(FPCore (x_s x_m y z)
:precision binary64
(*
x_s
(if (<= y -3.5e+14)
x_m
(if (or (<= y 9.2e-110) (and (not (<= y 1.3e-79)) (<= y 9.5e+36)))
(* 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 (y <= -3.5e+14) {
tmp = x_m;
} else if ((y <= 9.2e-110) || (!(y <= 1.3e-79) && (y <= 9.5e+36))) {
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 (y <= (-3.5d+14)) then
tmp = x_m
else if ((y <= 9.2d-110) .or. (.not. (y <= 1.3d-79)) .and. (y <= 9.5d+36)) 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 (y <= -3.5e+14) {
tmp = x_m;
} else if ((y <= 9.2e-110) || (!(y <= 1.3e-79) && (y <= 9.5e+36))) {
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 y <= -3.5e+14: tmp = x_m elif (y <= 9.2e-110) or (not (y <= 1.3e-79) and (y <= 9.5e+36)): 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 (y <= -3.5e+14) tmp = x_m; elseif ((y <= 9.2e-110) || (!(y <= 1.3e-79) && (y <= 9.5e+36))) 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 (y <= -3.5e+14) tmp = x_m; elseif ((y <= 9.2e-110) || (~((y <= 1.3e-79)) && (y <= 9.5e+36))) 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[LessEqual[y, -3.5e+14], x$95$m, If[Or[LessEqual[y, 9.2e-110], And[N[Not[LessEqual[y, 1.3e-79]], $MachinePrecision], LessEqual[y, 9.5e+36]]], 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}\;y \leq -3.5 \cdot 10^{+14}:\\
\;\;\;\;x\_m\\
\mathbf{elif}\;y \leq 9.2 \cdot 10^{-110} \lor \neg \left(y \leq 1.3 \cdot 10^{-79}\right) \land y \leq 9.5 \cdot 10^{+36}:\\
\;\;\;\;z \cdot \frac{x\_m}{-y}\\
\mathbf{else}:\\
\;\;\;\;x\_m\\
\end{array}
\end{array}
if y < -3.5e14 or 9.2000000000000006e-110 < y < 1.29999999999999997e-79 or 9.49999999999999974e36 < y Initial program 64.4%
remove-double-neg64.4%
distribute-frac-neg264.4%
distribute-frac-neg64.4%
distribute-rgt-neg-in64.4%
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 84.5%
if -3.5e14 < y < 9.2000000000000006e-110 or 1.29999999999999997e-79 < y < 9.49999999999999974e36Initial program 93.1%
remove-double-neg93.1%
distribute-frac-neg293.1%
distribute-frac-neg93.1%
distribute-rgt-neg-in93.1%
associate-/l*90.9%
distribute-frac-neg90.9%
distribute-frac-neg290.9%
remove-double-neg90.9%
div-sub90.9%
*-inverses90.9%
Simplified90.9%
Taylor expanded in z around inf 76.6%
mul-1-neg76.6%
*-commutative76.6%
associate-/l*75.9%
distribute-lft-neg-in75.9%
Simplified75.9%
Final simplification79.9%
x_m = (fabs.f64 x)
x_s = (copysign.f64 1 x)
(FPCore (x_s x_m y z)
:precision binary64
(*
x_s
(if (<= y -1.55e+19)
x_m
(if (<= y 1.02e-109)
(/ (* x_m (- z)) y)
(if (<= y 1.5e-79) x_m (if (<= y 1.55e+38) (* 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 (y <= -1.55e+19) {
tmp = x_m;
} else if (y <= 1.02e-109) {
tmp = (x_m * -z) / y;
} else if (y <= 1.5e-79) {
tmp = x_m;
} else if (y <= 1.55e+38) {
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 (y <= (-1.55d+19)) then
tmp = x_m
else if (y <= 1.02d-109) then
tmp = (x_m * -z) / y
else if (y <= 1.5d-79) then
tmp = x_m
else if (y <= 1.55d+38) 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 (y <= -1.55e+19) {
tmp = x_m;
} else if (y <= 1.02e-109) {
tmp = (x_m * -z) / y;
} else if (y <= 1.5e-79) {
tmp = x_m;
} else if (y <= 1.55e+38) {
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 y <= -1.55e+19: tmp = x_m elif y <= 1.02e-109: tmp = (x_m * -z) / y elif y <= 1.5e-79: tmp = x_m elif y <= 1.55e+38: 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 (y <= -1.55e+19) tmp = x_m; elseif (y <= 1.02e-109) tmp = Float64(Float64(x_m * Float64(-z)) / y); elseif (y <= 1.5e-79) tmp = x_m; elseif (y <= 1.55e+38) 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 (y <= -1.55e+19) tmp = x_m; elseif (y <= 1.02e-109) tmp = (x_m * -z) / y; elseif (y <= 1.5e-79) tmp = x_m; elseif (y <= 1.55e+38) 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[LessEqual[y, -1.55e+19], x$95$m, If[LessEqual[y, 1.02e-109], N[(N[(x$95$m * (-z)), $MachinePrecision] / y), $MachinePrecision], If[LessEqual[y, 1.5e-79], x$95$m, If[LessEqual[y, 1.55e+38], 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}\;y \leq -1.55 \cdot 10^{+19}:\\
\;\;\;\;x\_m\\
\mathbf{elif}\;y \leq 1.02 \cdot 10^{-109}:\\
\;\;\;\;\frac{x\_m \cdot \left(-z\right)}{y}\\
\mathbf{elif}\;y \leq 1.5 \cdot 10^{-79}:\\
\;\;\;\;x\_m\\
\mathbf{elif}\;y \leq 1.55 \cdot 10^{+38}:\\
\;\;\;\;z \cdot \frac{x\_m}{-y}\\
\mathbf{else}:\\
\;\;\;\;x\_m\\
\end{array}
\end{array}
if y < -1.55e19 or 1.02e-109 < y < 1.5e-79 or 1.55000000000000009e38 < y Initial program 64.4%
remove-double-neg64.4%
distribute-frac-neg264.4%
distribute-frac-neg64.4%
distribute-rgt-neg-in64.4%
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 84.5%
if -1.55e19 < y < 1.02e-109Initial program 91.8%
remove-double-neg91.8%
distribute-frac-neg291.8%
distribute-frac-neg91.8%
distribute-rgt-neg-in91.8%
associate-/l*89.7%
distribute-frac-neg89.7%
distribute-frac-neg289.7%
remove-double-neg89.7%
div-sub89.7%
*-inverses89.7%
Simplified89.7%
Taylor expanded in z around inf 79.6%
associate-*r/79.6%
mul-1-neg79.6%
distribute-rgt-neg-out79.6%
Simplified79.6%
if 1.5e-79 < y < 1.55000000000000009e38Initial program 98.4%
remove-double-neg98.4%
distribute-frac-neg298.4%
distribute-frac-neg98.4%
distribute-rgt-neg-in98.4%
associate-/l*96.0%
distribute-frac-neg96.0%
distribute-frac-neg296.0%
remove-double-neg96.0%
div-sub96.0%
*-inverses96.0%
Simplified96.0%
Taylor expanded in z around inf 64.0%
mul-1-neg64.0%
*-commutative64.0%
associate-/l*64.2%
distribute-lft-neg-in64.2%
Simplified64.2%
Final simplification80.2%
x_m = (fabs.f64 x) x_s = (copysign.f64 1 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 79.9%
remove-double-neg79.9%
distribute-frac-neg279.9%
distribute-frac-neg79.9%
distribute-rgt-neg-in79.9%
associate-/l*95.1%
distribute-frac-neg95.1%
distribute-frac-neg295.1%
remove-double-neg95.1%
div-sub95.1%
*-inverses95.1%
Simplified95.1%
Final simplification95.1%
x_m = (fabs.f64 x) x_s = (copysign.f64 1 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 79.9%
remove-double-neg79.9%
distribute-frac-neg279.9%
distribute-frac-neg79.9%
distribute-rgt-neg-in79.9%
associate-/l*95.1%
distribute-frac-neg95.1%
distribute-frac-neg295.1%
remove-double-neg95.1%
div-sub95.1%
*-inverses95.1%
Simplified95.1%
Taylor expanded in z around 0 92.5%
associate-*r/92.5%
mul-1-neg92.5%
distribute-rgt-neg-out92.5%
Simplified92.5%
associate-*l/95.1%
add-sqr-sqrt42.2%
sqrt-unprod60.8%
sqr-neg60.8%
sqrt-unprod25.6%
add-sqr-sqrt47.1%
*-commutative47.1%
cancel-sign-sub47.1%
associate-*r/45.8%
*-commutative45.8%
associate-/l*48.0%
add-sqr-sqrt22.1%
sqrt-unprod68.5%
sqr-neg68.5%
sqrt-unprod52.4%
add-sqr-sqrt95.1%
Applied egg-rr95.1%
Taylor expanded in x around 0 92.5%
associate-*l/95.1%
associate-/r/95.7%
Simplified95.7%
Final simplification95.7%
x_m = (fabs.f64 x) x_s = (copysign.f64 1 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 79.9%
remove-double-neg79.9%
distribute-frac-neg279.9%
distribute-frac-neg79.9%
distribute-rgt-neg-in79.9%
associate-/l*95.1%
distribute-frac-neg95.1%
distribute-frac-neg295.1%
remove-double-neg95.1%
div-sub95.1%
*-inverses95.1%
Simplified95.1%
Taylor expanded in z around 0 49.6%
Final simplification49.6%
(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 2024041
(FPCore (x y z)
:name "Diagrams.Backend.Cairo.Internal:setTexture from diagrams-cairo-1.3.0.3"
:precision binary64
:herbie-target
(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))