
(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 4 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))))
(t_2 (* t_0 (+ t_1 (sqrt (- (* t_1 t_1) (* M M)))))))
(if (<= t_2 -2e-321)
(* t_0 (* 2.0 (/ (* c0 (* (/ d D) (/ d D))) (* w h))))
(if (or (<= t_2 0.0) (not (<= t_2 INFINITY)))
(/ (* 0.25 (* h (pow (* D M) 2.0))) (pow d 2.0))
(* t_0 (* 2.0 (* (pow (/ d D) 2.0) (/ c0 (* w h)))))))))
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 t_2 = t_0 * (t_1 + sqrt(((t_1 * t_1) - (M * M))));
double tmp;
if (t_2 <= -2e-321) {
tmp = t_0 * (2.0 * ((c0 * ((d / D) * (d / D))) / (w * h)));
} else if ((t_2 <= 0.0) || !(t_2 <= ((double) INFINITY))) {
tmp = (0.25 * (h * pow((D * M), 2.0))) / pow(d, 2.0);
} else {
tmp = t_0 * (2.0 * (pow((d / D), 2.0) * (c0 / (w * h))));
}
return tmp;
}
public static 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 t_2 = t_0 * (t_1 + Math.sqrt(((t_1 * t_1) - (M * M))));
double tmp;
if (t_2 <= -2e-321) {
tmp = t_0 * (2.0 * ((c0 * ((d / D) * (d / D))) / (w * h)));
} else if ((t_2 <= 0.0) || !(t_2 <= Double.POSITIVE_INFINITY)) {
tmp = (0.25 * (h * Math.pow((D * M), 2.0))) / Math.pow(d, 2.0);
} else {
tmp = t_0 * (2.0 * (Math.pow((d / D), 2.0) * (c0 / (w * h))));
}
return tmp;
}
def code(c0, w, h, D, d, M): t_0 = c0 / (2.0 * w) t_1 = (c0 * (d * d)) / ((w * h) * (D * D)) t_2 = t_0 * (t_1 + math.sqrt(((t_1 * t_1) - (M * M)))) tmp = 0 if t_2 <= -2e-321: tmp = t_0 * (2.0 * ((c0 * ((d / D) * (d / D))) / (w * h))) elif (t_2 <= 0.0) or not (t_2 <= math.inf): tmp = (0.25 * (h * math.pow((D * M), 2.0))) / math.pow(d, 2.0) else: tmp = t_0 * (2.0 * (math.pow((d / D), 2.0) * (c0 / (w * h)))) 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))) t_2 = Float64(t_0 * Float64(t_1 + sqrt(Float64(Float64(t_1 * t_1) - Float64(M * M))))) tmp = 0.0 if (t_2 <= -2e-321) tmp = Float64(t_0 * Float64(2.0 * Float64(Float64(c0 * Float64(Float64(d / D) * Float64(d / D))) / Float64(w * h)))); elseif ((t_2 <= 0.0) || !(t_2 <= Inf)) tmp = Float64(Float64(0.25 * Float64(h * (Float64(D * M) ^ 2.0))) / (d ^ 2.0)); else tmp = Float64(t_0 * Float64(2.0 * Float64((Float64(d / D) ^ 2.0) * Float64(c0 / Float64(w * h))))); end return tmp end
function tmp_2 = code(c0, w, h, D, d, M) t_0 = c0 / (2.0 * w); t_1 = (c0 * (d * d)) / ((w * h) * (D * D)); t_2 = t_0 * (t_1 + sqrt(((t_1 * t_1) - (M * M)))); tmp = 0.0; if (t_2 <= -2e-321) tmp = t_0 * (2.0 * ((c0 * ((d / D) * (d / D))) / (w * h))); elseif ((t_2 <= 0.0) || ~((t_2 <= Inf))) tmp = (0.25 * (h * ((D * M) ^ 2.0))) / (d ^ 2.0); else tmp = t_0 * (2.0 * (((d / D) ^ 2.0) * (c0 / (w * h)))); end tmp_2 = 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]}, Block[{t$95$2 = 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]}, If[LessEqual[t$95$2, -2e-321], N[(t$95$0 * N[(2.0 * N[(N[(c0 * N[(N[(d / D), $MachinePrecision] * N[(d / D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(w * h), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[t$95$2, 0.0], N[Not[LessEqual[t$95$2, Infinity]], $MachinePrecision]], N[(N[(0.25 * N[(h * N[Power[N[(D * M), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Power[d, 2.0], $MachinePrecision]), $MachinePrecision], N[(t$95$0 * N[(2.0 * N[(N[Power[N[(d / D), $MachinePrecision], 2.0], $MachinePrecision] * N[(c0 / N[(w * h), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $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)}\\
t_2 := t\_0 \cdot \left(t\_1 + \sqrt{t\_1 \cdot t\_1 - M \cdot M}\right)\\
\mathbf{if}\;t\_2 \leq -2 \cdot 10^{-321}:\\
\;\;\;\;t\_0 \cdot \left(2 \cdot \frac{c0 \cdot \left(\frac{d}{D} \cdot \frac{d}{D}\right)}{w \cdot h}\right)\\
\mathbf{elif}\;t\_2 \leq 0 \lor \neg \left(t\_2 \leq \infty\right):\\
\;\;\;\;\frac{0.25 \cdot \left(h \cdot {\left(D \cdot M\right)}^{2}\right)}{{d}^{2}}\\
\mathbf{else}:\\
\;\;\;\;t\_0 \cdot \left(2 \cdot \left({\left(\frac{d}{D}\right)}^{2} \cdot \frac{c0}{w \cdot h}\right)\right)\\
\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))))) < -2.00097e-321Initial program 79.3%
Simplified81.3%
times-frac79.3%
times-frac79.2%
times-frac79.3%
frac-times79.3%
Applied egg-rr83.3%
*-lft-identity83.3%
associate-/r*83.3%
unpow283.3%
swap-sqr72.6%
unpow272.6%
pow-sqr72.6%
metadata-eval72.6%
unsub-neg72.6%
fma-undefine72.6%
associate-/r*72.7%
Simplified72.7%
Taylor expanded in c0 around inf 79.4%
*-commutative79.4%
*-commutative79.4%
times-frac83.1%
unpow283.1%
unpow283.1%
times-frac85.2%
unpow285.2%
associate-*r/85.3%
*-commutative85.3%
*-commutative85.3%
Simplified85.3%
pow285.3%
Applied egg-rr85.3%
if -2.00097e-321 < (*.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))))) < 0.0 or +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 3.8%
Simplified3.3%
Taylor expanded in c0 around -inf 3.7%
Taylor expanded in c0 around 0 43.2%
associate-*r/43.1%
associate-*r*45.0%
unpow245.0%
unpow245.0%
swap-sqr53.2%
unpow253.2%
Simplified53.2%
if 0.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))))) < +inf.0Initial program 79.4%
Simplified79.3%
times-frac79.4%
times-frac79.4%
times-frac79.4%
frac-times79.4%
Applied egg-rr79.4%
*-lft-identity79.4%
associate-/r*79.3%
unpow279.3%
swap-sqr68.0%
unpow268.0%
pow-sqr68.0%
metadata-eval68.0%
unsub-neg68.0%
fma-undefine68.0%
associate-/r*68.0%
Simplified68.0%
Taylor expanded in c0 around inf 84.0%
*-commutative84.0%
*-commutative84.0%
times-frac86.2%
unpow286.2%
unpow286.2%
times-frac90.6%
unpow290.6%
associate-*r/86.2%
*-commutative86.2%
*-commutative86.2%
Simplified86.2%
div-inv86.2%
Applied egg-rr86.2%
associate-*r/86.2%
*-rgt-identity86.2%
*-commutative86.2%
associate-*r/90.6%
Simplified90.6%
Final simplification65.2%
(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 (* (pow (/ d D) 2.0) (/ c0 (* w 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 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 * (pow((d / D), 2.0) * (c0 / (w * h))));
} else {
tmp = 0.0;
}
return tmp;
}
public static 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 + Math.sqrt(((t_1 * t_1) - (M * M))))) <= Double.POSITIVE_INFINITY) {
tmp = t_0 * (2.0 * (Math.pow((d / D), 2.0) * (c0 / (w * h))));
} else {
tmp = 0.0;
}
return tmp;
}
def code(c0, w, h, D, d, M): t_0 = c0 / (2.0 * w) t_1 = (c0 * (d * d)) / ((w * h) * (D * D)) tmp = 0 if (t_0 * (t_1 + math.sqrt(((t_1 * t_1) - (M * M))))) <= math.inf: tmp = t_0 * (2.0 * (math.pow((d / D), 2.0) * (c0 / (w * h)))) else: tmp = 0.0 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(d / D) ^ 2.0) * Float64(c0 / Float64(w * 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); t_1 = (c0 * (d * d)) / ((w * h) * (D * D)); tmp = 0.0; if ((t_0 * (t_1 + sqrt(((t_1 * t_1) - (M * M))))) <= Inf) tmp = t_0 * (2.0 * (((d / D) ^ 2.0) * (c0 / (w * 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]}, 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[Power[N[(d / D), $MachinePrecision], 2.0], $MachinePrecision] * N[(c0 / N[(w * h), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 0.0]]]
\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 \left({\left(\frac{d}{D}\right)}^{2} \cdot \frac{c0}{w \cdot h}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;0\\
\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.4%
Simplified75.4%
times-frac73.4%
times-frac73.4%
times-frac75.4%
frac-times73.6%
Applied egg-rr72.6%
*-lft-identity72.6%
associate-/r*72.6%
unpow272.6%
swap-sqr62.9%
unpow262.9%
pow-sqr62.9%
metadata-eval62.9%
unsub-neg62.9%
fma-undefine62.9%
associate-/r*62.9%
Simplified62.9%
Taylor expanded in c0 around inf 74.6%
*-commutative74.6%
*-commutative74.6%
times-frac77.2%
unpow277.2%
unpow277.2%
times-frac79.1%
unpow279.1%
associate-*r/77.3%
*-commutative77.3%
*-commutative77.3%
Simplified77.3%
div-inv77.3%
Applied egg-rr77.3%
associate-*r/77.3%
*-rgt-identity77.3%
*-commutative77.3%
associate-*r/79.1%
Simplified79.1%
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%
Simplified0.1%
Taylor expanded in c0 around -inf 0.1%
mul-1-neg0.1%
distribute-lft-in0.1%
mul-1-neg0.1%
*-commutative0.1%
*-commutative0.1%
associate-*r*0.1%
distribute-neg-frac0.1%
associate-*r/0.1%
distribute-rgt-neg-in0.1%
neg-mul-10.1%
associate-*r*0.0%
*-commutative0.0%
*-commutative0.0%
associate-*r/0.0%
Simplified35.1%
Taylor expanded in c0 around 0 40.6%
Final simplification56.0%
(FPCore (c0 w h D d M) :precision binary64 (if (<= w 4.5e+181) (* (/ c0 (* 2.0 w)) (* 2.0 (/ (* c0 (* (/ d D) (/ d D))) (* w h)))) 0.0))
double code(double c0, double w, double h, double D, double d, double M) {
double tmp;
if (w <= 4.5e+181) {
tmp = (c0 / (2.0 * w)) * (2.0 * ((c0 * ((d / D) * (d / D))) / (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 (w <= 4.5d+181) then
tmp = (c0 / (2.0d0 * w)) * (2.0d0 * ((c0 * ((d_1 / d) * (d_1 / d))) / (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 (w <= 4.5e+181) {
tmp = (c0 / (2.0 * w)) * (2.0 * ((c0 * ((d / D) * (d / D))) / (w * h)));
} else {
tmp = 0.0;
}
return tmp;
}
def code(c0, w, h, D, d, M): tmp = 0 if w <= 4.5e+181: tmp = (c0 / (2.0 * w)) * (2.0 * ((c0 * ((d / D) * (d / D))) / (w * h))) else: tmp = 0.0 return tmp
function code(c0, w, h, D, d, M) tmp = 0.0 if (w <= 4.5e+181) tmp = Float64(Float64(c0 / Float64(2.0 * w)) * Float64(2.0 * Float64(Float64(c0 * Float64(Float64(d / D) * Float64(d / D))) / 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 (w <= 4.5e+181) tmp = (c0 / (2.0 * w)) * (2.0 * ((c0 * ((d / D) * (d / D))) / (w * h))); else tmp = 0.0; end tmp_2 = tmp; end
code[c0_, w_, h_, D_, d_, M_] := If[LessEqual[w, 4.5e+181], N[(N[(c0 / N[(2.0 * w), $MachinePrecision]), $MachinePrecision] * N[(2.0 * N[(N[(c0 * N[(N[(d / D), $MachinePrecision] * N[(d / D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(w * h), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 0.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;w \leq 4.5 \cdot 10^{+181}:\\
\;\;\;\;\frac{c0}{2 \cdot w} \cdot \left(2 \cdot \frac{c0 \cdot \left(\frac{d}{D} \cdot \frac{d}{D}\right)}{w \cdot h}\right)\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if w < 4.5e181Initial program 32.3%
Simplified32.4%
times-frac31.9%
times-frac31.9%
times-frac32.3%
frac-times32.0%
Applied egg-rr36.9%
*-lft-identity36.9%
associate-/r*37.0%
unpow237.0%
swap-sqr30.5%
unpow230.5%
pow-sqr30.5%
metadata-eval30.5%
unsub-neg30.5%
fma-undefine30.5%
associate-/r*30.5%
Simplified30.5%
Taylor expanded in c0 around inf 43.9%
*-commutative43.9%
*-commutative43.9%
times-frac45.1%
unpow245.1%
unpow245.1%
times-frac52.6%
unpow252.6%
associate-*r/52.2%
*-commutative52.2%
*-commutative52.2%
Simplified52.2%
pow252.2%
Applied egg-rr52.2%
if 4.5e181 < w Initial program 9.0%
Simplified8.7%
Taylor expanded in c0 around -inf 4.6%
mul-1-neg4.6%
distribute-lft-in4.6%
mul-1-neg4.6%
*-commutative4.6%
*-commutative4.6%
associate-*r*4.5%
distribute-neg-frac4.5%
associate-*r/4.6%
distribute-rgt-neg-in4.6%
neg-mul-14.6%
associate-*r*4.5%
*-commutative4.5%
*-commutative4.5%
associate-*r/4.5%
Simplified45.7%
Taylor expanded in c0 around 0 45.7%
Final simplification51.6%
(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 30.0%
Simplified30.1%
Taylor expanded in c0 around -inf 2.6%
mul-1-neg2.6%
distribute-lft-in2.6%
mul-1-neg2.6%
*-commutative2.6%
*-commutative2.6%
associate-*r*1.5%
distribute-neg-frac1.5%
associate-*r/2.3%
distribute-rgt-neg-in2.3%
neg-mul-12.3%
associate-*r*3.4%
*-commutative3.4%
*-commutative3.4%
associate-*r/3.4%
Simplified24.5%
Taylor expanded in c0 around 0 27.9%
Final simplification27.9%
herbie shell --seed 2024032
(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))))))