
(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 6 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}
(FPCore (c0 w h D d M)
:precision binary64
(let* ((t_0 (/ c0 (* 2.0 w))) (t_1 (/ (* c0 (* d d)) (* (* w h) (* D D)))))
(if (<= (* t_0 (+ t_1 (sqrt (- (* t_1 t_1) (* M M))))) INFINITY)
(* t_0 (* 2.0 (/ (* (/ c0 w) (pow (/ d D) 2.0)) h)))
(/
(*
c0
(fma 0.5 (* (* w (* h (* M M))) (* (/ D d) (/ D (* c0 d)))) (* c0 0.0)))
(* 2.0 w)))))
double code(double c0, double w, double h, double D, double d, double M) {
double t_0 = c0 / (2.0 * w);
double t_1 = (c0 * (d * d)) / ((w * h) * (D * D));
double tmp;
if ((t_0 * (t_1 + sqrt(((t_1 * t_1) - (M * M))))) <= ((double) INFINITY)) {
tmp = t_0 * (2.0 * (((c0 / w) * pow((d / D), 2.0)) / h));
} else {
tmp = (c0 * fma(0.5, ((w * (h * (M * M))) * ((D / d) * (D / (c0 * d)))), (c0 * 0.0))) / (2.0 * w);
}
return tmp;
}
function code(c0, w, h, D, d, M) t_0 = Float64(c0 / Float64(2.0 * w)) t_1 = Float64(Float64(c0 * Float64(d * d)) / Float64(Float64(w * h) * Float64(D * D))) tmp = 0.0 if (Float64(t_0 * Float64(t_1 + sqrt(Float64(Float64(t_1 * t_1) - Float64(M * M))))) <= Inf) tmp = Float64(t_0 * Float64(2.0 * Float64(Float64(Float64(c0 / w) * (Float64(d / D) ^ 2.0)) / h))); else tmp = Float64(Float64(c0 * fma(0.5, Float64(Float64(w * Float64(h * Float64(M * M))) * Float64(Float64(D / d) * Float64(D / Float64(c0 * d)))), Float64(c0 * 0.0))) / Float64(2.0 * w)); end return tmp end
code[c0_, w_, h_, D_, d_, M_] := Block[{t$95$0 = N[(c0 / N[(2.0 * w), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(c0 * N[(d * d), $MachinePrecision]), $MachinePrecision] / N[(N[(w * h), $MachinePrecision] * N[(D * D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(t$95$0 * N[(t$95$1 + N[Sqrt[N[(N[(t$95$1 * t$95$1), $MachinePrecision] - N[(M * M), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], Infinity], N[(t$95$0 * N[(2.0 * N[(N[(N[(c0 / w), $MachinePrecision] * N[Power[N[(d / D), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / h), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(c0 * N[(0.5 * N[(N[(w * N[(h * N[(M * M), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[(D / d), $MachinePrecision] * N[(D / N[(c0 * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(c0 * 0.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(2.0 * w), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{c0}{2 \cdot w}\\
t_1 := \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)}\\
\mathbf{if}\;t_0 \cdot \left(t_1 + \sqrt{t_1 \cdot t_1 - M \cdot M}\right) \leq \infty:\\
\;\;\;\;t_0 \cdot \left(2 \cdot \frac{\frac{c0}{w} \cdot {\left(\frac{d}{D}\right)}^{2}}{h}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{c0 \cdot \mathsf{fma}\left(0.5, \left(w \cdot \left(h \cdot \left(M \cdot M\right)\right)\right) \cdot \left(\frac{D}{d} \cdot \frac{D}{c0 \cdot d}\right), c0 \cdot 0\right)}{2 \cdot w}\\
\end{array}
\end{array}
if (*.f64 (/.f64 c0 (*.f64 2 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 75.3%
times-frac72.9%
fma-def69.8%
times-frac70.3%
difference-of-squares70.3%
Simplified68.8%
associate-*r/69.9%
*-commutative69.9%
times-frac69.9%
associate-/l/72.2%
associate-*r/72.2%
associate-/l*72.1%
div-inv72.1%
clear-num72.1%
Applied egg-rr72.1%
associate-/l*72.1%
Simplified72.1%
fma-udef74.3%
pow274.3%
Applied egg-rr75.2%
Taylor expanded in c0 around inf 75.3%
times-frac72.7%
unpow272.7%
unpow272.7%
times-frac77.2%
unpow277.2%
Simplified77.2%
*-commutative77.2%
associate-*l/77.3%
frac-times73.7%
associate-*r/78.4%
Applied egg-rr78.4%
if +inf.0 < (*.f64 (/.f64 c0 (*.f64 2 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%
associate-*l/0.0%
*-commutative0.0%
fma-def0.0%
associate-*l*0.0%
*-commutative0.0%
associate-*r*0.0%
associate-*l*0.0%
*-commutative0.0%
Simplified2.7%
associate-*l/2.8%
associate-*l*1.6%
associate-/l/0.9%
associate-/l/1.0%
*-commutative1.0%
*-commutative1.0%
Applied egg-rr1.0%
Taylor expanded in c0 around -inf 1.8%
fma-def1.8%
associate-/l*1.8%
unpow21.8%
unpow21.8%
*-commutative1.8%
unpow21.8%
associate-*r*1.8%
Simplified34.6%
Taylor expanded in D around 0 34.0%
unpow234.0%
associate-*l/33.9%
unpow233.9%
unpow233.9%
associate-*r*34.7%
*-commutative34.7%
times-frac41.5%
Simplified41.5%
Final simplification54.2%
(FPCore (c0 w h D d M)
:precision binary64
(let* ((t_0 (/ c0 (* 2.0 w))))
(if (<= d 7e+153)
(* t_0 (* 2.0 (* (* (/ d D) (/ d D)) (/ c0 (* w h)))))
(if (<= d 8e+213)
0.0
(if (<= d 2.65e+292)
(* t_0 (* 2.0 (/ c0 (/ w (/ (pow (/ d D) 2.0) h)))))
0.0)))))
double code(double c0, double w, double h, double D, double d, double M) {
double t_0 = c0 / (2.0 * w);
double tmp;
if (d <= 7e+153) {
tmp = t_0 * (2.0 * (((d / D) * (d / D)) * (c0 / (w * h))));
} else if (d <= 8e+213) {
tmp = 0.0;
} else if (d <= 2.65e+292) {
tmp = t_0 * (2.0 * (c0 / (w / (pow((d / D), 2.0) / h))));
} else {
tmp = 0.0;
}
return tmp;
}
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
real(8) :: tmp
t_0 = c0 / (2.0d0 * w)
if (d_1 <= 7d+153) then
tmp = t_0 * (2.0d0 * (((d_1 / d) * (d_1 / d)) * (c0 / (w * h))))
else if (d_1 <= 8d+213) then
tmp = 0.0d0
else if (d_1 <= 2.65d+292) then
tmp = t_0 * (2.0d0 * (c0 / (w / (((d_1 / d) ** 2.0d0) / h))))
else
tmp = 0.0d0
end if
code = tmp
end function
public static double code(double c0, double w, double h, double D, double d, double M) {
double t_0 = c0 / (2.0 * w);
double tmp;
if (d <= 7e+153) {
tmp = t_0 * (2.0 * (((d / D) * (d / D)) * (c0 / (w * h))));
} else if (d <= 8e+213) {
tmp = 0.0;
} else if (d <= 2.65e+292) {
tmp = t_0 * (2.0 * (c0 / (w / (Math.pow((d / D), 2.0) / h))));
} else {
tmp = 0.0;
}
return tmp;
}
def code(c0, w, h, D, d, M): t_0 = c0 / (2.0 * w) tmp = 0 if d <= 7e+153: tmp = t_0 * (2.0 * (((d / D) * (d / D)) * (c0 / (w * h)))) elif d <= 8e+213: tmp = 0.0 elif d <= 2.65e+292: tmp = t_0 * (2.0 * (c0 / (w / (math.pow((d / D), 2.0) / h)))) else: tmp = 0.0 return tmp
function code(c0, w, h, D, d, M) t_0 = Float64(c0 / Float64(2.0 * w)) tmp = 0.0 if (d <= 7e+153) tmp = Float64(t_0 * Float64(2.0 * Float64(Float64(Float64(d / D) * Float64(d / D)) * Float64(c0 / Float64(w * h))))); elseif (d <= 8e+213) tmp = 0.0; elseif (d <= 2.65e+292) tmp = Float64(t_0 * Float64(2.0 * Float64(c0 / Float64(w / Float64((Float64(d / D) ^ 2.0) / h))))); else tmp = 0.0; end return tmp end
function tmp_2 = code(c0, w, h, D, d, M) t_0 = c0 / (2.0 * w); tmp = 0.0; if (d <= 7e+153) tmp = t_0 * (2.0 * (((d / D) * (d / D)) * (c0 / (w * h)))); elseif (d <= 8e+213) tmp = 0.0; elseif (d <= 2.65e+292) tmp = t_0 * (2.0 * (c0 / (w / (((d / D) ^ 2.0) / h)))); else tmp = 0.0; end tmp_2 = tmp; end
code[c0_, w_, h_, D_, d_, M_] := Block[{t$95$0 = N[(c0 / N[(2.0 * w), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, 7e+153], N[(t$95$0 * N[(2.0 * N[(N[(N[(d / D), $MachinePrecision] * N[(d / D), $MachinePrecision]), $MachinePrecision] * N[(c0 / N[(w * h), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 8e+213], 0.0, If[LessEqual[d, 2.65e+292], N[(t$95$0 * N[(2.0 * N[(c0 / N[(w / N[(N[Power[N[(d / D), $MachinePrecision], 2.0], $MachinePrecision] / h), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 0.0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{c0}{2 \cdot w}\\
\mathbf{if}\;d \leq 7 \cdot 10^{+153}:\\
\;\;\;\;t_0 \cdot \left(2 \cdot \left(\left(\frac{d}{D} \cdot \frac{d}{D}\right) \cdot \frac{c0}{w \cdot h}\right)\right)\\
\mathbf{elif}\;d \leq 8 \cdot 10^{+213}:\\
\;\;\;\;0\\
\mathbf{elif}\;d \leq 2.65 \cdot 10^{+292}:\\
\;\;\;\;t_0 \cdot \left(2 \cdot \frac{c0}{\frac{w}{\frac{{\left(\frac{d}{D}\right)}^{2}}{h}}}\right)\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if d < 6.9999999999999998e153Initial program 26.0%
times-frac25.1%
fma-def23.8%
times-frac24.5%
difference-of-squares31.0%
Simplified31.0%
associate-*r/30.4%
*-commutative30.4%
times-frac31.0%
associate-/l/35.7%
associate-*r/35.7%
associate-/l*40.7%
div-inv40.7%
clear-num40.7%
Applied egg-rr40.7%
associate-/l*40.7%
Simplified40.7%
fma-udef41.5%
pow241.5%
Applied egg-rr44.6%
Taylor expanded in c0 around inf 33.8%
times-frac33.3%
unpow233.3%
unpow233.3%
times-frac47.2%
unpow247.2%
Simplified47.2%
pow247.2%
Applied egg-rr47.2%
if 6.9999999999999998e153 < d < 7.99999999999999987e213 or 2.65e292 < d Initial program 17.6%
times-frac17.6%
fma-def17.6%
associate-/r*17.6%
difference-of-squares17.6%
Simplified17.6%
Taylor expanded in c0 around -inf 0.0%
associate-*r*0.0%
distribute-rgt1-in0.0%
metadata-eval0.0%
mul0-lft55.1%
metadata-eval55.1%
mul0-lft0.0%
metadata-eval0.0%
distribute-lft1-in0.0%
*-commutative0.0%
distribute-lft1-in0.0%
metadata-eval0.0%
mul0-lft55.1%
Simplified55.1%
Taylor expanded in c0 around 0 61.0%
if 7.99999999999999987e213 < d < 2.65e292Initial program 31.6%
times-frac31.6%
fma-def31.6%
times-frac31.6%
difference-of-squares42.1%
Simplified42.1%
associate-*r/42.1%
*-commutative42.1%
times-frac42.1%
associate-/l/42.8%
associate-*r/42.8%
associate-/l*42.8%
div-inv42.8%
clear-num42.8%
Applied egg-rr42.8%
associate-/l*42.8%
Simplified42.8%
fma-udef42.8%
pow242.8%
Applied egg-rr53.3%
Taylor expanded in c0 around inf 42.6%
times-frac42.4%
unpow242.4%
unpow242.4%
times-frac54.1%
unpow254.1%
Simplified54.1%
*-commutative54.1%
associate-*l/54.3%
frac-times54.2%
associate-*l/54.3%
Applied egg-rr54.3%
associate-/l*54.3%
Simplified54.3%
Final simplification48.7%
(FPCore (c0 w h D d M)
:precision binary64
(let* ((t_0 (pow (/ d D) 2.0)) (t_1 (/ c0 (* 2.0 w))))
(if (<= d 7e+153)
(* t_1 (* 2.0 (/ (* (/ c0 w) t_0) h)))
(if (<= d 5.2e+213)
0.0
(if (<= d 1.32e+293) (* t_1 (* 2.0 (/ c0 (/ w (/ t_0 h))))) 0.0)))))
double code(double c0, double w, double h, double D, double d, double M) {
double t_0 = pow((d / D), 2.0);
double t_1 = c0 / (2.0 * w);
double tmp;
if (d <= 7e+153) {
tmp = t_1 * (2.0 * (((c0 / w) * t_0) / h));
} else if (d <= 5.2e+213) {
tmp = 0.0;
} else if (d <= 1.32e+293) {
tmp = t_1 * (2.0 * (c0 / (w / (t_0 / h))));
} else {
tmp = 0.0;
}
return tmp;
}
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
real(8) :: t_1
real(8) :: tmp
t_0 = (d_1 / d) ** 2.0d0
t_1 = c0 / (2.0d0 * w)
if (d_1 <= 7d+153) then
tmp = t_1 * (2.0d0 * (((c0 / w) * t_0) / h))
else if (d_1 <= 5.2d+213) then
tmp = 0.0d0
else if (d_1 <= 1.32d+293) then
tmp = t_1 * (2.0d0 * (c0 / (w / (t_0 / h))))
else
tmp = 0.0d0
end if
code = tmp
end function
public static double code(double c0, double w, double h, double D, double d, double M) {
double t_0 = Math.pow((d / D), 2.0);
double t_1 = c0 / (2.0 * w);
double tmp;
if (d <= 7e+153) {
tmp = t_1 * (2.0 * (((c0 / w) * t_0) / h));
} else if (d <= 5.2e+213) {
tmp = 0.0;
} else if (d <= 1.32e+293) {
tmp = t_1 * (2.0 * (c0 / (w / (t_0 / h))));
} else {
tmp = 0.0;
}
return tmp;
}
def code(c0, w, h, D, d, M): t_0 = math.pow((d / D), 2.0) t_1 = c0 / (2.0 * w) tmp = 0 if d <= 7e+153: tmp = t_1 * (2.0 * (((c0 / w) * t_0) / h)) elif d <= 5.2e+213: tmp = 0.0 elif d <= 1.32e+293: tmp = t_1 * (2.0 * (c0 / (w / (t_0 / h)))) else: tmp = 0.0 return tmp
function code(c0, w, h, D, d, M) t_0 = Float64(d / D) ^ 2.0 t_1 = Float64(c0 / Float64(2.0 * w)) tmp = 0.0 if (d <= 7e+153) tmp = Float64(t_1 * Float64(2.0 * Float64(Float64(Float64(c0 / w) * t_0) / h))); elseif (d <= 5.2e+213) tmp = 0.0; elseif (d <= 1.32e+293) tmp = Float64(t_1 * Float64(2.0 * Float64(c0 / Float64(w / Float64(t_0 / h))))); else tmp = 0.0; end return tmp end
function tmp_2 = code(c0, w, h, D, d, M) t_0 = (d / D) ^ 2.0; t_1 = c0 / (2.0 * w); tmp = 0.0; if (d <= 7e+153) tmp = t_1 * (2.0 * (((c0 / w) * t_0) / h)); elseif (d <= 5.2e+213) tmp = 0.0; elseif (d <= 1.32e+293) tmp = t_1 * (2.0 * (c0 / (w / (t_0 / h)))); else tmp = 0.0; end tmp_2 = tmp; end
code[c0_, w_, h_, D_, d_, M_] := Block[{t$95$0 = N[Power[N[(d / D), $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$1 = N[(c0 / N[(2.0 * w), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, 7e+153], N[(t$95$1 * N[(2.0 * N[(N[(N[(c0 / w), $MachinePrecision] * t$95$0), $MachinePrecision] / h), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 5.2e+213], 0.0, If[LessEqual[d, 1.32e+293], N[(t$95$1 * N[(2.0 * N[(c0 / N[(w / N[(t$95$0 / h), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 0.0]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\left(\frac{d}{D}\right)}^{2}\\
t_1 := \frac{c0}{2 \cdot w}\\
\mathbf{if}\;d \leq 7 \cdot 10^{+153}:\\
\;\;\;\;t_1 \cdot \left(2 \cdot \frac{\frac{c0}{w} \cdot t_0}{h}\right)\\
\mathbf{elif}\;d \leq 5.2 \cdot 10^{+213}:\\
\;\;\;\;0\\
\mathbf{elif}\;d \leq 1.32 \cdot 10^{+293}:\\
\;\;\;\;t_1 \cdot \left(2 \cdot \frac{c0}{\frac{w}{\frac{t_0}{h}}}\right)\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if d < 6.9999999999999998e153Initial program 26.0%
times-frac25.1%
fma-def23.8%
times-frac24.5%
difference-of-squares31.0%
Simplified31.0%
associate-*r/30.4%
*-commutative30.4%
times-frac31.0%
associate-/l/35.7%
associate-*r/35.7%
associate-/l*40.7%
div-inv40.7%
clear-num40.7%
Applied egg-rr40.7%
associate-/l*40.7%
Simplified40.7%
fma-udef41.5%
pow241.5%
Applied egg-rr44.6%
Taylor expanded in c0 around inf 33.8%
times-frac33.3%
unpow233.3%
unpow233.3%
times-frac47.2%
unpow247.2%
Simplified47.2%
*-commutative47.2%
associate-*l/46.8%
frac-times45.2%
associate-*r/48.4%
Applied egg-rr48.4%
if 6.9999999999999998e153 < d < 5.19999999999999998e213 or 1.32e293 < d Initial program 17.6%
times-frac17.6%
fma-def17.6%
associate-/r*17.6%
difference-of-squares17.6%
Simplified17.6%
Taylor expanded in c0 around -inf 0.0%
associate-*r*0.0%
distribute-rgt1-in0.0%
metadata-eval0.0%
mul0-lft55.1%
metadata-eval55.1%
mul0-lft0.0%
metadata-eval0.0%
distribute-lft1-in0.0%
*-commutative0.0%
distribute-lft1-in0.0%
metadata-eval0.0%
mul0-lft55.1%
Simplified55.1%
Taylor expanded in c0 around 0 61.0%
if 5.19999999999999998e213 < d < 1.32e293Initial program 31.6%
times-frac31.6%
fma-def31.6%
times-frac31.6%
difference-of-squares42.1%
Simplified42.1%
associate-*r/42.1%
*-commutative42.1%
times-frac42.1%
associate-/l/42.8%
associate-*r/42.8%
associate-/l*42.8%
div-inv42.8%
clear-num42.8%
Applied egg-rr42.8%
associate-/l*42.8%
Simplified42.8%
fma-udef42.8%
pow242.8%
Applied egg-rr53.3%
Taylor expanded in c0 around inf 42.6%
times-frac42.4%
unpow242.4%
unpow242.4%
times-frac54.1%
unpow254.1%
Simplified54.1%
*-commutative54.1%
associate-*l/54.3%
frac-times54.2%
associate-*l/54.3%
Applied egg-rr54.3%
associate-/l*54.3%
Simplified54.3%
Final simplification49.7%
(FPCore (c0 w h D d M) :precision binary64 (if (or (<= d 6e+153) (and (not (<= d 6e+213)) (<= d 3.05e+292))) (* (/ c0 (* 2.0 w)) (* 2.0 (* (* (/ d D) (/ d D)) (/ c0 (* w h))))) 0.0))
double code(double c0, double w, double h, double D, double d, double M) {
double tmp;
if ((d <= 6e+153) || (!(d <= 6e+213) && (d <= 3.05e+292))) {
tmp = (c0 / (2.0 * w)) * (2.0 * (((d / D) * (d / D)) * (c0 / (w * h))));
} else {
tmp = 0.0;
}
return tmp;
}
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) :: tmp
if ((d_1 <= 6d+153) .or. (.not. (d_1 <= 6d+213)) .and. (d_1 <= 3.05d+292)) then
tmp = (c0 / (2.0d0 * w)) * (2.0d0 * (((d_1 / d) * (d_1 / d)) * (c0 / (w * h))))
else
tmp = 0.0d0
end if
code = tmp
end function
public static double code(double c0, double w, double h, double D, double d, double M) {
double tmp;
if ((d <= 6e+153) || (!(d <= 6e+213) && (d <= 3.05e+292))) {
tmp = (c0 / (2.0 * w)) * (2.0 * (((d / D) * (d / D)) * (c0 / (w * h))));
} else {
tmp = 0.0;
}
return tmp;
}
def code(c0, w, h, D, d, M): tmp = 0 if (d <= 6e+153) or (not (d <= 6e+213) and (d <= 3.05e+292)): tmp = (c0 / (2.0 * w)) * (2.0 * (((d / D) * (d / D)) * (c0 / (w * h)))) else: tmp = 0.0 return tmp
function code(c0, w, h, D, d, M) tmp = 0.0 if ((d <= 6e+153) || (!(d <= 6e+213) && (d <= 3.05e+292))) tmp = Float64(Float64(c0 / Float64(2.0 * w)) * Float64(2.0 * Float64(Float64(Float64(d / D) * Float64(d / D)) * Float64(c0 / Float64(w * h))))); else tmp = 0.0; end return tmp end
function tmp_2 = code(c0, w, h, D, d, M) tmp = 0.0; if ((d <= 6e+153) || (~((d <= 6e+213)) && (d <= 3.05e+292))) tmp = (c0 / (2.0 * w)) * (2.0 * (((d / D) * (d / D)) * (c0 / (w * h)))); else tmp = 0.0; end tmp_2 = tmp; end
code[c0_, w_, h_, D_, d_, M_] := If[Or[LessEqual[d, 6e+153], And[N[Not[LessEqual[d, 6e+213]], $MachinePrecision], LessEqual[d, 3.05e+292]]], N[(N[(c0 / N[(2.0 * w), $MachinePrecision]), $MachinePrecision] * N[(2.0 * N[(N[(N[(d / D), $MachinePrecision] * N[(d / D), $MachinePrecision]), $MachinePrecision] * N[(c0 / N[(w * h), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 0.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq 6 \cdot 10^{+153} \lor \neg \left(d \leq 6 \cdot 10^{+213}\right) \land d \leq 3.05 \cdot 10^{+292}:\\
\;\;\;\;\frac{c0}{2 \cdot w} \cdot \left(2 \cdot \left(\left(\frac{d}{D} \cdot \frac{d}{D}\right) \cdot \frac{c0}{w \cdot h}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if d < 6.00000000000000037e153 or 6.0000000000000002e213 < d < 3.05000000000000011e292Initial program 26.5%
times-frac25.6%
fma-def24.4%
times-frac25.1%
difference-of-squares31.8%
Simplified31.9%
associate-*r/31.4%
*-commutative31.4%
times-frac31.9%
associate-/l/36.3%
associate-*r/36.3%
associate-/l*40.8%
div-inv40.8%
clear-num40.8%
Applied egg-rr40.8%
associate-/l*40.9%
Simplified40.9%
fma-udef41.6%
pow241.6%
Applied egg-rr45.3%
Taylor expanded in c0 around inf 34.5%
times-frac34.0%
unpow234.0%
unpow234.0%
times-frac47.8%
unpow247.8%
Simplified47.8%
pow247.8%
Applied egg-rr47.8%
if 6.00000000000000037e153 < d < 6.0000000000000002e213 or 3.05000000000000011e292 < d Initial program 17.6%
times-frac17.6%
fma-def17.6%
associate-/r*17.6%
difference-of-squares17.6%
Simplified17.6%
Taylor expanded in c0 around -inf 0.0%
associate-*r*0.0%
distribute-rgt1-in0.0%
metadata-eval0.0%
mul0-lft55.1%
metadata-eval55.1%
mul0-lft0.0%
metadata-eval0.0%
distribute-lft1-in0.0%
*-commutative0.0%
distribute-lft1-in0.0%
metadata-eval0.0%
mul0-lft55.1%
Simplified55.1%
Taylor expanded in c0 around 0 61.0%
Final simplification48.7%
(FPCore (c0 w h D d M) :precision binary64 (if (or (<= d 5.8e+153) (and (not (<= d 5.1e+213)) (<= d 5.5e+292))) (* (* (/ d D) (/ (* c0 d) D)) (/ (/ c0 h) (* w w))) 0.0))
double code(double c0, double w, double h, double D, double d, double M) {
double tmp;
if ((d <= 5.8e+153) || (!(d <= 5.1e+213) && (d <= 5.5e+292))) {
tmp = ((d / D) * ((c0 * d) / D)) * ((c0 / h) / (w * w));
} else {
tmp = 0.0;
}
return tmp;
}
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) :: tmp
if ((d_1 <= 5.8d+153) .or. (.not. (d_1 <= 5.1d+213)) .and. (d_1 <= 5.5d+292)) then
tmp = ((d_1 / d) * ((c0 * d_1) / d)) * ((c0 / h) / (w * w))
else
tmp = 0.0d0
end if
code = tmp
end function
public static double code(double c0, double w, double h, double D, double d, double M) {
double tmp;
if ((d <= 5.8e+153) || (!(d <= 5.1e+213) && (d <= 5.5e+292))) {
tmp = ((d / D) * ((c0 * d) / D)) * ((c0 / h) / (w * w));
} else {
tmp = 0.0;
}
return tmp;
}
def code(c0, w, h, D, d, M): tmp = 0 if (d <= 5.8e+153) or (not (d <= 5.1e+213) and (d <= 5.5e+292)): tmp = ((d / D) * ((c0 * d) / D)) * ((c0 / h) / (w * w)) else: tmp = 0.0 return tmp
function code(c0, w, h, D, d, M) tmp = 0.0 if ((d <= 5.8e+153) || (!(d <= 5.1e+213) && (d <= 5.5e+292))) tmp = Float64(Float64(Float64(d / D) * Float64(Float64(c0 * d) / D)) * Float64(Float64(c0 / h) / Float64(w * w))); else tmp = 0.0; end return tmp end
function tmp_2 = code(c0, w, h, D, d, M) tmp = 0.0; if ((d <= 5.8e+153) || (~((d <= 5.1e+213)) && (d <= 5.5e+292))) tmp = ((d / D) * ((c0 * d) / D)) * ((c0 / h) / (w * w)); else tmp = 0.0; end tmp_2 = tmp; end
code[c0_, w_, h_, D_, d_, M_] := If[Or[LessEqual[d, 5.8e+153], And[N[Not[LessEqual[d, 5.1e+213]], $MachinePrecision], LessEqual[d, 5.5e+292]]], N[(N[(N[(d / D), $MachinePrecision] * N[(N[(c0 * d), $MachinePrecision] / D), $MachinePrecision]), $MachinePrecision] * N[(N[(c0 / h), $MachinePrecision] / N[(w * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 0.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq 5.8 \cdot 10^{+153} \lor \neg \left(d \leq 5.1 \cdot 10^{+213}\right) \land d \leq 5.5 \cdot 10^{+292}:\\
\;\;\;\;\left(\frac{d}{D} \cdot \frac{c0 \cdot d}{D}\right) \cdot \frac{\frac{c0}{h}}{w \cdot w}\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if d < 5.80000000000000004e153 or 5.1000000000000002e213 < d < 5.5000000000000003e292Initial program 26.3%
times-frac25.5%
fma-def24.3%
associate-/r*24.6%
difference-of-squares31.3%
Simplified36.9%
Taylor expanded in c0 around inf 28.1%
unpow228.1%
unpow228.1%
unpow228.1%
*-commutative28.1%
unpow228.1%
Simplified28.1%
Taylor expanded in d around 0 28.1%
unpow228.1%
associate-*r*31.2%
unpow231.2%
Simplified31.2%
*-un-lft-identity31.2%
times-frac31.7%
associate-*l*38.0%
Applied egg-rr38.0%
*-lft-identity38.0%
times-frac46.5%
unpow246.5%
associate-/r*45.3%
unpow245.3%
Simplified45.3%
if 5.80000000000000004e153 < d < 5.1000000000000002e213 or 5.5000000000000003e292 < d Initial program 18.8%
times-frac18.8%
fma-def18.8%
associate-/r*18.8%
difference-of-squares18.8%
Simplified18.8%
Taylor expanded in c0 around -inf 0.0%
associate-*r*0.0%
distribute-rgt1-in0.0%
metadata-eval0.0%
mul0-lft52.3%
metadata-eval52.3%
mul0-lft0.0%
metadata-eval0.0%
distribute-lft1-in0.0%
*-commutative0.0%
distribute-lft1-in0.0%
metadata-eval0.0%
mul0-lft52.3%
Simplified52.3%
Taylor expanded in c0 around 0 58.5%
Final simplification46.1%
(FPCore (c0 w h D d M) :precision binary64 0.0)
double code(double c0, double w, double h, double D, double d, double M) {
return 0.0;
}
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
code = 0.0d0
end function
public static double code(double c0, double w, double h, double D, double d, double M) {
return 0.0;
}
def code(c0, w, h, D, d, M): return 0.0
function code(c0, w, h, D, d, M) return 0.0 end
function tmp = code(c0, w, h, D, d, M) tmp = 0.0; end
code[c0_, w_, h_, D_, d_, M_] := 0.0
\begin{array}{l}
\\
0
\end{array}
Initial program 25.9%
times-frac25.1%
fma-def24.0%
associate-/r*24.2%
difference-of-squares30.5%
Simplified35.7%
Taylor expanded in c0 around -inf 3.6%
associate-*r*3.6%
distribute-rgt1-in3.6%
metadata-eval3.6%
mul0-lft26.8%
metadata-eval26.8%
mul0-lft4.0%
metadata-eval4.0%
distribute-lft1-in4.0%
*-commutative4.0%
distribute-lft1-in4.0%
metadata-eval4.0%
mul0-lft26.8%
Simplified26.8%
Taylor expanded in c0 around 0 30.6%
Final simplification30.6%
herbie shell --seed 2023213
(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))))))