
(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 8 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 1.02e+21) (/ (* x_m (+ y z)) 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.02e+21) {
tmp = (x_m * (y + z)) / 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.02d+21) then
tmp = (x_m * (y + z)) / 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.02e+21) {
tmp = (x_m * (y + z)) / 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.02e+21: tmp = (x_m * (y + z)) / 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.02e+21) tmp = Float64(Float64(x_m * Float64(y + z)) / 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.02e+21) tmp = (x_m * (y + z)) / 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.02e+21], N[(N[(x$95$m * N[(y + z), $MachinePrecision]), $MachinePrecision] / z), $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.02 \cdot 10^{+21}:\\
\;\;\;\;\frac{x\_m \cdot \left(y + z\right)}{z}\\
\mathbf{else}:\\
\;\;\;\;x\_m + x\_m \cdot \frac{y}{z}\\
\end{array}
\end{array}
if x < 1.02e21Initial program 93.6%
if 1.02e21 < x Initial program 67.1%
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%
sub-neg99.9%
metadata-eval99.9%
distribute-rgt-in100.0%
*-un-lft-identity100.0%
Applied egg-rr100.0%
Final simplification95.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 (<= z -7e-107)
x_m
(if (<= z -5.2e-277)
(* y (/ x_m z))
(if (<= z 3.1e+29) (* 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 <= -7e-107) {
tmp = x_m;
} else if (z <= -5.2e-277) {
tmp = y * (x_m / z);
} else if (z <= 3.1e+29) {
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 <= (-7d-107)) then
tmp = x_m
else if (z <= (-5.2d-277)) then
tmp = y * (x_m / z)
else if (z <= 3.1d+29) 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 <= -7e-107) {
tmp = x_m;
} else if (z <= -5.2e-277) {
tmp = y * (x_m / z);
} else if (z <= 3.1e+29) {
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 <= -7e-107: tmp = x_m elif z <= -5.2e-277: tmp = y * (x_m / z) elif z <= 3.1e+29: 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 <= -7e-107) tmp = x_m; elseif (z <= -5.2e-277) tmp = Float64(y * Float64(x_m / z)); elseif (z <= 3.1e+29) 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 <= -7e-107) tmp = x_m; elseif (z <= -5.2e-277) tmp = y * (x_m / z); elseif (z <= 3.1e+29) 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, -7e-107], x$95$m, If[LessEqual[z, -5.2e-277], N[(y * N[(x$95$m / z), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 3.1e+29], 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 -7 \cdot 10^{-107}:\\
\;\;\;\;x\_m\\
\mathbf{elif}\;z \leq -5.2 \cdot 10^{-277}:\\
\;\;\;\;y \cdot \frac{x\_m}{z}\\
\mathbf{elif}\;z \leq 3.1 \cdot 10^{+29}:\\
\;\;\;\;x\_m \cdot \frac{y}{z}\\
\mathbf{else}:\\
\;\;\;\;x\_m\\
\end{array}
\end{array}
if z < -6.99999999999999971e-107 or 3.0999999999999999e29 < z Initial program 77.0%
associate-/l*98.7%
remove-double-neg98.7%
unsub-neg98.7%
div-sub98.7%
remove-double-neg98.7%
distribute-frac-neg298.7%
*-inverses98.7%
metadata-eval98.7%
Simplified98.7%
Taylor expanded in y around 0 76.3%
if -6.99999999999999971e-107 < z < -5.2e-277Initial program 96.8%
associate-/l*84.5%
remove-double-neg84.5%
unsub-neg84.5%
div-sub84.5%
remove-double-neg84.5%
distribute-frac-neg284.5%
*-inverses84.5%
metadata-eval84.5%
Simplified84.5%
Taylor expanded in y around inf 86.7%
associate-*l/84.6%
*-commutative84.6%
Simplified84.6%
if -5.2e-277 < z < 3.0999999999999999e29Initial program 98.5%
associate-/l*94.9%
remove-double-neg94.9%
unsub-neg94.9%
div-sub94.9%
remove-double-neg94.9%
distribute-frac-neg294.9%
*-inverses94.9%
metadata-eval94.9%
Simplified94.9%
Taylor expanded in y around inf 75.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 -3.9e-107) x_m (if (<= z 4.2e+31) (/ (* 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.9e-107) {
tmp = x_m;
} else if (z <= 4.2e+31) {
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.9d-107)) then
tmp = x_m
else if (z <= 4.2d+31) 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.9e-107) {
tmp = x_m;
} else if (z <= 4.2e+31) {
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.9e-107: tmp = x_m elif z <= 4.2e+31: 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.9e-107) tmp = x_m; elseif (z <= 4.2e+31) 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.9e-107) tmp = x_m; elseif (z <= 4.2e+31) 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.9e-107], x$95$m, If[LessEqual[z, 4.2e+31], 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.9 \cdot 10^{-107}:\\
\;\;\;\;x\_m\\
\mathbf{elif}\;z \leq 4.2 \cdot 10^{+31}:\\
\;\;\;\;\frac{x\_m \cdot y}{z}\\
\mathbf{else}:\\
\;\;\;\;x\_m\\
\end{array}
\end{array}
if z < -3.9000000000000001e-107 or 4.19999999999999958e31 < z Initial program 77.0%
associate-/l*98.7%
remove-double-neg98.7%
unsub-neg98.7%
div-sub98.7%
remove-double-neg98.7%
distribute-frac-neg298.7%
*-inverses98.7%
metadata-eval98.7%
Simplified98.7%
Taylor expanded in y around 0 76.3%
if -3.9000000000000001e-107 < z < 4.19999999999999958e31Initial program 98.0%
Taylor expanded in y around inf 81.5%
*-commutative81.5%
Simplified81.5%
Final simplification78.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 (<= z -2.8e-107) x_m (if (<= z 1.55e+30) (* 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 <= -2.8e-107) {
tmp = x_m;
} else if (z <= 1.55e+30) {
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 <= (-2.8d-107)) then
tmp = x_m
else if (z <= 1.55d+30) 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 <= -2.8e-107) {
tmp = x_m;
} else if (z <= 1.55e+30) {
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 <= -2.8e-107: tmp = x_m elif z <= 1.55e+30: 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 <= -2.8e-107) tmp = x_m; elseif (z <= 1.55e+30) 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 <= -2.8e-107) tmp = x_m; elseif (z <= 1.55e+30) 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, -2.8e-107], x$95$m, If[LessEqual[z, 1.55e+30], 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 -2.8 \cdot 10^{-107}:\\
\;\;\;\;x\_m\\
\mathbf{elif}\;z \leq 1.55 \cdot 10^{+30}:\\
\;\;\;\;x\_m \cdot \frac{y}{z}\\
\mathbf{else}:\\
\;\;\;\;x\_m\\
\end{array}
\end{array}
if z < -2.7999999999999999e-107 or 1.5499999999999999e30 < z Initial program 77.0%
associate-/l*98.7%
remove-double-neg98.7%
unsub-neg98.7%
div-sub98.7%
remove-double-neg98.7%
distribute-frac-neg298.7%
*-inverses98.7%
metadata-eval98.7%
Simplified98.7%
Taylor expanded in y around 0 76.3%
if -2.7999999999999999e-107 < z < 1.5499999999999999e30Initial program 98.0%
associate-/l*91.8%
remove-double-neg91.8%
unsub-neg91.8%
div-sub91.8%
remove-double-neg91.8%
distribute-frac-neg291.8%
*-inverses91.8%
metadata-eval91.8%
Simplified91.8%
Taylor expanded in y around inf 74.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 (<= x_m 1.85e-12) (+ x_m (/ y (/ z x_m))) (+ 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.85e-12) {
tmp = x_m + (y / (z / x_m));
} 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.85d-12) then
tmp = x_m + (y / (z / x_m))
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.85e-12) {
tmp = x_m + (y / (z / x_m));
} 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.85e-12: tmp = x_m + (y / (z / x_m)) 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.85e-12) tmp = Float64(x_m + Float64(y / Float64(z / x_m))); 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.85e-12) tmp = x_m + (y / (z / x_m)); 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.85e-12], N[(x$95$m + N[(y / N[(z / x$95$m), $MachinePrecision]), $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.85 \cdot 10^{-12}:\\
\;\;\;\;x\_m + \frac{y}{\frac{z}{x\_m}}\\
\mathbf{else}:\\
\;\;\;\;x\_m + x\_m \cdot \frac{y}{z}\\
\end{array}
\end{array}
if x < 1.84999999999999999e-12Initial program 93.3%
associate-/l*93.9%
remove-double-neg93.9%
unsub-neg93.9%
div-sub93.9%
remove-double-neg93.9%
distribute-frac-neg293.9%
*-inverses93.9%
metadata-eval93.9%
Simplified93.9%
sub-neg93.9%
metadata-eval93.9%
distribute-rgt-in93.9%
*-un-lft-identity93.9%
Applied egg-rr93.9%
associate-*l/97.1%
associate-*r/92.7%
clear-num92.3%
un-div-inv93.1%
Applied egg-rr93.1%
if 1.84999999999999999e-12 < x Initial program 69.9%
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%
sub-neg99.9%
metadata-eval99.9%
distribute-rgt-in99.9%
*-un-lft-identity99.9%
Applied egg-rr99.9%
Final simplification95.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 (/ y z)))))
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 * (y / z)));
}
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 * (y / z)))
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 * (y / z)));
}
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 * (y / z)))
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(y / z)))) 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 * (y / z))); 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[(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 \left(x\_m + x\_m \cdot \frac{y}{z}\right)
\end{array}
Initial program 85.6%
associate-/l*95.9%
remove-double-neg95.9%
unsub-neg95.9%
div-sub95.9%
remove-double-neg95.9%
distribute-frac-neg295.9%
*-inverses95.9%
metadata-eval95.9%
Simplified95.9%
sub-neg95.9%
metadata-eval95.9%
distribute-rgt-in95.9%
*-un-lft-identity95.9%
Applied egg-rr95.9%
Final simplification95.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 (* 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.6%
associate-/l*95.9%
remove-double-neg95.9%
unsub-neg95.9%
div-sub95.9%
remove-double-neg95.9%
distribute-frac-neg295.9%
*-inverses95.9%
metadata-eval95.9%
Simplified95.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 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.6%
associate-/l*95.9%
remove-double-neg95.9%
unsub-neg95.9%
div-sub95.9%
remove-double-neg95.9%
distribute-frac-neg295.9%
*-inverses95.9%
metadata-eval95.9%
Simplified95.9%
Taylor expanded in y around 0 52.5%
(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 2024170
(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))