
(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 (* d d)) (* (* D D) (* w h)))))
(if (<=
(* (/ c0 (* 2.0 w)) (+ t_0 (sqrt (- (* t_0 t_0) (* M M)))))
INFINITY)
(*
c0
(/ (* 2.0 (/ (* c0 (pow d 2.0)) (* (pow D 2.0) (* w h)))) (* 2.0 w)))
(* c0 (/ 0.0 (* 2.0 w))))))
double code(double c0, double w, double h, double D, double d, double M) {
double t_0 = (c0 * (d * d)) / ((D * D) * (w * h));
double tmp;
if (((c0 / (2.0 * w)) * (t_0 + sqrt(((t_0 * t_0) - (M * M))))) <= ((double) INFINITY)) {
tmp = c0 * ((2.0 * ((c0 * pow(d, 2.0)) / (pow(D, 2.0) * (w * h)))) / (2.0 * w));
} else {
tmp = c0 * (0.0 / (2.0 * w));
}
return tmp;
}
public static double code(double c0, double w, double h, double D, double d, double M) {
double t_0 = (c0 * (d * d)) / ((D * D) * (w * h));
double tmp;
if (((c0 / (2.0 * w)) * (t_0 + Math.sqrt(((t_0 * t_0) - (M * M))))) <= Double.POSITIVE_INFINITY) {
tmp = c0 * ((2.0 * ((c0 * Math.pow(d, 2.0)) / (Math.pow(D, 2.0) * (w * h)))) / (2.0 * w));
} else {
tmp = c0 * (0.0 / (2.0 * w));
}
return tmp;
}
def code(c0, w, h, D, d, M): t_0 = (c0 * (d * d)) / ((D * D) * (w * h)) tmp = 0 if ((c0 / (2.0 * w)) * (t_0 + math.sqrt(((t_0 * t_0) - (M * M))))) <= math.inf: tmp = c0 * ((2.0 * ((c0 * math.pow(d, 2.0)) / (math.pow(D, 2.0) * (w * h)))) / (2.0 * w)) else: tmp = c0 * (0.0 / (2.0 * w)) return tmp
function code(c0, w, h, D, d, M) t_0 = Float64(Float64(c0 * Float64(d * d)) / Float64(Float64(D * D) * Float64(w * h))) tmp = 0.0 if (Float64(Float64(c0 / Float64(2.0 * w)) * Float64(t_0 + sqrt(Float64(Float64(t_0 * t_0) - Float64(M * M))))) <= Inf) tmp = Float64(c0 * Float64(Float64(2.0 * Float64(Float64(c0 * (d ^ 2.0)) / Float64((D ^ 2.0) * Float64(w * h)))) / Float64(2.0 * w))); else tmp = Float64(c0 * Float64(0.0 / Float64(2.0 * w))); end return tmp end
function tmp_2 = code(c0, w, h, D, d, M) t_0 = (c0 * (d * d)) / ((D * D) * (w * h)); tmp = 0.0; if (((c0 / (2.0 * w)) * (t_0 + sqrt(((t_0 * t_0) - (M * M))))) <= Inf) tmp = c0 * ((2.0 * ((c0 * (d ^ 2.0)) / ((D ^ 2.0) * (w * h)))) / (2.0 * w)); else tmp = c0 * (0.0 / (2.0 * w)); end tmp_2 = tmp; end
code[c0_, w_, h_, D_, d_, M_] := Block[{t$95$0 = N[(N[(c0 * N[(d * d), $MachinePrecision]), $MachinePrecision] / N[(N[(D * D), $MachinePrecision] * N[(w * h), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[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], Infinity], N[(c0 * N[(N[(2.0 * N[(N[(c0 * N[Power[d, 2.0], $MachinePrecision]), $MachinePrecision] / N[(N[Power[D, 2.0], $MachinePrecision] * N[(w * h), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(2.0 * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(c0 * N[(0.0 / N[(2.0 * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{c0 \cdot \left(d \cdot d\right)}{\left(D \cdot D\right) \cdot \left(w \cdot h\right)}\\
\mathbf{if}\;\frac{c0}{2 \cdot w} \cdot \left(t\_0 + \sqrt{t\_0 \cdot t\_0 - M \cdot M}\right) \leq \infty:\\
\;\;\;\;c0 \cdot \frac{2 \cdot \frac{c0 \cdot {d}^{2}}{{D}^{2} \cdot \left(w \cdot h\right)}}{2 \cdot w}\\
\mathbf{else}:\\
\;\;\;\;c0 \cdot \frac{0}{2 \cdot 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 70.6%
Simplified70.0%
Taylor expanded in c0 around inf 74.1%
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%
Simplified17.6%
Taylor expanded in c0 around -inf 1.3%
distribute-lft-in0.1%
mul-1-neg0.1%
distribute-rgt-neg-in0.1%
associate-/l*0.1%
mul-1-neg0.1%
associate-/l*0.1%
distribute-lft1-in0.1%
metadata-eval0.1%
mul0-lft44.8%
metadata-eval44.8%
Simplified44.8%
Final simplification54.0%
(FPCore (c0 w h D d M)
:precision binary64
(let* ((t_0 (/ (* c0 (* d d)) (* (* D D) (* w h)))))
(if (<=
(* (/ c0 (* 2.0 w)) (+ t_0 (sqrt (- (* t_0 t_0) (* M M)))))
INFINITY)
(* c0 (* (* c0 (* 2.0 (/ (pow (/ d D) 2.0) (* w h)))) (/ 1.0 (* 2.0 w))))
(* c0 (/ 0.0 (* 2.0 w))))))
double code(double c0, double w, double h, double D, double d, double M) {
double t_0 = (c0 * (d * d)) / ((D * D) * (w * h));
double tmp;
if (((c0 / (2.0 * w)) * (t_0 + sqrt(((t_0 * t_0) - (M * M))))) <= ((double) INFINITY)) {
tmp = c0 * ((c0 * (2.0 * (pow((d / D), 2.0) / (w * h)))) * (1.0 / (2.0 * w)));
} else {
tmp = c0 * (0.0 / (2.0 * w));
}
return tmp;
}
public static double code(double c0, double w, double h, double D, double d, double M) {
double t_0 = (c0 * (d * d)) / ((D * D) * (w * h));
double tmp;
if (((c0 / (2.0 * w)) * (t_0 + Math.sqrt(((t_0 * t_0) - (M * M))))) <= Double.POSITIVE_INFINITY) {
tmp = c0 * ((c0 * (2.0 * (Math.pow((d / D), 2.0) / (w * h)))) * (1.0 / (2.0 * w)));
} else {
tmp = c0 * (0.0 / (2.0 * w));
}
return tmp;
}
def code(c0, w, h, D, d, M): t_0 = (c0 * (d * d)) / ((D * D) * (w * h)) tmp = 0 if ((c0 / (2.0 * w)) * (t_0 + math.sqrt(((t_0 * t_0) - (M * M))))) <= math.inf: tmp = c0 * ((c0 * (2.0 * (math.pow((d / D), 2.0) / (w * h)))) * (1.0 / (2.0 * w))) else: tmp = c0 * (0.0 / (2.0 * w)) return tmp
function code(c0, w, h, D, d, M) t_0 = Float64(Float64(c0 * Float64(d * d)) / Float64(Float64(D * D) * Float64(w * h))) tmp = 0.0 if (Float64(Float64(c0 / Float64(2.0 * w)) * Float64(t_0 + sqrt(Float64(Float64(t_0 * t_0) - Float64(M * M))))) <= Inf) tmp = Float64(c0 * Float64(Float64(c0 * Float64(2.0 * Float64((Float64(d / D) ^ 2.0) / Float64(w * h)))) * Float64(1.0 / Float64(2.0 * w)))); else tmp = Float64(c0 * Float64(0.0 / Float64(2.0 * w))); end return tmp end
function tmp_2 = code(c0, w, h, D, d, M) t_0 = (c0 * (d * d)) / ((D * D) * (w * h)); tmp = 0.0; if (((c0 / (2.0 * w)) * (t_0 + sqrt(((t_0 * t_0) - (M * M))))) <= Inf) tmp = c0 * ((c0 * (2.0 * (((d / D) ^ 2.0) / (w * h)))) * (1.0 / (2.0 * w))); else tmp = c0 * (0.0 / (2.0 * w)); end tmp_2 = tmp; end
code[c0_, w_, h_, D_, d_, M_] := Block[{t$95$0 = N[(N[(c0 * N[(d * d), $MachinePrecision]), $MachinePrecision] / N[(N[(D * D), $MachinePrecision] * N[(w * h), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[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], Infinity], N[(c0 * N[(N[(c0 * N[(2.0 * N[(N[Power[N[(d / D), $MachinePrecision], 2.0], $MachinePrecision] / N[(w * h), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(1.0 / N[(2.0 * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(c0 * N[(0.0 / N[(2.0 * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{c0 \cdot \left(d \cdot d\right)}{\left(D \cdot D\right) \cdot \left(w \cdot h\right)}\\
\mathbf{if}\;\frac{c0}{2 \cdot w} \cdot \left(t\_0 + \sqrt{t\_0 \cdot t\_0 - M \cdot M}\right) \leq \infty:\\
\;\;\;\;c0 \cdot \left(\left(c0 \cdot \left(2 \cdot \frac{{\left(\frac{d}{D}\right)}^{2}}{w \cdot h}\right)\right) \cdot \frac{1}{2 \cdot w}\right)\\
\mathbf{else}:\\
\;\;\;\;c0 \cdot \frac{0}{2 \cdot 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 70.6%
Simplified70.0%
Taylor expanded in c0 around -inf 6.2%
associate-*r/6.2%
neg-mul-16.2%
distribute-rgt-neg-in6.2%
Simplified6.2%
times-frac4.5%
*-commutative4.5%
Applied egg-rr4.5%
fma-undefine4.5%
associate-*r/4.7%
pow24.7%
associate-*r*4.7%
*-commutative4.7%
frac-times6.1%
add-sqr-sqrt1.4%
sqrt-unprod68.8%
sqr-neg68.8%
sqrt-unprod70.4%
add-sqr-sqrt70.4%
*-commutative70.4%
frac-times68.8%
pow268.8%
pow268.8%
frac-times69.1%
pow269.1%
Applied egg-rr69.1%
+-commutative69.1%
associate-*l/68.1%
associate-/l*70.5%
distribute-lft-out70.5%
*-commutative70.5%
associate-*l*70.5%
associate-/r*71.4%
unpow271.4%
associate-*r/71.4%
associate-*r*72.6%
*-commutative72.6%
associate-/r*72.7%
associate-*l/73.8%
unpow273.8%
*-commutative73.8%
Simplified73.8%
div-inv73.8%
count-273.8%
Applied egg-rr73.8%
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%
Simplified17.6%
Taylor expanded in c0 around -inf 1.3%
distribute-lft-in0.1%
mul-1-neg0.1%
distribute-rgt-neg-in0.1%
associate-/l*0.1%
mul-1-neg0.1%
associate-/l*0.1%
distribute-lft1-in0.1%
metadata-eval0.1%
mul0-lft44.8%
metadata-eval44.8%
Simplified44.8%
Final simplification53.9%
(FPCore (c0 w h D d M) :precision binary64 (if (or (<= M 1.7e-109) (and (not (<= M 7e-32)) (<= M 64000000.0))) (* c0 (/ 0.0 (* 2.0 w))) (* c0 (/ (* 2.0 (* (/ c0 h) (/ (pow (/ d D) 2.0) w))) (* 2.0 w)))))
double code(double c0, double w, double h, double D, double d, double M) {
double tmp;
if ((M <= 1.7e-109) || (!(M <= 7e-32) && (M <= 64000000.0))) {
tmp = c0 * (0.0 / (2.0 * w));
} else {
tmp = c0 * ((2.0 * ((c0 / h) * (pow((d / D), 2.0) / w))) / (2.0 * w));
}
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 ((m <= 1.7d-109) .or. (.not. (m <= 7d-32)) .and. (m <= 64000000.0d0)) then
tmp = c0 * (0.0d0 / (2.0d0 * w))
else
tmp = c0 * ((2.0d0 * ((c0 / h) * (((d_1 / d) ** 2.0d0) / w))) / (2.0d0 * w))
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 ((M <= 1.7e-109) || (!(M <= 7e-32) && (M <= 64000000.0))) {
tmp = c0 * (0.0 / (2.0 * w));
} else {
tmp = c0 * ((2.0 * ((c0 / h) * (Math.pow((d / D), 2.0) / w))) / (2.0 * w));
}
return tmp;
}
def code(c0, w, h, D, d, M): tmp = 0 if (M <= 1.7e-109) or (not (M <= 7e-32) and (M <= 64000000.0)): tmp = c0 * (0.0 / (2.0 * w)) else: tmp = c0 * ((2.0 * ((c0 / h) * (math.pow((d / D), 2.0) / w))) / (2.0 * w)) return tmp
function code(c0, w, h, D, d, M) tmp = 0.0 if ((M <= 1.7e-109) || (!(M <= 7e-32) && (M <= 64000000.0))) tmp = Float64(c0 * Float64(0.0 / Float64(2.0 * w))); else tmp = Float64(c0 * Float64(Float64(2.0 * Float64(Float64(c0 / h) * Float64((Float64(d / D) ^ 2.0) / w))) / Float64(2.0 * w))); end return tmp end
function tmp_2 = code(c0, w, h, D, d, M) tmp = 0.0; if ((M <= 1.7e-109) || (~((M <= 7e-32)) && (M <= 64000000.0))) tmp = c0 * (0.0 / (2.0 * w)); else tmp = c0 * ((2.0 * ((c0 / h) * (((d / D) ^ 2.0) / w))) / (2.0 * w)); end tmp_2 = tmp; end
code[c0_, w_, h_, D_, d_, M_] := If[Or[LessEqual[M, 1.7e-109], And[N[Not[LessEqual[M, 7e-32]], $MachinePrecision], LessEqual[M, 64000000.0]]], N[(c0 * N[(0.0 / N[(2.0 * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(c0 * N[(N[(2.0 * N[(N[(c0 / h), $MachinePrecision] * N[(N[Power[N[(d / D), $MachinePrecision], 2.0], $MachinePrecision] / w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(2.0 * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;M \leq 1.7 \cdot 10^{-109} \lor \neg \left(M \leq 7 \cdot 10^{-32}\right) \land M \leq 64000000:\\
\;\;\;\;c0 \cdot \frac{0}{2 \cdot w}\\
\mathbf{else}:\\
\;\;\;\;c0 \cdot \frac{2 \cdot \left(\frac{c0}{h} \cdot \frac{{\left(\frac{d}{D}\right)}^{2}}{w}\right)}{2 \cdot w}\\
\end{array}
\end{array}
if M < 1.70000000000000006e-109 or 6.9999999999999997e-32 < M < 6.4e7Initial program 22.4%
Simplified31.2%
Taylor expanded in c0 around -inf 3.2%
distribute-lft-in2.1%
mul-1-neg2.1%
distribute-rgt-neg-in2.1%
associate-/l*2.2%
mul-1-neg2.2%
associate-/l*3.2%
distribute-lft1-in3.2%
metadata-eval3.2%
mul0-lft39.8%
metadata-eval39.8%
Simplified39.8%
if 1.70000000000000006e-109 < M < 6.9999999999999997e-32 or 6.4e7 < M Initial program 21.3%
Simplified41.0%
Taylor expanded in c0 around -inf 0.5%
associate-*r/0.5%
neg-mul-10.5%
distribute-rgt-neg-in0.5%
Simplified0.5%
times-frac0.0%
*-commutative0.0%
Applied egg-rr0.0%
fma-undefine0.0%
associate-*r/0.0%
pow20.0%
associate-*r*0.0%
*-commutative0.0%
frac-times0.3%
add-sqr-sqrt0.0%
sqrt-unprod35.8%
sqr-neg35.8%
sqrt-unprod40.1%
add-sqr-sqrt40.1%
*-commutative40.1%
frac-times41.5%
pow241.5%
pow241.5%
frac-times42.3%
pow242.3%
Applied egg-rr42.3%
+-commutative42.3%
associate-*l/40.9%
associate-/l*42.3%
distribute-lft-out42.3%
*-commutative42.3%
associate-*l*42.2%
associate-/r*47.5%
unpow247.5%
associate-*r/50.2%
associate-*r*50.2%
*-commutative50.2%
associate-/r*50.2%
associate-*l/50.2%
unpow250.2%
*-commutative50.2%
Simplified50.2%
distribute-lft-in50.2%
Applied egg-rr50.2%
count-250.2%
associate-*r/50.2%
times-frac55.7%
Simplified55.7%
Final simplification44.3%
(FPCore (c0 w h D d M)
:precision binary64
(let* ((t_0 (/ (pow (/ d D) 2.0) (* w h))) (t_1 (* c0 (/ 0.0 (* 2.0 w)))))
(if (<= M 1.45e-109)
t_1
(if (<= M 2.2e-33)
(* c0 (* c0 (/ t_0 w)))
(if (<= M 550.0) t_1 (* c0 (* (/ c0 2.0) (/ (* 2.0 t_0) w))))))))
double code(double c0, double w, double h, double D, double d, double M) {
double t_0 = pow((d / D), 2.0) / (w * h);
double t_1 = c0 * (0.0 / (2.0 * w));
double tmp;
if (M <= 1.45e-109) {
tmp = t_1;
} else if (M <= 2.2e-33) {
tmp = c0 * (c0 * (t_0 / w));
} else if (M <= 550.0) {
tmp = t_1;
} else {
tmp = c0 * ((c0 / 2.0) * ((2.0 * t_0) / w));
}
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) / (w * h)
t_1 = c0 * (0.0d0 / (2.0d0 * w))
if (m <= 1.45d-109) then
tmp = t_1
else if (m <= 2.2d-33) then
tmp = c0 * (c0 * (t_0 / w))
else if (m <= 550.0d0) then
tmp = t_1
else
tmp = c0 * ((c0 / 2.0d0) * ((2.0d0 * t_0) / w))
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) / (w * h);
double t_1 = c0 * (0.0 / (2.0 * w));
double tmp;
if (M <= 1.45e-109) {
tmp = t_1;
} else if (M <= 2.2e-33) {
tmp = c0 * (c0 * (t_0 / w));
} else if (M <= 550.0) {
tmp = t_1;
} else {
tmp = c0 * ((c0 / 2.0) * ((2.0 * t_0) / w));
}
return tmp;
}
def code(c0, w, h, D, d, M): t_0 = math.pow((d / D), 2.0) / (w * h) t_1 = c0 * (0.0 / (2.0 * w)) tmp = 0 if M <= 1.45e-109: tmp = t_1 elif M <= 2.2e-33: tmp = c0 * (c0 * (t_0 / w)) elif M <= 550.0: tmp = t_1 else: tmp = c0 * ((c0 / 2.0) * ((2.0 * t_0) / w)) return tmp
function code(c0, w, h, D, d, M) t_0 = Float64((Float64(d / D) ^ 2.0) / Float64(w * h)) t_1 = Float64(c0 * Float64(0.0 / Float64(2.0 * w))) tmp = 0.0 if (M <= 1.45e-109) tmp = t_1; elseif (M <= 2.2e-33) tmp = Float64(c0 * Float64(c0 * Float64(t_0 / w))); elseif (M <= 550.0) tmp = t_1; else tmp = Float64(c0 * Float64(Float64(c0 / 2.0) * Float64(Float64(2.0 * t_0) / w))); end return tmp end
function tmp_2 = code(c0, w, h, D, d, M) t_0 = ((d / D) ^ 2.0) / (w * h); t_1 = c0 * (0.0 / (2.0 * w)); tmp = 0.0; if (M <= 1.45e-109) tmp = t_1; elseif (M <= 2.2e-33) tmp = c0 * (c0 * (t_0 / w)); elseif (M <= 550.0) tmp = t_1; else tmp = c0 * ((c0 / 2.0) * ((2.0 * t_0) / w)); end tmp_2 = tmp; end
code[c0_, w_, h_, D_, d_, M_] := Block[{t$95$0 = N[(N[Power[N[(d / D), $MachinePrecision], 2.0], $MachinePrecision] / N[(w * h), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(c0 * N[(0.0 / N[(2.0 * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[M, 1.45e-109], t$95$1, If[LessEqual[M, 2.2e-33], N[(c0 * N[(c0 * N[(t$95$0 / w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[M, 550.0], t$95$1, N[(c0 * N[(N[(c0 / 2.0), $MachinePrecision] * N[(N[(2.0 * t$95$0), $MachinePrecision] / w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{{\left(\frac{d}{D}\right)}^{2}}{w \cdot h}\\
t_1 := c0 \cdot \frac{0}{2 \cdot w}\\
\mathbf{if}\;M \leq 1.45 \cdot 10^{-109}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;M \leq 2.2 \cdot 10^{-33}:\\
\;\;\;\;c0 \cdot \left(c0 \cdot \frac{t\_0}{w}\right)\\
\mathbf{elif}\;M \leq 550:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;c0 \cdot \left(\frac{c0}{2} \cdot \frac{2 \cdot t\_0}{w}\right)\\
\end{array}
\end{array}
if M < 1.45e-109 or 2.20000000000000005e-33 < M < 550Initial program 22.1%
Simplified30.9%
Taylor expanded in c0 around -inf 3.2%
distribute-lft-in2.1%
mul-1-neg2.1%
distribute-rgt-neg-in2.1%
associate-/l*2.2%
mul-1-neg2.2%
associate-/l*3.2%
distribute-lft1-in3.2%
metadata-eval3.2%
mul0-lft40.3%
metadata-eval40.3%
Simplified40.3%
if 1.45e-109 < M < 2.20000000000000005e-33Initial program 37.0%
Simplified42.4%
Taylor expanded in c0 around -inf 1.3%
associate-*r/1.3%
neg-mul-11.3%
distribute-rgt-neg-in1.3%
Simplified1.3%
times-frac0.1%
*-commutative0.1%
Applied egg-rr0.1%
fma-undefine0.0%
associate-*r/0.0%
pow20.0%
associate-*r*0.0%
*-commutative0.0%
frac-times0.6%
add-sqr-sqrt0.1%
sqrt-unprod37.8%
sqr-neg37.8%
sqrt-unprod37.8%
add-sqr-sqrt37.8%
*-commutative37.8%
frac-times37.9%
pow237.9%
pow237.9%
frac-times38.8%
pow238.8%
Applied egg-rr38.8%
+-commutative38.8%
associate-*l/38.4%
associate-/l*38.8%
distribute-lft-out38.8%
*-commutative38.8%
associate-*l*38.6%
associate-/r*49.4%
unpow249.4%
associate-*r/53.8%
associate-*r*53.8%
*-commutative53.8%
associate-/r*53.8%
associate-*l/54.1%
unpow254.1%
*-commutative54.1%
Simplified54.1%
associate-/l*54.1%
count-254.1%
Applied egg-rr54.1%
times-frac54.1%
metadata-eval54.1%
Simplified54.1%
if 550 < M Initial program 16.9%
Simplified41.0%
Taylor expanded in c0 around -inf 0.2%
associate-*r/0.2%
neg-mul-10.2%
distribute-rgt-neg-in0.2%
Simplified0.2%
times-frac0.0%
*-commutative0.0%
Applied egg-rr0.0%
fma-undefine0.0%
associate-*r/0.0%
pow20.0%
associate-*r*0.0%
*-commutative0.0%
frac-times0.2%
add-sqr-sqrt0.0%
sqrt-unprod35.6%
sqr-neg35.6%
sqrt-unprod41.2%
add-sqr-sqrt41.2%
*-commutative41.2%
frac-times43.0%
pow243.0%
pow243.0%
frac-times43.7%
pow243.7%
Applied egg-rr43.7%
+-commutative43.7%
associate-*l/42.1%
associate-/l*43.8%
distribute-lft-out43.8%
*-commutative43.8%
associate-*l*43.8%
associate-/r*47.0%
unpow247.0%
associate-*r/48.9%
associate-*r*49.2%
*-commutative49.2%
associate-/r*49.2%
associate-*l/50.7%
unpow250.7%
*-commutative50.7%
Simplified50.7%
times-frac49.0%
count-249.0%
Applied egg-rr49.0%
Final simplification43.2%
(FPCore (c0 w h D d M) :precision binary64 (if (or (<= M 1.05e-108) (and (not (<= M 4.1e-33)) (<= M 34000.0))) (* c0 (/ 0.0 (* 2.0 w))) (* c0 (* c0 (/ (/ (pow (/ d D) 2.0) (* w h)) w)))))
double code(double c0, double w, double h, double D, double d, double M) {
double tmp;
if ((M <= 1.05e-108) || (!(M <= 4.1e-33) && (M <= 34000.0))) {
tmp = c0 * (0.0 / (2.0 * w));
} else {
tmp = c0 * (c0 * ((pow((d / D), 2.0) / (w * h)) / w));
}
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 ((m <= 1.05d-108) .or. (.not. (m <= 4.1d-33)) .and. (m <= 34000.0d0)) then
tmp = c0 * (0.0d0 / (2.0d0 * w))
else
tmp = c0 * (c0 * ((((d_1 / d) ** 2.0d0) / (w * h)) / w))
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 ((M <= 1.05e-108) || (!(M <= 4.1e-33) && (M <= 34000.0))) {
tmp = c0 * (0.0 / (2.0 * w));
} else {
tmp = c0 * (c0 * ((Math.pow((d / D), 2.0) / (w * h)) / w));
}
return tmp;
}
def code(c0, w, h, D, d, M): tmp = 0 if (M <= 1.05e-108) or (not (M <= 4.1e-33) and (M <= 34000.0)): tmp = c0 * (0.0 / (2.0 * w)) else: tmp = c0 * (c0 * ((math.pow((d / D), 2.0) / (w * h)) / w)) return tmp
function code(c0, w, h, D, d, M) tmp = 0.0 if ((M <= 1.05e-108) || (!(M <= 4.1e-33) && (M <= 34000.0))) tmp = Float64(c0 * Float64(0.0 / Float64(2.0 * w))); else tmp = Float64(c0 * Float64(c0 * Float64(Float64((Float64(d / D) ^ 2.0) / Float64(w * h)) / w))); end return tmp end
function tmp_2 = code(c0, w, h, D, d, M) tmp = 0.0; if ((M <= 1.05e-108) || (~((M <= 4.1e-33)) && (M <= 34000.0))) tmp = c0 * (0.0 / (2.0 * w)); else tmp = c0 * (c0 * ((((d / D) ^ 2.0) / (w * h)) / w)); end tmp_2 = tmp; end
code[c0_, w_, h_, D_, d_, M_] := If[Or[LessEqual[M, 1.05e-108], And[N[Not[LessEqual[M, 4.1e-33]], $MachinePrecision], LessEqual[M, 34000.0]]], N[(c0 * N[(0.0 / N[(2.0 * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(c0 * N[(c0 * N[(N[(N[Power[N[(d / D), $MachinePrecision], 2.0], $MachinePrecision] / N[(w * h), $MachinePrecision]), $MachinePrecision] / w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;M \leq 1.05 \cdot 10^{-108} \lor \neg \left(M \leq 4.1 \cdot 10^{-33}\right) \land M \leq 34000:\\
\;\;\;\;c0 \cdot \frac{0}{2 \cdot w}\\
\mathbf{else}:\\
\;\;\;\;c0 \cdot \left(c0 \cdot \frac{\frac{{\left(\frac{d}{D}\right)}^{2}}{w \cdot h}}{w}\right)\\
\end{array}
\end{array}
if M < 1.05e-108 or 4.1e-33 < M < 34000Initial program 22.1%
Simplified30.9%
Taylor expanded in c0 around -inf 3.2%
distribute-lft-in2.1%
mul-1-neg2.1%
distribute-rgt-neg-in2.1%
associate-/l*2.2%
mul-1-neg2.2%
associate-/l*3.2%
distribute-lft1-in3.2%
metadata-eval3.2%
mul0-lft40.3%
metadata-eval40.3%
Simplified40.3%
if 1.05e-108 < M < 4.1e-33 or 34000 < M Initial program 22.1%
Simplified41.3%
Taylor expanded in c0 around -inf 0.5%
associate-*r/0.5%
neg-mul-10.5%
distribute-rgt-neg-in0.5%
Simplified0.5%
times-frac0.0%
*-commutative0.0%
Applied egg-rr0.0%
fma-undefine0.0%
associate-*r/0.0%
pow20.0%
associate-*r*0.0%
*-commutative0.0%
frac-times0.3%
add-sqr-sqrt0.0%
sqrt-unprod36.2%
sqr-neg36.2%
sqrt-unprod40.4%
add-sqr-sqrt40.4%
*-commutative40.4%
frac-times41.7%
pow241.7%
pow241.7%
frac-times42.5%
pow242.5%
Applied egg-rr42.5%
+-commutative42.5%
associate-*l/41.2%
associate-/l*42.5%
distribute-lft-out42.5%
*-commutative42.5%
associate-*l*42.4%
associate-/r*47.6%
unpow247.6%
associate-*r/50.2%
associate-*r*50.4%
*-commutative50.4%
associate-/r*50.4%
associate-*l/51.6%
unpow251.6%
*-commutative51.6%
Simplified51.6%
associate-/l*50.3%
count-250.3%
Applied egg-rr50.3%
times-frac50.3%
metadata-eval50.3%
Simplified50.3%
Final simplification43.2%
(FPCore (c0 w h D d M) :precision binary64 (* c0 (/ 0.0 (* 2.0 w))))
double code(double c0, double w, double h, double D, double d, double M) {
return c0 * (0.0 / (2.0 * w));
}
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 = c0 * (0.0d0 / (2.0d0 * w))
end function
public static double code(double c0, double w, double h, double D, double d, double M) {
return c0 * (0.0 / (2.0 * w));
}
def code(c0, w, h, D, d, M): return c0 * (0.0 / (2.0 * w))
function code(c0, w, h, D, d, M) return Float64(c0 * Float64(0.0 / Float64(2.0 * w))) end
function tmp = code(c0, w, h, D, d, M) tmp = c0 * (0.0 / (2.0 * w)); end
code[c0_, w_, h_, D_, d_, M_] := N[(c0 * N[(0.0 / N[(2.0 * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
c0 \cdot \frac{0}{2 \cdot w}
\end{array}
Initial program 22.1%
Simplified33.9%
Taylor expanded in c0 around -inf 2.3%
distribute-lft-in1.5%
mul-1-neg1.5%
distribute-rgt-neg-in1.5%
associate-/l*1.6%
mul-1-neg1.6%
associate-/l*2.3%
distribute-lft1-in2.3%
metadata-eval2.3%
mul0-lft33.5%
metadata-eval33.5%
Simplified33.5%
Final simplification33.5%
herbie shell --seed 2024071
(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))))))