
(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 (pow (/ d D) 2.0)) (* w h)))
(t_1 (/ (* c0 (* d d)) (* (* w h) (* D D)))))
(if (<=
(* (/ c0 (* 2.0 w)) (+ t_1 (sqrt (- (* t_1 t_1) (* M M)))))
INFINITY)
(* c0 (/ (+ t_0 (sqrt (- (pow t_0 2.0) (pow M 2.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 * pow((d / D), 2.0)) / (w * h);
double t_1 = (c0 * (d * d)) / ((w * h) * (D * D));
double tmp;
if (((c0 / (2.0 * w)) * (t_1 + sqrt(((t_1 * t_1) - (M * M))))) <= ((double) INFINITY)) {
tmp = c0 * ((t_0 + sqrt((pow(t_0, 2.0) - pow(M, 2.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 * Math.pow((d / D), 2.0)) / (w * h);
double t_1 = (c0 * (d * d)) / ((w * h) * (D * D));
double tmp;
if (((c0 / (2.0 * w)) * (t_1 + Math.sqrt(((t_1 * t_1) - (M * M))))) <= Double.POSITIVE_INFINITY) {
tmp = c0 * ((t_0 + Math.sqrt((Math.pow(t_0, 2.0) - Math.pow(M, 2.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 * math.pow((d / D), 2.0)) / (w * h) t_1 = (c0 * (d * d)) / ((w * h) * (D * D)) tmp = 0 if ((c0 / (2.0 * w)) * (t_1 + math.sqrt(((t_1 * t_1) - (M * M))))) <= math.inf: tmp = c0 * ((t_0 + math.sqrt((math.pow(t_0, 2.0) - math.pow(M, 2.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) ^ 2.0)) / Float64(w * h)) t_1 = Float64(Float64(c0 * Float64(d * d)) / Float64(Float64(w * h) * Float64(D * D))) tmp = 0.0 if (Float64(Float64(c0 / Float64(2.0 * w)) * Float64(t_1 + sqrt(Float64(Float64(t_1 * t_1) - Float64(M * M))))) <= Inf) tmp = Float64(c0 * Float64(Float64(t_0 + sqrt(Float64((t_0 ^ 2.0) - (M ^ 2.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) ^ 2.0)) / (w * h); t_1 = (c0 * (d * d)) / ((w * h) * (D * D)); tmp = 0.0; if (((c0 / (2.0 * w)) * (t_1 + sqrt(((t_1 * t_1) - (M * M))))) <= Inf) tmp = c0 * ((t_0 + sqrt(((t_0 ^ 2.0) - (M ^ 2.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[Power[N[(d / D), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / N[(w * h), $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[(N[(c0 / N[(2.0 * w), $MachinePrecision]), $MachinePrecision] * 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[(c0 * N[(N[(t$95$0 + N[Sqrt[N[(N[Power[t$95$0, 2.0], $MachinePrecision] - N[Power[M, 2.0], $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(\frac{d}{D}\right)}^{2}}{w \cdot h}\\
t_1 := \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)}\\
\mathbf{if}\;\frac{c0}{2 \cdot w} \cdot \left(t\_1 + \sqrt{t\_1 \cdot t\_1 - M \cdot M}\right) \leq \infty:\\
\;\;\;\;c0 \cdot \frac{t\_0 + \sqrt{{t\_0}^{2} - {M}^{2}}}{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 82.0%
Simplified75.6%
fma-undefine81.6%
associate-*r/76.8%
*-commutative76.8%
associate-*r*75.8%
associate-*r*74.9%
associate-/l*74.0%
frac-times72.2%
associate-*l/73.9%
times-frac74.7%
pow274.7%
Applied egg-rr82.9%
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%
Simplified25.6%
Taylor expanded in c0 around -inf 1.9%
mul-1-neg1.9%
distribute-lft-in1.2%
mul-1-neg1.2%
distribute-rgt-neg-in1.2%
associate-/l*0.1%
mul-1-neg0.1%
associate-/l*0.1%
distribute-lft1-in0.1%
metadata-eval0.1%
mul0-lft43.7%
metadata-eval43.7%
Simplified43.7%
(FPCore (c0 w h D d M)
:precision binary64
(let* ((t_0 (/ (* c0 (* d d)) (* (* w h) (* D D))))
(t_1 (* (/ c0 (* 2.0 w)) (+ t_0 (sqrt (- (* t_0 t_0) (* M M)))))))
(if (<= t_1 INFINITY) t_1 (* 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)) / ((w * h) * (D * D));
double t_1 = (c0 / (2.0 * w)) * (t_0 + sqrt(((t_0 * t_0) - (M * M))));
double tmp;
if (t_1 <= ((double) INFINITY)) {
tmp = t_1;
} 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)) / ((w * h) * (D * D));
double t_1 = (c0 / (2.0 * w)) * (t_0 + Math.sqrt(((t_0 * t_0) - (M * M))));
double tmp;
if (t_1 <= Double.POSITIVE_INFINITY) {
tmp = t_1;
} else {
tmp = c0 * (0.0 / (2.0 * w));
}
return tmp;
}
def code(c0, w, h, D, d, M): t_0 = (c0 * (d * d)) / ((w * h) * (D * D)) t_1 = (c0 / (2.0 * w)) * (t_0 + math.sqrt(((t_0 * t_0) - (M * M)))) tmp = 0 if t_1 <= math.inf: tmp = t_1 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(w * h) * Float64(D * D))) t_1 = Float64(Float64(c0 / Float64(2.0 * w)) * Float64(t_0 + sqrt(Float64(Float64(t_0 * t_0) - Float64(M * M))))) tmp = 0.0 if (t_1 <= Inf) tmp = t_1; 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)) / ((w * h) * (D * D)); t_1 = (c0 / (2.0 * w)) * (t_0 + sqrt(((t_0 * t_0) - (M * M)))); tmp = 0.0; if (t_1 <= Inf) tmp = t_1; 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[(w * h), $MachinePrecision] * N[(D * D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = 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]}, If[LessEqual[t$95$1, Infinity], t$95$1, 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(w \cdot h\right) \cdot \left(D \cdot D\right)}\\
t_1 := \frac{c0}{2 \cdot w} \cdot \left(t\_0 + \sqrt{t\_0 \cdot t\_0 - M \cdot M}\right)\\
\mathbf{if}\;t\_1 \leq \infty:\\
\;\;\;\;t\_1\\
\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 82.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%
Simplified25.6%
Taylor expanded in c0 around -inf 1.9%
mul-1-neg1.9%
distribute-lft-in1.2%
mul-1-neg1.2%
distribute-rgt-neg-in1.2%
associate-/l*0.1%
mul-1-neg0.1%
associate-/l*0.1%
distribute-lft1-in0.1%
metadata-eval0.1%
mul0-lft43.7%
metadata-eval43.7%
Simplified43.7%
(FPCore (c0 w h D d M) :precision binary64 (if (<= M 9.6e-255) (* c0 (/ 0.0 (* 2.0 w))) (* c0 (/ (* 2.0 (/ (/ (* c0 (pow (/ d D) 2.0)) w) h)) (* 2.0 w)))))
double code(double c0, double w, double h, double D, double d, double M) {
double tmp;
if (M <= 9.6e-255) {
tmp = c0 * (0.0 / (2.0 * w));
} else {
tmp = c0 * ((2.0 * (((c0 * pow((d / D), 2.0)) / w) / h)) / (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 <= 9.6d-255) then
tmp = c0 * (0.0d0 / (2.0d0 * w))
else
tmp = c0 * ((2.0d0 * (((c0 * ((d_1 / d) ** 2.0d0)) / w) / h)) / (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 <= 9.6e-255) {
tmp = c0 * (0.0 / (2.0 * w));
} else {
tmp = c0 * ((2.0 * (((c0 * Math.pow((d / D), 2.0)) / w) / h)) / (2.0 * w));
}
return tmp;
}
def code(c0, w, h, D, d, M): tmp = 0 if M <= 9.6e-255: tmp = c0 * (0.0 / (2.0 * w)) else: tmp = c0 * ((2.0 * (((c0 * math.pow((d / D), 2.0)) / w) / h)) / (2.0 * w)) return tmp
function code(c0, w, h, D, d, M) tmp = 0.0 if (M <= 9.6e-255) tmp = Float64(c0 * Float64(0.0 / Float64(2.0 * w))); else tmp = Float64(c0 * Float64(Float64(2.0 * Float64(Float64(Float64(c0 * (Float64(d / D) ^ 2.0)) / w) / h)) / Float64(2.0 * w))); end return tmp end
function tmp_2 = code(c0, w, h, D, d, M) tmp = 0.0; if (M <= 9.6e-255) tmp = c0 * (0.0 / (2.0 * w)); else tmp = c0 * ((2.0 * (((c0 * ((d / D) ^ 2.0)) / w) / h)) / (2.0 * w)); end tmp_2 = tmp; end
code[c0_, w_, h_, D_, d_, M_] := If[LessEqual[M, 9.6e-255], N[(c0 * N[(0.0 / N[(2.0 * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(c0 * N[(N[(2.0 * N[(N[(N[(c0 * N[Power[N[(d / D), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / w), $MachinePrecision] / h), $MachinePrecision]), $MachinePrecision] / N[(2.0 * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;M \leq 9.6 \cdot 10^{-255}:\\
\;\;\;\;c0 \cdot \frac{0}{2 \cdot w}\\
\mathbf{else}:\\
\;\;\;\;c0 \cdot \frac{2 \cdot \frac{\frac{c0 \cdot {\left(\frac{d}{D}\right)}^{2}}{w}}{h}}{2 \cdot w}\\
\end{array}
\end{array}
if M < 9.5999999999999993e-255Initial program 31.4%
Simplified42.9%
Taylor expanded in c0 around -inf 8.6%
mul-1-neg8.6%
distribute-lft-in7.8%
mul-1-neg7.8%
distribute-rgt-neg-in7.8%
associate-/l*5.9%
mul-1-neg5.9%
associate-/l*6.6%
distribute-lft1-in6.6%
metadata-eval6.6%
mul0-lft34.7%
metadata-eval34.7%
Simplified34.7%
if 9.5999999999999993e-255 < M Initial program 33.5%
Simplified48.3%
Taylor expanded in w around 0 48.4%
Taylor expanded in w around 0 48.4%
Taylor expanded in c0 around inf 41.6%
associate-/l*41.8%
Simplified41.8%
pow241.8%
associate-*r/41.6%
pow241.6%
*-commutative41.6%
*-commutative41.6%
frac-times40.9%
frac-times47.9%
pow247.9%
associate-*l/48.9%
associate-/r*50.8%
Applied egg-rr50.8%
(FPCore (c0 w h D d M) :precision binary64 (if (<= M 1.2e-253) (* c0 (/ 0.0 (* 2.0 w))) (* c0 (/ (* 2.0 (* c0 (/ (pow (/ d D) 2.0) (* w h)))) (* 2.0 w)))))
double code(double c0, double w, double h, double D, double d, double M) {
double tmp;
if (M <= 1.2e-253) {
tmp = c0 * (0.0 / (2.0 * w));
} else {
tmp = c0 * ((2.0 * (c0 * (pow((d / D), 2.0) / (w * h)))) / (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.2d-253) then
tmp = c0 * (0.0d0 / (2.0d0 * w))
else
tmp = c0 * ((2.0d0 * (c0 * (((d_1 / d) ** 2.0d0) / (w * h)))) / (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.2e-253) {
tmp = c0 * (0.0 / (2.0 * w));
} else {
tmp = c0 * ((2.0 * (c0 * (Math.pow((d / D), 2.0) / (w * h)))) / (2.0 * w));
}
return tmp;
}
def code(c0, w, h, D, d, M): tmp = 0 if M <= 1.2e-253: tmp = c0 * (0.0 / (2.0 * w)) else: tmp = c0 * ((2.0 * (c0 * (math.pow((d / D), 2.0) / (w * h)))) / (2.0 * w)) return tmp
function code(c0, w, h, D, d, M) tmp = 0.0 if (M <= 1.2e-253) tmp = Float64(c0 * Float64(0.0 / Float64(2.0 * w))); else tmp = Float64(c0 * Float64(Float64(2.0 * Float64(c0 * Float64((Float64(d / D) ^ 2.0) / Float64(w * h)))) / Float64(2.0 * w))); end return tmp end
function tmp_2 = code(c0, w, h, D, d, M) tmp = 0.0; if (M <= 1.2e-253) tmp = c0 * (0.0 / (2.0 * w)); else tmp = c0 * ((2.0 * (c0 * (((d / D) ^ 2.0) / (w * h)))) / (2.0 * w)); end tmp_2 = tmp; end
code[c0_, w_, h_, D_, d_, M_] := If[LessEqual[M, 1.2e-253], N[(c0 * N[(0.0 / N[(2.0 * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(c0 * N[(N[(2.0 * N[(c0 * N[(N[Power[N[(d / D), $MachinePrecision], 2.0], $MachinePrecision] / N[(w * h), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(2.0 * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;M \leq 1.2 \cdot 10^{-253}:\\
\;\;\;\;c0 \cdot \frac{0}{2 \cdot w}\\
\mathbf{else}:\\
\;\;\;\;c0 \cdot \frac{2 \cdot \left(c0 \cdot \frac{{\left(\frac{d}{D}\right)}^{2}}{w \cdot h}\right)}{2 \cdot w}\\
\end{array}
\end{array}
if M < 1.20000000000000005e-253Initial program 31.4%
Simplified42.9%
Taylor expanded in c0 around -inf 8.6%
mul-1-neg8.6%
distribute-lft-in7.8%
mul-1-neg7.8%
distribute-rgt-neg-in7.8%
associate-/l*5.9%
mul-1-neg5.9%
associate-/l*6.6%
distribute-lft1-in6.6%
metadata-eval6.6%
mul0-lft34.7%
metadata-eval34.7%
Simplified34.7%
if 1.20000000000000005e-253 < M Initial program 33.5%
Simplified48.3%
Taylor expanded in w around 0 48.4%
Taylor expanded in w around 0 48.4%
Taylor expanded in c0 around inf 41.6%
associate-/l*41.8%
Simplified41.8%
pow241.8%
pow241.8%
associate-/r*40.9%
frac-times48.0%
pow248.0%
div-inv48.0%
Applied egg-rr48.0%
associate-*r/48.0%
*-rgt-identity48.0%
Simplified48.0%
Final simplification40.6%
(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 32.3%
Simplified45.3%
Taylor expanded in c0 around -inf 5.9%
mul-1-neg5.9%
distribute-lft-in5.5%
mul-1-neg5.5%
distribute-rgt-neg-in5.5%
associate-/l*4.4%
mul-1-neg4.4%
associate-/l*4.8%
distribute-lft1-in4.8%
metadata-eval4.8%
mul0-lft31.7%
metadata-eval31.7%
Simplified31.7%
herbie shell --seed 2024097
(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))))))