
(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 5 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 (pow d 2.0)) (* (* w h) (pow D 2.0)))))
(*
-0.25
(pow
(pow (* (pow (* D M) 2.0) (* h (pow d -2.0))) 3.0)
0.3333333333333333)))))
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 * pow(d, 2.0)) / ((w * h) * pow(D, 2.0))));
} else {
tmp = -0.25 * pow(pow((pow((D * M), 2.0) * (h * pow(d, -2.0))), 3.0), 0.3333333333333333);
}
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 * ((c0 * Math.pow(d, 2.0)) / ((w * h) * Math.pow(D, 2.0))));
} else {
tmp = -0.25 * Math.pow(Math.pow((Math.pow((D * M), 2.0) * (h * Math.pow(d, -2.0))), 3.0), 0.3333333333333333);
}
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 * ((c0 * math.pow(d, 2.0)) / ((w * h) * math.pow(D, 2.0)))) else: tmp = -0.25 * math.pow(math.pow((math.pow((D * M), 2.0) * (h * math.pow(d, -2.0))), 3.0), 0.3333333333333333) 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(c0 * (d ^ 2.0)) / Float64(Float64(w * h) * (D ^ 2.0))))); else tmp = Float64(-0.25 * ((Float64((Float64(D * M) ^ 2.0) * Float64(h * (d ^ -2.0))) ^ 3.0) ^ 0.3333333333333333)); 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 * ((c0 * (d ^ 2.0)) / ((w * h) * (D ^ 2.0)))); else tmp = -0.25 * (((((D * M) ^ 2.0) * (h * (d ^ -2.0))) ^ 3.0) ^ 0.3333333333333333); 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[(c0 * N[Power[d, 2.0], $MachinePrecision]), $MachinePrecision] / N[(N[(w * h), $MachinePrecision] * N[Power[D, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-0.25 * N[Power[N[Power[N[(N[Power[N[(D * M), $MachinePrecision], 2.0], $MachinePrecision] * N[(h * N[Power[d, -2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 3.0], $MachinePrecision], 0.3333333333333333], $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{c0 \cdot {d}^{2}}{\left(w \cdot h\right) \cdot {D}^{2}}\right)\\
\mathbf{else}:\\
\;\;\;\;-0.25 \cdot {\left({\left({\left(D \cdot M\right)}^{2} \cdot \left(h \cdot {d}^{-2}\right)\right)}^{3}\right)}^{0.3333333333333333}\\
\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 74.6%
Simplified75.7%
Taylor expanded in M around 0 71.9%
Taylor expanded in D around 0 76.0%
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%
Simplified1.2%
Taylor expanded in M around 0 0.6%
Taylor expanded in c0 around 0 34.0%
associate-/l*34.0%
associate-/l*34.6%
Simplified34.6%
add-cbrt-cube34.6%
pow1/337.5%
pow337.5%
associate-*r*37.5%
unpow-prod-down45.5%
div-inv45.5%
pow-flip45.5%
metadata-eval45.5%
Applied egg-rr45.5%
Final simplification54.9%
(FPCore (c0 w h D d M) :precision binary64 (if (<= M 5.1e-182) (* c0 (log (pow (exp M) (/ (sqrt -1.0) (* 2.0 w))))) (* (/ c0 (* 2.0 w)) (* (/ 2.0 w) (* (/ c0 h) (pow (/ d D) 2.0))))))
double code(double c0, double w, double h, double D, double d, double M) {
double tmp;
if (M <= 5.1e-182) {
tmp = c0 * log(pow(exp(M), (sqrt(-1.0) / (2.0 * w))));
} else {
tmp = (c0 / (2.0 * w)) * ((2.0 / w) * ((c0 / h) * pow((d / D), 2.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 (m <= 5.1d-182) then
tmp = c0 * log((exp(m) ** (sqrt((-1.0d0)) / (2.0d0 * w))))
else
tmp = (c0 / (2.0d0 * w)) * ((2.0d0 / w) * ((c0 / h) * ((d_1 / d) ** 2.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 (M <= 5.1e-182) {
tmp = c0 * Math.log(Math.pow(Math.exp(M), (Math.sqrt(-1.0) / (2.0 * w))));
} else {
tmp = (c0 / (2.0 * w)) * ((2.0 / w) * ((c0 / h) * Math.pow((d / D), 2.0)));
}
return tmp;
}
def code(c0, w, h, D, d, M): tmp = 0 if M <= 5.1e-182: tmp = c0 * math.log(math.pow(math.exp(M), (math.sqrt(-1.0) / (2.0 * w)))) else: tmp = (c0 / (2.0 * w)) * ((2.0 / w) * ((c0 / h) * math.pow((d / D), 2.0))) return tmp
function code(c0, w, h, D, d, M) tmp = 0.0 if (M <= 5.1e-182) tmp = Float64(c0 * log((exp(M) ^ Float64(sqrt(-1.0) / Float64(2.0 * w))))); else tmp = Float64(Float64(c0 / Float64(2.0 * w)) * Float64(Float64(2.0 / w) * Float64(Float64(c0 / h) * (Float64(d / D) ^ 2.0)))); end return tmp end
function tmp_2 = code(c0, w, h, D, d, M) tmp = 0.0; if (M <= 5.1e-182) tmp = c0 * log((exp(M) ^ (sqrt(-1.0) / (2.0 * w)))); else tmp = (c0 / (2.0 * w)) * ((2.0 / w) * ((c0 / h) * ((d / D) ^ 2.0))); end tmp_2 = tmp; end
code[c0_, w_, h_, D_, d_, M_] := If[LessEqual[M, 5.1e-182], N[(c0 * N[Log[N[Power[N[Exp[M], $MachinePrecision], N[(N[Sqrt[-1.0], $MachinePrecision] / N[(2.0 * w), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(c0 / N[(2.0 * w), $MachinePrecision]), $MachinePrecision] * N[(N[(2.0 / w), $MachinePrecision] * N[(N[(c0 / h), $MachinePrecision] * N[Power[N[(d / D), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;M \leq 5.1 \cdot 10^{-182}:\\
\;\;\;\;c0 \cdot \log \left({\left(e^{M}\right)}^{\left(\frac{\sqrt{-1}}{2 \cdot w}\right)}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{c0}{2 \cdot w} \cdot \left(\frac{2}{w} \cdot \left(\frac{c0}{h} \cdot {\left(\frac{d}{D}\right)}^{2}\right)\right)\\
\end{array}
\end{array}
if M < 5.10000000000000017e-182Initial program 25.0%
Simplified34.0%
Taylor expanded in c0 around 0 0.0%
add-log-exp0.0%
associate-/l*0.0%
exp-prod33.8%
*-commutative33.8%
Applied egg-rr33.8%
if 5.10000000000000017e-182 < M Initial program 19.1%
Simplified20.2%
times-frac20.3%
Applied egg-rr20.3%
times-frac20.3%
Applied egg-rr20.3%
Taylor expanded in c0 around inf 27.9%
associate-*r/27.9%
*-commutative27.9%
*-commutative27.9%
associate-*l*30.3%
*-commutative30.3%
times-frac33.8%
*-commutative33.8%
times-frac34.4%
unpow234.4%
unpow234.4%
times-frac48.9%
unpow248.9%
Simplified48.9%
Final simplification38.8%
(FPCore (c0 w h D d M) :precision binary64 (if (<= M 5.7e-182) (/ (* -0.25 (* h (pow (* D M) 2.0))) (pow d 2.0)) (* (/ c0 (* 2.0 w)) (* (/ 2.0 w) (* (/ c0 h) (pow (/ d D) 2.0))))))
double code(double c0, double w, double h, double D, double d, double M) {
double tmp;
if (M <= 5.7e-182) {
tmp = (-0.25 * (h * pow((D * M), 2.0))) / pow(d, 2.0);
} else {
tmp = (c0 / (2.0 * w)) * ((2.0 / w) * ((c0 / h) * pow((d / D), 2.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 (m <= 5.7d-182) then
tmp = ((-0.25d0) * (h * ((d * m) ** 2.0d0))) / (d_1 ** 2.0d0)
else
tmp = (c0 / (2.0d0 * w)) * ((2.0d0 / w) * ((c0 / h) * ((d_1 / d) ** 2.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 (M <= 5.7e-182) {
tmp = (-0.25 * (h * Math.pow((D * M), 2.0))) / Math.pow(d, 2.0);
} else {
tmp = (c0 / (2.0 * w)) * ((2.0 / w) * ((c0 / h) * Math.pow((d / D), 2.0)));
}
return tmp;
}
def code(c0, w, h, D, d, M): tmp = 0 if M <= 5.7e-182: tmp = (-0.25 * (h * math.pow((D * M), 2.0))) / math.pow(d, 2.0) else: tmp = (c0 / (2.0 * w)) * ((2.0 / w) * ((c0 / h) * math.pow((d / D), 2.0))) return tmp
function code(c0, w, h, D, d, M) tmp = 0.0 if (M <= 5.7e-182) tmp = Float64(Float64(-0.25 * Float64(h * (Float64(D * M) ^ 2.0))) / (d ^ 2.0)); else tmp = Float64(Float64(c0 / Float64(2.0 * w)) * Float64(Float64(2.0 / w) * Float64(Float64(c0 / h) * (Float64(d / D) ^ 2.0)))); end return tmp end
function tmp_2 = code(c0, w, h, D, d, M) tmp = 0.0; if (M <= 5.7e-182) tmp = (-0.25 * (h * ((D * M) ^ 2.0))) / (d ^ 2.0); else tmp = (c0 / (2.0 * w)) * ((2.0 / w) * ((c0 / h) * ((d / D) ^ 2.0))); end tmp_2 = tmp; end
code[c0_, w_, h_, D_, d_, M_] := If[LessEqual[M, 5.7e-182], 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[(N[(c0 / N[(2.0 * w), $MachinePrecision]), $MachinePrecision] * N[(N[(2.0 / w), $MachinePrecision] * N[(N[(c0 / h), $MachinePrecision] * N[Power[N[(d / D), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;M \leq 5.7 \cdot 10^{-182}:\\
\;\;\;\;\frac{-0.25 \cdot \left(h \cdot {\left(D \cdot M\right)}^{2}\right)}{{d}^{2}}\\
\mathbf{else}:\\
\;\;\;\;\frac{c0}{2 \cdot w} \cdot \left(\frac{2}{w} \cdot \left(\frac{c0}{h} \cdot {\left(\frac{d}{D}\right)}^{2}\right)\right)\\
\end{array}
\end{array}
if M < 5.6999999999999998e-182Initial program 25.0%
Simplified26.2%
Taylor expanded in M around 0 24.8%
Taylor expanded in c0 around 0 32.7%
associate-/l*32.7%
associate-/l*32.1%
Simplified32.1%
Taylor expanded in D around 0 32.7%
associate-*r/32.7%
associate-*r*32.7%
unpow232.7%
unpow232.7%
swap-sqr36.2%
unpow236.2%
Simplified36.2%
if 5.6999999999999998e-182 < M Initial program 19.1%
Simplified20.2%
times-frac20.3%
Applied egg-rr20.3%
times-frac20.3%
Applied egg-rr20.3%
Taylor expanded in c0 around inf 27.9%
associate-*r/27.9%
*-commutative27.9%
*-commutative27.9%
associate-*l*30.3%
*-commutative30.3%
times-frac33.8%
*-commutative33.8%
times-frac34.4%
unpow234.4%
unpow234.4%
times-frac48.9%
unpow248.9%
Simplified48.9%
Final simplification40.5%
(FPCore (c0 w h D d M)
:precision binary64
(let* ((t_0 (/ c0 (* 2.0 w))))
(if (<= M 5.3e-182)
(* t_0 (* c0 0.0))
(* t_0 (* (/ 2.0 w) (* (/ c0 h) (pow (/ d D) 2.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 (M <= 5.3e-182) {
tmp = t_0 * (c0 * 0.0);
} else {
tmp = t_0 * ((2.0 / w) * ((c0 / h) * pow((d / D), 2.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 (m <= 5.3d-182) then
tmp = t_0 * (c0 * 0.0d0)
else
tmp = t_0 * ((2.0d0 / w) * ((c0 / h) * ((d_1 / d) ** 2.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 (M <= 5.3e-182) {
tmp = t_0 * (c0 * 0.0);
} else {
tmp = t_0 * ((2.0 / w) * ((c0 / h) * Math.pow((d / D), 2.0)));
}
return tmp;
}
def code(c0, w, h, D, d, M): t_0 = c0 / (2.0 * w) tmp = 0 if M <= 5.3e-182: tmp = t_0 * (c0 * 0.0) else: tmp = t_0 * ((2.0 / w) * ((c0 / h) * math.pow((d / D), 2.0))) return tmp
function code(c0, w, h, D, d, M) t_0 = Float64(c0 / Float64(2.0 * w)) tmp = 0.0 if (M <= 5.3e-182) tmp = Float64(t_0 * Float64(c0 * 0.0)); else tmp = Float64(t_0 * Float64(Float64(2.0 / w) * Float64(Float64(c0 / h) * (Float64(d / D) ^ 2.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 (M <= 5.3e-182) tmp = t_0 * (c0 * 0.0); else tmp = t_0 * ((2.0 / w) * ((c0 / h) * ((d / D) ^ 2.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[M, 5.3e-182], N[(t$95$0 * N[(c0 * 0.0), $MachinePrecision]), $MachinePrecision], N[(t$95$0 * N[(N[(2.0 / w), $MachinePrecision] * N[(N[(c0 / h), $MachinePrecision] * N[Power[N[(d / D), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{c0}{2 \cdot w}\\
\mathbf{if}\;M \leq 5.3 \cdot 10^{-182}:\\
\;\;\;\;t\_0 \cdot \left(c0 \cdot 0\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0 \cdot \left(\frac{2}{w} \cdot \left(\frac{c0}{h} \cdot {\left(\frac{d}{D}\right)}^{2}\right)\right)\\
\end{array}
\end{array}
if M < 5.30000000000000005e-182Initial program 25.0%
Simplified26.2%
times-frac25.7%
Applied egg-rr25.7%
times-frac25.7%
Applied egg-rr25.7%
Taylor expanded in c0 around -inf 6.7%
associate-*r*6.7%
mul-1-neg6.7%
distribute-lft1-in6.7%
metadata-eval6.7%
mul0-lft36.6%
distribute-lft-neg-in36.6%
distribute-rgt-neg-in36.6%
metadata-eval36.6%
Simplified36.6%
if 5.30000000000000005e-182 < M Initial program 19.1%
Simplified20.2%
times-frac20.3%
Applied egg-rr20.3%
times-frac20.3%
Applied egg-rr20.3%
Taylor expanded in c0 around inf 27.9%
associate-*r/27.9%
*-commutative27.9%
*-commutative27.9%
associate-*l*30.3%
*-commutative30.3%
times-frac33.8%
*-commutative33.8%
times-frac34.4%
unpow234.4%
unpow234.4%
times-frac48.9%
unpow248.9%
Simplified48.9%
(FPCore (c0 w h D d M) :precision binary64 (* (/ c0 (* 2.0 w)) (* c0 0.0)))
double code(double c0, double w, double h, double D, double d, double M) {
return (c0 / (2.0 * w)) * (c0 * 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 = (c0 / (2.0d0 * w)) * (c0 * 0.0d0)
end function
public static double code(double c0, double w, double h, double D, double d, double M) {
return (c0 / (2.0 * w)) * (c0 * 0.0);
}
def code(c0, w, h, D, d, M): return (c0 / (2.0 * w)) * (c0 * 0.0)
function code(c0, w, h, D, d, M) return Float64(Float64(c0 / Float64(2.0 * w)) * Float64(c0 * 0.0)) end
function tmp = code(c0, w, h, D, d, M) tmp = (c0 / (2.0 * w)) * (c0 * 0.0); end
code[c0_, w_, h_, D_, d_, M_] := N[(N[(c0 / N[(2.0 * w), $MachinePrecision]), $MachinePrecision] * N[(c0 * 0.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{c0}{2 \cdot w} \cdot \left(c0 \cdot 0\right)
\end{array}
Initial program 23.0%
Simplified24.2%
times-frac23.9%
Applied egg-rr23.9%
times-frac23.9%
Applied egg-rr23.9%
Taylor expanded in c0 around -inf 4.9%
associate-*r*4.9%
mul-1-neg4.9%
distribute-lft1-in4.9%
metadata-eval4.9%
mul0-lft31.4%
distribute-lft-neg-in31.4%
distribute-rgt-neg-in31.4%
metadata-eval31.4%
Simplified31.4%
herbie shell --seed 2024177
(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))))))