
(FPCore (c0 w h D d M) :precision binary64 (let* ((t_0 (/ (* c0 (* d d)) (* (* w h) (* D D))))) (* (/ c0 (* 2.0 w)) (+ t_0 (sqrt (- (* t_0 t_0) (* M M)))))))
double code(double c0, double w, double h, double D, double d, double M) {
double t_0 = (c0 * (d * d)) / ((w * h) * (D * D));
return (c0 / (2.0 * w)) * (t_0 + sqrt(((t_0 * t_0) - (M * M))));
}
real(8) function code(c0, w, h, d, d_1, m)
real(8), intent (in) :: c0
real(8), intent (in) :: w
real(8), intent (in) :: h
real(8), intent (in) :: d
real(8), intent (in) :: d_1
real(8), intent (in) :: m
real(8) :: t_0
t_0 = (c0 * (d_1 * d_1)) / ((w * h) * (d * d))
code = (c0 / (2.0d0 * w)) * (t_0 + sqrt(((t_0 * t_0) - (m * m))))
end function
public static double code(double c0, double w, double h, double D, double d, double M) {
double t_0 = (c0 * (d * d)) / ((w * h) * (D * D));
return (c0 / (2.0 * w)) * (t_0 + Math.sqrt(((t_0 * t_0) - (M * M))));
}
def code(c0, w, h, D, d, M): t_0 = (c0 * (d * d)) / ((w * h) * (D * D)) return (c0 / (2.0 * w)) * (t_0 + math.sqrt(((t_0 * t_0) - (M * M))))
function code(c0, w, h, D, d, M) t_0 = Float64(Float64(c0 * Float64(d * d)) / Float64(Float64(w * h) * Float64(D * D))) return Float64(Float64(c0 / Float64(2.0 * w)) * Float64(t_0 + sqrt(Float64(Float64(t_0 * t_0) - Float64(M * M))))) end
function tmp = code(c0, w, h, D, d, M) t_0 = (c0 * (d * d)) / ((w * h) * (D * D)); tmp = (c0 / (2.0 * w)) * (t_0 + sqrt(((t_0 * t_0) - (M * M)))); end
code[c0_, w_, h_, D_, d_, M_] := Block[{t$95$0 = N[(N[(c0 * N[(d * d), $MachinePrecision]), $MachinePrecision] / N[(N[(w * h), $MachinePrecision] * N[(D * D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, N[(N[(c0 / N[(2.0 * w), $MachinePrecision]), $MachinePrecision] * N[(t$95$0 + N[Sqrt[N[(N[(t$95$0 * t$95$0), $MachinePrecision] - N[(M * M), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)}\\
\frac{c0}{2 \cdot w} \cdot \left(t\_0 + \sqrt{t\_0 \cdot t\_0 - M \cdot M}\right)
\end{array}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 9 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (c0 w h D d M) :precision binary64 (let* ((t_0 (/ (* c0 (* d d)) (* (* w h) (* D D))))) (* (/ c0 (* 2.0 w)) (+ t_0 (sqrt (- (* t_0 t_0) (* M M)))))))
double code(double c0, double w, double h, double D, double d, double M) {
double t_0 = (c0 * (d * d)) / ((w * h) * (D * D));
return (c0 / (2.0 * w)) * (t_0 + sqrt(((t_0 * t_0) - (M * M))));
}
real(8) function code(c0, w, h, d, d_1, m)
real(8), intent (in) :: c0
real(8), intent (in) :: w
real(8), intent (in) :: h
real(8), intent (in) :: d
real(8), intent (in) :: d_1
real(8), intent (in) :: m
real(8) :: t_0
t_0 = (c0 * (d_1 * d_1)) / ((w * h) * (d * d))
code = (c0 / (2.0d0 * w)) * (t_0 + sqrt(((t_0 * t_0) - (m * m))))
end function
public static double code(double c0, double w, double h, double D, double d, double M) {
double t_0 = (c0 * (d * d)) / ((w * h) * (D * D));
return (c0 / (2.0 * w)) * (t_0 + Math.sqrt(((t_0 * t_0) - (M * M))));
}
def code(c0, w, h, D, d, M): t_0 = (c0 * (d * d)) / ((w * h) * (D * D)) return (c0 / (2.0 * w)) * (t_0 + math.sqrt(((t_0 * t_0) - (M * M))))
function code(c0, w, h, D, d, M) t_0 = Float64(Float64(c0 * Float64(d * d)) / Float64(Float64(w * h) * Float64(D * D))) return Float64(Float64(c0 / Float64(2.0 * w)) * Float64(t_0 + sqrt(Float64(Float64(t_0 * t_0) - Float64(M * M))))) end
function tmp = code(c0, w, h, D, d, M) t_0 = (c0 * (d * d)) / ((w * h) * (D * D)); tmp = (c0 / (2.0 * w)) * (t_0 + sqrt(((t_0 * t_0) - (M * M)))); end
code[c0_, w_, h_, D_, d_, M_] := Block[{t$95$0 = N[(N[(c0 * N[(d * d), $MachinePrecision]), $MachinePrecision] / N[(N[(w * h), $MachinePrecision] * N[(D * D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, N[(N[(c0 / N[(2.0 * w), $MachinePrecision]), $MachinePrecision] * N[(t$95$0 + N[Sqrt[N[(N[(t$95$0 * t$95$0), $MachinePrecision] - N[(M * M), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)}\\
\frac{c0}{2 \cdot w} \cdot \left(t\_0 + \sqrt{t\_0 \cdot t\_0 - M \cdot M}\right)
\end{array}
\end{array}
M_m = (fabs.f64 M)
(FPCore (c0 w h D d M_m)
:precision binary64
(let* ((t_0 (* h (pow w 2.0))) (t_1 (* c0 (/ d D))) (t_2 (* c0 (/ 0.0 w))))
(if (<= M_m 1.85e-221)
(* c0 (/ (* (/ (* c0 d) D) (/ d D)) t_0))
(if (<= M_m 1.55e-70)
t_2
(if (<= M_m 17000.0)
(* c0 (* (/ t_1 h) (/ (/ d D) (pow w 2.0))))
(if (<= M_m 6.3e+32)
t_2
(if (<= M_m 6e+68)
(* c0 (/ (* (/ d D) t_1) t_0))
(if (<= M_m 9.2e+111)
t_2
(*
(/ c0 (* 2.0 w))
(+ M_m (/ (* (/ c0 w) (pow (/ d D) 2.0)) h)))))))))))M_m = fabs(M);
double code(double c0, double w, double h, double D, double d, double M_m) {
double t_0 = h * pow(w, 2.0);
double t_1 = c0 * (d / D);
double t_2 = c0 * (0.0 / w);
double tmp;
if (M_m <= 1.85e-221) {
tmp = c0 * ((((c0 * d) / D) * (d / D)) / t_0);
} else if (M_m <= 1.55e-70) {
tmp = t_2;
} else if (M_m <= 17000.0) {
tmp = c0 * ((t_1 / h) * ((d / D) / pow(w, 2.0)));
} else if (M_m <= 6.3e+32) {
tmp = t_2;
} else if (M_m <= 6e+68) {
tmp = c0 * (((d / D) * t_1) / t_0);
} else if (M_m <= 9.2e+111) {
tmp = t_2;
} else {
tmp = (c0 / (2.0 * w)) * (M_m + (((c0 / w) * pow((d / D), 2.0)) / h));
}
return tmp;
}
M_m = abs(m)
real(8) function code(c0, w, h, d, d_1, m_m)
real(8), intent (in) :: c0
real(8), intent (in) :: w
real(8), intent (in) :: h
real(8), intent (in) :: d
real(8), intent (in) :: d_1
real(8), intent (in) :: m_m
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = h * (w ** 2.0d0)
t_1 = c0 * (d_1 / d)
t_2 = c0 * (0.0d0 / w)
if (m_m <= 1.85d-221) then
tmp = c0 * ((((c0 * d_1) / d) * (d_1 / d)) / t_0)
else if (m_m <= 1.55d-70) then
tmp = t_2
else if (m_m <= 17000.0d0) then
tmp = c0 * ((t_1 / h) * ((d_1 / d) / (w ** 2.0d0)))
else if (m_m <= 6.3d+32) then
tmp = t_2
else if (m_m <= 6d+68) then
tmp = c0 * (((d_1 / d) * t_1) / t_0)
else if (m_m <= 9.2d+111) then
tmp = t_2
else
tmp = (c0 / (2.0d0 * w)) * (m_m + (((c0 / w) * ((d_1 / d) ** 2.0d0)) / h))
end if
code = tmp
end function
M_m = Math.abs(M);
public static double code(double c0, double w, double h, double D, double d, double M_m) {
double t_0 = h * Math.pow(w, 2.0);
double t_1 = c0 * (d / D);
double t_2 = c0 * (0.0 / w);
double tmp;
if (M_m <= 1.85e-221) {
tmp = c0 * ((((c0 * d) / D) * (d / D)) / t_0);
} else if (M_m <= 1.55e-70) {
tmp = t_2;
} else if (M_m <= 17000.0) {
tmp = c0 * ((t_1 / h) * ((d / D) / Math.pow(w, 2.0)));
} else if (M_m <= 6.3e+32) {
tmp = t_2;
} else if (M_m <= 6e+68) {
tmp = c0 * (((d / D) * t_1) / t_0);
} else if (M_m <= 9.2e+111) {
tmp = t_2;
} else {
tmp = (c0 / (2.0 * w)) * (M_m + (((c0 / w) * Math.pow((d / D), 2.0)) / h));
}
return tmp;
}
M_m = math.fabs(M) def code(c0, w, h, D, d, M_m): t_0 = h * math.pow(w, 2.0) t_1 = c0 * (d / D) t_2 = c0 * (0.0 / w) tmp = 0 if M_m <= 1.85e-221: tmp = c0 * ((((c0 * d) / D) * (d / D)) / t_0) elif M_m <= 1.55e-70: tmp = t_2 elif M_m <= 17000.0: tmp = c0 * ((t_1 / h) * ((d / D) / math.pow(w, 2.0))) elif M_m <= 6.3e+32: tmp = t_2 elif M_m <= 6e+68: tmp = c0 * (((d / D) * t_1) / t_0) elif M_m <= 9.2e+111: tmp = t_2 else: tmp = (c0 / (2.0 * w)) * (M_m + (((c0 / w) * math.pow((d / D), 2.0)) / h)) return tmp
M_m = abs(M) function code(c0, w, h, D, d, M_m) t_0 = Float64(h * (w ^ 2.0)) t_1 = Float64(c0 * Float64(d / D)) t_2 = Float64(c0 * Float64(0.0 / w)) tmp = 0.0 if (M_m <= 1.85e-221) tmp = Float64(c0 * Float64(Float64(Float64(Float64(c0 * d) / D) * Float64(d / D)) / t_0)); elseif (M_m <= 1.55e-70) tmp = t_2; elseif (M_m <= 17000.0) tmp = Float64(c0 * Float64(Float64(t_1 / h) * Float64(Float64(d / D) / (w ^ 2.0)))); elseif (M_m <= 6.3e+32) tmp = t_2; elseif (M_m <= 6e+68) tmp = Float64(c0 * Float64(Float64(Float64(d / D) * t_1) / t_0)); elseif (M_m <= 9.2e+111) tmp = t_2; else tmp = Float64(Float64(c0 / Float64(2.0 * w)) * Float64(M_m + Float64(Float64(Float64(c0 / w) * (Float64(d / D) ^ 2.0)) / h))); end return tmp end
M_m = abs(M); function tmp_2 = code(c0, w, h, D, d, M_m) t_0 = h * (w ^ 2.0); t_1 = c0 * (d / D); t_2 = c0 * (0.0 / w); tmp = 0.0; if (M_m <= 1.85e-221) tmp = c0 * ((((c0 * d) / D) * (d / D)) / t_0); elseif (M_m <= 1.55e-70) tmp = t_2; elseif (M_m <= 17000.0) tmp = c0 * ((t_1 / h) * ((d / D) / (w ^ 2.0))); elseif (M_m <= 6.3e+32) tmp = t_2; elseif (M_m <= 6e+68) tmp = c0 * (((d / D) * t_1) / t_0); elseif (M_m <= 9.2e+111) tmp = t_2; else tmp = (c0 / (2.0 * w)) * (M_m + (((c0 / w) * ((d / D) ^ 2.0)) / h)); end tmp_2 = tmp; end
M_m = N[Abs[M], $MachinePrecision]
code[c0_, w_, h_, D_, d_, M$95$m_] := Block[{t$95$0 = N[(h * N[Power[w, 2.0], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(c0 * N[(d / D), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(c0 * N[(0.0 / w), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[M$95$m, 1.85e-221], N[(c0 * N[(N[(N[(N[(c0 * d), $MachinePrecision] / D), $MachinePrecision] * N[(d / D), $MachinePrecision]), $MachinePrecision] / t$95$0), $MachinePrecision]), $MachinePrecision], If[LessEqual[M$95$m, 1.55e-70], t$95$2, If[LessEqual[M$95$m, 17000.0], N[(c0 * N[(N[(t$95$1 / h), $MachinePrecision] * N[(N[(d / D), $MachinePrecision] / N[Power[w, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[M$95$m, 6.3e+32], t$95$2, If[LessEqual[M$95$m, 6e+68], N[(c0 * N[(N[(N[(d / D), $MachinePrecision] * t$95$1), $MachinePrecision] / t$95$0), $MachinePrecision]), $MachinePrecision], If[LessEqual[M$95$m, 9.2e+111], t$95$2, N[(N[(c0 / N[(2.0 * w), $MachinePrecision]), $MachinePrecision] * N[(M$95$m + N[(N[(N[(c0 / w), $MachinePrecision] * N[Power[N[(d / D), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / h), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]]]
\begin{array}{l}
M_m = \left|M\right|
\\
\begin{array}{l}
t_0 := h \cdot {w}^{2}\\
t_1 := c0 \cdot \frac{d}{D}\\
t_2 := c0 \cdot \frac{0}{w}\\
\mathbf{if}\;M\_m \leq 1.85 \cdot 10^{-221}:\\
\;\;\;\;c0 \cdot \frac{\frac{c0 \cdot d}{D} \cdot \frac{d}{D}}{t\_0}\\
\mathbf{elif}\;M\_m \leq 1.55 \cdot 10^{-70}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;M\_m \leq 17000:\\
\;\;\;\;c0 \cdot \left(\frac{t\_1}{h} \cdot \frac{\frac{d}{D}}{{w}^{2}}\right)\\
\mathbf{elif}\;M\_m \leq 6.3 \cdot 10^{+32}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;M\_m \leq 6 \cdot 10^{+68}:\\
\;\;\;\;c0 \cdot \frac{\frac{d}{D} \cdot t\_1}{t\_0}\\
\mathbf{elif}\;M\_m \leq 9.2 \cdot 10^{+111}:\\
\;\;\;\;t\_2\\
\mathbf{else}:\\
\;\;\;\;\frac{c0}{2 \cdot w} \cdot \left(M\_m + \frac{\frac{c0}{w} \cdot {\left(\frac{d}{D}\right)}^{2}}{h}\right)\\
\end{array}
\end{array}
if M < 1.84999999999999993e-221Initial program 28.4%
Simplified44.9%
Taylor expanded in c0 around inf 30.9%
associate-/r*30.5%
Simplified30.5%
associate-/l*31.2%
unpow231.2%
unpow231.2%
frac-times40.1%
associate-*r*42.9%
Applied egg-rr42.9%
Taylor expanded in c0 around 0 41.9%
if 1.84999999999999993e-221 < M < 1.55e-70 or 17000 < M < 6.3000000000000002e32 or 6.0000000000000004e68 < M < 9.20000000000000008e111Initial program 16.1%
Simplified20.3%
Taylor expanded in c0 around -inf 9.2%
associate-*r/9.2%
distribute-lft-in7.4%
mul-1-neg7.4%
distribute-rgt-neg-in7.4%
associate-/l*5.5%
mul-1-neg5.5%
associate-/l*7.2%
distribute-lft1-in7.2%
metadata-eval7.2%
mul0-lft55.7%
metadata-eval55.7%
Simplified55.7%
if 1.55e-70 < M < 17000Initial program 47.0%
Simplified64.8%
Taylor expanded in c0 around inf 44.6%
associate-/r*47.4%
Simplified47.4%
associate-/l*47.5%
unpow247.5%
unpow247.5%
frac-times65.6%
associate-*r*71.4%
Applied egg-rr71.4%
times-frac71.5%
Applied egg-rr71.5%
if 6.3000000000000002e32 < M < 6.0000000000000004e68Initial program 30.4%
Simplified31.9%
Taylor expanded in c0 around inf 31.5%
associate-/r*45.1%
Simplified45.1%
associate-/l*45.1%
unpow245.1%
unpow245.1%
frac-times59.4%
associate-*r*59.4%
Applied egg-rr59.4%
if 9.20000000000000008e111 < M Initial program 7.7%
Simplified7.7%
*-commutative7.7%
fma-define7.7%
times-frac7.7%
pow27.7%
frac-times7.7%
frac-times7.7%
Applied egg-rr11.5%
fma-undefine11.5%
*-commutative11.5%
associate-/r*11.5%
unpow211.5%
unpow211.5%
difference-of-squares42.5%
add-sqr-sqrt42.5%
sqrt-prod42.5%
sqr-neg42.5%
sqrt-unprod0.0%
add-sqr-sqrt42.5%
fma-undefine42.5%
unsub-neg42.5%
fma-undefine42.5%
Applied egg-rr66.1%
associate-*l/66.1%
Applied egg-rr66.1%
Taylor expanded in c0 around 0 63.1%
Final simplification49.6%
M_m = (fabs.f64 M)
(FPCore (c0 w h D d M_m)
:precision binary64
(let* ((t_0 (/ (* c0 (* d d)) (* (* w h) (* D D))))
(t_1 (* (/ c0 (* 2.0 w)) (+ t_0 (sqrt (- (* t_0 t_0) (* M_m M_m)))))))
(if (<= t_1 INFINITY) t_1 (* c0 (/ 0.0 w)))))M_m = fabs(M);
double code(double c0, double w, double h, double D, double d, double M_m) {
double t_0 = (c0 * (d * d)) / ((w * h) * (D * D));
double t_1 = (c0 / (2.0 * w)) * (t_0 + sqrt(((t_0 * t_0) - (M_m * M_m))));
double tmp;
if (t_1 <= ((double) INFINITY)) {
tmp = t_1;
} else {
tmp = c0 * (0.0 / w);
}
return tmp;
}
M_m = Math.abs(M);
public static double code(double c0, double w, double h, double D, double d, double M_m) {
double t_0 = (c0 * (d * d)) / ((w * h) * (D * D));
double t_1 = (c0 / (2.0 * w)) * (t_0 + Math.sqrt(((t_0 * t_0) - (M_m * M_m))));
double tmp;
if (t_1 <= Double.POSITIVE_INFINITY) {
tmp = t_1;
} else {
tmp = c0 * (0.0 / w);
}
return tmp;
}
M_m = math.fabs(M) def code(c0, w, h, D, d, M_m): t_0 = (c0 * (d * d)) / ((w * h) * (D * D)) t_1 = (c0 / (2.0 * w)) * (t_0 + math.sqrt(((t_0 * t_0) - (M_m * M_m)))) tmp = 0 if t_1 <= math.inf: tmp = t_1 else: tmp = c0 * (0.0 / w) return tmp
M_m = abs(M) function code(c0, w, h, D, d, M_m) t_0 = Float64(Float64(c0 * Float64(d * d)) / Float64(Float64(w * h) * Float64(D * D))) t_1 = Float64(Float64(c0 / Float64(2.0 * w)) * Float64(t_0 + sqrt(Float64(Float64(t_0 * t_0) - Float64(M_m * M_m))))) tmp = 0.0 if (t_1 <= Inf) tmp = t_1; else tmp = Float64(c0 * Float64(0.0 / w)); end return tmp end
M_m = abs(M); function tmp_2 = code(c0, w, h, D, d, M_m) t_0 = (c0 * (d * d)) / ((w * h) * (D * D)); t_1 = (c0 / (2.0 * w)) * (t_0 + sqrt(((t_0 * t_0) - (M_m * M_m)))); tmp = 0.0; if (t_1 <= Inf) tmp = t_1; else tmp = c0 * (0.0 / w); end tmp_2 = tmp; end
M_m = N[Abs[M], $MachinePrecision]
code[c0_, w_, h_, D_, d_, M$95$m_] := Block[{t$95$0 = N[(N[(c0 * N[(d * d), $MachinePrecision]), $MachinePrecision] / N[(N[(w * h), $MachinePrecision] * N[(D * D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(c0 / N[(2.0 * w), $MachinePrecision]), $MachinePrecision] * N[(t$95$0 + N[Sqrt[N[(N[(t$95$0 * t$95$0), $MachinePrecision] - N[(M$95$m * M$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, Infinity], t$95$1, N[(c0 * N[(0.0 / w), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
M_m = \left|M\right|
\\
\begin{array}{l}
t_0 := \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)}\\
t_1 := \frac{c0}{2 \cdot w} \cdot \left(t\_0 + \sqrt{t\_0 \cdot t\_0 - M\_m \cdot M\_m}\right)\\
\mathbf{if}\;t\_1 \leq \infty:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;c0 \cdot \frac{0}{w}\\
\end{array}
\end{array}
if (*.f64 (/.f64 c0 (*.f64 #s(literal 2 binary64) w)) (+.f64 (/.f64 (*.f64 c0 (*.f64 d d)) (*.f64 (*.f64 w h) (*.f64 D D))) (sqrt.f64 (-.f64 (*.f64 (/.f64 (*.f64 c0 (*.f64 d d)) (*.f64 (*.f64 w h) (*.f64 D D))) (/.f64 (*.f64 c0 (*.f64 d d)) (*.f64 (*.f64 w h) (*.f64 D D)))) (*.f64 M M))))) < +inf.0Initial program 76.7%
if +inf.0 < (*.f64 (/.f64 c0 (*.f64 #s(literal 2 binary64) w)) (+.f64 (/.f64 (*.f64 c0 (*.f64 d d)) (*.f64 (*.f64 w h) (*.f64 D D))) (sqrt.f64 (-.f64 (*.f64 (/.f64 (*.f64 c0 (*.f64 d d)) (*.f64 (*.f64 w h) (*.f64 D D))) (/.f64 (*.f64 c0 (*.f64 d d)) (*.f64 (*.f64 w h) (*.f64 D D)))) (*.f64 M M))))) Initial program 0.0%
Simplified25.7%
Taylor expanded in c0 around -inf 0.9%
associate-*r/0.9%
distribute-lft-in0.2%
mul-1-neg0.2%
distribute-rgt-neg-in0.2%
associate-/l*0.7%
mul-1-neg0.7%
associate-/l*0.1%
distribute-lft1-in0.1%
metadata-eval0.1%
mul0-lft43.5%
metadata-eval43.5%
Simplified43.5%
Final simplification54.3%
M_m = (fabs.f64 M)
(FPCore (c0 w h D d M_m)
:precision binary64
(let* ((t_0 (* h (pow w 2.0))) (t_1 (* c0 (/ d D))) (t_2 (* c0 (/ 0.0 w))))
(if (<= M_m 2.4e-221)
(* c0 (/ (* (/ (* c0 d) D) (/ d D)) t_0))
(if (<= M_m 2.05e-69)
t_2
(if (<= M_m 18000.0)
(* c0 (* (/ t_1 h) (/ (/ d D) (pow w 2.0))))
(if (<= M_m 3.6e+32)
t_2
(if (<= M_m 2.05e+65)
(* c0 (/ (* (/ d D) t_1) t_0))
(if (<= M_m 1.6e+111)
t_2
(*
(/ c0 (* 2.0 w))
(+ M_m (* (pow (/ d D) 2.0) (/ (/ c0 w) h))))))))))))M_m = fabs(M);
double code(double c0, double w, double h, double D, double d, double M_m) {
double t_0 = h * pow(w, 2.0);
double t_1 = c0 * (d / D);
double t_2 = c0 * (0.0 / w);
double tmp;
if (M_m <= 2.4e-221) {
tmp = c0 * ((((c0 * d) / D) * (d / D)) / t_0);
} else if (M_m <= 2.05e-69) {
tmp = t_2;
} else if (M_m <= 18000.0) {
tmp = c0 * ((t_1 / h) * ((d / D) / pow(w, 2.0)));
} else if (M_m <= 3.6e+32) {
tmp = t_2;
} else if (M_m <= 2.05e+65) {
tmp = c0 * (((d / D) * t_1) / t_0);
} else if (M_m <= 1.6e+111) {
tmp = t_2;
} else {
tmp = (c0 / (2.0 * w)) * (M_m + (pow((d / D), 2.0) * ((c0 / w) / h)));
}
return tmp;
}
M_m = abs(m)
real(8) function code(c0, w, h, d, d_1, m_m)
real(8), intent (in) :: c0
real(8), intent (in) :: w
real(8), intent (in) :: h
real(8), intent (in) :: d
real(8), intent (in) :: d_1
real(8), intent (in) :: m_m
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = h * (w ** 2.0d0)
t_1 = c0 * (d_1 / d)
t_2 = c0 * (0.0d0 / w)
if (m_m <= 2.4d-221) then
tmp = c0 * ((((c0 * d_1) / d) * (d_1 / d)) / t_0)
else if (m_m <= 2.05d-69) then
tmp = t_2
else if (m_m <= 18000.0d0) then
tmp = c0 * ((t_1 / h) * ((d_1 / d) / (w ** 2.0d0)))
else if (m_m <= 3.6d+32) then
tmp = t_2
else if (m_m <= 2.05d+65) then
tmp = c0 * (((d_1 / d) * t_1) / t_0)
else if (m_m <= 1.6d+111) then
tmp = t_2
else
tmp = (c0 / (2.0d0 * w)) * (m_m + (((d_1 / d) ** 2.0d0) * ((c0 / w) / h)))
end if
code = tmp
end function
M_m = Math.abs(M);
public static double code(double c0, double w, double h, double D, double d, double M_m) {
double t_0 = h * Math.pow(w, 2.0);
double t_1 = c0 * (d / D);
double t_2 = c0 * (0.0 / w);
double tmp;
if (M_m <= 2.4e-221) {
tmp = c0 * ((((c0 * d) / D) * (d / D)) / t_0);
} else if (M_m <= 2.05e-69) {
tmp = t_2;
} else if (M_m <= 18000.0) {
tmp = c0 * ((t_1 / h) * ((d / D) / Math.pow(w, 2.0)));
} else if (M_m <= 3.6e+32) {
tmp = t_2;
} else if (M_m <= 2.05e+65) {
tmp = c0 * (((d / D) * t_1) / t_0);
} else if (M_m <= 1.6e+111) {
tmp = t_2;
} else {
tmp = (c0 / (2.0 * w)) * (M_m + (Math.pow((d / D), 2.0) * ((c0 / w) / h)));
}
return tmp;
}
M_m = math.fabs(M) def code(c0, w, h, D, d, M_m): t_0 = h * math.pow(w, 2.0) t_1 = c0 * (d / D) t_2 = c0 * (0.0 / w) tmp = 0 if M_m <= 2.4e-221: tmp = c0 * ((((c0 * d) / D) * (d / D)) / t_0) elif M_m <= 2.05e-69: tmp = t_2 elif M_m <= 18000.0: tmp = c0 * ((t_1 / h) * ((d / D) / math.pow(w, 2.0))) elif M_m <= 3.6e+32: tmp = t_2 elif M_m <= 2.05e+65: tmp = c0 * (((d / D) * t_1) / t_0) elif M_m <= 1.6e+111: tmp = t_2 else: tmp = (c0 / (2.0 * w)) * (M_m + (math.pow((d / D), 2.0) * ((c0 / w) / h))) return tmp
M_m = abs(M) function code(c0, w, h, D, d, M_m) t_0 = Float64(h * (w ^ 2.0)) t_1 = Float64(c0 * Float64(d / D)) t_2 = Float64(c0 * Float64(0.0 / w)) tmp = 0.0 if (M_m <= 2.4e-221) tmp = Float64(c0 * Float64(Float64(Float64(Float64(c0 * d) / D) * Float64(d / D)) / t_0)); elseif (M_m <= 2.05e-69) tmp = t_2; elseif (M_m <= 18000.0) tmp = Float64(c0 * Float64(Float64(t_1 / h) * Float64(Float64(d / D) / (w ^ 2.0)))); elseif (M_m <= 3.6e+32) tmp = t_2; elseif (M_m <= 2.05e+65) tmp = Float64(c0 * Float64(Float64(Float64(d / D) * t_1) / t_0)); elseif (M_m <= 1.6e+111) tmp = t_2; else tmp = Float64(Float64(c0 / Float64(2.0 * w)) * Float64(M_m + Float64((Float64(d / D) ^ 2.0) * Float64(Float64(c0 / w) / h)))); end return tmp end
M_m = abs(M); function tmp_2 = code(c0, w, h, D, d, M_m) t_0 = h * (w ^ 2.0); t_1 = c0 * (d / D); t_2 = c0 * (0.0 / w); tmp = 0.0; if (M_m <= 2.4e-221) tmp = c0 * ((((c0 * d) / D) * (d / D)) / t_0); elseif (M_m <= 2.05e-69) tmp = t_2; elseif (M_m <= 18000.0) tmp = c0 * ((t_1 / h) * ((d / D) / (w ^ 2.0))); elseif (M_m <= 3.6e+32) tmp = t_2; elseif (M_m <= 2.05e+65) tmp = c0 * (((d / D) * t_1) / t_0); elseif (M_m <= 1.6e+111) tmp = t_2; else tmp = (c0 / (2.0 * w)) * (M_m + (((d / D) ^ 2.0) * ((c0 / w) / h))); end tmp_2 = tmp; end
M_m = N[Abs[M], $MachinePrecision]
code[c0_, w_, h_, D_, d_, M$95$m_] := Block[{t$95$0 = N[(h * N[Power[w, 2.0], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(c0 * N[(d / D), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(c0 * N[(0.0 / w), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[M$95$m, 2.4e-221], N[(c0 * N[(N[(N[(N[(c0 * d), $MachinePrecision] / D), $MachinePrecision] * N[(d / D), $MachinePrecision]), $MachinePrecision] / t$95$0), $MachinePrecision]), $MachinePrecision], If[LessEqual[M$95$m, 2.05e-69], t$95$2, If[LessEqual[M$95$m, 18000.0], N[(c0 * N[(N[(t$95$1 / h), $MachinePrecision] * N[(N[(d / D), $MachinePrecision] / N[Power[w, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[M$95$m, 3.6e+32], t$95$2, If[LessEqual[M$95$m, 2.05e+65], N[(c0 * N[(N[(N[(d / D), $MachinePrecision] * t$95$1), $MachinePrecision] / t$95$0), $MachinePrecision]), $MachinePrecision], If[LessEqual[M$95$m, 1.6e+111], t$95$2, N[(N[(c0 / N[(2.0 * w), $MachinePrecision]), $MachinePrecision] * N[(M$95$m + N[(N[Power[N[(d / D), $MachinePrecision], 2.0], $MachinePrecision] * N[(N[(c0 / w), $MachinePrecision] / h), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]]]
\begin{array}{l}
M_m = \left|M\right|
\\
\begin{array}{l}
t_0 := h \cdot {w}^{2}\\
t_1 := c0 \cdot \frac{d}{D}\\
t_2 := c0 \cdot \frac{0}{w}\\
\mathbf{if}\;M\_m \leq 2.4 \cdot 10^{-221}:\\
\;\;\;\;c0 \cdot \frac{\frac{c0 \cdot d}{D} \cdot \frac{d}{D}}{t\_0}\\
\mathbf{elif}\;M\_m \leq 2.05 \cdot 10^{-69}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;M\_m \leq 18000:\\
\;\;\;\;c0 \cdot \left(\frac{t\_1}{h} \cdot \frac{\frac{d}{D}}{{w}^{2}}\right)\\
\mathbf{elif}\;M\_m \leq 3.6 \cdot 10^{+32}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;M\_m \leq 2.05 \cdot 10^{+65}:\\
\;\;\;\;c0 \cdot \frac{\frac{d}{D} \cdot t\_1}{t\_0}\\
\mathbf{elif}\;M\_m \leq 1.6 \cdot 10^{+111}:\\
\;\;\;\;t\_2\\
\mathbf{else}:\\
\;\;\;\;\frac{c0}{2 \cdot w} \cdot \left(M\_m + {\left(\frac{d}{D}\right)}^{2} \cdot \frac{\frac{c0}{w}}{h}\right)\\
\end{array}
\end{array}
if M < 2.40000000000000024e-221Initial program 28.4%
Simplified44.9%
Taylor expanded in c0 around inf 30.9%
associate-/r*30.5%
Simplified30.5%
associate-/l*31.2%
unpow231.2%
unpow231.2%
frac-times40.1%
associate-*r*42.9%
Applied egg-rr42.9%
Taylor expanded in c0 around 0 41.9%
if 2.40000000000000024e-221 < M < 2.04999999999999995e-69 or 18000 < M < 3.5999999999999997e32 or 2.0500000000000001e65 < M < 1.6e111Initial program 16.1%
Simplified20.3%
Taylor expanded in c0 around -inf 9.2%
associate-*r/9.2%
distribute-lft-in7.4%
mul-1-neg7.4%
distribute-rgt-neg-in7.4%
associate-/l*5.5%
mul-1-neg5.5%
associate-/l*7.2%
distribute-lft1-in7.2%
metadata-eval7.2%
mul0-lft55.7%
metadata-eval55.7%
Simplified55.7%
if 2.04999999999999995e-69 < M < 18000Initial program 47.0%
Simplified64.8%
Taylor expanded in c0 around inf 44.6%
associate-/r*47.4%
Simplified47.4%
associate-/l*47.5%
unpow247.5%
unpow247.5%
frac-times65.6%
associate-*r*71.4%
Applied egg-rr71.4%
times-frac71.5%
Applied egg-rr71.5%
if 3.5999999999999997e32 < M < 2.0500000000000001e65Initial program 30.4%
Simplified31.9%
Taylor expanded in c0 around inf 31.5%
associate-/r*45.1%
Simplified45.1%
associate-/l*45.1%
unpow245.1%
unpow245.1%
frac-times59.4%
associate-*r*59.4%
Applied egg-rr59.4%
if 1.6e111 < M Initial program 7.7%
Simplified7.7%
*-commutative7.7%
fma-define7.7%
times-frac7.7%
pow27.7%
frac-times7.7%
frac-times7.7%
Applied egg-rr11.5%
fma-undefine11.5%
*-commutative11.5%
associate-/r*11.5%
unpow211.5%
unpow211.5%
difference-of-squares42.5%
add-sqr-sqrt42.5%
sqrt-prod42.5%
sqr-neg42.5%
sqrt-unprod0.0%
add-sqr-sqrt42.5%
fma-undefine42.5%
unsub-neg42.5%
fma-undefine42.5%
Applied egg-rr66.1%
Taylor expanded in c0 around 0 63.0%
Final simplification49.5%
M_m = (fabs.f64 M)
(FPCore (c0 w h D d M_m)
:precision binary64
(let* ((t_0 (* c0 (/ d D))))
(if (<= d 9.5e-112)
(* c0 (/ (* (/ d D) t_0) (* h (pow w 2.0))))
(if (<= d 1.05e-32)
(* 0.5 (+ -1.0 (fma c0 (/ M_m w) 1.0)))
(if (or (<= d 1.3e+66) (and (not (<= d 9e+110)) (<= d 2.6e+228)))
(* c0 (* (/ t_0 h) (/ (/ d D) (pow w 2.0))))
(* c0 (/ 0.0 w)))))))M_m = fabs(M);
double code(double c0, double w, double h, double D, double d, double M_m) {
double t_0 = c0 * (d / D);
double tmp;
if (d <= 9.5e-112) {
tmp = c0 * (((d / D) * t_0) / (h * pow(w, 2.0)));
} else if (d <= 1.05e-32) {
tmp = 0.5 * (-1.0 + fma(c0, (M_m / w), 1.0));
} else if ((d <= 1.3e+66) || (!(d <= 9e+110) && (d <= 2.6e+228))) {
tmp = c0 * ((t_0 / h) * ((d / D) / pow(w, 2.0)));
} else {
tmp = c0 * (0.0 / w);
}
return tmp;
}
M_m = abs(M) function code(c0, w, h, D, d, M_m) t_0 = Float64(c0 * Float64(d / D)) tmp = 0.0 if (d <= 9.5e-112) tmp = Float64(c0 * Float64(Float64(Float64(d / D) * t_0) / Float64(h * (w ^ 2.0)))); elseif (d <= 1.05e-32) tmp = Float64(0.5 * Float64(-1.0 + fma(c0, Float64(M_m / w), 1.0))); elseif ((d <= 1.3e+66) || (!(d <= 9e+110) && (d <= 2.6e+228))) tmp = Float64(c0 * Float64(Float64(t_0 / h) * Float64(Float64(d / D) / (w ^ 2.0)))); else tmp = Float64(c0 * Float64(0.0 / w)); end return tmp end
M_m = N[Abs[M], $MachinePrecision]
code[c0_, w_, h_, D_, d_, M$95$m_] := Block[{t$95$0 = N[(c0 * N[(d / D), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, 9.5e-112], N[(c0 * N[(N[(N[(d / D), $MachinePrecision] * t$95$0), $MachinePrecision] / N[(h * N[Power[w, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 1.05e-32], N[(0.5 * N[(-1.0 + N[(c0 * N[(M$95$m / w), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[d, 1.3e+66], And[N[Not[LessEqual[d, 9e+110]], $MachinePrecision], LessEqual[d, 2.6e+228]]], N[(c0 * N[(N[(t$95$0 / h), $MachinePrecision] * N[(N[(d / D), $MachinePrecision] / N[Power[w, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(c0 * N[(0.0 / w), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
M_m = \left|M\right|
\\
\begin{array}{l}
t_0 := c0 \cdot \frac{d}{D}\\
\mathbf{if}\;d \leq 9.5 \cdot 10^{-112}:\\
\;\;\;\;c0 \cdot \frac{\frac{d}{D} \cdot t\_0}{h \cdot {w}^{2}}\\
\mathbf{elif}\;d \leq 1.05 \cdot 10^{-32}:\\
\;\;\;\;0.5 \cdot \left(-1 + \mathsf{fma}\left(c0, \frac{M\_m}{w}, 1\right)\right)\\
\mathbf{elif}\;d \leq 1.3 \cdot 10^{+66} \lor \neg \left(d \leq 9 \cdot 10^{+110}\right) \land d \leq 2.6 \cdot 10^{+228}:\\
\;\;\;\;c0 \cdot \left(\frac{t\_0}{h} \cdot \frac{\frac{d}{D}}{{w}^{2}}\right)\\
\mathbf{else}:\\
\;\;\;\;c0 \cdot \frac{0}{w}\\
\end{array}
\end{array}
if d < 9.50000000000000056e-112Initial program 23.8%
Simplified46.2%
Taylor expanded in c0 around inf 27.5%
associate-/r*28.8%
Simplified28.8%
associate-/l*29.5%
unpow229.5%
unpow229.5%
frac-times43.9%
associate-*r*46.1%
Applied egg-rr46.1%
if 9.50000000000000056e-112 < d < 1.05e-32Initial program 20.0%
Simplified20.4%
*-commutative20.4%
fma-define20.4%
times-frac20.5%
pow220.5%
frac-times20.1%
frac-times20.1%
Applied egg-rr20.6%
fma-undefine27.1%
*-commutative27.1%
associate-/r*33.7%
unpow233.7%
unpow233.7%
difference-of-squares33.7%
add-sqr-sqrt13.3%
sqrt-prod34.1%
sqr-neg34.1%
sqrt-unprod20.7%
add-sqr-sqrt34.1%
fma-undefine34.1%
unsub-neg34.1%
fma-undefine34.1%
Applied egg-rr28.7%
Taylor expanded in c0 around 0 15.9%
associate-/l*16.5%
Simplified16.5%
expm1-log1p-u16.4%
expm1-undefine47.9%
associate-*r/47.9%
Applied egg-rr47.9%
sub-neg47.9%
metadata-eval47.9%
+-commutative47.9%
log1p-undefine47.9%
rem-exp-log48.0%
+-commutative48.0%
*-commutative48.0%
associate-/l*48.0%
fma-define48.0%
Simplified48.0%
if 1.05e-32 < d < 1.30000000000000006e66 or 9.0000000000000005e110 < d < 2.60000000000000007e228Initial program 30.2%
Simplified42.8%
Taylor expanded in c0 around inf 39.3%
associate-/r*40.9%
Simplified40.9%
associate-/l*41.1%
unpow241.1%
unpow241.1%
frac-times47.8%
associate-*r*49.7%
Applied egg-rr49.7%
times-frac53.0%
Applied egg-rr53.0%
if 1.30000000000000006e66 < d < 9.0000000000000005e110 or 2.60000000000000007e228 < d Initial program 22.2%
Simplified22.8%
Taylor expanded in c0 around -inf 9.9%
associate-*r/9.9%
distribute-lft-in7.5%
mul-1-neg7.5%
distribute-rgt-neg-in7.5%
associate-/l*2.7%
mul-1-neg2.7%
associate-/l*7.3%
distribute-lft1-in7.3%
metadata-eval7.3%
mul0-lft48.4%
metadata-eval48.4%
Simplified48.4%
Final simplification48.2%
M_m = (fabs.f64 M) (FPCore (c0 w h D d M_m) :precision binary64 (if (or (<= d 4.8e+66) (and (not (<= d 1.6e+111)) (<= d 2.95e+228))) (* c0 (* (/ (* c0 (/ d D)) h) (/ (/ d D) (pow w 2.0)))) (* c0 (/ 0.0 w))))
M_m = fabs(M);
double code(double c0, double w, double h, double D, double d, double M_m) {
double tmp;
if ((d <= 4.8e+66) || (!(d <= 1.6e+111) && (d <= 2.95e+228))) {
tmp = c0 * (((c0 * (d / D)) / h) * ((d / D) / pow(w, 2.0)));
} else {
tmp = c0 * (0.0 / w);
}
return tmp;
}
M_m = abs(m)
real(8) function code(c0, w, h, d, d_1, m_m)
real(8), intent (in) :: c0
real(8), intent (in) :: w
real(8), intent (in) :: h
real(8), intent (in) :: d
real(8), intent (in) :: d_1
real(8), intent (in) :: m_m
real(8) :: tmp
if ((d_1 <= 4.8d+66) .or. (.not. (d_1 <= 1.6d+111)) .and. (d_1 <= 2.95d+228)) then
tmp = c0 * (((c0 * (d_1 / d)) / h) * ((d_1 / d) / (w ** 2.0d0)))
else
tmp = c0 * (0.0d0 / w)
end if
code = tmp
end function
M_m = Math.abs(M);
public static double code(double c0, double w, double h, double D, double d, double M_m) {
double tmp;
if ((d <= 4.8e+66) || (!(d <= 1.6e+111) && (d <= 2.95e+228))) {
tmp = c0 * (((c0 * (d / D)) / h) * ((d / D) / Math.pow(w, 2.0)));
} else {
tmp = c0 * (0.0 / w);
}
return tmp;
}
M_m = math.fabs(M) def code(c0, w, h, D, d, M_m): tmp = 0 if (d <= 4.8e+66) or (not (d <= 1.6e+111) and (d <= 2.95e+228)): tmp = c0 * (((c0 * (d / D)) / h) * ((d / D) / math.pow(w, 2.0))) else: tmp = c0 * (0.0 / w) return tmp
M_m = abs(M) function code(c0, w, h, D, d, M_m) tmp = 0.0 if ((d <= 4.8e+66) || (!(d <= 1.6e+111) && (d <= 2.95e+228))) tmp = Float64(c0 * Float64(Float64(Float64(c0 * Float64(d / D)) / h) * Float64(Float64(d / D) / (w ^ 2.0)))); else tmp = Float64(c0 * Float64(0.0 / w)); end return tmp end
M_m = abs(M); function tmp_2 = code(c0, w, h, D, d, M_m) tmp = 0.0; if ((d <= 4.8e+66) || (~((d <= 1.6e+111)) && (d <= 2.95e+228))) tmp = c0 * (((c0 * (d / D)) / h) * ((d / D) / (w ^ 2.0))); else tmp = c0 * (0.0 / w); end tmp_2 = tmp; end
M_m = N[Abs[M], $MachinePrecision] code[c0_, w_, h_, D_, d_, M$95$m_] := If[Or[LessEqual[d, 4.8e+66], And[N[Not[LessEqual[d, 1.6e+111]], $MachinePrecision], LessEqual[d, 2.95e+228]]], N[(c0 * N[(N[(N[(c0 * N[(d / D), $MachinePrecision]), $MachinePrecision] / h), $MachinePrecision] * N[(N[(d / D), $MachinePrecision] / N[Power[w, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(c0 * N[(0.0 / w), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
M_m = \left|M\right|
\\
\begin{array}{l}
\mathbf{if}\;d \leq 4.8 \cdot 10^{+66} \lor \neg \left(d \leq 1.6 \cdot 10^{+111}\right) \land d \leq 2.95 \cdot 10^{+228}:\\
\;\;\;\;c0 \cdot \left(\frac{c0 \cdot \frac{d}{D}}{h} \cdot \frac{\frac{d}{D}}{{w}^{2}}\right)\\
\mathbf{else}:\\
\;\;\;\;c0 \cdot \frac{0}{w}\\
\end{array}
\end{array}
if d < 4.8000000000000003e66 or 1.6e111 < d < 2.9499999999999999e228Initial program 25.4%
Simplified44.4%
Taylor expanded in c0 around inf 29.8%
associate-/r*31.1%
Simplified31.1%
associate-/l*31.7%
unpow231.7%
unpow231.7%
frac-times43.0%
associate-*r*45.5%
Applied egg-rr45.5%
times-frac46.7%
Applied egg-rr46.7%
if 4.8000000000000003e66 < d < 1.6e111 or 2.9499999999999999e228 < d Initial program 22.2%
Simplified22.8%
Taylor expanded in c0 around -inf 9.9%
associate-*r/9.9%
distribute-lft-in7.5%
mul-1-neg7.5%
distribute-rgt-neg-in7.5%
associate-/l*2.7%
mul-1-neg2.7%
associate-/l*7.3%
distribute-lft1-in7.3%
metadata-eval7.3%
mul0-lft48.4%
metadata-eval48.4%
Simplified48.4%
Final simplification47.0%
M_m = (fabs.f64 M) (FPCore (c0 w h D d M_m) :precision binary64 (if (or (<= M_m 3.15e-29) (and (not (<= M_m 16000.0)) (<= M_m 1.05e+156))) (* c0 (/ 0.0 w)) (* 0.5 (+ -1.0 (fma c0 (/ M_m w) 1.0)))))
M_m = fabs(M);
double code(double c0, double w, double h, double D, double d, double M_m) {
double tmp;
if ((M_m <= 3.15e-29) || (!(M_m <= 16000.0) && (M_m <= 1.05e+156))) {
tmp = c0 * (0.0 / w);
} else {
tmp = 0.5 * (-1.0 + fma(c0, (M_m / w), 1.0));
}
return tmp;
}
M_m = abs(M) function code(c0, w, h, D, d, M_m) tmp = 0.0 if ((M_m <= 3.15e-29) || (!(M_m <= 16000.0) && (M_m <= 1.05e+156))) tmp = Float64(c0 * Float64(0.0 / w)); else tmp = Float64(0.5 * Float64(-1.0 + fma(c0, Float64(M_m / w), 1.0))); end return tmp end
M_m = N[Abs[M], $MachinePrecision] code[c0_, w_, h_, D_, d_, M$95$m_] := If[Or[LessEqual[M$95$m, 3.15e-29], And[N[Not[LessEqual[M$95$m, 16000.0]], $MachinePrecision], LessEqual[M$95$m, 1.05e+156]]], N[(c0 * N[(0.0 / w), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(-1.0 + N[(c0 * N[(M$95$m / w), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
M_m = \left|M\right|
\\
\begin{array}{l}
\mathbf{if}\;M\_m \leq 3.15 \cdot 10^{-29} \lor \neg \left(M\_m \leq 16000\right) \land M\_m \leq 1.05 \cdot 10^{+156}:\\
\;\;\;\;c0 \cdot \frac{0}{w}\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(-1 + \mathsf{fma}\left(c0, \frac{M\_m}{w}, 1\right)\right)\\
\end{array}
\end{array}
if M < 3.14999999999999998e-29 or 16000 < M < 1.04999999999999991e156Initial program 26.0%
Simplified38.3%
Taylor expanded in c0 around -inf 4.8%
associate-*r/4.8%
distribute-lft-in4.3%
mul-1-neg4.3%
distribute-rgt-neg-in4.3%
associate-/l*3.8%
mul-1-neg3.8%
associate-/l*4.3%
distribute-lft1-in4.3%
metadata-eval4.3%
mul0-lft37.2%
metadata-eval37.2%
Simplified37.2%
if 3.14999999999999998e-29 < M < 16000 or 1.04999999999999991e156 < M Initial program 14.8%
Simplified14.8%
*-commutative14.8%
fma-define14.8%
times-frac14.8%
pow214.8%
frac-times14.8%
frac-times14.8%
Applied egg-rr22.2%
fma-undefine22.2%
*-commutative22.2%
associate-/r*22.2%
unpow222.2%
unpow222.2%
difference-of-squares52.1%
add-sqr-sqrt52.1%
sqrt-prod52.0%
sqr-neg52.0%
sqrt-unprod0.0%
add-sqr-sqrt52.1%
fma-undefine52.1%
unsub-neg52.1%
fma-undefine52.1%
Applied egg-rr74.6%
Taylor expanded in c0 around 0 39.6%
associate-/l*36.1%
Simplified36.1%
expm1-log1p-u16.6%
expm1-undefine16.7%
associate-*r/16.7%
Applied egg-rr16.7%
sub-neg16.7%
metadata-eval16.7%
+-commutative16.7%
log1p-undefine16.7%
rem-exp-log39.6%
+-commutative39.6%
*-commutative39.6%
associate-/l*39.7%
fma-define39.7%
Simplified39.7%
Final simplification37.5%
M_m = (fabs.f64 M) (FPCore (c0 w h D d M_m) :precision binary64 (if (<= M_m 3.1e+156) (* c0 (/ 0.0 w)) (* 0.5 (* M_m (/ c0 w)))))
M_m = fabs(M);
double code(double c0, double w, double h, double D, double d, double M_m) {
double tmp;
if (M_m <= 3.1e+156) {
tmp = c0 * (0.0 / w);
} else {
tmp = 0.5 * (M_m * (c0 / w));
}
return tmp;
}
M_m = abs(m)
real(8) function code(c0, w, h, d, d_1, m_m)
real(8), intent (in) :: c0
real(8), intent (in) :: w
real(8), intent (in) :: h
real(8), intent (in) :: d
real(8), intent (in) :: d_1
real(8), intent (in) :: m_m
real(8) :: tmp
if (m_m <= 3.1d+156) then
tmp = c0 * (0.0d0 / w)
else
tmp = 0.5d0 * (m_m * (c0 / w))
end if
code = tmp
end function
M_m = Math.abs(M);
public static double code(double c0, double w, double h, double D, double d, double M_m) {
double tmp;
if (M_m <= 3.1e+156) {
tmp = c0 * (0.0 / w);
} else {
tmp = 0.5 * (M_m * (c0 / w));
}
return tmp;
}
M_m = math.fabs(M) def code(c0, w, h, D, d, M_m): tmp = 0 if M_m <= 3.1e+156: tmp = c0 * (0.0 / w) else: tmp = 0.5 * (M_m * (c0 / w)) return tmp
M_m = abs(M) function code(c0, w, h, D, d, M_m) tmp = 0.0 if (M_m <= 3.1e+156) tmp = Float64(c0 * Float64(0.0 / w)); else tmp = Float64(0.5 * Float64(M_m * Float64(c0 / w))); end return tmp end
M_m = abs(M); function tmp_2 = code(c0, w, h, D, d, M_m) tmp = 0.0; if (M_m <= 3.1e+156) tmp = c0 * (0.0 / w); else tmp = 0.5 * (M_m * (c0 / w)); end tmp_2 = tmp; end
M_m = N[Abs[M], $MachinePrecision] code[c0_, w_, h_, D_, d_, M$95$m_] := If[LessEqual[M$95$m, 3.1e+156], N[(c0 * N[(0.0 / w), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(M$95$m * N[(c0 / w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
M_m = \left|M\right|
\\
\begin{array}{l}
\mathbf{if}\;M\_m \leq 3.1 \cdot 10^{+156}:\\
\;\;\;\;c0 \cdot \frac{0}{w}\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(M\_m \cdot \frac{c0}{w}\right)\\
\end{array}
\end{array}
if M < 3.1000000000000002e156Initial program 26.8%
Simplified40.0%
Taylor expanded in c0 around -inf 4.7%
associate-*r/4.7%
distribute-lft-in4.2%
mul-1-neg4.2%
distribute-rgt-neg-in4.2%
associate-/l*3.7%
mul-1-neg3.7%
associate-/l*4.1%
distribute-lft1-in4.1%
metadata-eval4.1%
mul0-lft36.0%
metadata-eval36.0%
Simplified36.0%
if 3.1000000000000002e156 < M Initial program 0.0%
Simplified0.0%
*-commutative0.0%
fma-define0.0%
times-frac0.0%
pow20.0%
frac-times0.0%
frac-times0.0%
Applied egg-rr0.0%
fma-undefine0.0%
*-commutative0.0%
associate-/r*0.0%
unpow20.0%
unpow20.0%
difference-of-squares42.4%
add-sqr-sqrt42.4%
sqrt-prod42.4%
sqr-neg42.4%
sqrt-unprod0.0%
add-sqr-sqrt42.4%
fma-undefine42.4%
unsub-neg42.4%
fma-undefine42.4%
Applied egg-rr74.4%
Taylor expanded in c0 around 0 38.7%
associate-/l*33.8%
Simplified33.8%
Final simplification35.9%
M_m = (fabs.f64 M) (FPCore (c0 w h D d M_m) :precision binary64 (if (<= M_m 1.7e+157) (* c0 (/ 0.0 w)) (* 0.5 (* c0 (/ M_m w)))))
M_m = fabs(M);
double code(double c0, double w, double h, double D, double d, double M_m) {
double tmp;
if (M_m <= 1.7e+157) {
tmp = c0 * (0.0 / w);
} else {
tmp = 0.5 * (c0 * (M_m / w));
}
return tmp;
}
M_m = abs(m)
real(8) function code(c0, w, h, d, d_1, m_m)
real(8), intent (in) :: c0
real(8), intent (in) :: w
real(8), intent (in) :: h
real(8), intent (in) :: d
real(8), intent (in) :: d_1
real(8), intent (in) :: m_m
real(8) :: tmp
if (m_m <= 1.7d+157) then
tmp = c0 * (0.0d0 / w)
else
tmp = 0.5d0 * (c0 * (m_m / w))
end if
code = tmp
end function
M_m = Math.abs(M);
public static double code(double c0, double w, double h, double D, double d, double M_m) {
double tmp;
if (M_m <= 1.7e+157) {
tmp = c0 * (0.0 / w);
} else {
tmp = 0.5 * (c0 * (M_m / w));
}
return tmp;
}
M_m = math.fabs(M) def code(c0, w, h, D, d, M_m): tmp = 0 if M_m <= 1.7e+157: tmp = c0 * (0.0 / w) else: tmp = 0.5 * (c0 * (M_m / w)) return tmp
M_m = abs(M) function code(c0, w, h, D, d, M_m) tmp = 0.0 if (M_m <= 1.7e+157) tmp = Float64(c0 * Float64(0.0 / w)); else tmp = Float64(0.5 * Float64(c0 * Float64(M_m / w))); end return tmp end
M_m = abs(M); function tmp_2 = code(c0, w, h, D, d, M_m) tmp = 0.0; if (M_m <= 1.7e+157) tmp = c0 * (0.0 / w); else tmp = 0.5 * (c0 * (M_m / w)); end tmp_2 = tmp; end
M_m = N[Abs[M], $MachinePrecision] code[c0_, w_, h_, D_, d_, M$95$m_] := If[LessEqual[M$95$m, 1.7e+157], N[(c0 * N[(0.0 / w), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(c0 * N[(M$95$m / w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
M_m = \left|M\right|
\\
\begin{array}{l}
\mathbf{if}\;M\_m \leq 1.7 \cdot 10^{+157}:\\
\;\;\;\;c0 \cdot \frac{0}{w}\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(c0 \cdot \frac{M\_m}{w}\right)\\
\end{array}
\end{array}
if M < 1.6999999999999999e157Initial program 26.8%
Simplified40.0%
Taylor expanded in c0 around -inf 4.7%
associate-*r/4.7%
distribute-lft-in4.2%
mul-1-neg4.2%
distribute-rgt-neg-in4.2%
associate-/l*3.7%
mul-1-neg3.7%
associate-/l*4.1%
distribute-lft1-in4.1%
metadata-eval4.1%
mul0-lft36.0%
metadata-eval36.0%
Simplified36.0%
if 1.6999999999999999e157 < M Initial program 0.0%
Simplified0.0%
*-commutative0.0%
fma-define0.0%
times-frac0.0%
pow20.0%
frac-times0.0%
frac-times0.0%
Applied egg-rr0.0%
fma-undefine0.0%
*-commutative0.0%
associate-/r*0.0%
unpow20.0%
unpow20.0%
difference-of-squares42.4%
add-sqr-sqrt42.4%
sqrt-prod42.4%
sqr-neg42.4%
sqrt-unprod0.0%
add-sqr-sqrt42.4%
fma-undefine42.4%
unsub-neg42.4%
fma-undefine42.4%
Applied egg-rr74.4%
Taylor expanded in c0 around 0 38.7%
associate-*r/38.7%
associate-*r*38.7%
associate-*l/38.9%
associate-*r/38.9%
associate-*l*38.9%
Simplified38.9%
Final simplification36.2%
M_m = (fabs.f64 M) (FPCore (c0 w h D d M_m) :precision binary64 (* c0 (/ 0.0 w)))
M_m = fabs(M);
double code(double c0, double w, double h, double D, double d, double M_m) {
return c0 * (0.0 / w);
}
M_m = abs(m)
real(8) function code(c0, w, h, d, d_1, m_m)
real(8), intent (in) :: c0
real(8), intent (in) :: w
real(8), intent (in) :: h
real(8), intent (in) :: d
real(8), intent (in) :: d_1
real(8), intent (in) :: m_m
code = c0 * (0.0d0 / w)
end function
M_m = Math.abs(M);
public static double code(double c0, double w, double h, double D, double d, double M_m) {
return c0 * (0.0 / w);
}
M_m = math.fabs(M) def code(c0, w, h, D, d, M_m): return c0 * (0.0 / w)
M_m = abs(M) function code(c0, w, h, D, d, M_m) return Float64(c0 * Float64(0.0 / w)) end
M_m = abs(M); function tmp = code(c0, w, h, D, d, M_m) tmp = c0 * (0.0 / w); end
M_m = N[Abs[M], $MachinePrecision] code[c0_, w_, h_, D_, d_, M$95$m_] := N[(c0 * N[(0.0 / w), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
M_m = \left|M\right|
\\
c0 \cdot \frac{0}{w}
\end{array}
Initial program 24.9%
Simplified40.9%
Taylor expanded in c0 around -inf 4.3%
associate-*r/4.3%
distribute-lft-in3.9%
mul-1-neg3.9%
distribute-rgt-neg-in3.9%
associate-/l*3.4%
mul-1-neg3.4%
associate-/l*3.8%
distribute-lft1-in3.8%
metadata-eval3.8%
mul0-lft33.5%
metadata-eval33.5%
Simplified33.5%
Final simplification33.5%
herbie shell --seed 2024073
(FPCore (c0 w h D d M)
:name "Henrywood and Agarwal, Equation (13)"
:precision binary64
(* (/ c0 (* 2.0 w)) (+ (/ (* c0 (* d d)) (* (* w h) (* D D))) (sqrt (- (* (/ (* c0 (* d d)) (* (* w h) (* D D))) (/ (* c0 (* d d)) (* (* w h) (* D D)))) (* M M))))))