
(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 7 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)) (* (* 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
(* 0.25 (* (pow D 2.0) (* h (pow (/ M d) 2.0)))))))
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 = 0.25 * (pow(D, 2.0) * (h * pow((M / d), 2.0)));
}
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 = 0.25 * (Math.pow(D, 2.0) * (h * Math.pow((M / d), 2.0)));
}
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 = 0.25 * (math.pow(D, 2.0) * (h * math.pow((M / d), 2.0))) 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(0.25 * Float64((D ^ 2.0) * Float64(h * (Float64(M / d) ^ 2.0)))); 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 = 0.25 * ((D ^ 2.0) * (h * ((M / d) ^ 2.0))); 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[(0.25 * N[(N[Power[D, 2.0], $MachinePrecision] * N[(h * N[Power[N[(M / d), $MachinePrecision], 2.0], $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)}\\
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}:\\
\;\;\;\;0.25 \cdot \left({D}^{2} \cdot \left(h \cdot {\left(\frac{M}{d}\right)}^{2}\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))))) < +inf.0Initial program 71.9%
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%
associate-/l*0.0%
associate-*r*0.0%
associate-*r*0.0%
*-commutative0.0%
associate-*r/0.0%
*-commutative0.0%
Applied egg-rr0.6%
Taylor expanded in c0 around -inf 1.8%
+-commutative1.8%
fma-define1.8%
times-frac2.8%
associate-*l/3.4%
*-commutative3.4%
*-commutative3.4%
associate-/l*2.9%
*-commutative2.9%
associate-*r*2.9%
Simplified22.4%
Taylor expanded in c0 around 0 31.1%
associate-/l*31.6%
*-commutative31.6%
associate-/l*31.2%
unpow231.2%
unpow231.2%
times-frac43.3%
unpow243.3%
Simplified43.3%
Final simplification52.1%
(FPCore (c0 w h D d M)
:precision binary64
(let* ((t_0 (* c0 (/ 0.0 (* 2.0 w))))
(t_1 (pow (/ d D) 2.0))
(t_2 (* c0 (/ (* (/ t_1 h) (/ c0 w)) w))))
(if (<= c0 -3.8e-180)
t_2
(if (<= c0 1.85e-128)
t_0
(if (<= c0 1.05e+74)
(* c0 (/ (* 2.0 (* c0 (/ t_1 (* w h)))) (* 2.0 w)))
(if (<= c0 1.85e+124) t_0 t_2))))))
double code(double c0, double w, double h, double D, double d, double M) {
double t_0 = c0 * (0.0 / (2.0 * w));
double t_1 = pow((d / D), 2.0);
double t_2 = c0 * (((t_1 / h) * (c0 / w)) / w);
double tmp;
if (c0 <= -3.8e-180) {
tmp = t_2;
} else if (c0 <= 1.85e-128) {
tmp = t_0;
} else if (c0 <= 1.05e+74) {
tmp = c0 * ((2.0 * (c0 * (t_1 / (w * h)))) / (2.0 * w));
} else if (c0 <= 1.85e+124) {
tmp = t_0;
} else {
tmp = t_2;
}
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) :: t_2
real(8) :: tmp
t_0 = c0 * (0.0d0 / (2.0d0 * w))
t_1 = (d_1 / d) ** 2.0d0
t_2 = c0 * (((t_1 / h) * (c0 / w)) / w)
if (c0 <= (-3.8d-180)) then
tmp = t_2
else if (c0 <= 1.85d-128) then
tmp = t_0
else if (c0 <= 1.05d+74) then
tmp = c0 * ((2.0d0 * (c0 * (t_1 / (w * h)))) / (2.0d0 * w))
else if (c0 <= 1.85d+124) then
tmp = t_0
else
tmp = t_2
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 * (0.0 / (2.0 * w));
double t_1 = Math.pow((d / D), 2.0);
double t_2 = c0 * (((t_1 / h) * (c0 / w)) / w);
double tmp;
if (c0 <= -3.8e-180) {
tmp = t_2;
} else if (c0 <= 1.85e-128) {
tmp = t_0;
} else if (c0 <= 1.05e+74) {
tmp = c0 * ((2.0 * (c0 * (t_1 / (w * h)))) / (2.0 * w));
} else if (c0 <= 1.85e+124) {
tmp = t_0;
} else {
tmp = t_2;
}
return tmp;
}
def code(c0, w, h, D, d, M): t_0 = c0 * (0.0 / (2.0 * w)) t_1 = math.pow((d / D), 2.0) t_2 = c0 * (((t_1 / h) * (c0 / w)) / w) tmp = 0 if c0 <= -3.8e-180: tmp = t_2 elif c0 <= 1.85e-128: tmp = t_0 elif c0 <= 1.05e+74: tmp = c0 * ((2.0 * (c0 * (t_1 / (w * h)))) / (2.0 * w)) elif c0 <= 1.85e+124: tmp = t_0 else: tmp = t_2 return tmp
function code(c0, w, h, D, d, M) t_0 = Float64(c0 * Float64(0.0 / Float64(2.0 * w))) t_1 = Float64(d / D) ^ 2.0 t_2 = Float64(c0 * Float64(Float64(Float64(t_1 / h) * Float64(c0 / w)) / w)) tmp = 0.0 if (c0 <= -3.8e-180) tmp = t_2; elseif (c0 <= 1.85e-128) tmp = t_0; elseif (c0 <= 1.05e+74) tmp = Float64(c0 * Float64(Float64(2.0 * Float64(c0 * Float64(t_1 / Float64(w * h)))) / Float64(2.0 * w))); elseif (c0 <= 1.85e+124) tmp = t_0; else tmp = t_2; end return tmp end
function tmp_2 = code(c0, w, h, D, d, M) t_0 = c0 * (0.0 / (2.0 * w)); t_1 = (d / D) ^ 2.0; t_2 = c0 * (((t_1 / h) * (c0 / w)) / w); tmp = 0.0; if (c0 <= -3.8e-180) tmp = t_2; elseif (c0 <= 1.85e-128) tmp = t_0; elseif (c0 <= 1.05e+74) tmp = c0 * ((2.0 * (c0 * (t_1 / (w * h)))) / (2.0 * w)); elseif (c0 <= 1.85e+124) tmp = t_0; else tmp = t_2; end tmp_2 = tmp; end
code[c0_, w_, h_, D_, d_, M_] := Block[{t$95$0 = N[(c0 * N[(0.0 / N[(2.0 * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Power[N[(d / D), $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$2 = N[(c0 * N[(N[(N[(t$95$1 / h), $MachinePrecision] * N[(c0 / w), $MachinePrecision]), $MachinePrecision] / w), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[c0, -3.8e-180], t$95$2, If[LessEqual[c0, 1.85e-128], t$95$0, If[LessEqual[c0, 1.05e+74], N[(c0 * N[(N[(2.0 * N[(c0 * N[(t$95$1 / N[(w * h), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(2.0 * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c0, 1.85e+124], t$95$0, t$95$2]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := c0 \cdot \frac{0}{2 \cdot w}\\
t_1 := {\left(\frac{d}{D}\right)}^{2}\\
t_2 := c0 \cdot \frac{\frac{t\_1}{h} \cdot \frac{c0}{w}}{w}\\
\mathbf{if}\;c0 \leq -3.8 \cdot 10^{-180}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;c0 \leq 1.85 \cdot 10^{-128}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;c0 \leq 1.05 \cdot 10^{+74}:\\
\;\;\;\;c0 \cdot \frac{2 \cdot \left(c0 \cdot \frac{t\_1}{w \cdot h}\right)}{2 \cdot w}\\
\mathbf{elif}\;c0 \leq 1.85 \cdot 10^{+124}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if c0 < -3.79999999999999999e-180 or 1.85000000000000004e124 < c0 Initial program 22.1%
Simplified38.4%
Taylor expanded in c0 around inf 36.4%
*-commutative36.4%
associate-/l/37.0%
associate-/r*38.5%
associate-*l/39.7%
associate-/r*39.1%
associate-/l*39.1%
*-commutative39.1%
Simplified39.1%
times-frac39.1%
metadata-eval39.1%
associate-/r*38.0%
pow238.0%
pow238.0%
frac-times48.9%
pow248.9%
Applied egg-rr48.9%
if -3.79999999999999999e-180 < c0 < 1.85e-128 or 1.0499999999999999e74 < c0 < 1.85000000000000004e124Initial program 14.0%
Simplified22.1%
Taylor expanded in c0 around -inf 4.0%
associate-*r*4.0%
neg-mul-14.0%
distribute-lft1-in4.0%
metadata-eval4.0%
mul0-lft51.4%
distribute-lft-neg-in51.4%
distribute-rgt-neg-in51.4%
metadata-eval51.4%
mul0-lft4.0%
metadata-eval4.0%
distribute-lft1-in4.0%
distribute-lft-in4.0%
associate-/l*3.9%
Simplified51.4%
if 1.85e-128 < c0 < 1.0499999999999999e74Initial program 30.2%
Simplified53.9%
Applied egg-rr61.7%
fma-define61.7%
associate-/r*61.7%
associate-/r*61.7%
Simplified61.7%
Taylor expanded in d around inf 49.7%
associate-/r*51.6%
associate-/l*51.6%
unpow251.6%
unpow251.6%
times-frac61.7%
unpow261.7%
*-commutative61.7%
associate-*r/61.7%
*-commutative61.7%
Simplified61.7%
Final simplification51.8%
(FPCore (c0 w h D d M) :precision binary64 (if (<= (* M M) 2e-244) (* c0 (/ 0.0 (* 2.0 w))) (* c0 (/ (* 2.0 (/ (* c0 (/ (pow (/ d D) 2.0) h)) w)) (* 2.0 w)))))
double code(double c0, double w, double h, double D, double d, double M) {
double tmp;
if ((M * M) <= 2e-244) {
tmp = c0 * (0.0 / (2.0 * w));
} else {
tmp = c0 * ((2.0 * ((c0 * (pow((d / D), 2.0) / h)) / 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 * m) <= 2d-244) then
tmp = c0 * (0.0d0 / (2.0d0 * w))
else
tmp = c0 * ((2.0d0 * ((c0 * (((d_1 / d) ** 2.0d0) / h)) / 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 * M) <= 2e-244) {
tmp = c0 * (0.0 / (2.0 * w));
} else {
tmp = c0 * ((2.0 * ((c0 * (Math.pow((d / D), 2.0) / h)) / w)) / (2.0 * w));
}
return tmp;
}
def code(c0, w, h, D, d, M): tmp = 0 if (M * M) <= 2e-244: tmp = c0 * (0.0 / (2.0 * w)) else: tmp = c0 * ((2.0 * ((c0 * (math.pow((d / D), 2.0) / h)) / w)) / (2.0 * w)) return tmp
function code(c0, w, h, D, d, M) tmp = 0.0 if (Float64(M * M) <= 2e-244) tmp = Float64(c0 * Float64(0.0 / Float64(2.0 * w))); else tmp = Float64(c0 * Float64(Float64(2.0 * Float64(Float64(c0 * Float64((Float64(d / D) ^ 2.0) / h)) / w)) / Float64(2.0 * w))); end return tmp end
function tmp_2 = code(c0, w, h, D, d, M) tmp = 0.0; if ((M * M) <= 2e-244) tmp = c0 * (0.0 / (2.0 * w)); else tmp = c0 * ((2.0 * ((c0 * (((d / D) ^ 2.0) / h)) / w)) / (2.0 * w)); end tmp_2 = tmp; end
code[c0_, w_, h_, D_, d_, M_] := If[LessEqual[N[(M * M), $MachinePrecision], 2e-244], N[(c0 * N[(0.0 / N[(2.0 * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(c0 * N[(N[(2.0 * N[(N[(c0 * N[(N[Power[N[(d / D), $MachinePrecision], 2.0], $MachinePrecision] / h), $MachinePrecision]), $MachinePrecision] / w), $MachinePrecision]), $MachinePrecision] / N[(2.0 * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;M \cdot M \leq 2 \cdot 10^{-244}:\\
\;\;\;\;c0 \cdot \frac{0}{2 \cdot w}\\
\mathbf{else}:\\
\;\;\;\;c0 \cdot \frac{2 \cdot \frac{c0 \cdot \frac{{\left(\frac{d}{D}\right)}^{2}}{h}}{w}}{2 \cdot w}\\
\end{array}
\end{array}
if (*.f64 M M) < 1.9999999999999999e-244Initial program 28.8%
Simplified31.8%
Taylor expanded in c0 around -inf 12.4%
associate-*r*12.4%
neg-mul-112.4%
distribute-lft1-in12.4%
metadata-eval12.4%
mul0-lft45.2%
distribute-lft-neg-in45.2%
distribute-rgt-neg-in45.2%
metadata-eval45.2%
mul0-lft12.4%
metadata-eval12.4%
distribute-lft1-in12.4%
distribute-lft-in12.4%
associate-/l*8.1%
Simplified45.2%
if 1.9999999999999999e-244 < (*.f64 M M) Initial program 18.0%
Simplified41.3%
Taylor expanded in c0 around inf 39.2%
*-commutative39.2%
associate-/l/39.2%
associate-/r*41.0%
associate-*l/42.2%
associate-/r*41.6%
associate-/l*41.0%
*-commutative41.0%
Simplified41.0%
associate-*l/41.1%
associate-/r*40.0%
pow240.0%
pow240.0%
frac-times50.0%
pow250.0%
Applied egg-rr50.0%
Final simplification48.3%
(FPCore (c0 w h D d M) :precision binary64 (if (or (<= c0 -2.7e-177) (not (<= c0 2.3e-125))) (* c0 (/ (* (/ (pow (/ d D) 2.0) h) (/ c0 w)) w)) (* c0 (/ 0.0 (* 2.0 w)))))
double code(double c0, double w, double h, double D, double d, double M) {
double tmp;
if ((c0 <= -2.7e-177) || !(c0 <= 2.3e-125)) {
tmp = c0 * (((pow((d / D), 2.0) / h) * (c0 / w)) / w);
} else {
tmp = c0 * (0.0 / (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 ((c0 <= (-2.7d-177)) .or. (.not. (c0 <= 2.3d-125))) then
tmp = c0 * (((((d_1 / d) ** 2.0d0) / h) * (c0 / w)) / w)
else
tmp = c0 * (0.0d0 / (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 ((c0 <= -2.7e-177) || !(c0 <= 2.3e-125)) {
tmp = c0 * (((Math.pow((d / D), 2.0) / h) * (c0 / w)) / w);
} else {
tmp = c0 * (0.0 / (2.0 * w));
}
return tmp;
}
def code(c0, w, h, D, d, M): tmp = 0 if (c0 <= -2.7e-177) or not (c0 <= 2.3e-125): tmp = c0 * (((math.pow((d / D), 2.0) / h) * (c0 / w)) / w) else: tmp = c0 * (0.0 / (2.0 * w)) return tmp
function code(c0, w, h, D, d, M) tmp = 0.0 if ((c0 <= -2.7e-177) || !(c0 <= 2.3e-125)) tmp = Float64(c0 * Float64(Float64(Float64((Float64(d / D) ^ 2.0) / h) * Float64(c0 / w)) / 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) tmp = 0.0; if ((c0 <= -2.7e-177) || ~((c0 <= 2.3e-125))) tmp = c0 * (((((d / D) ^ 2.0) / h) * (c0 / w)) / w); else tmp = c0 * (0.0 / (2.0 * w)); end tmp_2 = tmp; end
code[c0_, w_, h_, D_, d_, M_] := If[Or[LessEqual[c0, -2.7e-177], N[Not[LessEqual[c0, 2.3e-125]], $MachinePrecision]], N[(c0 * N[(N[(N[(N[Power[N[(d / D), $MachinePrecision], 2.0], $MachinePrecision] / h), $MachinePrecision] * N[(c0 / w), $MachinePrecision]), $MachinePrecision] / w), $MachinePrecision]), $MachinePrecision], N[(c0 * N[(0.0 / N[(2.0 * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c0 \leq -2.7 \cdot 10^{-177} \lor \neg \left(c0 \leq 2.3 \cdot 10^{-125}\right):\\
\;\;\;\;c0 \cdot \frac{\frac{{\left(\frac{d}{D}\right)}^{2}}{h} \cdot \frac{c0}{w}}{w}\\
\mathbf{else}:\\
\;\;\;\;c0 \cdot \frac{0}{2 \cdot w}\\
\end{array}
\end{array}
if c0 < -2.7000000000000002e-177 or 2.2999999999999999e-125 < c0 Initial program 23.5%
Simplified40.4%
Taylor expanded in c0 around inf 37.6%
*-commutative37.6%
associate-/l/38.5%
associate-/r*40.0%
associate-*l/40.9%
associate-/r*39.5%
associate-/l*39.6%
*-commutative39.6%
Simplified39.6%
times-frac39.6%
metadata-eval39.6%
associate-/r*38.8%
pow238.8%
pow238.8%
frac-times49.4%
pow249.4%
Applied egg-rr49.4%
if -2.7000000000000002e-177 < c0 < 2.2999999999999999e-125Initial program 13.4%
Simplified23.9%
Taylor expanded in c0 around -inf 2.6%
associate-*r*2.6%
neg-mul-12.6%
distribute-lft1-in2.6%
metadata-eval2.6%
mul0-lft50.4%
distribute-lft-neg-in50.4%
distribute-rgt-neg-in50.4%
metadata-eval50.4%
mul0-lft2.6%
metadata-eval2.6%
distribute-lft1-in2.6%
distribute-lft-in2.6%
associate-/l*2.6%
Simplified50.4%
Final simplification49.5%
(FPCore (c0 w h D d M) :precision binary64 (if (<= M 3.05e+91) (* c0 (/ 0.0 (* 2.0 w))) (* 0.5 (* M (/ c0 w)))))
double code(double c0, double w, double h, double D, double d, double M) {
double tmp;
if (M <= 3.05e+91) {
tmp = c0 * (0.0 / (2.0 * w));
} else {
tmp = 0.5 * (M * (c0 / 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 <= 3.05d+91) then
tmp = c0 * (0.0d0 / (2.0d0 * w))
else
tmp = 0.5d0 * (m * (c0 / 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 <= 3.05e+91) {
tmp = c0 * (0.0 / (2.0 * w));
} else {
tmp = 0.5 * (M * (c0 / w));
}
return tmp;
}
def code(c0, w, h, D, d, M): tmp = 0 if M <= 3.05e+91: tmp = c0 * (0.0 / (2.0 * w)) else: tmp = 0.5 * (M * (c0 / w)) return tmp
function code(c0, w, h, D, d, M) tmp = 0.0 if (M <= 3.05e+91) tmp = Float64(c0 * Float64(0.0 / Float64(2.0 * w))); else tmp = Float64(0.5 * Float64(M * Float64(c0 / w))); end return tmp end
function tmp_2 = code(c0, w, h, D, d, M) tmp = 0.0; if (M <= 3.05e+91) tmp = c0 * (0.0 / (2.0 * w)); else tmp = 0.5 * (M * (c0 / w)); end tmp_2 = tmp; end
code[c0_, w_, h_, D_, d_, M_] := If[LessEqual[M, 3.05e+91], N[(c0 * N[(0.0 / N[(2.0 * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(M * N[(c0 / w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;M \leq 3.05 \cdot 10^{+91}:\\
\;\;\;\;c0 \cdot \frac{0}{2 \cdot w}\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(M \cdot \frac{c0}{w}\right)\\
\end{array}
\end{array}
if M < 3.05e91Initial program 23.9%
Simplified39.0%
Taylor expanded in c0 around -inf 5.4%
associate-*r*5.4%
neg-mul-15.4%
distribute-lft1-in5.4%
metadata-eval5.4%
mul0-lft29.0%
distribute-lft-neg-in29.0%
distribute-rgt-neg-in29.0%
metadata-eval29.0%
mul0-lft5.4%
metadata-eval5.4%
distribute-lft1-in5.4%
distribute-lft-in5.4%
associate-/l*4.0%
Simplified29.0%
if 3.05e91 < M Initial program 10.5%
Simplified31.6%
Applied egg-rr48.6%
Taylor expanded in c0 around 0 22.8%
associate-/l*25.5%
Simplified25.5%
Final simplification28.5%
(FPCore (c0 w h D d M) :precision binary64 (if (<= M 2.1e+91) (* c0 (/ 0.0 (* 2.0 w))) (* c0 (/ (* M 0.5) w))))
double code(double c0, double w, double h, double D, double d, double M) {
double tmp;
if (M <= 2.1e+91) {
tmp = c0 * (0.0 / (2.0 * w));
} else {
tmp = c0 * ((M * 0.5) / 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 <= 2.1d+91) then
tmp = c0 * (0.0d0 / (2.0d0 * w))
else
tmp = c0 * ((m * 0.5d0) / 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 <= 2.1e+91) {
tmp = c0 * (0.0 / (2.0 * w));
} else {
tmp = c0 * ((M * 0.5) / w);
}
return tmp;
}
def code(c0, w, h, D, d, M): tmp = 0 if M <= 2.1e+91: tmp = c0 * (0.0 / (2.0 * w)) else: tmp = c0 * ((M * 0.5) / w) return tmp
function code(c0, w, h, D, d, M) tmp = 0.0 if (M <= 2.1e+91) tmp = Float64(c0 * Float64(0.0 / Float64(2.0 * w))); else tmp = Float64(c0 * Float64(Float64(M * 0.5) / w)); end return tmp end
function tmp_2 = code(c0, w, h, D, d, M) tmp = 0.0; if (M <= 2.1e+91) tmp = c0 * (0.0 / (2.0 * w)); else tmp = c0 * ((M * 0.5) / w); end tmp_2 = tmp; end
code[c0_, w_, h_, D_, d_, M_] := If[LessEqual[M, 2.1e+91], N[(c0 * N[(0.0 / N[(2.0 * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(c0 * N[(N[(M * 0.5), $MachinePrecision] / w), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;M \leq 2.1 \cdot 10^{+91}:\\
\;\;\;\;c0 \cdot \frac{0}{2 \cdot w}\\
\mathbf{else}:\\
\;\;\;\;c0 \cdot \frac{M \cdot 0.5}{w}\\
\end{array}
\end{array}
if M < 2.10000000000000008e91Initial program 23.9%
Simplified39.0%
Taylor expanded in c0 around -inf 5.4%
associate-*r*5.4%
neg-mul-15.4%
distribute-lft1-in5.4%
metadata-eval5.4%
mul0-lft29.0%
distribute-lft-neg-in29.0%
distribute-rgt-neg-in29.0%
metadata-eval29.0%
mul0-lft5.4%
metadata-eval5.4%
distribute-lft1-in5.4%
distribute-lft-in5.4%
associate-/l*4.0%
Simplified29.0%
if 2.10000000000000008e91 < M Initial program 10.5%
Simplified31.6%
Applied egg-rr48.6%
fma-define48.6%
associate-/r*48.6%
associate-/r*48.6%
Simplified48.6%
Taylor expanded in d around 0 27.7%
associate-*r/27.7%
Simplified27.7%
Final simplification28.8%
(FPCore (c0 w h D d M) :precision binary64 (* 0.5 (* M (/ c0 w))))
double code(double c0, double w, double h, double D, double d, double M) {
return 0.5 * (M * (c0 / 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 = 0.5d0 * (m * (c0 / w))
end function
public static double code(double c0, double w, double h, double D, double d, double M) {
return 0.5 * (M * (c0 / w));
}
def code(c0, w, h, D, d, M): return 0.5 * (M * (c0 / w))
function code(c0, w, h, D, d, M) return Float64(0.5 * Float64(M * Float64(c0 / w))) end
function tmp = code(c0, w, h, D, d, M) tmp = 0.5 * (M * (c0 / w)); end
code[c0_, w_, h_, D_, d_, M_] := N[(0.5 * N[(M * N[(c0 / w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
0.5 \cdot \left(M \cdot \frac{c0}{w}\right)
\end{array}
Initial program 21.9%
Simplified37.9%
Applied egg-rr43.9%
Taylor expanded in c0 around 0 15.0%
associate-/l*16.8%
Simplified16.8%
Final simplification16.8%
herbie shell --seed 2024052
(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))))))