
(FPCore (x y z) :precision binary64 (/ (* x (+ y z)) z))
double code(double x, double y, double z) {
return (x * (y + z)) / z;
}
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)) / z
end function
public static double code(double x, double y, double z) {
return (x * (y + z)) / z;
}
def code(x, y, z): return (x * (y + z)) / z
function code(x, y, z) return Float64(Float64(x * Float64(y + z)) / z) end
function tmp = code(x, y, z) tmp = (x * (y + z)) / z; end
code[x_, y_, z_] := N[(N[(x * N[(y + z), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]
\begin{array}{l}
\\
\frac{x \cdot \left(y + z\right)}{z}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 9 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 (/ (* x (+ y z)) z))
double code(double x, double y, double z) {
return (x * (y + z)) / z;
}
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)) / z
end function
public static double code(double x, double y, double z) {
return (x * (y + z)) / z;
}
def code(x, y, z): return (x * (y + z)) / z
function code(x, y, z) return Float64(Float64(x * Float64(y + z)) / z) end
function tmp = code(x, y, z) tmp = (x * (y + z)) / z; end
code[x_, y_, z_] := N[(N[(x * N[(y + z), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]
\begin{array}{l}
\\
\frac{x \cdot \left(y + z\right)}{z}
\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 1e-26) (+ x_m (/ y (/ z x_m))) (* x_m (- (/ y z) -1.0)))))
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 <= 1e-26) {
tmp = x_m + (y / (z / x_m));
} else {
tmp = x_m * ((y / z) - -1.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) :: tmp
if (x_m <= 1d-26) then
tmp = x_m + (y / (z / x_m))
else
tmp = x_m * ((y / z) - (-1.0d0))
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 <= 1e-26) {
tmp = x_m + (y / (z / x_m));
} else {
tmp = x_m * ((y / z) - -1.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): tmp = 0 if x_m <= 1e-26: tmp = x_m + (y / (z / x_m)) else: tmp = x_m * ((y / z) - -1.0) 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 <= 1e-26) tmp = Float64(x_m + Float64(y / Float64(z / x_m))); else tmp = Float64(x_m * Float64(Float64(y / z) - -1.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) tmp = 0.0; if (x_m <= 1e-26) tmp = x_m + (y / (z / x_m)); else tmp = x_m * ((y / z) - -1.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_] := N[(x$95$s * If[LessEqual[x$95$m, 1e-26], N[(x$95$m + N[(y / N[(z / x$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x$95$m * N[(N[(y / z), $MachinePrecision] - -1.0), $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 10^{-26}:\\
\;\;\;\;x\_m + \frac{y}{\frac{z}{x\_m}}\\
\mathbf{else}:\\
\;\;\;\;x\_m \cdot \left(\frac{y}{z} - -1\right)\\
\end{array}
\end{array}
if x < 1e-26Initial program 88.6%
associate-/l*92.6%
remove-double-neg92.6%
unsub-neg92.6%
div-sub92.6%
remove-double-neg92.6%
distribute-frac-neg292.6%
*-inverses92.6%
metadata-eval92.6%
Simplified92.6%
sub-neg92.6%
metadata-eval92.6%
distribute-rgt-in92.6%
*-un-lft-identity92.6%
Applied egg-rr92.6%
associate-*l/95.1%
associate-*r/95.7%
clear-num95.2%
un-div-inv95.9%
Applied egg-rr95.9%
if 1e-26 < x Initial program 82.4%
associate-/l*100.0%
remove-double-neg100.0%
unsub-neg100.0%
div-sub100.0%
remove-double-neg100.0%
distribute-frac-neg2100.0%
*-inverses100.0%
metadata-eval100.0%
Simplified100.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
(if (or (<= z 2.2e-287) (not (<= z 4.6e+38)))
(* x_m (- (/ y z) -1.0))
(* (+ y z) (/ x_m z)))))x\_m = fabs(x);
x\_s = copysign(1.0, x);
double code(double x_s, double x_m, double y, double z) {
double tmp;
if ((z <= 2.2e-287) || !(z <= 4.6e+38)) {
tmp = x_m * ((y / z) - -1.0);
} else {
tmp = (y + z) * (x_m / z);
}
return x_s * tmp;
}
x\_m = abs(x)
x\_s = copysign(1.0d0, x)
real(8) function code(x_s, x_m, y, z)
real(8), intent (in) :: x_s
real(8), intent (in) :: x_m
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if ((z <= 2.2d-287) .or. (.not. (z <= 4.6d+38))) then
tmp = x_m * ((y / z) - (-1.0d0))
else
tmp = (y + z) * (x_m / z)
end if
code = x_s * tmp
end function
x\_m = Math.abs(x);
x\_s = Math.copySign(1.0, x);
public static double code(double x_s, double x_m, double y, double z) {
double tmp;
if ((z <= 2.2e-287) || !(z <= 4.6e+38)) {
tmp = x_m * ((y / z) - -1.0);
} else {
tmp = (y + z) * (x_m / z);
}
return x_s * tmp;
}
x\_m = math.fabs(x) x\_s = math.copysign(1.0, x) def code(x_s, x_m, y, z): tmp = 0 if (z <= 2.2e-287) or not (z <= 4.6e+38): tmp = x_m * ((y / z) - -1.0) else: tmp = (y + z) * (x_m / z) return x_s * tmp
x\_m = abs(x) x\_s = copysign(1.0, x) function code(x_s, x_m, y, z) tmp = 0.0 if ((z <= 2.2e-287) || !(z <= 4.6e+38)) tmp = Float64(x_m * Float64(Float64(y / z) - -1.0)); else tmp = Float64(Float64(y + z) * Float64(x_m / z)); end return Float64(x_s * tmp) end
x\_m = abs(x); x\_s = sign(x) * abs(1.0); function tmp_2 = code(x_s, x_m, y, z) tmp = 0.0; if ((z <= 2.2e-287) || ~((z <= 4.6e+38))) tmp = x_m * ((y / z) - -1.0); else tmp = (y + z) * (x_m / z); end tmp_2 = x_s * tmp; end
x\_m = N[Abs[x], $MachinePrecision]
x\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[x$95$s_, x$95$m_, y_, z_] := N[(x$95$s * If[Or[LessEqual[z, 2.2e-287], N[Not[LessEqual[z, 4.6e+38]], $MachinePrecision]], N[(x$95$m * N[(N[(y / z), $MachinePrecision] - -1.0), $MachinePrecision]), $MachinePrecision], N[(N[(y + z), $MachinePrecision] * N[(x$95$m / z), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
x\_m = \left|x\right|
\\
x\_s = \mathsf{copysign}\left(1, x\right)
\\
x\_s \cdot \begin{array}{l}
\mathbf{if}\;z \leq 2.2 \cdot 10^{-287} \lor \neg \left(z \leq 4.6 \cdot 10^{+38}\right):\\
\;\;\;\;x\_m \cdot \left(\frac{y}{z} - -1\right)\\
\mathbf{else}:\\
\;\;\;\;\left(y + z\right) \cdot \frac{x\_m}{z}\\
\end{array}
\end{array}
if z < 2.2e-287 or 4.6000000000000002e38 < z Initial program 83.6%
associate-/l*97.8%
remove-double-neg97.8%
unsub-neg97.8%
div-sub97.8%
remove-double-neg97.8%
distribute-frac-neg297.8%
*-inverses97.8%
metadata-eval97.8%
Simplified97.8%
if 2.2e-287 < z < 4.6000000000000002e38Initial program 94.2%
*-commutative94.2%
associate-/l*97.6%
Simplified97.6%
Final simplification97.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 (<= z 9.5e-287)
(* x_m (- (/ y z) -1.0))
(if (<= z 5e+38) (* (+ y z) (/ x_m z)) (+ x_m (* x_m (/ y z)))))))x\_m = fabs(x);
x\_s = copysign(1.0, x);
double code(double x_s, double x_m, double y, double z) {
double tmp;
if (z <= 9.5e-287) {
tmp = x_m * ((y / z) - -1.0);
} else if (z <= 5e+38) {
tmp = (y + z) * (x_m / z);
} else {
tmp = x_m + (x_m * (y / z));
}
return x_s * tmp;
}
x\_m = abs(x)
x\_s = copysign(1.0d0, x)
real(8) function code(x_s, x_m, y, z)
real(8), intent (in) :: x_s
real(8), intent (in) :: x_m
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (z <= 9.5d-287) then
tmp = x_m * ((y / z) - (-1.0d0))
else if (z <= 5d+38) then
tmp = (y + z) * (x_m / z)
else
tmp = x_m + (x_m * (y / z))
end if
code = x_s * tmp
end function
x\_m = Math.abs(x);
x\_s = Math.copySign(1.0, x);
public static double code(double x_s, double x_m, double y, double z) {
double tmp;
if (z <= 9.5e-287) {
tmp = x_m * ((y / z) - -1.0);
} else if (z <= 5e+38) {
tmp = (y + z) * (x_m / z);
} else {
tmp = x_m + (x_m * (y / z));
}
return x_s * tmp;
}
x\_m = math.fabs(x) x\_s = math.copysign(1.0, x) def code(x_s, x_m, y, z): tmp = 0 if z <= 9.5e-287: tmp = x_m * ((y / z) - -1.0) elif z <= 5e+38: tmp = (y + z) * (x_m / z) else: tmp = x_m + (x_m * (y / z)) return x_s * tmp
x\_m = abs(x) x\_s = copysign(1.0, x) function code(x_s, x_m, y, z) tmp = 0.0 if (z <= 9.5e-287) tmp = Float64(x_m * Float64(Float64(y / z) - -1.0)); elseif (z <= 5e+38) tmp = Float64(Float64(y + z) * Float64(x_m / z)); else tmp = Float64(x_m + Float64(x_m * Float64(y / z))); end return Float64(x_s * tmp) end
x\_m = abs(x); x\_s = sign(x) * abs(1.0); function tmp_2 = code(x_s, x_m, y, z) tmp = 0.0; if (z <= 9.5e-287) tmp = x_m * ((y / z) - -1.0); elseif (z <= 5e+38) tmp = (y + z) * (x_m / z); else tmp = x_m + (x_m * (y / z)); end tmp_2 = x_s * tmp; end
x\_m = N[Abs[x], $MachinePrecision]
x\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[x$95$s_, x$95$m_, y_, z_] := N[(x$95$s * If[LessEqual[z, 9.5e-287], N[(x$95$m * N[(N[(y / z), $MachinePrecision] - -1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 5e+38], N[(N[(y + z), $MachinePrecision] * N[(x$95$m / z), $MachinePrecision]), $MachinePrecision], N[(x$95$m + N[(x$95$m * N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]), $MachinePrecision]
\begin{array}{l}
x\_m = \left|x\right|
\\
x\_s = \mathsf{copysign}\left(1, x\right)
\\
x\_s \cdot \begin{array}{l}
\mathbf{if}\;z \leq 9.5 \cdot 10^{-287}:\\
\;\;\;\;x\_m \cdot \left(\frac{y}{z} - -1\right)\\
\mathbf{elif}\;z \leq 5 \cdot 10^{+38}:\\
\;\;\;\;\left(y + z\right) \cdot \frac{x\_m}{z}\\
\mathbf{else}:\\
\;\;\;\;x\_m + x\_m \cdot \frac{y}{z}\\
\end{array}
\end{array}
if z < 9.5000000000000004e-287Initial program 87.8%
associate-/l*96.7%
remove-double-neg96.7%
unsub-neg96.7%
div-sub96.7%
remove-double-neg96.7%
distribute-frac-neg296.7%
*-inverses96.7%
metadata-eval96.7%
Simplified96.7%
if 9.5000000000000004e-287 < z < 4.9999999999999997e38Initial program 94.2%
*-commutative94.2%
associate-/l*97.6%
Simplified97.6%
if 4.9999999999999997e38 < z Initial program 75.5%
associate-/l*99.8%
remove-double-neg99.8%
unsub-neg99.8%
div-sub99.8%
remove-double-neg99.8%
distribute-frac-neg299.8%
*-inverses99.8%
metadata-eval99.8%
Simplified99.8%
sub-neg99.8%
metadata-eval99.8%
distribute-rgt-in99.8%
*-un-lft-identity99.8%
Applied egg-rr99.8%
Final simplification97.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 (<= z -1.35e+63) x_m (if (<= z 3e-19) (/ y (/ z x_m)) 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.35e+63) {
tmp = x_m;
} else if (z <= 3e-19) {
tmp = y / (z / x_m);
} 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.35d+63)) then
tmp = x_m
else if (z <= 3d-19) then
tmp = y / (z / x_m)
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.35e+63) {
tmp = x_m;
} else if (z <= 3e-19) {
tmp = y / (z / x_m);
} 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.35e+63: tmp = x_m elif z <= 3e-19: tmp = y / (z / x_m) 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.35e+63) tmp = x_m; elseif (z <= 3e-19) tmp = Float64(y / Float64(z / x_m)); 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.35e+63) tmp = x_m; elseif (z <= 3e-19) tmp = y / (z / x_m); 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[z, -1.35e+63], x$95$m, If[LessEqual[z, 3e-19], N[(y / N[(z / x$95$m), $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.35 \cdot 10^{+63}:\\
\;\;\;\;x\_m\\
\mathbf{elif}\;z \leq 3 \cdot 10^{-19}:\\
\;\;\;\;\frac{y}{\frac{z}{x\_m}}\\
\mathbf{else}:\\
\;\;\;\;x\_m\\
\end{array}
\end{array}
if z < -1.35000000000000009e63 or 2.99999999999999993e-19 < z Initial program 81.5%
associate-/l*99.9%
remove-double-neg99.9%
unsub-neg99.9%
div-sub99.9%
remove-double-neg99.9%
distribute-frac-neg299.9%
*-inverses99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in y around 0 79.4%
if -1.35000000000000009e63 < z < 2.99999999999999993e-19Initial program 92.2%
Taylor expanded in y around inf 80.7%
*-commutative80.7%
Simplified80.7%
associate-*l/74.4%
Applied egg-rr74.4%
associate-*l/95.7%
associate-*r/93.5%
clear-num93.5%
un-div-inv95.2%
Applied egg-rr80.9%
x\_m = (fabs.f64 x) x\_s = (copysign.f64 #s(literal 1 binary64) x) (FPCore (x_s x_m y z) :precision binary64 (* x_s (if (<= z -7.5e+62) x_m (if (<= z 3.9e-19) (* y (/ x_m z)) 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 <= -7.5e+62) {
tmp = x_m;
} else if (z <= 3.9e-19) {
tmp = y * (x_m / z);
} 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 <= (-7.5d+62)) then
tmp = x_m
else if (z <= 3.9d-19) then
tmp = y * (x_m / z)
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 <= -7.5e+62) {
tmp = x_m;
} else if (z <= 3.9e-19) {
tmp = y * (x_m / z);
} 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 <= -7.5e+62: tmp = x_m elif z <= 3.9e-19: tmp = y * (x_m / z) 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 <= -7.5e+62) tmp = x_m; elseif (z <= 3.9e-19) tmp = Float64(y * Float64(x_m / z)); 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 <= -7.5e+62) tmp = x_m; elseif (z <= 3.9e-19) tmp = y * (x_m / z); 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[z, -7.5e+62], x$95$m, If[LessEqual[z, 3.9e-19], N[(y * N[(x$95$m / z), $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 -7.5 \cdot 10^{+62}:\\
\;\;\;\;x\_m\\
\mathbf{elif}\;z \leq 3.9 \cdot 10^{-19}:\\
\;\;\;\;y \cdot \frac{x\_m}{z}\\
\mathbf{else}:\\
\;\;\;\;x\_m\\
\end{array}
\end{array}
if z < -7.49999999999999998e62 or 3.89999999999999995e-19 < z Initial program 81.5%
associate-/l*99.9%
remove-double-neg99.9%
unsub-neg99.9%
div-sub99.9%
remove-double-neg99.9%
distribute-frac-neg299.9%
*-inverses99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in y around 0 79.4%
if -7.49999999999999998e62 < z < 3.89999999999999995e-19Initial program 92.2%
associate-/l*89.4%
remove-double-neg89.4%
unsub-neg89.4%
div-sub89.4%
remove-double-neg89.4%
distribute-frac-neg289.4%
*-inverses89.4%
metadata-eval89.4%
Simplified89.4%
Taylor expanded in y around inf 80.7%
associate-*l/79.9%
*-commutative79.9%
Simplified79.9%
x\_m = (fabs.f64 x) x\_s = (copysign.f64 #s(literal 1 binary64) x) (FPCore (x_s x_m y z) :precision binary64 (* x_s (if (<= z -8.5e+62) x_m (if (<= z 2e-19) (* x_m (/ y z)) 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.5e+62) {
tmp = x_m;
} else if (z <= 2e-19) {
tmp = x_m * (y / z);
} 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.5d+62)) then
tmp = x_m
else if (z <= 2d-19) then
tmp = x_m * (y / z)
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.5e+62) {
tmp = x_m;
} else if (z <= 2e-19) {
tmp = x_m * (y / z);
} 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.5e+62: tmp = x_m elif z <= 2e-19: tmp = x_m * (y / z) 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.5e+62) tmp = x_m; elseif (z <= 2e-19) tmp = Float64(x_m * Float64(y / z)); 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.5e+62) tmp = x_m; elseif (z <= 2e-19) tmp = x_m * (y / z); 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[z, -8.5e+62], x$95$m, If[LessEqual[z, 2e-19], N[(x$95$m * N[(y / z), $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.5 \cdot 10^{+62}:\\
\;\;\;\;x\_m\\
\mathbf{elif}\;z \leq 2 \cdot 10^{-19}:\\
\;\;\;\;x\_m \cdot \frac{y}{z}\\
\mathbf{else}:\\
\;\;\;\;x\_m\\
\end{array}
\end{array}
if z < -8.4999999999999997e62 or 2e-19 < z Initial program 81.5%
associate-/l*99.9%
remove-double-neg99.9%
unsub-neg99.9%
div-sub99.9%
remove-double-neg99.9%
distribute-frac-neg299.9%
*-inverses99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in y around 0 79.4%
if -8.4999999999999997e62 < z < 2e-19Initial program 92.2%
associate-/l*89.4%
remove-double-neg89.4%
unsub-neg89.4%
div-sub89.4%
remove-double-neg89.4%
distribute-frac-neg289.4%
*-inverses89.4%
metadata-eval89.4%
Simplified89.4%
Taylor expanded in y around inf 74.4%
x\_m = (fabs.f64 x) x\_s = (copysign.f64 #s(literal 1 binary64) x) (FPCore (x_s x_m y z) :precision binary64 (* x_s (+ 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) {
return x_s * (x_m + (x_m / (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 + (x_m / (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 + (x_m / (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 + (x_m / (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(x_m / 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 + (x_m / (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[(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 \left(x\_m + \frac{x\_m}{\frac{z}{y}}\right)
\end{array}
Initial program 87.1%
associate-/l*94.4%
remove-double-neg94.4%
unsub-neg94.4%
div-sub94.5%
remove-double-neg94.5%
distribute-frac-neg294.5%
*-inverses94.5%
metadata-eval94.5%
Simplified94.5%
sub-neg94.5%
metadata-eval94.5%
distribute-rgt-in94.5%
*-un-lft-identity94.5%
Applied egg-rr94.5%
*-commutative94.5%
clear-num94.4%
un-div-inv95.0%
Applied egg-rr95.0%
Final simplification95.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 (- (/ y z) -1.0))))
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 * ((y / z) - -1.0));
}
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 * ((y / z) - (-1.0d0)))
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 * ((y / z) - -1.0));
}
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 * ((y / z) - -1.0))
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(Float64(y / z) - -1.0))) 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 * ((y / z) - -1.0)); 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[(N[(y / z), $MachinePrecision] - -1.0), $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(\frac{y}{z} - -1\right)\right)
\end{array}
Initial program 87.1%
associate-/l*94.4%
remove-double-neg94.4%
unsub-neg94.4%
div-sub94.5%
remove-double-neg94.5%
distribute-frac-neg294.5%
*-inverses94.5%
metadata-eval94.5%
Simplified94.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 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.1%
associate-/l*94.4%
remove-double-neg94.4%
unsub-neg94.4%
div-sub94.5%
remove-double-neg94.5%
distribute-frac-neg294.5%
*-inverses94.5%
metadata-eval94.5%
Simplified94.5%
Taylor expanded in y around 0 47.3%
(FPCore (x y z) :precision binary64 (/ x (/ z (+ y z))))
double code(double x, double y, double z) {
return x / (z / (y + z));
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = x / (z / (y + z))
end function
public static double code(double x, double y, double z) {
return x / (z / (y + z));
}
def code(x, y, z): return x / (z / (y + z))
function code(x, y, z) return Float64(x / Float64(z / Float64(y + z))) end
function tmp = code(x, y, z) tmp = x / (z / (y + z)); end
code[x_, y_, z_] := N[(x / N[(z / N[(y + z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x}{\frac{z}{y + z}}
\end{array}
herbie shell --seed 2024172
(FPCore (x y z)
:name "Numeric.SpecFunctions:choose from math-functions-0.1.5.2"
:precision binary64
:alt
(! :herbie-platform default (/ x (/ z (+ y z))))
(/ (* x (+ y z)) z))