
(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 1 x)
(FPCore (x_s x_m y z)
:precision binary64
(*
x_s
(if (<= (/ (* x_m (+ y z)) z) -1e+129)
(* (+ y z) (/ x_m z))
(/ x_m (/ z (+ 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 * (y + z)) / z) <= -1e+129) {
tmp = (y + z) * (x_m / z);
} else {
tmp = x_m / (z / (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 * (y + z)) / z) <= (-1d+129)) then
tmp = (y + z) * (x_m / z)
else
tmp = x_m / (z / (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 * (y + z)) / z) <= -1e+129) {
tmp = (y + z) * (x_m / z);
} else {
tmp = x_m / (z / (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 * (y + z)) / z) <= -1e+129: tmp = (y + z) * (x_m / z) else: tmp = x_m / (z / (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 (Float64(Float64(x_m * Float64(y + z)) / z) <= -1e+129) tmp = Float64(Float64(y + z) * Float64(x_m / z)); else tmp = Float64(x_m / Float64(z / 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 * (y + z)) / z) <= -1e+129) tmp = (y + z) * (x_m / z); else tmp = x_m / (z / (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[N[(N[(x$95$m * N[(y + z), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision], -1e+129], N[(N[(y + z), $MachinePrecision] * N[(x$95$m / z), $MachinePrecision]), $MachinePrecision], N[(x$95$m / N[(z / 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}\;\frac{x_m \cdot \left(y + z\right)}{z} \leq -1 \cdot 10^{+129}:\\
\;\;\;\;\left(y + z\right) \cdot \frac{x_m}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{x_m}{\frac{z}{y + z}}\\
\end{array}
\end{array}
if (/.f64 (*.f64 x (+.f64 y z)) z) < -1e129Initial program 79.3%
associate-*l/93.9%
*-commutative93.9%
Simplified93.9%
if -1e129 < (/.f64 (*.f64 x (+.f64 y z)) z) Initial program 86.0%
associate-*l/80.1%
*-commutative80.1%
Simplified80.1%
*-commutative80.1%
associate-/r/97.9%
Applied egg-rr97.9%
Final simplification96.9%
x_m = (fabs.f64 x) x_s = (copysign.f64 1 x) (FPCore (x_s x_m y z) :precision binary64 (* x_s (if (<= z -1.1e+139) x_m (if (<= z 2e+110) (* (+ y z) (/ 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 <= -1.1e+139) {
tmp = x_m;
} else if (z <= 2e+110) {
tmp = (y + z) * (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 <= (-1.1d+139)) then
tmp = x_m
else if (z <= 2d+110) then
tmp = (y + z) * (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 <= -1.1e+139) {
tmp = x_m;
} else if (z <= 2e+110) {
tmp = (y + z) * (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 <= -1.1e+139: tmp = x_m elif z <= 2e+110: tmp = (y + z) * (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 <= -1.1e+139) tmp = x_m; elseif (z <= 2e+110) tmp = Float64(Float64(y + z) * 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 <= -1.1e+139) tmp = x_m; elseif (z <= 2e+110) tmp = (y + z) * (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, -1.1e+139], x$95$m, If[LessEqual[z, 2e+110], N[(N[(y + z), $MachinePrecision] * 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 -1.1 \cdot 10^{+139}:\\
\;\;\;\;x_m\\
\mathbf{elif}\;z \leq 2 \cdot 10^{+110}:\\
\;\;\;\;\left(y + z\right) \cdot \frac{x_m}{z}\\
\mathbf{else}:\\
\;\;\;\;x_m\\
\end{array}
\end{array}
if z < -1.1e139 or 2e110 < z Initial program 69.3%
associate-*l/63.2%
*-commutative63.2%
Simplified63.2%
Taylor expanded in y around 0 90.4%
if -1.1e139 < z < 2e110Initial program 90.8%
associate-*l/92.3%
*-commutative92.3%
Simplified92.3%
Final simplification91.7%
x_m = (fabs.f64 x) x_s = (copysign.f64 1 x) (FPCore (x_s x_m y z) :precision binary64 (* x_s (if (or (<= y -1.1e+21) (not (<= y 1.7e-26))) (* 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.1e+21) || !(y <= 1.7e-26)) {
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.1d+21)) .or. (.not. (y <= 1.7d-26))) 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.1e+21) || !(y <= 1.7e-26)) {
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.1e+21) or not (y <= 1.7e-26): 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.1e+21) || !(y <= 1.7e-26)) 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.1e+21) || ~((y <= 1.7e-26))) 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.1e+21], N[Not[LessEqual[y, 1.7e-26]], $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.1 \cdot 10^{+21} \lor \neg \left(y \leq 1.7 \cdot 10^{-26}\right):\\
\;\;\;\;x_m \cdot \frac{y}{z}\\
\mathbf{else}:\\
\;\;\;\;x_m\\
\end{array}
\end{array}
if y < -1.1e21 or 1.70000000000000007e-26 < y Initial program 90.2%
associate-*l/85.4%
*-commutative85.4%
Simplified85.4%
Taylor expanded in y around inf 70.5%
associate-*r/67.8%
Simplified67.8%
if -1.1e21 < y < 1.70000000000000007e-26Initial program 78.5%
associate-*l/81.7%
*-commutative81.7%
Simplified81.7%
Taylor expanded in y around 0 81.3%
Final simplification74.6%
x_m = (fabs.f64 x) x_s = (copysign.f64 1 x) (FPCore (x_s x_m y z) :precision binary64 (* x_s (if (<= z -1.5e-7) x_m (if (<= z 1.28e+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 <= -1.5e-7) {
tmp = x_m;
} else if (z <= 1.28e+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 <= (-1.5d-7)) then
tmp = x_m
else if (z <= 1.28d+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 <= -1.5e-7) {
tmp = x_m;
} else if (z <= 1.28e+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 <= -1.5e-7: tmp = x_m elif z <= 1.28e+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 <= -1.5e-7) tmp = x_m; elseif (z <= 1.28e+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 <= -1.5e-7) tmp = x_m; elseif (z <= 1.28e+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, -1.5e-7], x$95$m, If[LessEqual[z, 1.28e+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 -1.5 \cdot 10^{-7}:\\
\;\;\;\;x_m\\
\mathbf{elif}\;z \leq 1.28 \cdot 10^{+19}:\\
\;\;\;\;y \cdot \frac{x_m}{z}\\
\mathbf{else}:\\
\;\;\;\;x_m\\
\end{array}
\end{array}
if z < -1.4999999999999999e-7 or 1.28e19 < z Initial program 77.2%
associate-*l/77.1%
*-commutative77.1%
Simplified77.1%
Taylor expanded in y around 0 79.0%
if -1.4999999999999999e-7 < z < 1.28e19Initial program 92.0%
associate-*l/90.6%
*-commutative90.6%
Simplified90.6%
Taylor expanded in y around inf 71.5%
associate-*l/71.5%
Applied egg-rr71.5%
Final simplification75.4%
x_m = (fabs.f64 x) x_s = (copysign.f64 1 x) (FPCore (x_s x_m y z) :precision binary64 (* x_s (if (<= z -0.0017) x_m (if (<= z 4.5e+18) (/ 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 <= -0.0017) {
tmp = x_m;
} else if (z <= 4.5e+18) {
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 <= (-0.0017d0)) then
tmp = x_m
else if (z <= 4.5d+18) 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 <= -0.0017) {
tmp = x_m;
} else if (z <= 4.5e+18) {
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 <= -0.0017: tmp = x_m elif z <= 4.5e+18: 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 <= -0.0017) tmp = x_m; elseif (z <= 4.5e+18) 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 <= -0.0017) tmp = x_m; elseif (z <= 4.5e+18) 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, -0.0017], x$95$m, If[LessEqual[z, 4.5e+18], 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 -0.0017:\\
\;\;\;\;x_m\\
\mathbf{elif}\;z \leq 4.5 \cdot 10^{+18}:\\
\;\;\;\;\frac{y}{\frac{z}{x_m}}\\
\mathbf{else}:\\
\;\;\;\;x_m\\
\end{array}
\end{array}
if z < -0.00169999999999999991 or 4.5e18 < z Initial program 77.2%
associate-*l/77.1%
*-commutative77.1%
Simplified77.1%
Taylor expanded in y around 0 79.0%
if -0.00169999999999999991 < z < 4.5e18Initial program 92.0%
associate-*l/90.6%
*-commutative90.6%
Simplified90.6%
Taylor expanded in y around inf 71.5%
associate-*l/71.5%
Applied egg-rr71.5%
*-commutative71.5%
clear-num71.5%
un-div-inv71.7%
Applied egg-rr71.7%
Final simplification75.5%
x_m = (fabs.f64 x) x_s = (copysign.f64 1 x) (FPCore (x_s x_m y z) :precision binary64 (* x_s (if (<= x_m 1e-55) (+ 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 <= 1e-55) {
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 <= 1d-55) 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 <= 1e-55) {
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 <= 1e-55: 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 <= 1e-55) 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 <= 1e-55) 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, 1e-55], 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 10^{-55}:\\
\;\;\;\;x_m + \frac{x_m \cdot y}{z}\\
\mathbf{else}:\\
\;\;\;\;x_m + x_m \cdot \frac{y}{z}\\
\end{array}
\end{array}
if x < 9.99999999999999995e-56Initial program 88.8%
associate-*l/79.8%
*-commutative79.8%
Simplified79.8%
Taylor expanded in y around 0 96.6%
if 9.99999999999999995e-56 < x Initial program 73.9%
remove-double-neg73.9%
distribute-lft-neg-out73.9%
*-commutative73.9%
distribute-lft-neg-in73.9%
associate-/l*92.4%
distribute-neg-in92.4%
unsub-neg92.4%
div-sub85.5%
distribute-frac-neg85.5%
associate-/r/85.9%
distribute-rgt-neg-out85.9%
remove-double-neg85.9%
associate-/r/99.9%
*-inverses99.9%
*-lft-identity99.9%
*-commutative99.9%
fma-neg99.9%
remove-double-neg99.9%
Simplified99.9%
fma-udef99.9%
Applied egg-rr99.9%
Final simplification97.6%
x_m = (fabs.f64 x) x_s = (copysign.f64 1 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(Float64(x_m * 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[(N[(x$95$m * y), $MachinePrecision] / z), $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 \cdot y}{z}\right)
\end{array}
Initial program 84.3%
associate-*l/83.6%
*-commutative83.6%
Simplified83.6%
Taylor expanded in y around 0 94.9%
Final simplification94.9%
x_m = (fabs.f64 x) x_s = (copysign.f64 1 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.3%
associate-*l/83.6%
*-commutative83.6%
Simplified83.6%
Taylor expanded in y around 0 54.0%
Final simplification54.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 2023322
(FPCore (x y z)
:name "Numeric.SpecFunctions:choose from math-functions-0.1.5.2"
:precision binary64
:herbie-target
(/ x (/ z (+ y z)))
(/ (* x (+ y z)) z))