
(FPCore (x y z) :precision binary64 (/ (* x (- y z)) y))
double code(double x, double y, double z) {
return (x * (y - z)) / y;
}
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)) / y
end function
public static double code(double x, double y, double z) {
return (x * (y - z)) / y;
}
def code(x, y, z): return (x * (y - z)) / y
function code(x, y, z) return Float64(Float64(x * Float64(y - z)) / y) end
function tmp = code(x, y, z) tmp = (x * (y - z)) / y; end
code[x_, y_, z_] := N[(N[(x * N[(y - z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]
\begin{array}{l}
\\
\frac{x \cdot \left(y - z\right)}{y}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 8 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 (/ (* x (- y z)) y))
double code(double x, double y, double z) {
return (x * (y - z)) / y;
}
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)) / y
end function
public static double code(double x, double y, double z) {
return (x * (y - z)) / y;
}
def code(x, y, z): return (x * (y - z)) / y
function code(x, y, z) return Float64(Float64(x * Float64(y - z)) / y) end
function tmp = code(x, y, z) tmp = (x * (y - z)) / y; end
code[x_, y_, z_] := N[(N[(x * N[(y - z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]
\begin{array}{l}
\\
\frac{x \cdot \left(y - z\right)}{y}
\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 4e+52) (- x_m (/ (* x_m z) y)) (- 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 <= 4e+52) {
tmp = x_m - ((x_m * z) / y);
} 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 <= 4d+52) then
tmp = x_m - ((x_m * z) / y)
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 <= 4e+52) {
tmp = x_m - ((x_m * z) / y);
} 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 <= 4e+52: tmp = x_m - ((x_m * z) / y) 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 <= 4e+52) tmp = Float64(x_m - Float64(Float64(x_m * z) / y)); 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 <= 4e+52) tmp = x_m - ((x_m * z) / y); 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, 4e+52], N[(x$95$m - N[(N[(x$95$m * z), $MachinePrecision] / y), $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 4 \cdot 10^{+52}:\\
\;\;\;\;x\_m - \frac{x\_m \cdot z}{y}\\
\mathbf{else}:\\
\;\;\;\;x\_m - x\_m \cdot \frac{z}{y}\\
\end{array}
\end{array}
if x < 4e52Initial program 86.2%
remove-double-neg86.2%
distribute-frac-neg286.2%
distribute-frac-neg86.2%
distribute-rgt-neg-in86.2%
associate-/l*91.5%
distribute-frac-neg91.5%
distribute-frac-neg291.5%
remove-double-neg91.5%
div-sub91.5%
*-inverses91.5%
Simplified91.5%
Taylor expanded in z around 0 92.7%
associate-*r/92.7%
associate-*r*92.7%
mul-1-neg92.7%
Simplified92.7%
if 4e52 < x Initial program 80.1%
remove-double-neg80.1%
distribute-frac-neg280.1%
distribute-frac-neg80.1%
distribute-rgt-neg-in80.1%
associate-/l*99.9%
distribute-frac-neg99.9%
distribute-frac-neg299.9%
remove-double-neg99.9%
div-sub99.9%
*-inverses99.9%
Simplified99.9%
Taylor expanded in z around 0 90.8%
associate-*r/90.8%
associate-*r*90.8%
mul-1-neg90.8%
Simplified90.8%
associate-/l*99.9%
add-sqr-sqrt99.8%
sqrt-unprod68.2%
sqr-neg68.2%
sqrt-unprod0.0%
add-sqr-sqrt44.7%
cancel-sign-sub-inv44.7%
associate-/l*38.7%
associate-/l*44.7%
add-sqr-sqrt0.0%
sqrt-unprod68.2%
sqr-neg68.2%
sqrt-unprod99.8%
add-sqr-sqrt99.9%
Applied egg-rr99.9%
Final simplification93.9%
x\_m = (fabs.f64 x) x\_s = (copysign.f64 #s(literal 1 binary64) x) (FPCore (x_s x_m y z) :precision binary64 (* x_s (if (<= y -3.5e-21) x_m (if (<= y 0.017) (* z (/ x_m (- y))) 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 <= -3.5e-21) {
tmp = x_m;
} else if (y <= 0.017) {
tmp = z * (x_m / -y);
} 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 <= (-3.5d-21)) then
tmp = x_m
else if (y <= 0.017d0) then
tmp = z * (x_m / -y)
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 <= -3.5e-21) {
tmp = x_m;
} else if (y <= 0.017) {
tmp = z * (x_m / -y);
} 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 <= -3.5e-21: tmp = x_m elif y <= 0.017: tmp = z * (x_m / -y) 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 <= -3.5e-21) tmp = x_m; elseif (y <= 0.017) tmp = Float64(z * Float64(x_m / Float64(-y))); 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 <= -3.5e-21) tmp = x_m; elseif (y <= 0.017) tmp = z * (x_m / -y); 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[y, -3.5e-21], x$95$m, If[LessEqual[y, 0.017], N[(z * N[(x$95$m / (-y)), $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 -3.5 \cdot 10^{-21}:\\
\;\;\;\;x\_m\\
\mathbf{elif}\;y \leq 0.017:\\
\;\;\;\;z \cdot \frac{x\_m}{-y}\\
\mathbf{else}:\\
\;\;\;\;x\_m\\
\end{array}
\end{array}
if y < -3.5000000000000003e-21 or 0.017000000000000001 < y Initial program 76.4%
remove-double-neg76.4%
distribute-frac-neg276.4%
distribute-frac-neg76.4%
distribute-rgt-neg-in76.4%
associate-/l*99.8%
distribute-frac-neg99.8%
distribute-frac-neg299.8%
remove-double-neg99.8%
div-sub99.9%
*-inverses99.9%
Simplified99.9%
Taylor expanded in z around 0 77.5%
if -3.5000000000000003e-21 < y < 0.017000000000000001Initial program 92.9%
remove-double-neg92.9%
distribute-frac-neg292.9%
distribute-frac-neg92.9%
distribute-rgt-neg-in92.9%
associate-/l*86.8%
distribute-frac-neg86.8%
distribute-frac-neg286.8%
remove-double-neg86.8%
div-sub86.8%
*-inverses86.8%
Simplified86.8%
Taylor expanded in z around inf 73.1%
mul-1-neg73.1%
distribute-frac-neg273.1%
*-commutative73.1%
associate-/l*74.5%
Simplified74.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 (<= y -4.6e-28) x_m (if (<= y 0.085) (* x_m (/ (- z) y)) 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 <= -4.6e-28) {
tmp = x_m;
} else if (y <= 0.085) {
tmp = x_m * (-z / y);
} 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 <= (-4.6d-28)) then
tmp = x_m
else if (y <= 0.085d0) then
tmp = x_m * (-z / y)
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 <= -4.6e-28) {
tmp = x_m;
} else if (y <= 0.085) {
tmp = x_m * (-z / y);
} 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 <= -4.6e-28: tmp = x_m elif y <= 0.085: tmp = x_m * (-z / y) 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 <= -4.6e-28) tmp = x_m; elseif (y <= 0.085) tmp = Float64(x_m * Float64(Float64(-z) / y)); 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 <= -4.6e-28) tmp = x_m; elseif (y <= 0.085) tmp = x_m * (-z / y); 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[y, -4.6e-28], x$95$m, If[LessEqual[y, 0.085], N[(x$95$m * N[((-z) / y), $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 -4.6 \cdot 10^{-28}:\\
\;\;\;\;x\_m\\
\mathbf{elif}\;y \leq 0.085:\\
\;\;\;\;x\_m \cdot \frac{-z}{y}\\
\mathbf{else}:\\
\;\;\;\;x\_m\\
\end{array}
\end{array}
if y < -4.59999999999999971e-28 or 0.0850000000000000061 < y Initial program 77.2%
remove-double-neg77.2%
distribute-frac-neg277.2%
distribute-frac-neg77.2%
distribute-rgt-neg-in77.2%
associate-/l*99.1%
distribute-frac-neg99.1%
distribute-frac-neg299.1%
remove-double-neg99.1%
div-sub99.1%
*-inverses99.1%
Simplified99.1%
Taylor expanded in z around 0 76.6%
if -4.59999999999999971e-28 < y < 0.0850000000000000061Initial program 92.7%
remove-double-neg92.7%
distribute-frac-neg292.7%
distribute-frac-neg92.7%
distribute-rgt-neg-in92.7%
associate-/l*87.2%
distribute-frac-neg87.2%
distribute-frac-neg287.2%
remove-double-neg87.2%
div-sub87.2%
*-inverses87.2%
Simplified87.2%
Taylor expanded in z around inf 73.7%
mul-1-neg73.7%
distribute-frac-neg273.7%
associate-*r/64.7%
Simplified64.7%
Final simplification70.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 (if (<= x_m 2.5e-34) (/ (* x_m (- y z)) y) (- 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.5e-34) {
tmp = (x_m * (y - z)) / y;
} 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.5d-34) then
tmp = (x_m * (y - z)) / y
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.5e-34) {
tmp = (x_m * (y - z)) / y;
} 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.5e-34: tmp = (x_m * (y - z)) / y 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.5e-34) tmp = Float64(Float64(x_m * Float64(y - z)) / y); 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.5e-34) tmp = (x_m * (y - z)) / y; 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.5e-34], N[(N[(x$95$m * N[(y - z), $MachinePrecision]), $MachinePrecision] / y), $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.5 \cdot 10^{-34}:\\
\;\;\;\;\frac{x\_m \cdot \left(y - z\right)}{y}\\
\mathbf{else}:\\
\;\;\;\;x\_m - x\_m \cdot \frac{z}{y}\\
\end{array}
\end{array}
if x < 2.5000000000000001e-34Initial program 85.3%
if 2.5000000000000001e-34 < x Initial program 85.1%
remove-double-neg85.1%
distribute-frac-neg285.1%
distribute-frac-neg85.1%
distribute-rgt-neg-in85.1%
associate-/l*99.8%
distribute-frac-neg99.8%
distribute-frac-neg299.8%
remove-double-neg99.8%
div-sub99.9%
*-inverses99.9%
Simplified99.9%
Taylor expanded in z around 0 93.9%
associate-*r/93.9%
associate-*r*93.9%
mul-1-neg93.9%
Simplified93.9%
associate-/l*99.9%
add-sqr-sqrt99.8%
sqrt-unprod78.7%
sqr-neg78.7%
sqrt-unprod0.0%
add-sqr-sqrt51.4%
cancel-sign-sub-inv51.4%
associate-/l*47.4%
associate-/l*51.4%
add-sqr-sqrt0.0%
sqrt-unprod78.7%
sqr-neg78.7%
sqrt-unprod99.8%
add-sqr-sqrt99.9%
Applied egg-rr99.9%
x\_m = (fabs.f64 x) x\_s = (copysign.f64 #s(literal 1 binary64) x) (FPCore (x_s x_m y z) :precision binary64 (* x_s (if (<= z 2.9e+116) (- x_m (* x_m (/ z y))) (* z (/ x_m (- 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 (z <= 2.9e+116) {
tmp = x_m - (x_m * (z / y));
} else {
tmp = z * (x_m / -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 (z <= 2.9d+116) then
tmp = x_m - (x_m * (z / y))
else
tmp = z * (x_m / -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 (z <= 2.9e+116) {
tmp = x_m - (x_m * (z / y));
} else {
tmp = z * (x_m / -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 z <= 2.9e+116: tmp = x_m - (x_m * (z / y)) else: tmp = z * (x_m / -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 (z <= 2.9e+116) tmp = Float64(x_m - Float64(x_m * Float64(z / y))); else tmp = Float64(z * Float64(x_m / Float64(-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 (z <= 2.9e+116) tmp = x_m - (x_m * (z / y)); else tmp = z * (x_m / -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[z, 2.9e+116], N[(x$95$m - N[(x$95$m * N[(z / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(z * N[(x$95$m / (-y)), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
x\_m = \left|x\right|
\\
x\_s = \mathsf{copysign}\left(1, x\right)
\\
x\_s \cdot \begin{array}{l}
\mathbf{if}\;z \leq 2.9 \cdot 10^{+116}:\\
\;\;\;\;x\_m - x\_m \cdot \frac{z}{y}\\
\mathbf{else}:\\
\;\;\;\;z \cdot \frac{x\_m}{-y}\\
\end{array}
\end{array}
if z < 2.9000000000000001e116Initial program 84.8%
remove-double-neg84.8%
distribute-frac-neg284.8%
distribute-frac-neg84.8%
distribute-rgt-neg-in84.8%
associate-/l*95.8%
distribute-frac-neg95.8%
distribute-frac-neg295.8%
remove-double-neg95.8%
div-sub95.8%
*-inverses95.8%
Simplified95.8%
Taylor expanded in z around 0 93.1%
associate-*r/93.1%
associate-*r*93.1%
mul-1-neg93.1%
Simplified93.1%
associate-/l*95.9%
add-sqr-sqrt40.6%
sqrt-unprod55.8%
sqr-neg55.8%
sqrt-unprod31.4%
add-sqr-sqrt56.0%
cancel-sign-sub-inv56.0%
associate-/l*52.5%
associate-/l*56.0%
add-sqr-sqrt31.4%
sqrt-unprod55.8%
sqr-neg55.8%
sqrt-unprod40.6%
add-sqr-sqrt95.9%
Applied egg-rr95.9%
if 2.9000000000000001e116 < z Initial program 87.0%
remove-double-neg87.0%
distribute-frac-neg287.0%
distribute-frac-neg87.0%
distribute-rgt-neg-in87.0%
associate-/l*78.7%
distribute-frac-neg78.7%
distribute-frac-neg278.7%
remove-double-neg78.7%
div-sub78.7%
*-inverses78.7%
Simplified78.7%
Taylor expanded in z around inf 85.1%
mul-1-neg85.1%
distribute-frac-neg285.1%
*-commutative85.1%
associate-/l*89.4%
Simplified89.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 (if (<= z 2.9e+116) (* x_m (- 1.0 (/ z y))) (* z (/ x_m (- 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 (z <= 2.9e+116) {
tmp = x_m * (1.0 - (z / y));
} else {
tmp = z * (x_m / -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 (z <= 2.9d+116) then
tmp = x_m * (1.0d0 - (z / y))
else
tmp = z * (x_m / -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 (z <= 2.9e+116) {
tmp = x_m * (1.0 - (z / y));
} else {
tmp = z * (x_m / -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 z <= 2.9e+116: tmp = x_m * (1.0 - (z / y)) else: tmp = z * (x_m / -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 (z <= 2.9e+116) tmp = Float64(x_m * Float64(1.0 - Float64(z / y))); else tmp = Float64(z * Float64(x_m / Float64(-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 (z <= 2.9e+116) tmp = x_m * (1.0 - (z / y)); else tmp = z * (x_m / -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[z, 2.9e+116], N[(x$95$m * N[(1.0 - N[(z / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(z * N[(x$95$m / (-y)), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
x\_m = \left|x\right|
\\
x\_s = \mathsf{copysign}\left(1, x\right)
\\
x\_s \cdot \begin{array}{l}
\mathbf{if}\;z \leq 2.9 \cdot 10^{+116}:\\
\;\;\;\;x\_m \cdot \left(1 - \frac{z}{y}\right)\\
\mathbf{else}:\\
\;\;\;\;z \cdot \frac{x\_m}{-y}\\
\end{array}
\end{array}
if z < 2.9000000000000001e116Initial program 84.8%
remove-double-neg84.8%
distribute-frac-neg284.8%
distribute-frac-neg84.8%
distribute-rgt-neg-in84.8%
associate-/l*95.8%
distribute-frac-neg95.8%
distribute-frac-neg295.8%
remove-double-neg95.8%
div-sub95.8%
*-inverses95.8%
Simplified95.8%
if 2.9000000000000001e116 < z Initial program 87.0%
remove-double-neg87.0%
distribute-frac-neg287.0%
distribute-frac-neg87.0%
distribute-rgt-neg-in87.0%
associate-/l*78.7%
distribute-frac-neg78.7%
distribute-frac-neg278.7%
remove-double-neg78.7%
div-sub78.7%
*-inverses78.7%
Simplified78.7%
Taylor expanded in z around inf 85.1%
mul-1-neg85.1%
distribute-frac-neg285.1%
*-commutative85.1%
associate-/l*89.4%
Simplified89.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 (if (<= x_m 6e+197) x_m (* y (/ x_m 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 <= 6e+197) {
tmp = x_m;
} else {
tmp = y * (x_m / 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 <= 6d+197) then
tmp = x_m
else
tmp = y * (x_m / 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 <= 6e+197) {
tmp = x_m;
} else {
tmp = y * (x_m / 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 <= 6e+197: tmp = x_m else: tmp = y * (x_m / 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 <= 6e+197) tmp = x_m; else tmp = Float64(y * Float64(x_m / 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 <= 6e+197) tmp = x_m; else tmp = y * (x_m / 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, 6e+197], x$95$m, N[(y * N[(x$95$m / y), $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 6 \cdot 10^{+197}:\\
\;\;\;\;x\_m\\
\mathbf{else}:\\
\;\;\;\;y \cdot \frac{x\_m}{y}\\
\end{array}
\end{array}
if x < 6.0000000000000004e197Initial program 86.7%
remove-double-neg86.7%
distribute-frac-neg286.7%
distribute-frac-neg86.7%
distribute-rgt-neg-in86.7%
associate-/l*92.3%
distribute-frac-neg92.3%
distribute-frac-neg292.3%
remove-double-neg92.3%
div-sub92.3%
*-inverses92.3%
Simplified92.3%
Taylor expanded in z around 0 50.6%
if 6.0000000000000004e197 < x Initial program 66.3%
Taylor expanded in y around inf 16.3%
*-commutative16.3%
associate-/l*73.2%
Applied egg-rr73.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 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.2%
remove-double-neg85.2%
distribute-frac-neg285.2%
distribute-frac-neg85.2%
distribute-rgt-neg-in85.2%
associate-/l*92.9%
distribute-frac-neg92.9%
distribute-frac-neg292.9%
remove-double-neg92.9%
div-sub92.9%
*-inverses92.9%
Simplified92.9%
Taylor expanded in z around 0 49.8%
(FPCore (x y z) :precision binary64 (if (< z -2.060202331921739e+104) (- x (/ (* z x) y)) (if (< z 1.6939766013828526e+213) (/ x (/ y (- y z))) (* (- y z) (/ x y)))))
double code(double x, double y, double z) {
double tmp;
if (z < -2.060202331921739e+104) {
tmp = x - ((z * x) / y);
} else if (z < 1.6939766013828526e+213) {
tmp = x / (y / (y - z));
} else {
tmp = (y - z) * (x / y);
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (z < (-2.060202331921739d+104)) then
tmp = x - ((z * x) / y)
else if (z < 1.6939766013828526d+213) then
tmp = x / (y / (y - z))
else
tmp = (y - z) * (x / y)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z < -2.060202331921739e+104) {
tmp = x - ((z * x) / y);
} else if (z < 1.6939766013828526e+213) {
tmp = x / (y / (y - z));
} else {
tmp = (y - z) * (x / y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if z < -2.060202331921739e+104: tmp = x - ((z * x) / y) elif z < 1.6939766013828526e+213: tmp = x / (y / (y - z)) else: tmp = (y - z) * (x / y) return tmp
function code(x, y, z) tmp = 0.0 if (z < -2.060202331921739e+104) tmp = Float64(x - Float64(Float64(z * x) / y)); elseif (z < 1.6939766013828526e+213) tmp = Float64(x / Float64(y / Float64(y - z))); else tmp = Float64(Float64(y - z) * Float64(x / y)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z < -2.060202331921739e+104) tmp = x - ((z * x) / y); elseif (z < 1.6939766013828526e+213) tmp = x / (y / (y - z)); else tmp = (y - z) * (x / y); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Less[z, -2.060202331921739e+104], N[(x - N[(N[(z * x), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], If[Less[z, 1.6939766013828526e+213], N[(x / N[(y / N[(y - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(y - z), $MachinePrecision] * N[(x / y), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z < -2.060202331921739 \cdot 10^{+104}:\\
\;\;\;\;x - \frac{z \cdot x}{y}\\
\mathbf{elif}\;z < 1.6939766013828526 \cdot 10^{+213}:\\
\;\;\;\;\frac{x}{\frac{y}{y - z}}\\
\mathbf{else}:\\
\;\;\;\;\left(y - z\right) \cdot \frac{x}{y}\\
\end{array}
\end{array}
herbie shell --seed 2024157
(FPCore (x y z)
:name "Diagrams.Backend.Cairo.Internal:setTexture from diagrams-cairo-1.3.0.3"
:precision binary64
:alt
(! :herbie-platform default (if (< z -206020233192173900000000000000000000000000000000000000000000000000000000000000000000000000000000000000000) (- x (/ (* z x) y)) (if (< z 1693976601382852600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000) (/ x (/ y (- y z))) (* (- y z) (/ x y)))))
(/ (* x (- y z)) y))