
(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 #s(literal 1 binary64) 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 * Float64(-z)) / 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 \left(-z\right)}{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%
mul-1-neg68.5%
distribute-rgt-neg-out68.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 #s(literal 1 binary64) 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 * Float64(-z)) / 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 \left(-z\right)}{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%
mul-1-neg68.5%
distribute-rgt-neg-out68.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 #s(literal 1 binary64) x) (FPCore (x_s x_m y z) :precision binary64 (* x_s (if (or (<= z -2.7e-58) (not (<= z 9e-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 <= -2.7e-58) || !(z <= 9e-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 <= (-2.7d-58)) .or. (.not. (z <= 9d-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 <= -2.7e-58) || !(z <= 9e-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 <= -2.7e-58) or not (z <= 9e-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 <= -2.7e-58) || !(z <= 9e-15)) tmp = Float64(Float64(x_m * Float64(-z)) / 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.7e-58) || ~((z <= 9e-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, -2.7e-58], N[Not[LessEqual[z, 9e-15]], $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 -2.7 \cdot 10^{-58} \lor \neg \left(z \leq 9 \cdot 10^{-15}\right):\\
\;\;\;\;\frac{x\_m \cdot \left(-z\right)}{y}\\
\mathbf{else}:\\
\;\;\;\;x\_m\\
\end{array}
\end{array}
if z < -2.6999999999999999e-58 or 8.9999999999999995e-15 < z Initial program 92.8%
Taylor expanded in y around 0 74.6%
mul-1-neg74.6%
distribute-rgt-neg-out74.6%
Simplified74.6%
if -2.6999999999999999e-58 < z < 8.9999999999999995e-15Initial 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 #s(literal 1 binary64) x) (FPCore (x_s x_m y z) :precision binary64 (* x_s (if (or (<= z -2.5e-83) (not (<= z 5.2e-16))) (* (- 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 <= 5.2e-16)) {
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 <= 5.2d-16))) 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 <= 5.2e-16)) {
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 <= 5.2e-16): 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 <= 5.2e-16)) tmp = Float64(Float64(-z) * 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 <= 5.2e-16))) 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, 5.2e-16]], $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 5.2 \cdot 10^{-16}\right):\\
\;\;\;\;\left(-z\right) \cdot \frac{x\_m}{y}\\
\mathbf{else}:\\
\;\;\;\;x\_m\\
\end{array}
\end{array}
if z < -2.5e-83 or 5.1999999999999997e-16 < 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%
mul-1-neg73.8%
associate-*l/73.1%
distribute-rgt-neg-in73.1%
Simplified73.1%
if -2.5e-83 < z < 5.1999999999999997e-16Initial 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 #s(literal 1 binary64) x) (FPCore (x_s x_m y z) :precision binary64 (* x_s (if (or (<= z -1.9e-83) (not (<= z 1.5e-13))) (* 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.9e-83) || !(z <= 1.5e-13)) {
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.9d-83)) .or. (.not. (z <= 1.5d-13))) 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.9e-83) || !(z <= 1.5e-13)) {
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.9e-83) or not (z <= 1.5e-13): 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.9e-83) || !(z <= 1.5e-13)) tmp = Float64(x_m * Float64(Float64(-z) / 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.9e-83) || ~((z <= 1.5e-13))) 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.9e-83], N[Not[LessEqual[z, 1.5e-13]], $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.9 \cdot 10^{-83} \lor \neg \left(z \leq 1.5 \cdot 10^{-13}\right):\\
\;\;\;\;x\_m \cdot \frac{-z}{y}\\
\mathbf{else}:\\
\;\;\;\;x\_m\\
\end{array}
\end{array}
if z < -1.89999999999999988e-83 or 1.49999999999999992e-13 < 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%
associate-*r/67.4%
neg-mul-167.4%
Simplified67.4%
if -1.89999999999999988e-83 < z < 1.49999999999999992e-13Initial 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 #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 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%
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 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%
(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))