
(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 7 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-13) (+ x_m (/ (* x_m y) z)) (* 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-13) {
tmp = x_m + ((x_m * y) / z);
} 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-13) then
tmp = x_m + ((x_m * y) / z)
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-13) {
tmp = x_m + ((x_m * y) / z);
} 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-13: tmp = x_m + ((x_m * y) / z) 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-13) tmp = Float64(x_m + Float64(Float64(x_m * y) / z)); 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-13) tmp = x_m + ((x_m * y) / z); 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-13], N[(x$95$m + N[(N[(x$95$m * y), $MachinePrecision] / z), $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^{-13}:\\
\;\;\;\;x\_m + \frac{x\_m \cdot y}{z}\\
\mathbf{else}:\\
\;\;\;\;x\_m \cdot \left(\frac{y}{z} - -1\right)\\
\end{array}
\end{array}
if x < 1e-13Initial program 84.8%
associate-/l*93.1%
remove-double-neg93.1%
unsub-neg93.1%
div-sub93.1%
remove-double-neg93.1%
distribute-frac-neg293.1%
*-inverses93.1%
metadata-eval93.1%
Simplified93.1%
Taylor expanded in y around 0 92.4%
if 1e-13 < x Initial program 81.3%
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%
Final simplification94.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
(if (or (<= y -1.9e+82)
(and (not (<= y -1.25e-5)) (or (<= y -3e-71) (not (<= y 4.5e-65)))))
(* 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 ((y <= -1.9e+82) || (!(y <= -1.25e-5) && ((y <= -3e-71) || !(y <= 4.5e-65)))) {
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 ((y <= (-1.9d+82)) .or. (.not. (y <= (-1.25d-5))) .and. (y <= (-3d-71)) .or. (.not. (y <= 4.5d-65))) 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 ((y <= -1.9e+82) || (!(y <= -1.25e-5) && ((y <= -3e-71) || !(y <= 4.5e-65)))) {
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 (y <= -1.9e+82) or (not (y <= -1.25e-5) and ((y <= -3e-71) or not (y <= 4.5e-65))): 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 ((y <= -1.9e+82) || (!(y <= -1.25e-5) && ((y <= -3e-71) || !(y <= 4.5e-65)))) 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 ((y <= -1.9e+82) || (~((y <= -1.25e-5)) && ((y <= -3e-71) || ~((y <= 4.5e-65))))) 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[Or[LessEqual[y, -1.9e+82], And[N[Not[LessEqual[y, -1.25e-5]], $MachinePrecision], Or[LessEqual[y, -3e-71], N[Not[LessEqual[y, 4.5e-65]], $MachinePrecision]]]], 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}\;y \leq -1.9 \cdot 10^{+82} \lor \neg \left(y \leq -1.25 \cdot 10^{-5}\right) \land \left(y \leq -3 \cdot 10^{-71} \lor \neg \left(y \leq 4.5 \cdot 10^{-65}\right)\right):\\
\;\;\;\;x\_m \cdot \frac{y}{z}\\
\mathbf{else}:\\
\;\;\;\;x\_m\\
\end{array}
\end{array}
if y < -1.90000000000000017e82 or -1.25000000000000006e-5 < y < -3.0000000000000001e-71 or 4.4999999999999998e-65 < y Initial program 87.4%
associate-/l*90.9%
remove-double-neg90.9%
unsub-neg90.9%
div-sub90.9%
remove-double-neg90.9%
distribute-frac-neg290.9%
*-inverses90.9%
metadata-eval90.9%
Simplified90.9%
Taylor expanded in y around inf 71.7%
if -1.90000000000000017e82 < y < -1.25000000000000006e-5 or -3.0000000000000001e-71 < y < 4.4999999999999998e-65Initial program 80.1%
associate-/l*99.1%
remove-double-neg99.1%
unsub-neg99.1%
div-sub99.1%
remove-double-neg99.1%
distribute-frac-neg299.1%
*-inverses99.1%
metadata-eval99.1%
Simplified99.1%
Taylor expanded in y around 0 78.2%
Final simplification74.7%
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 (* y (/ x_m z))))
(*
x_s
(if (<= y -1.3e+82)
t_0
(if (<= y -5.5)
x_m
(if (<= y -8.5e-72) (* x_m (/ y z)) (if (<= y 3.6e-65) x_m t_0)))))))x\_m = fabs(x);
x\_s = copysign(1.0, x);
double code(double x_s, double x_m, double y, double z) {
double t_0 = y * (x_m / z);
double tmp;
if (y <= -1.3e+82) {
tmp = t_0;
} else if (y <= -5.5) {
tmp = x_m;
} else if (y <= -8.5e-72) {
tmp = x_m * (y / z);
} else if (y <= 3.6e-65) {
tmp = x_m;
} else {
tmp = t_0;
}
return x_s * tmp;
}
x\_m = abs(x)
x\_s = copysign(1.0d0, x)
real(8) function code(x_s, x_m, y, z)
real(8), intent (in) :: x_s
real(8), intent (in) :: x_m
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: t_0
real(8) :: tmp
t_0 = y * (x_m / z)
if (y <= (-1.3d+82)) then
tmp = t_0
else if (y <= (-5.5d0)) then
tmp = x_m
else if (y <= (-8.5d-72)) then
tmp = x_m * (y / z)
else if (y <= 3.6d-65) then
tmp = x_m
else
tmp = t_0
end if
code = x_s * tmp
end function
x\_m = Math.abs(x);
x\_s = Math.copySign(1.0, x);
public static double code(double x_s, double x_m, double y, double z) {
double t_0 = y * (x_m / z);
double tmp;
if (y <= -1.3e+82) {
tmp = t_0;
} else if (y <= -5.5) {
tmp = x_m;
} else if (y <= -8.5e-72) {
tmp = x_m * (y / z);
} else if (y <= 3.6e-65) {
tmp = x_m;
} else {
tmp = t_0;
}
return x_s * tmp;
}
x\_m = math.fabs(x) x\_s = math.copysign(1.0, x) def code(x_s, x_m, y, z): t_0 = y * (x_m / z) tmp = 0 if y <= -1.3e+82: tmp = t_0 elif y <= -5.5: tmp = x_m elif y <= -8.5e-72: tmp = x_m * (y / z) elif y <= 3.6e-65: tmp = x_m else: tmp = t_0 return x_s * tmp
x\_m = abs(x) x\_s = copysign(1.0, x) function code(x_s, x_m, y, z) t_0 = Float64(y * Float64(x_m / z)) tmp = 0.0 if (y <= -1.3e+82) tmp = t_0; elseif (y <= -5.5) tmp = x_m; elseif (y <= -8.5e-72) tmp = Float64(x_m * Float64(y / z)); elseif (y <= 3.6e-65) tmp = x_m; else tmp = t_0; end return Float64(x_s * tmp) end
x\_m = abs(x); x\_s = sign(x) * abs(1.0); function tmp_2 = code(x_s, x_m, y, z) t_0 = y * (x_m / z); tmp = 0.0; if (y <= -1.3e+82) tmp = t_0; elseif (y <= -5.5) tmp = x_m; elseif (y <= -8.5e-72) tmp = x_m * (y / z); elseif (y <= 3.6e-65) tmp = x_m; else tmp = t_0; end tmp_2 = x_s * tmp; end
x\_m = N[Abs[x], $MachinePrecision]
x\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[x$95$s_, x$95$m_, y_, z_] := Block[{t$95$0 = N[(y * N[(x$95$m / z), $MachinePrecision]), $MachinePrecision]}, N[(x$95$s * If[LessEqual[y, -1.3e+82], t$95$0, If[LessEqual[y, -5.5], x$95$m, If[LessEqual[y, -8.5e-72], N[(x$95$m * N[(y / z), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 3.6e-65], x$95$m, t$95$0]]]]), $MachinePrecision]]
\begin{array}{l}
x\_m = \left|x\right|
\\
x\_s = \mathsf{copysign}\left(1, x\right)
\\
\begin{array}{l}
t_0 := y \cdot \frac{x\_m}{z}\\
x\_s \cdot \begin{array}{l}
\mathbf{if}\;y \leq -1.3 \cdot 10^{+82}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq -5.5:\\
\;\;\;\;x\_m\\
\mathbf{elif}\;y \leq -8.5 \cdot 10^{-72}:\\
\;\;\;\;x\_m \cdot \frac{y}{z}\\
\mathbf{elif}\;y \leq 3.6 \cdot 10^{-65}:\\
\;\;\;\;x\_m\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
\end{array}
if y < -1.2999999999999999e82 or 3.5999999999999998e-65 < y Initial program 88.2%
associate-/l*89.8%
remove-double-neg89.8%
unsub-neg89.8%
div-sub89.8%
remove-double-neg89.8%
distribute-frac-neg289.8%
*-inverses89.8%
metadata-eval89.8%
Simplified89.8%
Taylor expanded in y around inf 76.8%
associate-*l/76.6%
*-commutative76.6%
Simplified76.6%
if -1.2999999999999999e82 < y < -5.5 or -8.50000000000000008e-72 < y < 3.5999999999999998e-65Initial program 80.1%
associate-/l*99.1%
remove-double-neg99.1%
unsub-neg99.1%
div-sub99.1%
remove-double-neg99.1%
distribute-frac-neg299.1%
*-inverses99.1%
metadata-eval99.1%
Simplified99.1%
Taylor expanded in y around 0 78.2%
if -5.5 < y < -8.50000000000000008e-72Initial program 80.7%
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%
Taylor expanded in y around inf 71.8%
Final simplification77.1%
x\_m = (fabs.f64 x)
x\_s = (copysign.f64 #s(literal 1 binary64) x)
(FPCore (x_s x_m y z)
:precision binary64
(*
x_s
(if (<= y -1.3e+82)
(/ y (/ z x_m))
(if (<= y -1.9)
x_m
(if (<= y -4.8e-69)
(* x_m (/ y z))
(if (<= y 3e-65) x_m (* y (/ 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 (y <= -1.3e+82) {
tmp = y / (z / x_m);
} else if (y <= -1.9) {
tmp = x_m;
} else if (y <= -4.8e-69) {
tmp = x_m * (y / z);
} else if (y <= 3e-65) {
tmp = x_m;
} else {
tmp = y * (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 (y <= (-1.3d+82)) then
tmp = y / (z / x_m)
else if (y <= (-1.9d0)) then
tmp = x_m
else if (y <= (-4.8d-69)) then
tmp = x_m * (y / z)
else if (y <= 3d-65) then
tmp = x_m
else
tmp = y * (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 (y <= -1.3e+82) {
tmp = y / (z / x_m);
} else if (y <= -1.9) {
tmp = x_m;
} else if (y <= -4.8e-69) {
tmp = x_m * (y / z);
} else if (y <= 3e-65) {
tmp = x_m;
} else {
tmp = y * (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 y <= -1.3e+82: tmp = y / (z / x_m) elif y <= -1.9: tmp = x_m elif y <= -4.8e-69: tmp = x_m * (y / z) elif y <= 3e-65: tmp = x_m else: tmp = y * (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 (y <= -1.3e+82) tmp = Float64(y / Float64(z / x_m)); elseif (y <= -1.9) tmp = x_m; elseif (y <= -4.8e-69) tmp = Float64(x_m * Float64(y / z)); elseif (y <= 3e-65) tmp = x_m; else tmp = Float64(y * 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 (y <= -1.3e+82) tmp = y / (z / x_m); elseif (y <= -1.9) tmp = x_m; elseif (y <= -4.8e-69) tmp = x_m * (y / z); elseif (y <= 3e-65) tmp = x_m; else tmp = y * (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[LessEqual[y, -1.3e+82], N[(y / N[(z / x$95$m), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, -1.9], x$95$m, If[LessEqual[y, -4.8e-69], N[(x$95$m * N[(y / z), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 3e-65], x$95$m, N[(y * 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}\;y \leq -1.3 \cdot 10^{+82}:\\
\;\;\;\;\frac{y}{\frac{z}{x\_m}}\\
\mathbf{elif}\;y \leq -1.9:\\
\;\;\;\;x\_m\\
\mathbf{elif}\;y \leq -4.8 \cdot 10^{-69}:\\
\;\;\;\;x\_m \cdot \frac{y}{z}\\
\mathbf{elif}\;y \leq 3 \cdot 10^{-65}:\\
\;\;\;\;x\_m\\
\mathbf{else}:\\
\;\;\;\;y \cdot \frac{x\_m}{z}\\
\end{array}
\end{array}
if y < -1.2999999999999999e82Initial program 93.7%
associate-/l*87.8%
remove-double-neg87.8%
unsub-neg87.8%
div-sub87.8%
remove-double-neg87.8%
distribute-frac-neg287.8%
*-inverses87.8%
metadata-eval87.8%
Simplified87.8%
Taylor expanded in y around inf 87.6%
associate-*l/82.1%
*-commutative82.1%
Simplified82.1%
clear-num82.1%
un-div-inv82.2%
Applied egg-rr82.2%
if -1.2999999999999999e82 < y < -1.8999999999999999 or -4.8000000000000002e-69 < y < 2.99999999999999998e-65Initial program 80.1%
associate-/l*99.1%
remove-double-neg99.1%
unsub-neg99.1%
div-sub99.1%
remove-double-neg99.1%
distribute-frac-neg299.1%
*-inverses99.1%
metadata-eval99.1%
Simplified99.1%
Taylor expanded in y around 0 78.2%
if -1.8999999999999999 < y < -4.8000000000000002e-69Initial program 80.7%
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%
Taylor expanded in y around inf 71.8%
if 2.99999999999999998e-65 < y Initial program 84.9%
associate-/l*91.1%
remove-double-neg91.1%
unsub-neg91.1%
div-sub91.0%
remove-double-neg91.0%
distribute-frac-neg291.0%
*-inverses91.0%
metadata-eval91.0%
Simplified91.0%
Taylor expanded in y around inf 70.1%
associate-*l/73.3%
*-commutative73.3%
Simplified73.3%
Final simplification77.1%
x\_m = (fabs.f64 x) x\_s = (copysign.f64 #s(literal 1 binary64) x) (FPCore (x_s x_m y z) :precision binary64 (* x_s (if (<= y -5e-69) (/ (* x_m y) z) (if (<= y 8.5e-68) x_m (* y (/ 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 (y <= -5e-69) {
tmp = (x_m * y) / z;
} else if (y <= 8.5e-68) {
tmp = x_m;
} else {
tmp = y * (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 (y <= (-5d-69)) then
tmp = (x_m * y) / z
else if (y <= 8.5d-68) then
tmp = x_m
else
tmp = y * (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 (y <= -5e-69) {
tmp = (x_m * y) / z;
} else if (y <= 8.5e-68) {
tmp = x_m;
} else {
tmp = y * (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 y <= -5e-69: tmp = (x_m * y) / z elif y <= 8.5e-68: tmp = x_m else: tmp = y * (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 (y <= -5e-69) tmp = Float64(Float64(x_m * y) / z); elseif (y <= 8.5e-68) tmp = x_m; else tmp = Float64(y * 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 (y <= -5e-69) tmp = (x_m * y) / z; elseif (y <= 8.5e-68) tmp = x_m; else tmp = y * (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[LessEqual[y, -5e-69], N[(N[(x$95$m * y), $MachinePrecision] / z), $MachinePrecision], If[LessEqual[y, 8.5e-68], x$95$m, N[(y * 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}\;y \leq -5 \cdot 10^{-69}:\\
\;\;\;\;\frac{x\_m \cdot y}{z}\\
\mathbf{elif}\;y \leq 8.5 \cdot 10^{-68}:\\
\;\;\;\;x\_m\\
\mathbf{else}:\\
\;\;\;\;y \cdot \frac{x\_m}{z}\\
\end{array}
\end{array}
if y < -5.00000000000000033e-69Initial program 92.7%
associate-/l*91.7%
remove-double-neg91.7%
unsub-neg91.7%
div-sub91.7%
remove-double-neg91.7%
distribute-frac-neg291.7%
*-inverses91.7%
metadata-eval91.7%
Simplified91.7%
Taylor expanded in y around inf 73.9%
if -5.00000000000000033e-69 < y < 8.50000000000000026e-68Initial program 76.4%
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 81.7%
if 8.50000000000000026e-68 < y Initial program 84.9%
associate-/l*91.1%
remove-double-neg91.1%
unsub-neg91.1%
div-sub91.0%
remove-double-neg91.0%
distribute-frac-neg291.0%
*-inverses91.0%
metadata-eval91.0%
Simplified91.0%
Taylor expanded in y around inf 70.1%
associate-*l/73.3%
*-commutative73.3%
Simplified73.3%
Final simplification76.8%
x\_m = (fabs.f64 x) x\_s = (copysign.f64 #s(literal 1 binary64) x) (FPCore (x_s x_m y z) :precision binary64 (* x_s (if (<= y -4e+134) (/ (* x_m y) z) (* 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 (y <= -4e+134) {
tmp = (x_m * y) / z;
} 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 (y <= (-4d+134)) then
tmp = (x_m * y) / z
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 (y <= -4e+134) {
tmp = (x_m * y) / z;
} 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 y <= -4e+134: tmp = (x_m * y) / z 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 (y <= -4e+134) tmp = Float64(Float64(x_m * y) / z); 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 (y <= -4e+134) tmp = (x_m * y) / z; 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[y, -4e+134], N[(N[(x$95$m * y), $MachinePrecision] / z), $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}\;y \leq -4 \cdot 10^{+134}:\\
\;\;\;\;\frac{x\_m \cdot y}{z}\\
\mathbf{else}:\\
\;\;\;\;x\_m \cdot \left(\frac{y}{z} - -1\right)\\
\end{array}
\end{array}
if y < -3.99999999999999969e134Initial program 97.2%
associate-/l*83.5%
remove-double-neg83.5%
unsub-neg83.5%
div-sub83.6%
remove-double-neg83.6%
distribute-frac-neg283.6%
*-inverses83.6%
metadata-eval83.6%
Simplified83.6%
Taylor expanded in y around inf 97.0%
if -3.99999999999999969e134 < y Initial program 82.0%
associate-/l*96.5%
remove-double-neg96.5%
unsub-neg96.5%
div-sub96.4%
remove-double-neg96.4%
distribute-frac-neg296.4%
*-inverses96.4%
metadata-eval96.4%
Simplified96.4%
Final simplification96.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 84.0%
associate-/l*94.7%
remove-double-neg94.7%
unsub-neg94.7%
div-sub94.7%
remove-double-neg94.7%
distribute-frac-neg294.7%
*-inverses94.7%
metadata-eval94.7%
Simplified94.7%
Taylor expanded in y around 0 46.9%
Final simplification46.9%
(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 2024115
(FPCore (x y z)
:name "Numeric.SpecFunctions:choose from math-functions-0.1.5.2"
:precision binary64
:alt
(/ x (/ z (+ y z)))
(/ (* x (+ y z)) z))