
(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 1 x)
(FPCore (x_s x_m y z)
:precision binary64
(let* ((t_0 (/ (* x_m (- y z)) y)))
(*
x_s
(if (<= t_0 -2e+38)
(/ (* x_m z) (- y))
(if (<= t_0 1e-9)
(- x_m (* x_m (/ z y)))
(if (<= t_0 4e+307) t_0 (* 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 t_0 = (x_m * (y - z)) / y;
double tmp;
if (t_0 <= -2e+38) {
tmp = (x_m * z) / -y;
} else if (t_0 <= 1e-9) {
tmp = x_m - (x_m * (z / y));
} else if (t_0 <= 4e+307) {
tmp = t_0;
} 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) :: t_0
real(8) :: tmp
t_0 = (x_m * (y - z)) / y
if (t_0 <= (-2d+38)) then
tmp = (x_m * z) / -y
else if (t_0 <= 1d-9) then
tmp = x_m - (x_m * (z / y))
else if (t_0 <= 4d+307) then
tmp = t_0
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 t_0 = (x_m * (y - z)) / y;
double tmp;
if (t_0 <= -2e+38) {
tmp = (x_m * z) / -y;
} else if (t_0 <= 1e-9) {
tmp = x_m - (x_m * (z / y));
} else if (t_0 <= 4e+307) {
tmp = t_0;
} 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): t_0 = (x_m * (y - z)) / y tmp = 0 if t_0 <= -2e+38: tmp = (x_m * z) / -y elif t_0 <= 1e-9: tmp = x_m - (x_m * (z / y)) elif t_0 <= 4e+307: tmp = t_0 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) t_0 = Float64(Float64(x_m * Float64(y - z)) / y) tmp = 0.0 if (t_0 <= -2e+38) tmp = Float64(Float64(x_m * z) / Float64(-y)); elseif (t_0 <= 1e-9) tmp = Float64(x_m - Float64(x_m * Float64(z / y))); elseif (t_0 <= 4e+307) tmp = t_0; 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) t_0 = (x_m * (y - z)) / y; tmp = 0.0; if (t_0 <= -2e+38) tmp = (x_m * z) / -y; elseif (t_0 <= 1e-9) tmp = x_m - (x_m * (z / y)); elseif (t_0 <= 4e+307) tmp = t_0; 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_] := 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, -2e+38], N[(N[(x$95$m * z), $MachinePrecision] / (-y)), $MachinePrecision], If[LessEqual[t$95$0, 1e-9], N[(x$95$m - N[(x$95$m * N[(z / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 4e+307], t$95$0, 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)
\\
\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 -2 \cdot 10^{+38}:\\
\;\;\;\;\frac{x\_m \cdot z}{-y}\\
\mathbf{elif}\;t\_0 \leq 10^{-9}:\\
\;\;\;\;x\_m - x\_m \cdot \frac{z}{y}\\
\mathbf{elif}\;t\_0 \leq 4 \cdot 10^{+307}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;x\_m \cdot \left(1 - \frac{z}{y}\right)\\
\end{array}
\end{array}
\end{array}
if (/.f64 (*.f64 x (-.f64 y z)) y) < -1.99999999999999995e38Initial program 85.2%
Taylor expanded in y around 0 68.5%
associate-*r*68.5%
mul-1-neg68.5%
Simplified68.5%
if -1.99999999999999995e38 < (/.f64 (*.f64 x (-.f64 y z)) y) < 1.00000000000000006e-9Initial program 87.5%
remove-double-neg87.5%
distribute-frac-neg287.5%
distribute-frac-neg87.5%
distribute-rgt-neg-in87.5%
associate-/l*99.8%
distribute-frac-neg99.8%
distribute-frac-neg299.8%
remove-double-neg99.8%
div-sub99.8%
*-inverses99.8%
Simplified99.8%
sub-neg99.8%
distribute-rgt-in99.9%
*-un-lft-identity99.9%
distribute-neg-frac299.9%
Applied egg-rr99.9%
if 1.00000000000000006e-9 < (/.f64 (*.f64 x (-.f64 y z)) y) < 3.99999999999999994e307Initial program 99.8%
if 3.99999999999999994e307 < (/.f64 (*.f64 x (-.f64 y z)) y) Initial program 70.2%
remove-double-neg70.2%
distribute-frac-neg270.2%
distribute-frac-neg70.2%
distribute-rgt-neg-in70.2%
associate-/l*100.0%
distribute-frac-neg100.0%
distribute-frac-neg2100.0%
remove-double-neg100.0%
div-sub100.0%
*-inverses100.0%
Simplified100.0%
Final simplification90.5%
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 -2e+38)
(/ (* x_m z) (- y))
(if (or (<= t_0 5e-36) (not (<= t_0 4e+307)))
(* x_m (- 1.0 (/ z y)))
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 = (x_m * (y - z)) / y;
double tmp;
if (t_0 <= -2e+38) {
tmp = (x_m * z) / -y;
} else if ((t_0 <= 5e-36) || !(t_0 <= 4e+307)) {
tmp = x_m * (1.0 - (z / y));
} 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 = (x_m * (y - z)) / y
if (t_0 <= (-2d+38)) then
tmp = (x_m * z) / -y
else if ((t_0 <= 5d-36) .or. (.not. (t_0 <= 4d+307))) then
tmp = x_m * (1.0d0 - (z / y))
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 = (x_m * (y - z)) / y;
double tmp;
if (t_0 <= -2e+38) {
tmp = (x_m * z) / -y;
} else if ((t_0 <= 5e-36) || !(t_0 <= 4e+307)) {
tmp = x_m * (1.0 - (z / y));
} 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 = (x_m * (y - z)) / y tmp = 0 if t_0 <= -2e+38: tmp = (x_m * z) / -y elif (t_0 <= 5e-36) or not (t_0 <= 4e+307): tmp = x_m * (1.0 - (z / y)) 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(Float64(x_m * Float64(y - z)) / y) tmp = 0.0 if (t_0 <= -2e+38) tmp = Float64(Float64(x_m * z) / Float64(-y)); elseif ((t_0 <= 5e-36) || !(t_0 <= 4e+307)) tmp = Float64(x_m * Float64(1.0 - Float64(z / y))); 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 = (x_m * (y - z)) / y; tmp = 0.0; if (t_0 <= -2e+38) tmp = (x_m * z) / -y; elseif ((t_0 <= 5e-36) || ~((t_0 <= 4e+307))) tmp = x_m * (1.0 - (z / y)); 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[(N[(x$95$m * N[(y - z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]}, N[(x$95$s * If[LessEqual[t$95$0, -2e+38], N[(N[(x$95$m * z), $MachinePrecision] / (-y)), $MachinePrecision], If[Or[LessEqual[t$95$0, 5e-36], N[Not[LessEqual[t$95$0, 4e+307]], $MachinePrecision]], N[(x$95$m * N[(1.0 - N[(z / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 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 := \frac{x\_m \cdot \left(y - z\right)}{y}\\
x\_s \cdot \begin{array}{l}
\mathbf{if}\;t\_0 \leq -2 \cdot 10^{+38}:\\
\;\;\;\;\frac{x\_m \cdot z}{-y}\\
\mathbf{elif}\;t\_0 \leq 5 \cdot 10^{-36} \lor \neg \left(t\_0 \leq 4 \cdot 10^{+307}\right):\\
\;\;\;\;x\_m \cdot \left(1 - \frac{z}{y}\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
\end{array}
if (/.f64 (*.f64 x (-.f64 y z)) y) < -1.99999999999999995e38Initial program 85.2%
Taylor expanded in y around 0 68.5%
associate-*r*68.5%
mul-1-neg68.5%
Simplified68.5%
if -1.99999999999999995e38 < (/.f64 (*.f64 x (-.f64 y z)) y) < 5.00000000000000004e-36 or 3.99999999999999994e307 < (/.f64 (*.f64 x (-.f64 y z)) y) Initial program 82.8%
remove-double-neg82.8%
distribute-frac-neg282.8%
distribute-frac-neg82.8%
distribute-rgt-neg-in82.8%
associate-/l*99.9%
distribute-frac-neg99.9%
distribute-frac-neg299.9%
remove-double-neg99.9%
div-sub99.9%
*-inverses99.9%
Simplified99.9%
if 5.00000000000000004e-36 < (/.f64 (*.f64 x (-.f64 y z)) y) < 3.99999999999999994e307Initial program 99.7%
Final simplification90.5%
x\_m = (fabs.f64 x) x\_s = (copysign.f64 1 x) (FPCore (x_s x_m y z) :precision binary64 (* x_s (if (or (<= z -3.2e-84) (not (<= z 1.25e-15))) (* 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.2e-84) || !(z <= 1.25e-15)) {
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.2d-84)) .or. (.not. (z <= 1.25d-15))) 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.2e-84) || !(z <= 1.25e-15)) {
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.2e-84) or not (z <= 1.25e-15): 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.2e-84) || !(z <= 1.25e-15)) 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.2e-84) || ~((z <= 1.25e-15))) 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.2e-84], N[Not[LessEqual[z, 1.25e-15]], $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.2 \cdot 10^{-84} \lor \neg \left(z \leq 1.25 \cdot 10^{-15}\right):\\
\;\;\;\;x\_m \cdot \frac{z}{-y}\\
\mathbf{else}:\\
\;\;\;\;x\_m\\
\end{array}
\end{array}
if z < -3.1999999999999999e-84 or 1.25e-15 < z Initial program 91.7%
remove-double-neg91.7%
distribute-frac-neg291.7%
distribute-frac-neg91.7%
distribute-rgt-neg-in91.7%
associate-/l*91.0%
distribute-frac-neg91.0%
distribute-frac-neg291.0%
remove-double-neg91.0%
div-sub91.0%
*-inverses91.0%
Simplified91.0%
Taylor expanded in z around inf 67.4%
mul-1-neg67.4%
distribute-frac-neg267.4%
Simplified67.4%
if -3.1999999999999999e-84 < z < 1.25e-15Initial program 81.7%
remove-double-neg81.7%
distribute-frac-neg281.7%
distribute-frac-neg81.7%
distribute-rgt-neg-in81.7%
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.8%
Final simplification72.2%
x\_m = (fabs.f64 x) x\_s = (copysign.f64 1 x) (FPCore (x_s x_m y z) :precision binary64 (* x_s (if (or (<= z -2.5e-83) (not (<= z 1.2e-14))) (* 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 <= -2.5e-83) || !(z <= 1.2e-14)) {
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 <= (-2.5d-83)) .or. (.not. (z <= 1.2d-14))) 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 <= -2.5e-83) || !(z <= 1.2e-14)) {
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 <= -2.5e-83) or not (z <= 1.2e-14): 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 <= -2.5e-83) || !(z <= 1.2e-14)) tmp = Float64(z * Float64(-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 ((z <= -2.5e-83) || ~((z <= 1.2e-14))) 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, -2.5e-83], N[Not[LessEqual[z, 1.2e-14]], $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 -2.5 \cdot 10^{-83} \lor \neg \left(z \leq 1.2 \cdot 10^{-14}\right):\\
\;\;\;\;z \cdot \left(-\frac{x\_m}{y}\right)\\
\mathbf{else}:\\
\;\;\;\;x\_m\\
\end{array}
\end{array}
if z < -2.5e-83 or 1.2e-14 < z Initial program 91.7%
remove-double-neg91.7%
distribute-frac-neg291.7%
distribute-frac-neg91.7%
distribute-rgt-neg-in91.7%
associate-/l*91.0%
distribute-frac-neg91.0%
distribute-frac-neg291.0%
remove-double-neg91.0%
div-sub91.0%
*-inverses91.0%
Simplified91.0%
Taylor expanded in z around inf 73.8%
associate-*l/73.1%
associate-*l*73.1%
*-commutative73.1%
associate-*r/73.1%
mul-1-neg73.1%
Simplified73.1%
if -2.5e-83 < z < 1.2e-14Initial program 81.7%
remove-double-neg81.7%
distribute-frac-neg281.7%
distribute-frac-neg81.7%
distribute-rgt-neg-in81.7%
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.8%
Final simplification75.5%
x\_m = (fabs.f64 x) x\_s = (copysign.f64 1 x) (FPCore (x_s x_m y z) :precision binary64 (* x_s (if (or (<= z -5.5e-58) (not (<= z 1.15e-11))) (/ (* 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 <= -5.5e-58) || !(z <= 1.15e-11)) {
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 <= (-5.5d-58)) .or. (.not. (z <= 1.15d-11))) 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 <= -5.5e-58) || !(z <= 1.15e-11)) {
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 <= -5.5e-58) or not (z <= 1.15e-11): 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 <= -5.5e-58) || !(z <= 1.15e-11)) tmp = Float64(Float64(x_m * 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 <= -5.5e-58) || ~((z <= 1.15e-11))) 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, -5.5e-58], N[Not[LessEqual[z, 1.15e-11]], $MachinePrecision]], N[(N[(x$95$m * z), $MachinePrecision] / (-y)), $MachinePrecision], x$95$m]), $MachinePrecision]
\begin{array}{l}
x\_m = \left|x\right|
\\
x\_s = \mathsf{copysign}\left(1, x\right)
\\
x\_s \cdot \begin{array}{l}
\mathbf{if}\;z \leq -5.5 \cdot 10^{-58} \lor \neg \left(z \leq 1.15 \cdot 10^{-11}\right):\\
\;\;\;\;\frac{x\_m \cdot z}{-y}\\
\mathbf{else}:\\
\;\;\;\;x\_m\\
\end{array}
\end{array}
if z < -5.49999999999999996e-58 or 1.15000000000000007e-11 < z Initial program 92.8%
Taylor expanded in y around 0 74.6%
associate-*r*74.6%
mul-1-neg74.6%
Simplified74.6%
if -5.49999999999999996e-58 < z < 1.15000000000000007e-11Initial program 80.5%
remove-double-neg80.5%
distribute-frac-neg280.5%
distribute-frac-neg80.5%
distribute-rgt-neg-in80.5%
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.6%
Final simplification75.9%
x\_m = (fabs.f64 x)
x\_s = (copysign.f64 1 x)
(FPCore (x_s x_m y z)
:precision binary64
(*
x_s
(if (<= x_m 7.4e-60)
(+ x_m (/ -1.0 (/ y (* x_m z))))
(- 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 <= 7.4e-60) {
tmp = x_m + (-1.0 / (y / (x_m * z)));
} 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 <= 7.4d-60) then
tmp = x_m + ((-1.0d0) / (y / (x_m * z)))
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 <= 7.4e-60) {
tmp = x_m + (-1.0 / (y / (x_m * z)));
} 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 <= 7.4e-60: tmp = x_m + (-1.0 / (y / (x_m * z))) 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 <= 7.4e-60) tmp = Float64(x_m + Float64(-1.0 / Float64(y / Float64(x_m * z)))); 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 <= 7.4e-60) tmp = x_m + (-1.0 / (y / (x_m * z))); 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, 7.4e-60], N[(x$95$m + N[(-1.0 / N[(y / N[(x$95$m * z), $MachinePrecision]), $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 7.4 \cdot 10^{-60}:\\
\;\;\;\;x\_m + \frac{-1}{\frac{y}{x\_m \cdot z}}\\
\mathbf{else}:\\
\;\;\;\;x\_m - x\_m \cdot \frac{z}{y}\\
\end{array}
\end{array}
if x < 7.4000000000000005e-60Initial program 87.7%
remove-double-neg87.7%
distribute-frac-neg287.7%
distribute-frac-neg87.7%
distribute-rgt-neg-in87.7%
associate-/l*92.5%
distribute-frac-neg92.5%
distribute-frac-neg292.5%
remove-double-neg92.5%
div-sub92.5%
*-inverses92.5%
Simplified92.5%
sub-neg92.5%
distribute-rgt-in92.5%
*-un-lft-identity92.5%
distribute-neg-frac292.5%
Applied egg-rr92.5%
*-commutative92.5%
distribute-frac-neg292.5%
distribute-rgt-neg-out92.5%
distribute-lft-neg-out92.5%
associate-/l*94.2%
clear-num94.1%
frac-2neg94.1%
metadata-eval94.1%
frac-2neg94.1%
add-sqr-sqrt45.8%
sqrt-unprod57.2%
sqr-neg57.2%
sqrt-unprod21.2%
add-sqr-sqrt43.6%
distribute-frac-neg243.6%
distribute-lft-neg-out43.6%
remove-double-neg43.6%
distribute-lft-neg-out43.6%
frac-2neg43.6%
add-sqr-sqrt22.5%
sqrt-unprod57.5%
sqr-neg57.5%
sqrt-unprod48.2%
add-sqr-sqrt94.1%
distribute-lft-neg-out94.1%
remove-double-neg94.1%
Applied egg-rr94.1%
if 7.4000000000000005e-60 < x Initial program 86.9%
remove-double-neg86.9%
distribute-frac-neg286.9%
distribute-frac-neg86.9%
distribute-rgt-neg-in86.9%
associate-/l*99.8%
distribute-frac-neg99.8%
distribute-frac-neg299.8%
remove-double-neg99.8%
div-sub99.9%
*-inverses99.9%
Simplified99.9%
sub-neg99.9%
distribute-rgt-in99.9%
*-un-lft-identity99.9%
distribute-neg-frac299.9%
Applied egg-rr99.9%
Final simplification95.9%
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 87.5%
remove-double-neg87.5%
distribute-frac-neg287.5%
distribute-frac-neg87.5%
distribute-rgt-neg-in87.5%
associate-/l*94.8%
distribute-frac-neg94.8%
distribute-frac-neg294.8%
remove-double-neg94.8%
div-sub94.8%
*-inverses94.8%
Simplified94.8%
Final simplification94.8%
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 87.5%
remove-double-neg87.5%
distribute-frac-neg287.5%
distribute-frac-neg87.5%
distribute-rgt-neg-in87.5%
associate-/l*94.8%
distribute-frac-neg94.8%
distribute-frac-neg294.8%
remove-double-neg94.8%
div-sub94.8%
*-inverses94.8%
Simplified94.8%
Taylor expanded in z around 0 48.2%
Final simplification48.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 2024096
(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))