
(FPCore (x y z) :precision binary64 (/ (* x y) (* (* z z) (+ z 1.0))))
double code(double x, double y, double z) {
return (x * y) / ((z * z) * (z + 1.0));
}
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) * (z + 1.0d0))
end function
public static double code(double x, double y, double z) {
return (x * y) / ((z * z) * (z + 1.0));
}
def code(x, y, z): return (x * y) / ((z * z) * (z + 1.0))
function code(x, y, z) return Float64(Float64(x * y) / Float64(Float64(z * z) * Float64(z + 1.0))) end
function tmp = code(x, y, z) tmp = (x * y) / ((z * z) * (z + 1.0)); end
code[x_, y_, z_] := N[(N[(x * y), $MachinePrecision] / N[(N[(z * z), $MachinePrecision] * N[(z + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x \cdot y}{\left(z \cdot z\right) \cdot \left(z + 1\right)}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 10 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 (/ (* x y) (* (* z z) (+ z 1.0))))
double code(double x, double y, double z) {
return (x * y) / ((z * z) * (z + 1.0));
}
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) * (z + 1.0d0))
end function
public static double code(double x, double y, double z) {
return (x * y) / ((z * z) * (z + 1.0));
}
def code(x, y, z): return (x * y) / ((z * z) * (z + 1.0))
function code(x, y, z) return Float64(Float64(x * y) / Float64(Float64(z * z) * Float64(z + 1.0))) end
function tmp = code(x, y, z) tmp = (x * y) / ((z * z) * (z + 1.0)); end
code[x_, y_, z_] := N[(N[(x * y), $MachinePrecision] / N[(N[(z * z), $MachinePrecision] * N[(z + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x \cdot y}{\left(z \cdot z\right) \cdot \left(z + 1\right)}
\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 (let* ((t_0 (/ (sqrt x_m) z))) (* x_s (* t_0 (* t_0 (/ 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 t_0 = sqrt(x_m) / z;
return x_s * (t_0 * (t_0 * (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
real(8) :: t_0
t_0 = sqrt(x_m) / z
code = x_s * (t_0 * (t_0 * (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) {
double t_0 = Math.sqrt(x_m) / z;
return x_s * (t_0 * (t_0 * (y / (z + 1.0))));
}
x\_m = math.fabs(x) x\_s = math.copysign(1.0, x) def code(x_s, x_m, y, z): t_0 = math.sqrt(x_m) / z return x_s * (t_0 * (t_0 * (y / (z + 1.0))))
x\_m = abs(x) x\_s = copysign(1.0, x) function code(x_s, x_m, y, z) t_0 = Float64(sqrt(x_m) / z) return Float64(x_s * Float64(t_0 * Float64(t_0 * Float64(y / Float64(z + 1.0))))) end
x\_m = abs(x); x\_s = sign(x) * abs(1.0); function tmp = code(x_s, x_m, y, z) t_0 = sqrt(x_m) / z; tmp = x_s * (t_0 * (t_0 * (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_] := Block[{t$95$0 = N[(N[Sqrt[x$95$m], $MachinePrecision] / z), $MachinePrecision]}, N[(x$95$s * N[(t$95$0 * N[(t$95$0 * N[(y / N[(z + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
x\_m = \left|x\right|
\\
x\_s = \mathsf{copysign}\left(1, x\right)
\\
\begin{array}{l}
t_0 := \frac{\sqrt{x\_m}}{z}\\
x\_s \cdot \left(t\_0 \cdot \left(t\_0 \cdot \frac{y}{z + 1}\right)\right)
\end{array}
\end{array}
Initial program 80.1%
times-frac85.5%
add-sqr-sqrt56.0%
associate-*l*56.0%
sqrt-div47.3%
sqrt-prod22.8%
add-sqr-sqrt32.6%
sqrt-div34.0%
sqrt-prod27.2%
add-sqr-sqrt55.6%
Applied egg-rr55.6%
Final simplification55.6%
x\_m = (fabs.f64 x)
x\_s = (copysign.f64 #s(literal 1 binary64) x)
(FPCore (x_s x_m y z)
:precision binary64
(let* ((t_0 (/ (/ x_m z) (* z (/ z y)))))
(*
x_s
(if (<= z -2.5e+15)
t_0
(if (<= z -3.6e-101)
(* y (/ (/ x_m (* z z)) (+ z 1.0)))
(if (<= z 1.0) (/ (* y (/ x_m z)) z) t_0))))))x\_m = fabs(x);
x\_s = copysign(1.0, x);
double code(double x_s, double x_m, double y, double z) {
double t_0 = (x_m / z) / (z * (z / y));
double tmp;
if (z <= -2.5e+15) {
tmp = t_0;
} else if (z <= -3.6e-101) {
tmp = y * ((x_m / (z * z)) / (z + 1.0));
} else if (z <= 1.0) {
tmp = (y * (x_m / z)) / z;
} else {
tmp = t_0;
}
return x_s * tmp;
}
x\_m = abs(x)
x\_s = copysign(1.0d0, x)
real(8) function code(x_s, x_m, y, z)
real(8), intent (in) :: x_s
real(8), intent (in) :: x_m
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: t_0
real(8) :: tmp
t_0 = (x_m / z) / (z * (z / y))
if (z <= (-2.5d+15)) then
tmp = t_0
else if (z <= (-3.6d-101)) then
tmp = y * ((x_m / (z * z)) / (z + 1.0d0))
else if (z <= 1.0d0) then
tmp = (y * (x_m / z)) / z
else
tmp = t_0
end if
code = x_s * tmp
end function
x\_m = Math.abs(x);
x\_s = Math.copySign(1.0, x);
public static double code(double x_s, double x_m, double y, double z) {
double t_0 = (x_m / z) / (z * (z / y));
double tmp;
if (z <= -2.5e+15) {
tmp = t_0;
} else if (z <= -3.6e-101) {
tmp = y * ((x_m / (z * z)) / (z + 1.0));
} else if (z <= 1.0) {
tmp = (y * (x_m / z)) / z;
} else {
tmp = t_0;
}
return x_s * tmp;
}
x\_m = math.fabs(x) x\_s = math.copysign(1.0, x) def code(x_s, x_m, y, z): t_0 = (x_m / z) / (z * (z / y)) tmp = 0 if z <= -2.5e+15: tmp = t_0 elif z <= -3.6e-101: tmp = y * ((x_m / (z * z)) / (z + 1.0)) elif z <= 1.0: tmp = (y * (x_m / z)) / z else: tmp = t_0 return x_s * tmp
x\_m = abs(x) x\_s = copysign(1.0, x) function code(x_s, x_m, y, z) t_0 = Float64(Float64(x_m / z) / Float64(z * Float64(z / y))) tmp = 0.0 if (z <= -2.5e+15) tmp = t_0; elseif (z <= -3.6e-101) tmp = Float64(y * Float64(Float64(x_m / Float64(z * z)) / Float64(z + 1.0))); elseif (z <= 1.0) tmp = Float64(Float64(y * Float64(x_m / z)) / z); else tmp = t_0; end return Float64(x_s * tmp) end
x\_m = abs(x); x\_s = sign(x) * abs(1.0); function tmp_2 = code(x_s, x_m, y, z) t_0 = (x_m / z) / (z * (z / y)); tmp = 0.0; if (z <= -2.5e+15) tmp = t_0; elseif (z <= -3.6e-101) tmp = y * ((x_m / (z * z)) / (z + 1.0)); elseif (z <= 1.0) tmp = (y * (x_m / z)) / z; else tmp = t_0; end tmp_2 = x_s * tmp; end
x\_m = N[Abs[x], $MachinePrecision]
x\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[x$95$s_, x$95$m_, y_, z_] := Block[{t$95$0 = N[(N[(x$95$m / z), $MachinePrecision] / N[(z * N[(z / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, N[(x$95$s * If[LessEqual[z, -2.5e+15], t$95$0, If[LessEqual[z, -3.6e-101], N[(y * N[(N[(x$95$m / N[(z * z), $MachinePrecision]), $MachinePrecision] / N[(z + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 1.0], N[(N[(y * N[(x$95$m / z), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision], t$95$0]]]), $MachinePrecision]]
\begin{array}{l}
x\_m = \left|x\right|
\\
x\_s = \mathsf{copysign}\left(1, x\right)
\\
\begin{array}{l}
t_0 := \frac{\frac{x\_m}{z}}{z \cdot \frac{z}{y}}\\
x\_s \cdot \begin{array}{l}
\mathbf{if}\;z \leq -2.5 \cdot 10^{+15}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq -3.6 \cdot 10^{-101}:\\
\;\;\;\;y \cdot \frac{\frac{x\_m}{z \cdot z}}{z + 1}\\
\mathbf{elif}\;z \leq 1:\\
\;\;\;\;\frac{y \cdot \frac{x\_m}{z}}{z}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
\end{array}
if z < -2.5e15 or 1 < z Initial program 78.2%
*-commutative78.2%
frac-times93.5%
associate-*l/92.0%
times-frac97.5%
Applied egg-rr97.5%
Taylor expanded in z around inf 96.8%
clear-num96.9%
frac-times96.0%
*-un-lft-identity96.0%
Applied egg-rr96.0%
if -2.5e15 < z < -3.6e-101Initial program 90.5%
*-commutative90.5%
associate-/l*90.2%
sqr-neg90.2%
associate-/r*90.2%
sqr-neg90.2%
Simplified90.2%
if -3.6e-101 < z < 1Initial program 80.1%
*-commutative80.1%
associate-/l*77.2%
sqr-neg77.2%
associate-/r*77.2%
sqr-neg77.2%
Simplified77.2%
associate-/r*77.2%
associate-*r/80.1%
frac-times79.6%
frac-2neg79.6%
associate-/r*92.8%
frac-times98.3%
+-commutative98.3%
distribute-neg-in98.3%
metadata-eval98.3%
Applied egg-rr98.3%
Taylor expanded in z around 0 97.1%
mul-1-neg97.1%
Simplified97.1%
*-commutative97.1%
associate-/l*91.6%
add-sqr-sqrt41.0%
sqrt-unprod31.4%
sqr-neg31.4%
sqrt-unprod0.4%
add-sqr-sqrt2.2%
add-sqr-sqrt0.1%
sqrt-unprod54.1%
sqr-neg54.1%
sqrt-unprod59.5%
add-sqr-sqrt91.6%
Applied egg-rr91.6%
associate-*r/97.1%
frac-2neg97.1%
associate-*r/87.8%
distribute-neg-frac287.8%
associate-*l/97.0%
*-commutative97.0%
distribute-lft-neg-in97.0%
add-sqr-sqrt52.9%
sqrt-unprod36.9%
sqr-neg36.9%
sqrt-unprod1.1%
add-sqr-sqrt2.2%
add-sqr-sqrt1.1%
sqrt-unprod36.1%
sqr-neg36.1%
sqrt-unprod43.9%
add-sqr-sqrt97.0%
Applied egg-rr97.0%
Final simplification96.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 (or (<= z -1.0) (not (<= z 1.0)))
(* (/ y z) (/ (/ x_m z) z))
(/ (* y (/ x_m z)) 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 ((z <= -1.0) || !(z <= 1.0)) {
tmp = (y / z) * ((x_m / z) / z);
} else {
tmp = (y * (x_m / z)) / 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 ((z <= (-1.0d0)) .or. (.not. (z <= 1.0d0))) then
tmp = (y / z) * ((x_m / z) / z)
else
tmp = (y * (x_m / z)) / 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 ((z <= -1.0) || !(z <= 1.0)) {
tmp = (y / z) * ((x_m / z) / z);
} else {
tmp = (y * (x_m / z)) / 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 (z <= -1.0) or not (z <= 1.0): tmp = (y / z) * ((x_m / z) / z) else: tmp = (y * (x_m / z)) / 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 ((z <= -1.0) || !(z <= 1.0)) tmp = Float64(Float64(y / z) * Float64(Float64(x_m / z) / z)); else tmp = Float64(Float64(y * Float64(x_m / z)) / 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 ((z <= -1.0) || ~((z <= 1.0))) tmp = (y / z) * ((x_m / z) / z); else tmp = (y * (x_m / z)) / 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[Or[LessEqual[z, -1.0], N[Not[LessEqual[z, 1.0]], $MachinePrecision]], N[(N[(y / z), $MachinePrecision] * N[(N[(x$95$m / z), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision], N[(N[(y * N[(x$95$m / z), $MachinePrecision]), $MachinePrecision] / z), $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 -1 \lor \neg \left(z \leq 1\right):\\
\;\;\;\;\frac{y}{z} \cdot \frac{\frac{x\_m}{z}}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{y \cdot \frac{x\_m}{z}}{z}\\
\end{array}
\end{array}
if z < -1 or 1 < z Initial program 78.8%
*-commutative78.8%
frac-times93.7%
associate-*l/92.2%
times-frac97.6%
Applied egg-rr97.6%
Taylor expanded in z around inf 95.6%
if -1 < z < 1Initial program 81.2%
*-commutative81.2%
associate-/l*78.6%
sqr-neg78.6%
associate-/r*78.6%
sqr-neg78.6%
Simplified78.6%
associate-/r*78.6%
associate-*r/81.2%
frac-times82.1%
frac-2neg82.1%
associate-/r*93.6%
frac-times97.1%
+-commutative97.1%
distribute-neg-in97.1%
metadata-eval97.1%
Applied egg-rr97.1%
Taylor expanded in z around 0 95.6%
mul-1-neg95.6%
Simplified95.6%
*-commutative95.6%
associate-/l*92.0%
add-sqr-sqrt40.3%
sqrt-unprod31.4%
sqr-neg31.4%
sqrt-unprod0.5%
add-sqr-sqrt2.2%
add-sqr-sqrt0.3%
sqrt-unprod47.7%
sqr-neg47.7%
sqrt-unprod52.2%
add-sqr-sqrt92.0%
Applied egg-rr92.0%
associate-*r/95.6%
frac-2neg95.6%
associate-*r/87.4%
distribute-neg-frac287.4%
associate-*l/94.9%
*-commutative94.9%
distribute-lft-neg-in94.9%
add-sqr-sqrt50.0%
sqrt-unprod34.8%
sqr-neg34.8%
sqrt-unprod1.2%
add-sqr-sqrt2.2%
add-sqr-sqrt1.0%
sqrt-unprod36.4%
sqr-neg36.4%
sqrt-unprod44.6%
add-sqr-sqrt94.9%
Applied egg-rr94.9%
Final simplification95.2%
x\_m = (fabs.f64 x)
x\_s = (copysign.f64 #s(literal 1 binary64) x)
(FPCore (x_s x_m y z)
:precision binary64
(*
x_s
(if (or (<= z -1.0) (not (<= z 1.0)))
(/ (/ x_m z) (* z (/ z y)))
(/ (* y (/ x_m z)) 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 ((z <= -1.0) || !(z <= 1.0)) {
tmp = (x_m / z) / (z * (z / y));
} else {
tmp = (y * (x_m / z)) / 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 ((z <= (-1.0d0)) .or. (.not. (z <= 1.0d0))) then
tmp = (x_m / z) / (z * (z / y))
else
tmp = (y * (x_m / z)) / 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 ((z <= -1.0) || !(z <= 1.0)) {
tmp = (x_m / z) / (z * (z / y));
} else {
tmp = (y * (x_m / z)) / 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 (z <= -1.0) or not (z <= 1.0): tmp = (x_m / z) / (z * (z / y)) else: tmp = (y * (x_m / z)) / 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 ((z <= -1.0) || !(z <= 1.0)) tmp = Float64(Float64(x_m / z) / Float64(z * Float64(z / y))); else tmp = Float64(Float64(y * Float64(x_m / z)) / 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 ((z <= -1.0) || ~((z <= 1.0))) tmp = (x_m / z) / (z * (z / y)); else tmp = (y * (x_m / z)) / 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[Or[LessEqual[z, -1.0], N[Not[LessEqual[z, 1.0]], $MachinePrecision]], N[(N[(x$95$m / z), $MachinePrecision] / N[(z * N[(z / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(y * N[(x$95$m / z), $MachinePrecision]), $MachinePrecision] / z), $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 -1 \lor \neg \left(z \leq 1\right):\\
\;\;\;\;\frac{\frac{x\_m}{z}}{z \cdot \frac{z}{y}}\\
\mathbf{else}:\\
\;\;\;\;\frac{y \cdot \frac{x\_m}{z}}{z}\\
\end{array}
\end{array}
if z < -1 or 1 < z Initial program 78.8%
*-commutative78.8%
frac-times93.7%
associate-*l/92.2%
times-frac97.6%
Applied egg-rr97.6%
Taylor expanded in z around inf 95.6%
clear-num95.6%
frac-times94.8%
*-un-lft-identity94.8%
Applied egg-rr94.8%
if -1 < z < 1Initial program 81.2%
*-commutative81.2%
associate-/l*78.6%
sqr-neg78.6%
associate-/r*78.6%
sqr-neg78.6%
Simplified78.6%
associate-/r*78.6%
associate-*r/81.2%
frac-times82.1%
frac-2neg82.1%
associate-/r*93.6%
frac-times97.1%
+-commutative97.1%
distribute-neg-in97.1%
metadata-eval97.1%
Applied egg-rr97.1%
Taylor expanded in z around 0 95.6%
mul-1-neg95.6%
Simplified95.6%
*-commutative95.6%
associate-/l*92.0%
add-sqr-sqrt40.3%
sqrt-unprod31.4%
sqr-neg31.4%
sqrt-unprod0.5%
add-sqr-sqrt2.2%
add-sqr-sqrt0.3%
sqrt-unprod47.7%
sqr-neg47.7%
sqrt-unprod52.2%
add-sqr-sqrt92.0%
Applied egg-rr92.0%
associate-*r/95.6%
frac-2neg95.6%
associate-*r/87.4%
distribute-neg-frac287.4%
associate-*l/94.9%
*-commutative94.9%
distribute-lft-neg-in94.9%
add-sqr-sqrt50.0%
sqrt-unprod34.8%
sqr-neg34.8%
sqrt-unprod1.2%
add-sqr-sqrt2.2%
add-sqr-sqrt1.0%
sqrt-unprod36.4%
sqr-neg36.4%
sqrt-unprod44.6%
add-sqr-sqrt94.9%
Applied egg-rr94.9%
Final simplification94.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 -1.0)
(* (/ x_m z) (/ y (* z z)))
(if (<= z 1.0) (/ (* y (/ x_m z)) z) (* (/ y z) (/ (/ x_m z) 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 (z <= -1.0) {
tmp = (x_m / z) * (y / (z * z));
} else if (z <= 1.0) {
tmp = (y * (x_m / z)) / z;
} else {
tmp = (y / z) * ((x_m / z) / 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 (z <= (-1.0d0)) then
tmp = (x_m / z) * (y / (z * z))
else if (z <= 1.0d0) then
tmp = (y * (x_m / z)) / z
else
tmp = (y / z) * ((x_m / z) / 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 (z <= -1.0) {
tmp = (x_m / z) * (y / (z * z));
} else if (z <= 1.0) {
tmp = (y * (x_m / z)) / z;
} else {
tmp = (y / z) * ((x_m / z) / 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 z <= -1.0: tmp = (x_m / z) * (y / (z * z)) elif z <= 1.0: tmp = (y * (x_m / z)) / z else: tmp = (y / z) * ((x_m / z) / 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 (z <= -1.0) tmp = Float64(Float64(x_m / z) * Float64(y / Float64(z * z))); elseif (z <= 1.0) tmp = Float64(Float64(y * Float64(x_m / z)) / z); else tmp = Float64(Float64(y / z) * Float64(Float64(x_m / z) / 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 (z <= -1.0) tmp = (x_m / z) * (y / (z * z)); elseif (z <= 1.0) tmp = (y * (x_m / z)) / z; else tmp = (y / z) * ((x_m / z) / 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[z, -1.0], N[(N[(x$95$m / z), $MachinePrecision] * N[(y / N[(z * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 1.0], N[(N[(y * N[(x$95$m / z), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision], N[(N[(y / z), $MachinePrecision] * N[(N[(x$95$m / z), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision]]]), $MachinePrecision]
\begin{array}{l}
x\_m = \left|x\right|
\\
x\_s = \mathsf{copysign}\left(1, x\right)
\\
x\_s \cdot \begin{array}{l}
\mathbf{if}\;z \leq -1:\\
\;\;\;\;\frac{x\_m}{z} \cdot \frac{y}{z \cdot z}\\
\mathbf{elif}\;z \leq 1:\\
\;\;\;\;\frac{y \cdot \frac{x\_m}{z}}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{z} \cdot \frac{\frac{x\_m}{z}}{z}\\
\end{array}
\end{array}
if z < -1Initial program 81.6%
*-commutative81.6%
sqr-neg81.6%
times-frac96.1%
sqr-neg96.1%
Simplified96.1%
Taylor expanded in z around inf 93.8%
if -1 < z < 1Initial program 81.2%
*-commutative81.2%
associate-/l*78.6%
sqr-neg78.6%
associate-/r*78.6%
sqr-neg78.6%
Simplified78.6%
associate-/r*78.6%
associate-*r/81.2%
frac-times82.1%
frac-2neg82.1%
associate-/r*93.6%
frac-times97.1%
+-commutative97.1%
distribute-neg-in97.1%
metadata-eval97.1%
Applied egg-rr97.1%
Taylor expanded in z around 0 95.6%
mul-1-neg95.6%
Simplified95.6%
*-commutative95.6%
associate-/l*92.0%
add-sqr-sqrt40.3%
sqrt-unprod31.4%
sqr-neg31.4%
sqrt-unprod0.5%
add-sqr-sqrt2.2%
add-sqr-sqrt0.3%
sqrt-unprod47.7%
sqr-neg47.7%
sqrt-unprod52.2%
add-sqr-sqrt92.0%
Applied egg-rr92.0%
associate-*r/95.6%
frac-2neg95.6%
associate-*r/87.4%
distribute-neg-frac287.4%
associate-*l/94.9%
*-commutative94.9%
distribute-lft-neg-in94.9%
add-sqr-sqrt50.0%
sqrt-unprod34.8%
sqr-neg34.8%
sqrt-unprod1.2%
add-sqr-sqrt2.2%
add-sqr-sqrt1.0%
sqrt-unprod36.4%
sqr-neg36.4%
sqrt-unprod44.6%
add-sqr-sqrt94.9%
Applied egg-rr94.9%
if 1 < z Initial program 75.0%
*-commutative75.0%
frac-times90.5%
associate-*l/90.4%
times-frac99.6%
Applied egg-rr99.6%
Taylor expanded in z around inf 98.0%
Final simplification95.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 (* (/ y z) (/ (/ x_m (+ z 1.0)) 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 * ((y / z) * ((x_m / (z + 1.0)) / 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 * ((y / z) * ((x_m / (z + 1.0d0)) / 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 * ((y / z) * ((x_m / (z + 1.0)) / z));
}
x\_m = math.fabs(x) x\_s = math.copysign(1.0, x) def code(x_s, x_m, y, z): return x_s * ((y / z) * ((x_m / (z + 1.0)) / z))
x\_m = abs(x) x\_s = copysign(1.0, x) function code(x_s, x_m, y, z) return Float64(x_s * Float64(Float64(y / z) * Float64(Float64(x_m / Float64(z + 1.0)) / 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 * ((y / z) * ((x_m / (z + 1.0)) / 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[(N[(y / z), $MachinePrecision] * N[(N[(x$95$m / N[(z + 1.0), $MachinePrecision]), $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(\frac{y}{z} \cdot \frac{\frac{x\_m}{z + 1}}{z}\right)
\end{array}
Initial program 80.1%
*-commutative80.1%
frac-times87.4%
associate-*l/86.2%
times-frac97.0%
Applied egg-rr97.0%
Final simplification97.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 (/ (* (/ y (+ z 1.0)) (/ x_m z)) 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 * (((y / (z + 1.0)) * (x_m / z)) / 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 * (((y / (z + 1.0d0)) * (x_m / z)) / 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 * (((y / (z + 1.0)) * (x_m / z)) / z);
}
x\_m = math.fabs(x) x\_s = math.copysign(1.0, x) def code(x_s, x_m, y, z): return x_s * (((y / (z + 1.0)) * (x_m / z)) / z)
x\_m = abs(x) x\_s = copysign(1.0, x) function code(x_s, x_m, y, z) return Float64(x_s * Float64(Float64(Float64(y / Float64(z + 1.0)) * Float64(x_m / z)) / 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 * (((y / (z + 1.0)) * (x_m / z)) / 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[(N[(N[(y / N[(z + 1.0), $MachinePrecision]), $MachinePrecision] * N[(x$95$m / z), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
x\_m = \left|x\right|
\\
x\_s = \mathsf{copysign}\left(1, x\right)
\\
x\_s \cdot \frac{\frac{y}{z + 1} \cdot \frac{x\_m}{z}}{z}
\end{array}
Initial program 80.1%
*-commutative80.1%
associate-/l*79.6%
sqr-neg79.6%
associate-/r*82.3%
sqr-neg82.3%
Simplified82.3%
associate-*r/84.1%
*-commutative84.1%
associate-*r/85.5%
associate-/r*89.9%
associate-*l/96.3%
Applied egg-rr96.3%
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 (* x_m (/ (/ y z) 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 * ((y / z) / 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 * ((y / z) / 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 * ((y / z) / 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 * ((y / z) / 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(y / z) / 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 * ((y / z) / 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[(y / z), $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 \cdot \frac{\frac{y}{z}}{z}\right)
\end{array}
Initial program 80.1%
*-commutative80.1%
associate-/l*79.6%
sqr-neg79.6%
associate-/r*82.3%
sqr-neg82.3%
Simplified82.3%
associate-/r*79.6%
associate-*r/80.1%
frac-times87.4%
frac-2neg87.4%
associate-/r*95.1%
frac-times95.1%
+-commutative95.1%
distribute-neg-in95.1%
metadata-eval95.1%
Applied egg-rr95.1%
Taylor expanded in z around 0 74.4%
mul-1-neg74.4%
Simplified74.4%
*-commutative74.4%
associate-/l*74.3%
add-sqr-sqrt31.1%
sqrt-unprod36.2%
sqr-neg36.2%
sqrt-unprod15.2%
add-sqr-sqrt25.3%
add-sqr-sqrt14.7%
sqrt-unprod52.0%
sqr-neg52.0%
sqrt-unprod39.1%
add-sqr-sqrt74.3%
Applied egg-rr74.3%
Final simplification74.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 (* y (/ (/ x_m z) 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 * (y * ((x_m / z) / 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 * (y * ((x_m / z) / 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 * (y * ((x_m / z) / z));
}
x\_m = math.fabs(x) x\_s = math.copysign(1.0, x) def code(x_s, x_m, y, z): return x_s * (y * ((x_m / z) / z))
x\_m = abs(x) x\_s = copysign(1.0, x) function code(x_s, x_m, y, z) return Float64(x_s * Float64(y * Float64(Float64(x_m / z) / 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 * (y * ((x_m / z) / 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[(y * N[(N[(x$95$m / z), $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(y \cdot \frac{\frac{x\_m}{z}}{z}\right)
\end{array}
Initial program 80.1%
*-commutative80.1%
associate-/l*79.6%
sqr-neg79.6%
associate-/r*82.3%
sqr-neg82.3%
Simplified82.3%
*-commutative82.3%
clear-num82.1%
associate-*l/82.2%
associate-/r/82.8%
frac-times87.0%
associate-/r*94.7%
frac-times97.2%
*-un-lft-identity97.2%
Applied egg-rr97.2%
Taylor expanded in z around 0 74.5%
associate-/l/68.7%
add-sqr-sqrt34.3%
sqrt-unprod39.8%
sqr-neg39.8%
sqrt-unprod11.4%
add-sqr-sqrt24.0%
*-un-lft-identity24.0%
frac-times23.7%
clear-num23.7%
associate-/l*22.6%
*-commutative22.6%
*-un-lft-identity22.6%
times-frac24.0%
add-sqr-sqrt11.4%
sqrt-unprod39.5%
sqr-neg39.5%
sqrt-unprod33.5%
add-sqr-sqrt67.6%
/-rgt-identity67.6%
Applied egg-rr67.6%
Final simplification67.6%
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 (/ y (* z (/ 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) {
return x_s * (y / (z * (z / 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 * (y / (z * (z / 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 * (y / (z * (z / 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 * (y / (z * (z / x_m)))
x\_m = abs(x) x\_s = copysign(1.0, x) function code(x_s, x_m, y, z) return Float64(x_s * Float64(y / Float64(z * Float64(z / 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 * (y / (z * (z / 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 * N[(y / N[(z * N[(z / x$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
x\_m = \left|x\right|
\\
x\_s = \mathsf{copysign}\left(1, x\right)
\\
x\_s \cdot \frac{y}{z \cdot \frac{z}{x\_m}}
\end{array}
Initial program 80.1%
*-commutative80.1%
frac-times87.4%
associate-*l/86.2%
times-frac97.0%
Applied egg-rr97.0%
*-commutative97.0%
clear-num96.9%
frac-times86.3%
*-un-lft-identity86.3%
div-inv86.3%
clear-num86.3%
Applied egg-rr86.3%
Taylor expanded in z around 0 68.7%
Final simplification68.7%
(FPCore (x y z) :precision binary64 (if (< z 249.6182814532307) (/ (* y (/ x z)) (+ z (* z z))) (/ (* (/ (/ y z) (+ 1.0 z)) x) z)))
double code(double x, double y, double z) {
double tmp;
if (z < 249.6182814532307) {
tmp = (y * (x / z)) / (z + (z * z));
} else {
tmp = (((y / z) / (1.0 + z)) * x) / z;
}
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 < 249.6182814532307d0) then
tmp = (y * (x / z)) / (z + (z * z))
else
tmp = (((y / z) / (1.0d0 + z)) * x) / z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z < 249.6182814532307) {
tmp = (y * (x / z)) / (z + (z * z));
} else {
tmp = (((y / z) / (1.0 + z)) * x) / z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z < 249.6182814532307: tmp = (y * (x / z)) / (z + (z * z)) else: tmp = (((y / z) / (1.0 + z)) * x) / z return tmp
function code(x, y, z) tmp = 0.0 if (z < 249.6182814532307) tmp = Float64(Float64(y * Float64(x / z)) / Float64(z + Float64(z * z))); else tmp = Float64(Float64(Float64(Float64(y / z) / Float64(1.0 + z)) * x) / z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z < 249.6182814532307) tmp = (y * (x / z)) / (z + (z * z)); else tmp = (((y / z) / (1.0 + z)) * x) / z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Less[z, 249.6182814532307], N[(N[(y * N[(x / z), $MachinePrecision]), $MachinePrecision] / N[(z + N[(z * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(y / z), $MachinePrecision] / N[(1.0 + z), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision] / z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z < 249.6182814532307:\\
\;\;\;\;\frac{y \cdot \frac{x}{z}}{z + z \cdot z}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\frac{y}{z}}{1 + z} \cdot x}{z}\\
\end{array}
\end{array}
herbie shell --seed 2024078
(FPCore (x y z)
:name "Statistics.Distribution.Beta:$cvariance from math-functions-0.1.5.2"
:precision binary64
:alt
(if (< z 249.6182814532307) (/ (* y (/ x z)) (+ z (* z z))) (/ (* (/ (/ y z) (+ 1.0 z)) x) z))
(/ (* x y) (* (* z z) (+ z 1.0))))