
(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 (* d d)) (* (* w h) (* D D)))))
(if (<=
(* (/ c0 (* 2.0 w)) (+ t_0 (sqrt (- (* t_0 t_0) (* M M)))))
INFINITY)
(*
c0
(/
(fma
c0
(* d (/ d (* D (* w (* h D)))))
(* (/ d D) (/ (* (/ c0 w) (/ d D)) h)))
(* 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 * (d * d)) / ((w * h) * (D * D));
double tmp;
if (((c0 / (2.0 * w)) * (t_0 + sqrt(((t_0 * t_0) - (M * M))))) <= ((double) INFINITY)) {
tmp = c0 * (fma(c0, (d * (d / (D * (w * (h * D))))), ((d / D) * (((c0 / w) * (d / D)) / h))) / (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)) / Float64(Float64(w * h) * Float64(D * D))) tmp = 0.0 if (Float64(Float64(c0 / Float64(2.0 * w)) * Float64(t_0 + sqrt(Float64(Float64(t_0 * t_0) - Float64(M * M))))) <= Inf) tmp = Float64(c0 * Float64(fma(c0, Float64(d * Float64(d / Float64(D * Float64(w * Float64(h * D))))), Float64(Float64(d / D) * Float64(Float64(Float64(c0 / w) * Float64(d / D)) / h))) / Float64(2.0 * w))); else tmp = Float64(c0 * Float64(0.0 / Float64(2.0 * w))); end return 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]}, If[LessEqual[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], Infinity], N[(c0 * N[(N[(c0 * N[(d * N[(d / N[(D * N[(w * N[(h * D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(d / D), $MachinePrecision] * N[(N[(N[(c0 / w), $MachinePrecision] * N[(d / D), $MachinePrecision]), $MachinePrecision] / h), $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(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\_0 + \sqrt{t\_0 \cdot t\_0 - M \cdot M}\right) \leq \infty:\\
\;\;\;\;c0 \cdot \frac{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, \frac{d}{D} \cdot \frac{\frac{c0}{w} \cdot \frac{d}{D}}{h}\right)}{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 77.0%
Simplified74.9%
Taylor expanded in c0 around inf 77.7%
pow277.7%
pow277.7%
*-commutative77.7%
*-commutative77.7%
frac-times76.6%
frac-times79.6%
associate-*r*80.6%
associate-/r*80.1%
Applied egg-rr80.1%
associate-*l/81.1%
Applied egg-rr81.1%
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%
Simplified16.2%
pow1/216.8%
*-commutative16.8%
unpow-prod-down15.3%
pow1/215.3%
pow1/215.3%
Applied egg-rr14.9%
Taylor expanded in c0 around -inf 1.5%
mul-1-neg1.5%
distribute-rgt-in0.2%
mul-1-neg0.2%
distribute-lft-neg-in0.2%
*-commutative0.2%
*-commutative0.2%
*-commutative0.2%
associate-*r/0.1%
*-commutative0.1%
*-commutative0.1%
mul-1-neg0.1%
Simplified48.5%
Final simplification60.6%
(FPCore (c0 w h D d M)
:precision binary64
(let* ((t_0
(*
c0
(/
(fma
c0
(* d (/ d (* D (* w (* h D)))))
(* (/ d D) (* (/ d D) (/ (/ c0 w) h))))
(* 2.0 w))))
(t_1 (* c0 (/ 0.0 (* 2.0 w)))))
(if (<= M 6.5e-221)
t_1
(if (<= M 5.2e-173)
t_0
(if (<= M 2.4e-154)
t_1
(if (<= M 8e+91)
t_0
(if (<= M 2.45e+150)
t_1
(*
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 t_0 = c0 * (fma(c0, (d * (d / (D * (w * (h * D))))), ((d / D) * ((d / D) * ((c0 / w) / h)))) / (2.0 * w));
double t_1 = c0 * (0.0 / (2.0 * w));
double tmp;
if (M <= 6.5e-221) {
tmp = t_1;
} else if (M <= 5.2e-173) {
tmp = t_0;
} else if (M <= 2.4e-154) {
tmp = t_1;
} else if (M <= 8e+91) {
tmp = t_0;
} else if (M <= 2.45e+150) {
tmp = t_1;
} else {
tmp = c0 * ((2.0 * (((c0 * pow((d / D), 2.0)) / h) / w)) / (2.0 * w));
}
return tmp;
}
function code(c0, w, h, D, d, M) t_0 = Float64(c0 * Float64(fma(c0, Float64(d * Float64(d / Float64(D * Float64(w * Float64(h * D))))), Float64(Float64(d / D) * Float64(Float64(d / D) * Float64(Float64(c0 / w) / h)))) / Float64(2.0 * w))) t_1 = Float64(c0 * Float64(0.0 / Float64(2.0 * w))) tmp = 0.0 if (M <= 6.5e-221) tmp = t_1; elseif (M <= 5.2e-173) tmp = t_0; elseif (M <= 2.4e-154) tmp = t_1; elseif (M <= 8e+91) tmp = t_0; elseif (M <= 2.45e+150) tmp = t_1; else tmp = Float64(c0 * Float64(Float64(2.0 * Float64(Float64(Float64(c0 * (Float64(d / D) ^ 2.0)) / h) / w)) / Float64(2.0 * w))); end return tmp end
code[c0_, w_, h_, D_, d_, M_] := Block[{t$95$0 = N[(c0 * N[(N[(c0 * N[(d * N[(d / N[(D * N[(w * N[(h * D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(d / D), $MachinePrecision] * N[(N[(d / D), $MachinePrecision] * N[(N[(c0 / w), $MachinePrecision] / h), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(2.0 * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(c0 * N[(0.0 / N[(2.0 * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[M, 6.5e-221], t$95$1, If[LessEqual[M, 5.2e-173], t$95$0, If[LessEqual[M, 2.4e-154], t$95$1, If[LessEqual[M, 8e+91], t$95$0, If[LessEqual[M, 2.45e+150], t$95$1, N[(c0 * N[(N[(2.0 * N[(N[(N[(c0 * N[Power[N[(d / D), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / h), $MachinePrecision] / w), $MachinePrecision]), $MachinePrecision] / N[(2.0 * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := c0 \cdot \frac{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, \frac{d}{D} \cdot \left(\frac{d}{D} \cdot \frac{\frac{c0}{w}}{h}\right)\right)}{2 \cdot w}\\
t_1 := c0 \cdot \frac{0}{2 \cdot w}\\
\mathbf{if}\;M \leq 6.5 \cdot 10^{-221}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;M \leq 5.2 \cdot 10^{-173}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;M \leq 2.4 \cdot 10^{-154}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;M \leq 8 \cdot 10^{+91}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;M \leq 2.45 \cdot 10^{+150}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;c0 \cdot \frac{2 \cdot \frac{\frac{c0 \cdot {\left(\frac{d}{D}\right)}^{2}}{h}}{w}}{2 \cdot w}\\
\end{array}
\end{array}
if M < 6.5e-221 or 5.20000000000000007e-173 < M < 2.39999999999999987e-154 or 8.00000000000000064e91 < M < 2.45000000000000003e150Initial program 25.6%
Simplified34.7%
pow1/234.8%
*-commutative34.8%
unpow-prod-down35.5%
pow1/235.4%
pow1/235.4%
Applied egg-rr34.5%
Taylor expanded in c0 around -inf 5.1%
mul-1-neg5.1%
distribute-rgt-in3.9%
mul-1-neg3.9%
distribute-lft-neg-in3.9%
*-commutative3.9%
*-commutative3.9%
*-commutative3.9%
associate-*r/3.7%
*-commutative3.7%
*-commutative3.7%
mul-1-neg3.7%
Simplified40.5%
if 6.5e-221 < M < 5.20000000000000007e-173 or 2.39999999999999987e-154 < M < 8.00000000000000064e91Initial program 46.0%
Simplified49.5%
Taylor expanded in c0 around inf 49.4%
pow249.4%
pow249.4%
*-commutative49.4%
*-commutative49.4%
frac-times48.1%
frac-times54.6%
associate-*r*57.9%
associate-/r*59.4%
Applied egg-rr59.4%
if 2.45000000000000003e150 < M Initial program 0.0%
Simplified29.1%
Taylor expanded in c0 around inf 25.4%
pow225.4%
pow225.4%
*-commutative25.4%
*-commutative25.4%
frac-times25.2%
frac-times30.7%
associate-*r*30.8%
associate-/r*30.8%
Applied egg-rr30.8%
fma-undefine30.8%
associate-*r/25.7%
*-commutative25.7%
associate-*r*25.7%
associate-*r*25.4%
associate-/l*27.7%
times-frac29.7%
frac-times35.1%
pow235.1%
*-commutative35.1%
associate-*l*35.1%
pow235.1%
associate-/r*35.1%
*-commutative35.1%
Applied egg-rr35.1%
count-235.1%
associate-*r/35.3%
*-commutative35.3%
associate-/l/40.0%
Simplified40.0%
Final simplification45.2%
(FPCore (c0 w h D d M)
:precision binary64
(let* ((t_0 (* d (/ d (* D (* w (* h D)))))) (t_1 (* c0 (/ 0.0 (* 2.0 w)))))
(if (<= M 1.05e-220)
t_1
(if (<= M 3.9e-173)
(* c0 (/ (fma c0 t_0 (* (/ d D) (/ (* d (/ c0 w)) (* h D)))) (* 2.0 w)))
(if (<= M 4.5e-155)
t_1
(if (<= M 2.45e+92)
(*
c0
(/ (fma c0 t_0 (* (/ d D) (* (/ d D) (/ (/ c0 w) h)))) (* 2.0 w)))
(if (<= M 2.6e+150)
t_1
(*
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 t_0 = d * (d / (D * (w * (h * D))));
double t_1 = c0 * (0.0 / (2.0 * w));
double tmp;
if (M <= 1.05e-220) {
tmp = t_1;
} else if (M <= 3.9e-173) {
tmp = c0 * (fma(c0, t_0, ((d / D) * ((d * (c0 / w)) / (h * D)))) / (2.0 * w));
} else if (M <= 4.5e-155) {
tmp = t_1;
} else if (M <= 2.45e+92) {
tmp = c0 * (fma(c0, t_0, ((d / D) * ((d / D) * ((c0 / w) / h)))) / (2.0 * w));
} else if (M <= 2.6e+150) {
tmp = t_1;
} else {
tmp = c0 * ((2.0 * (((c0 * pow((d / D), 2.0)) / h) / w)) / (2.0 * w));
}
return tmp;
}
function code(c0, w, h, D, d, M) t_0 = Float64(d * Float64(d / Float64(D * Float64(w * Float64(h * D))))) t_1 = Float64(c0 * Float64(0.0 / Float64(2.0 * w))) tmp = 0.0 if (M <= 1.05e-220) tmp = t_1; elseif (M <= 3.9e-173) tmp = Float64(c0 * Float64(fma(c0, t_0, Float64(Float64(d / D) * Float64(Float64(d * Float64(c0 / w)) / Float64(h * D)))) / Float64(2.0 * w))); elseif (M <= 4.5e-155) tmp = t_1; elseif (M <= 2.45e+92) tmp = Float64(c0 * Float64(fma(c0, t_0, Float64(Float64(d / D) * Float64(Float64(d / D) * Float64(Float64(c0 / w) / h)))) / Float64(2.0 * w))); elseif (M <= 2.6e+150) tmp = t_1; else tmp = Float64(c0 * Float64(Float64(2.0 * Float64(Float64(Float64(c0 * (Float64(d / D) ^ 2.0)) / h) / w)) / Float64(2.0 * w))); end return tmp end
code[c0_, w_, h_, D_, d_, M_] := Block[{t$95$0 = N[(d * N[(d / N[(D * N[(w * N[(h * D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(c0 * N[(0.0 / N[(2.0 * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[M, 1.05e-220], t$95$1, If[LessEqual[M, 3.9e-173], N[(c0 * N[(N[(c0 * t$95$0 + N[(N[(d / D), $MachinePrecision] * N[(N[(d * N[(c0 / w), $MachinePrecision]), $MachinePrecision] / N[(h * D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(2.0 * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[M, 4.5e-155], t$95$1, If[LessEqual[M, 2.45e+92], N[(c0 * N[(N[(c0 * t$95$0 + N[(N[(d / D), $MachinePrecision] * N[(N[(d / D), $MachinePrecision] * N[(N[(c0 / w), $MachinePrecision] / h), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(2.0 * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[M, 2.6e+150], t$95$1, N[(c0 * N[(N[(2.0 * N[(N[(N[(c0 * N[Power[N[(d / D), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / h), $MachinePrecision] / w), $MachinePrecision]), $MachinePrecision] / N[(2.0 * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}\\
t_1 := c0 \cdot \frac{0}{2 \cdot w}\\
\mathbf{if}\;M \leq 1.05 \cdot 10^{-220}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;M \leq 3.9 \cdot 10^{-173}:\\
\;\;\;\;c0 \cdot \frac{\mathsf{fma}\left(c0, t\_0, \frac{d}{D} \cdot \frac{d \cdot \frac{c0}{w}}{h \cdot D}\right)}{2 \cdot w}\\
\mathbf{elif}\;M \leq 4.5 \cdot 10^{-155}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;M \leq 2.45 \cdot 10^{+92}:\\
\;\;\;\;c0 \cdot \frac{\mathsf{fma}\left(c0, t\_0, \frac{d}{D} \cdot \left(\frac{d}{D} \cdot \frac{\frac{c0}{w}}{h}\right)\right)}{2 \cdot w}\\
\mathbf{elif}\;M \leq 2.6 \cdot 10^{+150}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;c0 \cdot \frac{2 \cdot \frac{\frac{c0 \cdot {\left(\frac{d}{D}\right)}^{2}}{h}}{w}}{2 \cdot w}\\
\end{array}
\end{array}
if M < 1.04999999999999996e-220 or 3.89999999999999987e-173 < M < 4.5000000000000004e-155 or 2.4500000000000001e92 < M < 2.60000000000000006e150Initial program 25.6%
Simplified34.7%
pow1/234.8%
*-commutative34.8%
unpow-prod-down35.5%
pow1/235.4%
pow1/235.4%
Applied egg-rr34.5%
Taylor expanded in c0 around -inf 5.1%
mul-1-neg5.1%
distribute-rgt-in3.9%
mul-1-neg3.9%
distribute-lft-neg-in3.9%
*-commutative3.9%
*-commutative3.9%
*-commutative3.9%
associate-*r/3.7%
*-commutative3.7%
*-commutative3.7%
mul-1-neg3.7%
Simplified40.5%
if 1.04999999999999996e-220 < M < 3.89999999999999987e-173Initial program 70.2%
Simplified71.4%
Taylor expanded in c0 around inf 83.7%
pow283.7%
pow283.7%
*-commutative83.7%
*-commutative83.7%
frac-times78.2%
frac-times78.2%
associate-*r*84.5%
associate-/r*84.5%
Applied egg-rr84.5%
frac-times84.7%
Applied egg-rr84.7%
if 4.5000000000000004e-155 < M < 2.4500000000000001e92Initial program 39.8%
Simplified43.9%
Taylor expanded in c0 around inf 40.6%
pow240.6%
pow240.6%
*-commutative40.6%
*-commutative40.6%
frac-times40.4%
frac-times48.6%
associate-*r*51.1%
associate-/r*53.0%
Applied egg-rr53.0%
if 2.60000000000000006e150 < M Initial program 0.0%
Simplified29.1%
Taylor expanded in c0 around inf 25.4%
pow225.4%
pow225.4%
*-commutative25.4%
*-commutative25.4%
frac-times25.2%
frac-times30.7%
associate-*r*30.8%
associate-/r*30.8%
Applied egg-rr30.8%
fma-undefine30.8%
associate-*r/25.7%
*-commutative25.7%
associate-*r*25.7%
associate-*r*25.4%
associate-/l*27.7%
times-frac29.7%
frac-times35.1%
pow235.1%
*-commutative35.1%
associate-*l*35.1%
pow235.1%
associate-/r*35.1%
*-commutative35.1%
Applied egg-rr35.1%
count-235.1%
associate-*r/35.3%
*-commutative35.3%
associate-/l/40.0%
Simplified40.0%
Final simplification45.2%
(FPCore (c0 w h D d M) :precision binary64 (if (or (<= M 8.3e-221) (and (not (<= M 4.9e-172)) (<= M 1.55e-150))) (* 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 <= 8.3e-221) || (!(M <= 4.9e-172) && (M <= 1.55e-150))) {
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 <= 8.3d-221) .or. (.not. (m <= 4.9d-172)) .and. (m <= 1.55d-150)) 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 <= 8.3e-221) || (!(M <= 4.9e-172) && (M <= 1.55e-150))) {
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 <= 8.3e-221) or (not (M <= 4.9e-172) and (M <= 1.55e-150)): 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 ((M <= 8.3e-221) || (!(M <= 4.9e-172) && (M <= 1.55e-150))) 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)) / 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 <= 8.3e-221) || (~((M <= 4.9e-172)) && (M <= 1.55e-150))) 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[Or[LessEqual[M, 8.3e-221], And[N[Not[LessEqual[M, 4.9e-172]], $MachinePrecision], LessEqual[M, 1.55e-150]]], 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] / h), $MachinePrecision] / w), $MachinePrecision]), $MachinePrecision] / N[(2.0 * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;M \leq 8.3 \cdot 10^{-221} \lor \neg \left(M \leq 4.9 \cdot 10^{-172}\right) \land M \leq 1.55 \cdot 10^{-150}:\\
\;\;\;\;c0 \cdot \frac{0}{2 \cdot w}\\
\mathbf{else}:\\
\;\;\;\;c0 \cdot \frac{2 \cdot \frac{\frac{c0 \cdot {\left(\frac{d}{D}\right)}^{2}}{h}}{w}}{2 \cdot w}\\
\end{array}
\end{array}
if M < 8.30000000000000035e-221 or 4.9000000000000001e-172 < M < 1.54999999999999999e-150Initial program 25.4%
Simplified35.6%
pow1/235.6%
*-commutative35.6%
unpow-prod-down36.4%
pow1/236.3%
pow1/236.3%
Applied egg-rr34.7%
Taylor expanded in c0 around -inf 5.3%
mul-1-neg5.3%
distribute-rgt-in4.0%
mul-1-neg4.0%
distribute-lft-neg-in4.0%
*-commutative4.0%
*-commutative4.0%
*-commutative4.0%
associate-*r/3.8%
*-commutative3.8%
*-commutative3.8%
mul-1-neg3.8%
Simplified39.7%
if 8.30000000000000035e-221 < M < 4.9000000000000001e-172 or 1.54999999999999999e-150 < M Initial program 34.2%
Simplified42.2%
Taylor expanded in c0 around inf 42.4%
pow242.4%
pow242.4%
*-commutative42.4%
*-commutative42.4%
frac-times41.5%
frac-times47.3%
associate-*r*49.4%
associate-/r*49.6%
Applied egg-rr49.6%
fma-undefine49.6%
associate-*r/44.6%
*-commutative44.6%
associate-*r*44.6%
associate-*r*42.3%
associate-/l*42.9%
times-frac42.5%
frac-times49.2%
pow249.2%
*-commutative49.2%
associate-*l*49.0%
pow249.0%
associate-/r*49.0%
*-commutative49.0%
Applied egg-rr49.0%
count-249.0%
associate-*r/48.0%
*-commutative48.0%
associate-/l/48.3%
Simplified48.3%
Final simplification42.8%
(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.6%
Simplified38.0%
pow1/238.4%
*-commutative38.4%
unpow-prod-down39.5%
pow1/239.4%
pow1/239.4%
Applied egg-rr38.8%
Taylor expanded in c0 around -inf 4.0%
mul-1-neg4.0%
distribute-rgt-in3.1%
mul-1-neg3.1%
distribute-lft-neg-in3.1%
*-commutative3.1%
*-commutative3.1%
*-commutative3.1%
associate-*r/3.0%
*-commutative3.0%
*-commutative3.0%
mul-1-neg3.0%
Simplified34.0%
Final simplification34.0%
herbie shell --seed 2024077
(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))))))