
(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 2.4e-191) (+ x_m (/ (* x_m y) 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 <= 2.4e-191) {
tmp = x_m + ((x_m * y) / 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 <= 2.4d-191) then
tmp = x_m + ((x_m * y) / 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 <= 2.4e-191) {
tmp = x_m + ((x_m * y) / 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 <= 2.4e-191: tmp = x_m + ((x_m * y) / 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 <= 2.4e-191) tmp = Float64(x_m + Float64(Float64(x_m * y) / 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 <= 2.4e-191) tmp = x_m + ((x_m * y) / 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, 2.4e-191], N[(x$95$m + N[(N[(x$95$m * y), $MachinePrecision] / z), $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 2.4 \cdot 10^{-191}:\\
\;\;\;\;x\_m + \frac{x\_m \cdot y}{z}\\
\mathbf{else}:\\
\;\;\;\;x\_m + \frac{x\_m}{\frac{z}{y}}\\
\end{array}
\end{array}
if x < 2.3999999999999999e-191Initial program 89.7%
associate-/l*93.5%
remove-double-neg93.5%
distribute-frac-neg293.5%
neg-sub093.5%
remove-double-neg93.5%
unsub-neg93.5%
div-sub93.5%
*-inverses93.5%
metadata-eval93.5%
associate--r-93.5%
neg-sub093.5%
distribute-frac-neg293.5%
remove-double-neg93.5%
sub-neg93.5%
Simplified93.5%
Taylor expanded in y around 0 94.4%
if 2.3999999999999999e-191 < x Initial program 78.8%
associate-/l*99.0%
remove-double-neg99.0%
distribute-frac-neg299.0%
neg-sub099.0%
remove-double-neg99.0%
unsub-neg99.0%
div-sub99.1%
*-inverses99.1%
metadata-eval99.1%
associate--r-99.1%
neg-sub099.1%
distribute-frac-neg299.1%
remove-double-neg99.1%
sub-neg99.1%
Simplified99.1%
sub-neg99.1%
metadata-eval99.1%
distribute-rgt-in99.1%
*-un-lft-identity99.1%
Applied egg-rr99.1%
*-commutative99.1%
clear-num99.0%
un-div-inv99.1%
Applied egg-rr99.1%
Final simplification96.3%
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 -3.4e+97) x_m (if (<= z 7.2e+16) (/ (* 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 <= -3.4e+97) {
tmp = x_m;
} else if (z <= 7.2e+16) {
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 <= (-3.4d+97)) then
tmp = x_m
else if (z <= 7.2d+16) 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 <= -3.4e+97) {
tmp = x_m;
} else if (z <= 7.2e+16) {
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 <= -3.4e+97: tmp = x_m elif z <= 7.2e+16: 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 <= -3.4e+97) tmp = x_m; elseif (z <= 7.2e+16) tmp = Float64(Float64(x_m * 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 <= -3.4e+97) tmp = x_m; elseif (z <= 7.2e+16) 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, -3.4e+97], x$95$m, If[LessEqual[z, 7.2e+16], N[(N[(x$95$m * y), $MachinePrecision] / z), $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.4 \cdot 10^{+97}:\\
\;\;\;\;x\_m\\
\mathbf{elif}\;z \leq 7.2 \cdot 10^{+16}:\\
\;\;\;\;\frac{x\_m \cdot y}{z}\\
\mathbf{else}:\\
\;\;\;\;x\_m\\
\end{array}
\end{array}
if z < -3.4000000000000001e97 or 7.2e16 < z Initial program 72.4%
associate-/l*100.0%
remove-double-neg100.0%
distribute-frac-neg2100.0%
neg-sub0100.0%
remove-double-neg100.0%
unsub-neg100.0%
div-sub100.0%
*-inverses100.0%
metadata-eval100.0%
associate--r-100.0%
neg-sub0100.0%
distribute-frac-neg2100.0%
remove-double-neg100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in y around 0 81.2%
if -3.4000000000000001e97 < z < 7.2e16Initial program 94.1%
Taylor expanded in y around inf 72.6%
*-commutative72.6%
Simplified72.6%
Final simplification76.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 (<= z -2.5e+89) x_m (if (<= z 1.12e+17) (/ 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 <= -2.5e+89) {
tmp = x_m;
} else if (z <= 1.12e+17) {
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 <= (-2.5d+89)) then
tmp = x_m
else if (z <= 1.12d+17) 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 <= -2.5e+89) {
tmp = x_m;
} else if (z <= 1.12e+17) {
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 <= -2.5e+89: tmp = x_m elif z <= 1.12e+17: 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 <= -2.5e+89) tmp = x_m; elseif (z <= 1.12e+17) 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 <= -2.5e+89) tmp = x_m; elseif (z <= 1.12e+17) 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, -2.5e+89], x$95$m, If[LessEqual[z, 1.12e+17], 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 -2.5 \cdot 10^{+89}:\\
\;\;\;\;x\_m\\
\mathbf{elif}\;z \leq 1.12 \cdot 10^{+17}:\\
\;\;\;\;\frac{y}{\frac{z}{x\_m}}\\
\mathbf{else}:\\
\;\;\;\;x\_m\\
\end{array}
\end{array}
if z < -2.49999999999999992e89 or 1.12e17 < z Initial program 72.9%
associate-/l*99.9%
remove-double-neg99.9%
distribute-frac-neg299.9%
neg-sub099.9%
remove-double-neg99.9%
unsub-neg99.9%
div-sub100.0%
*-inverses100.0%
metadata-eval100.0%
associate--r-100.0%
neg-sub0100.0%
distribute-frac-neg2100.0%
remove-double-neg100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in y around 0 79.8%
if -2.49999999999999992e89 < z < 1.12e17Initial program 94.0%
*-commutative94.0%
associate-/l*90.9%
Simplified90.9%
clear-num90.3%
un-div-inv90.4%
Applied egg-rr90.4%
Taylor expanded in y around inf 71.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 (<= z -2.8e+89) x_m (if (<= z 1e+17) (* 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 <= -2.8e+89) {
tmp = x_m;
} else if (z <= 1e+17) {
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 <= (-2.8d+89)) then
tmp = x_m
else if (z <= 1d+17) 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 <= -2.8e+89) {
tmp = x_m;
} else if (z <= 1e+17) {
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 <= -2.8e+89: tmp = x_m elif z <= 1e+17: 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 <= -2.8e+89) tmp = x_m; elseif (z <= 1e+17) 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 <= -2.8e+89) tmp = x_m; elseif (z <= 1e+17) 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, -2.8e+89], x$95$m, If[LessEqual[z, 1e+17], 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 -2.8 \cdot 10^{+89}:\\
\;\;\;\;x\_m\\
\mathbf{elif}\;z \leq 10^{+17}:\\
\;\;\;\;y \cdot \frac{x\_m}{z}\\
\mathbf{else}:\\
\;\;\;\;x\_m\\
\end{array}
\end{array}
if z < -2.7999999999999998e89 or 1e17 < z Initial program 72.9%
associate-/l*99.9%
remove-double-neg99.9%
distribute-frac-neg299.9%
neg-sub099.9%
remove-double-neg99.9%
unsub-neg99.9%
div-sub100.0%
*-inverses100.0%
metadata-eval100.0%
associate--r-100.0%
neg-sub0100.0%
distribute-frac-neg2100.0%
remove-double-neg100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in y around 0 79.8%
if -2.7999999999999998e89 < z < 1e17Initial program 94.0%
associate-/l*92.8%
remove-double-neg92.8%
distribute-frac-neg292.8%
neg-sub092.8%
remove-double-neg92.8%
unsub-neg92.8%
div-sub92.8%
*-inverses92.8%
metadata-eval92.8%
associate--r-92.8%
neg-sub092.8%
distribute-frac-neg292.8%
remove-double-neg92.8%
sub-neg92.8%
Simplified92.8%
Taylor expanded in y around inf 72.2%
associate-*l/71.1%
*-commutative71.1%
Simplified71.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 (<= z -3.4e+97) x_m (if (<= z 1.15e+17) (* 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 <= -3.4e+97) {
tmp = x_m;
} else if (z <= 1.15e+17) {
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 <= (-3.4d+97)) then
tmp = x_m
else if (z <= 1.15d+17) 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 <= -3.4e+97) {
tmp = x_m;
} else if (z <= 1.15e+17) {
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 <= -3.4e+97: tmp = x_m elif z <= 1.15e+17: 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 <= -3.4e+97) tmp = x_m; elseif (z <= 1.15e+17) 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 <= -3.4e+97) tmp = x_m; elseif (z <= 1.15e+17) 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, -3.4e+97], x$95$m, If[LessEqual[z, 1.15e+17], 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 -3.4 \cdot 10^{+97}:\\
\;\;\;\;x\_m\\
\mathbf{elif}\;z \leq 1.15 \cdot 10^{+17}:\\
\;\;\;\;x\_m \cdot \frac{y}{z}\\
\mathbf{else}:\\
\;\;\;\;x\_m\\
\end{array}
\end{array}
if z < -3.4000000000000001e97 or 1.15e17 < z Initial program 72.4%
associate-/l*100.0%
remove-double-neg100.0%
distribute-frac-neg2100.0%
neg-sub0100.0%
remove-double-neg100.0%
unsub-neg100.0%
div-sub100.0%
*-inverses100.0%
metadata-eval100.0%
associate--r-100.0%
neg-sub0100.0%
distribute-frac-neg2100.0%
remove-double-neg100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in y around 0 81.2%
if -3.4000000000000001e97 < z < 1.15e17Initial program 94.1%
associate-/l*92.9%
remove-double-neg92.9%
distribute-frac-neg292.9%
neg-sub092.9%
remove-double-neg92.9%
unsub-neg92.9%
div-sub92.9%
*-inverses92.9%
metadata-eval92.9%
associate--r-92.9%
neg-sub092.9%
distribute-frac-neg292.9%
remove-double-neg92.9%
sub-neg92.9%
Simplified92.9%
Taylor expanded in y around inf 69.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 (<= x_m 1.92e-191) (+ x_m (/ (* x_m y) 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 (x_m <= 1.92e-191) {
tmp = x_m + ((x_m * y) / 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 (x_m <= 1.92d-191) then
tmp = x_m + ((x_m * y) / 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 (x_m <= 1.92e-191) {
tmp = x_m + ((x_m * y) / 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 x_m <= 1.92e-191: tmp = x_m + ((x_m * y) / 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 (x_m <= 1.92e-191) tmp = Float64(x_m + Float64(Float64(x_m * y) / 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 (x_m <= 1.92e-191) tmp = x_m + ((x_m * y) / 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[x$95$m, 1.92e-191], N[(x$95$m + N[(N[(x$95$m * y), $MachinePrecision] / 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}\;x\_m \leq 1.92 \cdot 10^{-191}:\\
\;\;\;\;x\_m + \frac{x\_m \cdot y}{z}\\
\mathbf{else}:\\
\;\;\;\;x\_m + x\_m \cdot \frac{y}{z}\\
\end{array}
\end{array}
if x < 1.9199999999999999e-191Initial program 89.7%
associate-/l*93.5%
remove-double-neg93.5%
distribute-frac-neg293.5%
neg-sub093.5%
remove-double-neg93.5%
unsub-neg93.5%
div-sub93.5%
*-inverses93.5%
metadata-eval93.5%
associate--r-93.5%
neg-sub093.5%
distribute-frac-neg293.5%
remove-double-neg93.5%
sub-neg93.5%
Simplified93.5%
Taylor expanded in y around 0 94.4%
if 1.9199999999999999e-191 < x Initial program 78.8%
associate-/l*99.0%
remove-double-neg99.0%
distribute-frac-neg299.0%
neg-sub099.0%
remove-double-neg99.0%
unsub-neg99.0%
div-sub99.1%
*-inverses99.1%
metadata-eval99.1%
associate--r-99.1%
neg-sub099.1%
distribute-frac-neg299.1%
remove-double-neg99.1%
sub-neg99.1%
Simplified99.1%
sub-neg99.1%
metadata-eval99.1%
distribute-rgt-in99.1%
*-un-lft-identity99.1%
Applied egg-rr99.1%
Final simplification96.3%
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 1.9e-191) (+ 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 <= 1.9e-191) {
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 <= 1.9d-191) 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 <= 1.9e-191) {
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 <= 1.9e-191: 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 <= 1.9e-191) 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 <= 1.9e-191) 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, 1.9e-191], 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 1.9 \cdot 10^{-191}:\\
\;\;\;\;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 < 1.8999999999999999e-191Initial program 89.7%
associate-/l*93.5%
remove-double-neg93.5%
distribute-frac-neg293.5%
neg-sub093.5%
remove-double-neg93.5%
unsub-neg93.5%
div-sub93.5%
*-inverses93.5%
metadata-eval93.5%
associate--r-93.5%
neg-sub093.5%
distribute-frac-neg293.5%
remove-double-neg93.5%
sub-neg93.5%
Simplified93.5%
Taylor expanded in y around 0 94.4%
if 1.8999999999999999e-191 < x Initial program 78.8%
associate-/l*99.0%
remove-double-neg99.0%
distribute-frac-neg299.0%
neg-sub099.0%
remove-double-neg99.0%
unsub-neg99.0%
div-sub99.1%
*-inverses99.1%
metadata-eval99.1%
associate--r-99.1%
neg-sub099.1%
distribute-frac-neg299.1%
remove-double-neg99.1%
sub-neg99.1%
Simplified99.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 (* 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 85.1%
associate-/l*95.8%
remove-double-neg95.8%
distribute-frac-neg295.8%
neg-sub095.8%
remove-double-neg95.8%
unsub-neg95.8%
div-sub95.8%
*-inverses95.8%
metadata-eval95.8%
associate--r-95.8%
neg-sub095.8%
distribute-frac-neg295.8%
remove-double-neg95.8%
sub-neg95.8%
Simplified95.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 85.1%
associate-/l*95.8%
remove-double-neg95.8%
distribute-frac-neg295.8%
neg-sub095.8%
remove-double-neg95.8%
unsub-neg95.8%
div-sub95.8%
*-inverses95.8%
metadata-eval95.8%
associate--r-95.8%
neg-sub095.8%
distribute-frac-neg295.8%
remove-double-neg95.8%
sub-neg95.8%
Simplified95.8%
Taylor expanded in y around 0 48.0%
(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 2024146
(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))