
(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))))))
(t_3 (/ (* D M) d)))
(if (<= t_2 -1e-44)
(* t_0 (* 2.0 (* c0 (* (/ d D) (/ (/ d D) (* w h))))))
(if (or (<= t_2 0.0) (not (<= t_2 INFINITY)))
(* 0.25 (* h (* t_3 t_3)))
(* t_0 (* 2.0 (* c0 (* (/ (/ d D) w) (/ (/ d D) 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 t_3 = (D * M) / d;
double tmp;
if (t_2 <= -1e-44) {
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 * (t_3 * t_3));
} else {
tmp = t_0 * (2.0 * (c0 * (((d / D) / w) * ((d / D) / 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 t_3 = (D * M) / d;
double tmp;
if (t_2 <= -1e-44) {
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 * (t_3 * t_3));
} else {
tmp = t_0 * (2.0 * (c0 * (((d / D) / w) * ((d / D) / 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)))) t_3 = (D * M) / d tmp = 0 if t_2 <= -1e-44: 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 * (t_3 * t_3)) else: tmp = t_0 * (2.0 * (c0 * (((d / D) / w) * ((d / D) / 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))))) t_3 = Float64(Float64(D * M) / d) tmp = 0.0 if (t_2 <= -1e-44) tmp = Float64(t_0 * Float64(2.0 * Float64(c0 * Float64(Float64(d / D) * Float64(Float64(d / D) / Float64(w * h)))))); elseif ((t_2 <= 0.0) || !(t_2 <= Inf)) tmp = Float64(0.25 * Float64(h * Float64(t_3 * t_3))); else tmp = Float64(t_0 * Float64(2.0 * Float64(c0 * Float64(Float64(Float64(d / D) / w) * Float64(Float64(d / D) / 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)))); t_3 = (D * M) / d; tmp = 0.0; if (t_2 <= -1e-44) tmp = t_0 * (2.0 * (c0 * ((d / D) * ((d / D) / (w * h))))); elseif ((t_2 <= 0.0) || ~((t_2 <= Inf))) tmp = 0.25 * (h * (t_3 * t_3)); else tmp = t_0 * (2.0 * (c0 * (((d / D) / w) * ((d / D) / 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]}, Block[{t$95$3 = N[(N[(D * M), $MachinePrecision] / d), $MachinePrecision]}, If[LessEqual[t$95$2, -1e-44], N[(t$95$0 * N[(2.0 * N[(c0 * N[(N[(d / D), $MachinePrecision] * N[(N[(d / D), $MachinePrecision] / N[(w * h), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[t$95$2, 0.0], N[Not[LessEqual[t$95$2, Infinity]], $MachinePrecision]], N[(0.25 * N[(h * N[(t$95$3 * t$95$3), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$0 * N[(2.0 * N[(c0 * N[(N[(N[(d / D), $MachinePrecision] / w), $MachinePrecision] * N[(N[(d / D), $MachinePrecision] / 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)\\
t_3 := \frac{D \cdot M}{d}\\
\mathbf{if}\;t\_2 \leq -1 \cdot 10^{-44}:\\
\;\;\;\;t\_0 \cdot \left(2 \cdot \left(c0 \cdot \left(\frac{d}{D} \cdot \frac{\frac{d}{D}}{w \cdot h}\right)\right)\right)\\
\mathbf{elif}\;t\_2 \leq 0 \lor \neg \left(t\_2 \leq \infty\right):\\
\;\;\;\;0.25 \cdot \left(h \cdot \left(t\_3 \cdot t\_3\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0 \cdot \left(2 \cdot \left(c0 \cdot \left(\frac{\frac{d}{D}}{w} \cdot \frac{\frac{d}{D}}{h}\right)\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))))) < -9.99999999999999953e-45Initial program 81.2%
Simplified81.2%
times-frac81.2%
Applied egg-rr81.2%
Taylor expanded in c0 around inf 84.0%
associate-/l*84.1%
associate-/r*84.1%
unpow284.1%
unpow284.1%
times-frac84.1%
unpow284.1%
Simplified84.1%
unpow284.1%
*-un-lft-identity84.1%
times-frac89.4%
Applied egg-rr89.4%
if -9.99999999999999953e-45 < (*.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.0%
Simplified3.1%
Taylor expanded in c0 around -inf 7.6%
+-commutative7.6%
associate-/l*8.0%
*-commutative8.0%
distribute-lft-in6.2%
Simplified34.7%
Taylor expanded in c0 around 0 51.4%
associate-/l*51.3%
pow251.3%
*-commutative51.3%
pow251.3%
Applied egg-rr51.3%
associate-*r/51.4%
*-commutative51.4%
associate-*r*51.7%
unpow251.7%
unpow251.7%
swap-sqr61.2%
unpow261.2%
*-commutative61.2%
associate-/l*61.2%
*-commutative61.2%
Simplified61.2%
unpow261.2%
unpow261.2%
times-frac74.2%
Applied egg-rr74.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 84.9%
Simplified80.6%
times-frac80.5%
Applied egg-rr80.5%
Taylor expanded in c0 around inf 83.7%
associate-/l*81.5%
associate-/r*79.3%
unpow279.3%
unpow279.3%
times-frac81.4%
unpow281.4%
Simplified81.4%
unpow281.4%
*-commutative81.4%
times-frac85.6%
Applied egg-rr85.6%
Final simplification78.4%
(FPCore (c0 w h D d M)
:precision binary64
(let* ((t_0 (/ (* D M) d)))
(if (or (<= d 9e+223) (not (<= d 4.4e+295)))
(* 0.25 (* h (* t_0 t_0)))
(* (/ c0 (* 2.0 w)) (* 2.0 (* c0 (* (/ (/ d D) w) (/ (/ d D) h))))))))
double code(double c0, double w, double h, double D, double d, double M) {
double t_0 = (D * M) / d;
double tmp;
if ((d <= 9e+223) || !(d <= 4.4e+295)) {
tmp = 0.25 * (h * (t_0 * t_0));
} else {
tmp = (c0 / (2.0 * w)) * (2.0 * (c0 * (((d / D) / w) * ((d / D) / h))));
}
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 = (d * m) / d_1
if ((d_1 <= 9d+223) .or. (.not. (d_1 <= 4.4d+295))) then
tmp = 0.25d0 * (h * (t_0 * t_0))
else
tmp = (c0 / (2.0d0 * w)) * (2.0d0 * (c0 * (((d_1 / d) / w) * ((d_1 / d) / h))))
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 = (D * M) / d;
double tmp;
if ((d <= 9e+223) || !(d <= 4.4e+295)) {
tmp = 0.25 * (h * (t_0 * t_0));
} else {
tmp = (c0 / (2.0 * w)) * (2.0 * (c0 * (((d / D) / w) * ((d / D) / h))));
}
return tmp;
}
def code(c0, w, h, D, d, M): t_0 = (D * M) / d tmp = 0 if (d <= 9e+223) or not (d <= 4.4e+295): tmp = 0.25 * (h * (t_0 * t_0)) else: tmp = (c0 / (2.0 * w)) * (2.0 * (c0 * (((d / D) / w) * ((d / D) / h)))) return tmp
function code(c0, w, h, D, d, M) t_0 = Float64(Float64(D * M) / d) tmp = 0.0 if ((d <= 9e+223) || !(d <= 4.4e+295)) tmp = Float64(0.25 * Float64(h * Float64(t_0 * t_0))); else tmp = Float64(Float64(c0 / Float64(2.0 * w)) * Float64(2.0 * Float64(c0 * Float64(Float64(Float64(d / D) / w) * Float64(Float64(d / D) / h))))); end return tmp end
function tmp_2 = code(c0, w, h, D, d, M) t_0 = (D * M) / d; tmp = 0.0; if ((d <= 9e+223) || ~((d <= 4.4e+295))) tmp = 0.25 * (h * (t_0 * t_0)); else tmp = (c0 / (2.0 * w)) * (2.0 * (c0 * (((d / D) / w) * ((d / D) / h)))); end tmp_2 = tmp; end
code[c0_, w_, h_, D_, d_, M_] := Block[{t$95$0 = N[(N[(D * M), $MachinePrecision] / d), $MachinePrecision]}, If[Or[LessEqual[d, 9e+223], N[Not[LessEqual[d, 4.4e+295]], $MachinePrecision]], N[(0.25 * N[(h * N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(c0 / N[(2.0 * w), $MachinePrecision]), $MachinePrecision] * N[(2.0 * N[(c0 * N[(N[(N[(d / D), $MachinePrecision] / w), $MachinePrecision] * N[(N[(d / D), $MachinePrecision] / h), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{D \cdot M}{d}\\
\mathbf{if}\;d \leq 9 \cdot 10^{+223} \lor \neg \left(d \leq 4.4 \cdot 10^{+295}\right):\\
\;\;\;\;0.25 \cdot \left(h \cdot \left(t\_0 \cdot t\_0\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{c0}{2 \cdot w} \cdot \left(2 \cdot \left(c0 \cdot \left(\frac{\frac{d}{D}}{w} \cdot \frac{\frac{d}{D}}{h}\right)\right)\right)\\
\end{array}
\end{array}
if d < 9e223 or 4.3999999999999996e295 < d Initial program 27.3%
Simplified26.4%
Taylor expanded in c0 around -inf 7.3%
+-commutative7.3%
associate-/l*7.6%
*-commutative7.6%
distribute-lft-in6.2%
Simplified28.8%
Taylor expanded in c0 around 0 41.5%
associate-/l*41.4%
pow241.4%
*-commutative41.4%
pow241.4%
Applied egg-rr41.4%
associate-*r/41.5%
*-commutative41.5%
associate-*r*42.7%
unpow242.7%
unpow242.7%
swap-sqr49.1%
unpow249.1%
*-commutative49.1%
associate-/l*49.1%
*-commutative49.1%
Simplified49.1%
unpow249.1%
unpow249.1%
times-frac56.7%
Applied egg-rr56.7%
if 9e223 < d < 4.3999999999999996e295Initial program 38.2%
Simplified38.2%
times-frac38.2%
Applied egg-rr38.2%
Taylor expanded in c0 around inf 47.1%
associate-/l*47.1%
associate-/r*47.1%
unpow247.1%
unpow247.1%
times-frac56.7%
unpow256.7%
Simplified56.7%
unpow256.7%
*-commutative56.7%
times-frac59.8%
Applied egg-rr59.8%
Final simplification57.1%
(FPCore (c0 w h D d M) :precision binary64 (let* ((t_0 (/ (* D M) d))) (* 0.25 (* h (* t_0 t_0)))))
double code(double c0, double w, double h, double D, double d, double M) {
double t_0 = (D * M) / d;
return 0.25 * (h * (t_0 * t_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
real(8) :: t_0
t_0 = (d * m) / d_1
code = 0.25d0 * (h * (t_0 * t_0))
end function
public static double code(double c0, double w, double h, double D, double d, double M) {
double t_0 = (D * M) / d;
return 0.25 * (h * (t_0 * t_0));
}
def code(c0, w, h, D, d, M): t_0 = (D * M) / d return 0.25 * (h * (t_0 * t_0))
function code(c0, w, h, D, d, M) t_0 = Float64(Float64(D * M) / d) return Float64(0.25 * Float64(h * Float64(t_0 * t_0))) end
function tmp = code(c0, w, h, D, d, M) t_0 = (D * M) / d; tmp = 0.25 * (h * (t_0 * t_0)); end
code[c0_, w_, h_, D_, d_, M_] := Block[{t$95$0 = N[(N[(D * M), $MachinePrecision] / d), $MachinePrecision]}, N[(0.25 * N[(h * N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{D \cdot M}{d}\\
0.25 \cdot \left(h \cdot \left(t\_0 \cdot t\_0\right)\right)
\end{array}
\end{array}
Initial program 28.7%
Simplified28.0%
Taylor expanded in c0 around -inf 6.3%
+-commutative6.3%
associate-/l*6.6%
*-commutative6.6%
distribute-lft-in5.4%
Simplified25.9%
Taylor expanded in c0 around 0 37.3%
associate-/l*37.3%
pow237.3%
*-commutative37.3%
pow237.3%
Applied egg-rr37.3%
associate-*r/37.3%
*-commutative37.3%
associate-*r*38.3%
unpow238.3%
unpow238.3%
swap-sqr44.7%
unpow244.7%
*-commutative44.7%
associate-/l*44.8%
*-commutative44.8%
Simplified44.8%
unpow244.8%
unpow244.8%
times-frac53.3%
Applied egg-rr53.3%
Final simplification53.3%
(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 28.7%
Simplified39.3%
Taylor expanded in c0 around -inf 3.9%
distribute-lft-in3.1%
mul-1-neg3.1%
distribute-rgt-neg-in3.1%
associate-/l*2.7%
mul-1-neg2.7%
associate-/l*3.1%
distribute-lft1-in3.1%
metadata-eval3.1%
mul0-lft34.3%
metadata-eval34.3%
Simplified34.3%
Final simplification34.3%
herbie shell --seed 2024041
(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))))))