
(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 11 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 w) (* D (sqrt h))))
(t_1 (/ (* c0 (* d d)) (* (* w h) (* D D))))
(t_2 (* (/ c0 (* 2.0 w)) (+ t_1 (sqrt (- (* t_1 t_1) (* M M)))))))
(if (<= t_2 -4e-7)
(/ c0 (/ (* 2.0 w) (+ M (/ (* (/ (/ (* c0 2.0) w) h) (/ d D)) (/ D d)))))
(if (<= t_2 0.0)
(* 0.25 (* (/ (* (pow D 2.0) (pow M 2.0)) d) (/ h d)))
(if (<= t_2 INFINITY)
(* d (* d (* t_0 t_0)))
(* 0.25 (/ (- h) (* (/ -1.0 (pow M 2.0)) (pow (/ d D) 2.0)))))))))
double code(double c0, double w, double h, double D, double d, double M) {
double t_0 = (c0 / w) / (D * sqrt(h));
double t_1 = (c0 * (d * d)) / ((w * h) * (D * D));
double t_2 = (c0 / (2.0 * w)) * (t_1 + sqrt(((t_1 * t_1) - (M * M))));
double tmp;
if (t_2 <= -4e-7) {
tmp = c0 / ((2.0 * w) / (M + (((((c0 * 2.0) / w) / h) * (d / D)) / (D / d))));
} else if (t_2 <= 0.0) {
tmp = 0.25 * (((pow(D, 2.0) * pow(M, 2.0)) / d) * (h / d));
} else if (t_2 <= ((double) INFINITY)) {
tmp = d * (d * (t_0 * t_0));
} else {
tmp = 0.25 * (-h / ((-1.0 / pow(M, 2.0)) * pow((d / 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 / w) / (D * Math.sqrt(h));
double t_1 = (c0 * (d * d)) / ((w * h) * (D * D));
double t_2 = (c0 / (2.0 * w)) * (t_1 + Math.sqrt(((t_1 * t_1) - (M * M))));
double tmp;
if (t_2 <= -4e-7) {
tmp = c0 / ((2.0 * w) / (M + (((((c0 * 2.0) / w) / h) * (d / D)) / (D / d))));
} else if (t_2 <= 0.0) {
tmp = 0.25 * (((Math.pow(D, 2.0) * Math.pow(M, 2.0)) / d) * (h / d));
} else if (t_2 <= Double.POSITIVE_INFINITY) {
tmp = d * (d * (t_0 * t_0));
} else {
tmp = 0.25 * (-h / ((-1.0 / Math.pow(M, 2.0)) * Math.pow((d / D), 2.0)));
}
return tmp;
}
def code(c0, w, h, D, d, M): t_0 = (c0 / w) / (D * math.sqrt(h)) t_1 = (c0 * (d * d)) / ((w * h) * (D * D)) t_2 = (c0 / (2.0 * w)) * (t_1 + math.sqrt(((t_1 * t_1) - (M * M)))) tmp = 0 if t_2 <= -4e-7: tmp = c0 / ((2.0 * w) / (M + (((((c0 * 2.0) / w) / h) * (d / D)) / (D / d)))) elif t_2 <= 0.0: tmp = 0.25 * (((math.pow(D, 2.0) * math.pow(M, 2.0)) / d) * (h / d)) elif t_2 <= math.inf: tmp = d * (d * (t_0 * t_0)) else: tmp = 0.25 * (-h / ((-1.0 / math.pow(M, 2.0)) * math.pow((d / D), 2.0))) return tmp
function code(c0, w, h, D, d, M) t_0 = Float64(Float64(c0 / w) / Float64(D * sqrt(h))) t_1 = Float64(Float64(c0 * Float64(d * d)) / Float64(Float64(w * h) * Float64(D * D))) t_2 = Float64(Float64(c0 / Float64(2.0 * w)) * Float64(t_1 + sqrt(Float64(Float64(t_1 * t_1) - Float64(M * M))))) tmp = 0.0 if (t_2 <= -4e-7) tmp = Float64(c0 / Float64(Float64(2.0 * w) / Float64(M + Float64(Float64(Float64(Float64(Float64(c0 * 2.0) / w) / h) * Float64(d / D)) / Float64(D / d))))); elseif (t_2 <= 0.0) tmp = Float64(0.25 * Float64(Float64(Float64((D ^ 2.0) * (M ^ 2.0)) / d) * Float64(h / d))); elseif (t_2 <= Inf) tmp = Float64(d * Float64(d * Float64(t_0 * t_0))); else tmp = Float64(0.25 * Float64(Float64(-h) / Float64(Float64(-1.0 / (M ^ 2.0)) * (Float64(d / D) ^ 2.0)))); end return tmp end
function tmp_2 = code(c0, w, h, D, d, M) t_0 = (c0 / w) / (D * sqrt(h)); t_1 = (c0 * (d * d)) / ((w * h) * (D * D)); t_2 = (c0 / (2.0 * w)) * (t_1 + sqrt(((t_1 * t_1) - (M * M)))); tmp = 0.0; if (t_2 <= -4e-7) tmp = c0 / ((2.0 * w) / (M + (((((c0 * 2.0) / w) / h) * (d / D)) / (D / d)))); elseif (t_2 <= 0.0) tmp = 0.25 * ((((D ^ 2.0) * (M ^ 2.0)) / d) * (h / d)); elseif (t_2 <= Inf) tmp = d * (d * (t_0 * t_0)); else tmp = 0.25 * (-h / ((-1.0 / (M ^ 2.0)) * ((d / D) ^ 2.0))); end tmp_2 = tmp; end
code[c0_, w_, h_, D_, d_, M_] := Block[{t$95$0 = N[(N[(c0 / w), $MachinePrecision] / N[(D * N[Sqrt[h], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(c0 * N[(d * d), $MachinePrecision]), $MachinePrecision] / N[(N[(w * h), $MachinePrecision] * N[(D * D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(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]}, If[LessEqual[t$95$2, -4e-7], N[(c0 / N[(N[(2.0 * w), $MachinePrecision] / N[(M + N[(N[(N[(N[(N[(c0 * 2.0), $MachinePrecision] / w), $MachinePrecision] / h), $MachinePrecision] * N[(d / D), $MachinePrecision]), $MachinePrecision] / N[(D / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 0.0], N[(0.25 * N[(N[(N[(N[Power[D, 2.0], $MachinePrecision] * N[Power[M, 2.0], $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision] * N[(h / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, Infinity], N[(d * N[(d * N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.25 * N[((-h) / N[(N[(-1.0 / N[Power[M, 2.0], $MachinePrecision]), $MachinePrecision] * N[Power[N[(d / D), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\frac{c0}{w}}{D \cdot \sqrt{h}}\\
t_1 := \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)}\\
t_2 := \frac{c0}{2 \cdot w} \cdot \left(t_1 + \sqrt{t_1 \cdot t_1 - M \cdot M}\right)\\
\mathbf{if}\;t_2 \leq -4 \cdot 10^{-7}:\\
\;\;\;\;\frac{c0}{\frac{2 \cdot w}{M + \frac{\frac{\frac{c0 \cdot 2}{w}}{h} \cdot \frac{d}{D}}{\frac{D}{d}}}}\\
\mathbf{elif}\;t_2 \leq 0:\\
\;\;\;\;0.25 \cdot \left(\frac{{D}^{2} \cdot {M}^{2}}{d} \cdot \frac{h}{d}\right)\\
\mathbf{elif}\;t_2 \leq \infty:\\
\;\;\;\;d \cdot \left(d \cdot \left(t_0 \cdot t_0\right)\right)\\
\mathbf{else}:\\
\;\;\;\;0.25 \cdot \frac{-h}{\frac{-1}{{M}^{2}} \cdot {\left(\frac{d}{D}\right)}^{2}}\\
\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))))) < -3.9999999999999998e-7Initial program 67.9%
Applied egg-rr73.4%
fma-udef73.4%
+-commutative73.4%
*-commutative73.4%
Applied egg-rr73.4%
fma-udef73.4%
*-commutative73.4%
+-commutative73.4%
associate-+r+73.4%
distribute-lft-out73.4%
count-273.4%
associate-/r*77.5%
Simplified77.5%
*-commutative77.5%
unpow277.5%
clear-num77.5%
div-inv77.5%
associate-*r/81.6%
associate-*r/81.6%
associate-*r/81.6%
Applied egg-rr81.6%
if -3.9999999999999998e-7 < (*.f64 (/.f64 c0 (*.f64 2 w)) (+.f64 (/.f64 (*.f64 c0 (*.f64 d d)) (*.f64 (*.f64 w h) (*.f64 D D))) (sqrt.f64 (-.f64 (*.f64 (/.f64 (*.f64 c0 (*.f64 d d)) (*.f64 (*.f64 w h) (*.f64 D D))) (/.f64 (*.f64 c0 (*.f64 d d)) (*.f64 (*.f64 w h) (*.f64 D D)))) (*.f64 M M))))) < 0.0Initial program 45.8%
Simplified35.8%
Taylor expanded in c0 around -inf 72.3%
fma-def72.3%
Simplified63.4%
Taylor expanded in c0 around 0 81.5%
associate-*r*81.7%
unpow281.7%
times-frac82.2%
Applied egg-rr82.2%
if 0.0 < (*.f64 (/.f64 c0 (*.f64 2 w)) (+.f64 (/.f64 (*.f64 c0 (*.f64 d d)) (*.f64 (*.f64 w h) (*.f64 D D))) (sqrt.f64 (-.f64 (*.f64 (/.f64 (*.f64 c0 (*.f64 d d)) (*.f64 (*.f64 w h) (*.f64 D D))) (/.f64 (*.f64 c0 (*.f64 d d)) (*.f64 (*.f64 w h) (*.f64 D D)))) (*.f64 M M))))) < +inf.0Initial program 84.7%
Taylor expanded in c0 around inf 73.0%
associate-/l*73.1%
associate-*r*73.1%
Simplified73.1%
associate-/r/75.4%
unpow275.4%
associate-*r*75.5%
*-commutative75.5%
associate-/r*75.7%
unpow275.7%
unpow275.7%
frac-times83.8%
pow183.8%
metadata-eval83.8%
pow183.8%
metadata-eval83.8%
pow-sqr83.8%
metadata-eval83.8%
metadata-eval83.8%
*-commutative83.8%
Applied egg-rr83.8%
unpow283.8%
add-sqr-sqrt83.7%
times-frac86.7%
*-commutative86.7%
sqrt-prod86.9%
unpow286.9%
sqrt-prod43.6%
add-sqr-sqrt43.7%
*-commutative43.7%
sqrt-prod43.6%
unpow243.6%
sqrt-prod45.7%
add-sqr-sqrt94.2%
Applied egg-rr94.2%
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%
Simplified1.4%
Taylor expanded in c0 around -inf 3.0%
fma-def3.0%
Simplified6.2%
Taylor expanded in c0 around 0 39.3%
frac-2neg39.3%
div-inv38.6%
*-commutative38.6%
distribute-rgt-neg-in38.6%
*-commutative38.6%
Applied egg-rr38.6%
associate-*r/39.3%
*-rgt-identity39.3%
associate-*l*39.9%
distribute-rgt-neg-out39.9%
*-commutative39.9%
distribute-rgt-neg-in39.9%
distribute-neg-frac39.9%
associate-/l*38.8%
distribute-neg-frac38.8%
neg-mul-138.8%
*-commutative38.8%
times-frac39.5%
unpow239.5%
unpow239.5%
times-frac55.2%
unpow255.2%
Simplified55.2%
Final simplification66.9%
(FPCore (c0 w h D d M)
:precision binary64
(let* ((t_0 (/ (* c0 2.0) w))
(t_1 (/ (* c0 (* d d)) (* (* w h) (* D D))))
(t_2 (* (/ c0 (* 2.0 w)) (+ t_1 (sqrt (- (* t_1 t_1) (* M M)))))))
(if (<= t_2 -4e-7)
(/ c0 (/ (* 2.0 w) (+ M (/ (* (/ t_0 h) (/ d D)) (/ D d)))))
(if (<= t_2 0.0)
(* 0.25 (* (/ (* (pow D 2.0) (pow M 2.0)) d) (/ h d)))
(if (<= t_2 INFINITY)
(/ c0 (/ (* 2.0 w) (+ M (/ (* t_0 (/ d D)) (* h (/ D d))))))
(* 0.25 (/ (- h) (* (/ -1.0 (pow M 2.0)) (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 t_1 = (c0 * (d * d)) / ((w * h) * (D * D));
double t_2 = (c0 / (2.0 * w)) * (t_1 + sqrt(((t_1 * t_1) - (M * M))));
double tmp;
if (t_2 <= -4e-7) {
tmp = c0 / ((2.0 * w) / (M + (((t_0 / h) * (d / D)) / (D / d))));
} else if (t_2 <= 0.0) {
tmp = 0.25 * (((pow(D, 2.0) * pow(M, 2.0)) / d) * (h / d));
} else if (t_2 <= ((double) INFINITY)) {
tmp = c0 / ((2.0 * w) / (M + ((t_0 * (d / D)) / (h * (D / d)))));
} else {
tmp = 0.25 * (-h / ((-1.0 / pow(M, 2.0)) * pow((d / 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 * 2.0) / w;
double t_1 = (c0 * (d * d)) / ((w * h) * (D * D));
double t_2 = (c0 / (2.0 * w)) * (t_1 + Math.sqrt(((t_1 * t_1) - (M * M))));
double tmp;
if (t_2 <= -4e-7) {
tmp = c0 / ((2.0 * w) / (M + (((t_0 / h) * (d / D)) / (D / d))));
} else if (t_2 <= 0.0) {
tmp = 0.25 * (((Math.pow(D, 2.0) * Math.pow(M, 2.0)) / d) * (h / d));
} else if (t_2 <= Double.POSITIVE_INFINITY) {
tmp = c0 / ((2.0 * w) / (M + ((t_0 * (d / D)) / (h * (D / d)))));
} else {
tmp = 0.25 * (-h / ((-1.0 / Math.pow(M, 2.0)) * Math.pow((d / D), 2.0)));
}
return tmp;
}
def code(c0, w, h, D, d, M): t_0 = (c0 * 2.0) / w t_1 = (c0 * (d * d)) / ((w * h) * (D * D)) t_2 = (c0 / (2.0 * w)) * (t_1 + math.sqrt(((t_1 * t_1) - (M * M)))) tmp = 0 if t_2 <= -4e-7: tmp = c0 / ((2.0 * w) / (M + (((t_0 / h) * (d / D)) / (D / d)))) elif t_2 <= 0.0: tmp = 0.25 * (((math.pow(D, 2.0) * math.pow(M, 2.0)) / d) * (h / d)) elif t_2 <= math.inf: tmp = c0 / ((2.0 * w) / (M + ((t_0 * (d / D)) / (h * (D / d))))) else: tmp = 0.25 * (-h / ((-1.0 / math.pow(M, 2.0)) * math.pow((d / D), 2.0))) return tmp
function code(c0, w, h, D, d, M) t_0 = Float64(Float64(c0 * 2.0) / w) t_1 = Float64(Float64(c0 * Float64(d * d)) / Float64(Float64(w * h) * Float64(D * D))) t_2 = Float64(Float64(c0 / Float64(2.0 * w)) * Float64(t_1 + sqrt(Float64(Float64(t_1 * t_1) - Float64(M * M))))) tmp = 0.0 if (t_2 <= -4e-7) tmp = Float64(c0 / Float64(Float64(2.0 * w) / Float64(M + Float64(Float64(Float64(t_0 / h) * Float64(d / D)) / Float64(D / d))))); elseif (t_2 <= 0.0) tmp = Float64(0.25 * Float64(Float64(Float64((D ^ 2.0) * (M ^ 2.0)) / d) * Float64(h / d))); elseif (t_2 <= Inf) tmp = Float64(c0 / Float64(Float64(2.0 * w) / Float64(M + Float64(Float64(t_0 * Float64(d / D)) / Float64(h * Float64(D / d)))))); else tmp = Float64(0.25 * Float64(Float64(-h) / Float64(Float64(-1.0 / (M ^ 2.0)) * (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; t_1 = (c0 * (d * d)) / ((w * h) * (D * D)); t_2 = (c0 / (2.0 * w)) * (t_1 + sqrt(((t_1 * t_1) - (M * M)))); tmp = 0.0; if (t_2 <= -4e-7) tmp = c0 / ((2.0 * w) / (M + (((t_0 / h) * (d / D)) / (D / d)))); elseif (t_2 <= 0.0) tmp = 0.25 * ((((D ^ 2.0) * (M ^ 2.0)) / d) * (h / d)); elseif (t_2 <= Inf) tmp = c0 / ((2.0 * w) / (M + ((t_0 * (d / D)) / (h * (D / d))))); else tmp = 0.25 * (-h / ((-1.0 / (M ^ 2.0)) * ((d / D) ^ 2.0))); end tmp_2 = tmp; end
code[c0_, w_, h_, D_, d_, M_] := Block[{t$95$0 = N[(N[(c0 * 2.0), $MachinePrecision] / w), $MachinePrecision]}, Block[{t$95$1 = N[(N[(c0 * N[(d * d), $MachinePrecision]), $MachinePrecision] / N[(N[(w * h), $MachinePrecision] * N[(D * D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(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]}, If[LessEqual[t$95$2, -4e-7], N[(c0 / N[(N[(2.0 * w), $MachinePrecision] / N[(M + N[(N[(N[(t$95$0 / h), $MachinePrecision] * N[(d / D), $MachinePrecision]), $MachinePrecision] / N[(D / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 0.0], N[(0.25 * N[(N[(N[(N[Power[D, 2.0], $MachinePrecision] * N[Power[M, 2.0], $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision] * N[(h / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, Infinity], N[(c0 / N[(N[(2.0 * w), $MachinePrecision] / N[(M + N[(N[(t$95$0 * N[(d / D), $MachinePrecision]), $MachinePrecision] / N[(h * N[(D / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.25 * N[((-h) / N[(N[(-1.0 / N[Power[M, 2.0], $MachinePrecision]), $MachinePrecision] * N[Power[N[(d / D), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{c0 \cdot 2}{w}\\
t_1 := \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)}\\
t_2 := \frac{c0}{2 \cdot w} \cdot \left(t_1 + \sqrt{t_1 \cdot t_1 - M \cdot M}\right)\\
\mathbf{if}\;t_2 \leq -4 \cdot 10^{-7}:\\
\;\;\;\;\frac{c0}{\frac{2 \cdot w}{M + \frac{\frac{t_0}{h} \cdot \frac{d}{D}}{\frac{D}{d}}}}\\
\mathbf{elif}\;t_2 \leq 0:\\
\;\;\;\;0.25 \cdot \left(\frac{{D}^{2} \cdot {M}^{2}}{d} \cdot \frac{h}{d}\right)\\
\mathbf{elif}\;t_2 \leq \infty:\\
\;\;\;\;\frac{c0}{\frac{2 \cdot w}{M + \frac{t_0 \cdot \frac{d}{D}}{h \cdot \frac{D}{d}}}}\\
\mathbf{else}:\\
\;\;\;\;0.25 \cdot \frac{-h}{\frac{-1}{{M}^{2}} \cdot {\left(\frac{d}{D}\right)}^{2}}\\
\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))))) < -3.9999999999999998e-7Initial program 67.9%
Applied egg-rr73.4%
fma-udef73.4%
+-commutative73.4%
*-commutative73.4%
Applied egg-rr73.4%
fma-udef73.4%
*-commutative73.4%
+-commutative73.4%
associate-+r+73.4%
distribute-lft-out73.4%
count-273.4%
associate-/r*77.5%
Simplified77.5%
*-commutative77.5%
unpow277.5%
clear-num77.5%
div-inv77.5%
associate-*r/81.6%
associate-*r/81.6%
associate-*r/81.6%
Applied egg-rr81.6%
if -3.9999999999999998e-7 < (*.f64 (/.f64 c0 (*.f64 2 w)) (+.f64 (/.f64 (*.f64 c0 (*.f64 d d)) (*.f64 (*.f64 w h) (*.f64 D D))) (sqrt.f64 (-.f64 (*.f64 (/.f64 (*.f64 c0 (*.f64 d d)) (*.f64 (*.f64 w h) (*.f64 D D))) (/.f64 (*.f64 c0 (*.f64 d d)) (*.f64 (*.f64 w h) (*.f64 D D)))) (*.f64 M M))))) < 0.0Initial program 45.8%
Simplified35.8%
Taylor expanded in c0 around -inf 72.3%
fma-def72.3%
Simplified63.4%
Taylor expanded in c0 around 0 81.5%
associate-*r*81.7%
unpow281.7%
times-frac82.2%
Applied egg-rr82.2%
if 0.0 < (*.f64 (/.f64 c0 (*.f64 2 w)) (+.f64 (/.f64 (*.f64 c0 (*.f64 d d)) (*.f64 (*.f64 w h) (*.f64 D D))) (sqrt.f64 (-.f64 (*.f64 (/.f64 (*.f64 c0 (*.f64 d d)) (*.f64 (*.f64 w h) (*.f64 D D))) (/.f64 (*.f64 c0 (*.f64 d d)) (*.f64 (*.f64 w h) (*.f64 D D)))) (*.f64 M M))))) < +inf.0Initial program 84.7%
Applied egg-rr84.4%
fma-udef84.4%
+-commutative84.4%
*-commutative84.4%
Applied egg-rr84.4%
fma-udef84.4%
*-commutative84.4%
+-commutative84.4%
associate-+r+84.4%
distribute-lft-out84.4%
count-284.4%
associate-/r*84.5%
Simplified84.5%
*-commutative84.5%
associate-*r/84.5%
unpow284.5%
clear-num84.6%
div-inv84.6%
frac-times87.3%
associate-*r/87.3%
Applied egg-rr87.3%
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%
Simplified1.4%
Taylor expanded in c0 around -inf 3.0%
fma-def3.0%
Simplified6.2%
Taylor expanded in c0 around 0 39.3%
frac-2neg39.3%
div-inv38.6%
*-commutative38.6%
distribute-rgt-neg-in38.6%
*-commutative38.6%
Applied egg-rr38.6%
associate-*r/39.3%
*-rgt-identity39.3%
associate-*l*39.9%
distribute-rgt-neg-out39.9%
*-commutative39.9%
distribute-rgt-neg-in39.9%
distribute-neg-frac39.9%
associate-/l*38.8%
distribute-neg-frac38.8%
neg-mul-138.8%
*-commutative38.8%
times-frac39.5%
unpow239.5%
unpow239.5%
times-frac55.2%
unpow255.2%
Simplified55.2%
Final simplification65.9%
(FPCore (c0 w h D d M)
:precision binary64
(let* ((t_0 (/ (* c0 2.0) w))
(t_1 (/ (* c0 (* d d)) (* (* w h) (* D D))))
(t_2 (* (/ c0 (* 2.0 w)) (+ t_1 (sqrt (- (* t_1 t_1) (* M M)))))))
(if (<= t_2 -4e-7)
(/ c0 (/ (* 2.0 w) (+ M (/ (* (/ t_0 h) (/ d D)) (/ D d)))))
(if (or (<= t_2 0.0) (not (<= t_2 INFINITY)))
(* (pow M 2.0) (/ 0.25 (/ (pow (/ d D) 2.0) h)))
(/ c0 (/ (* 2.0 w) (+ M (/ (* t_0 (/ d D)) (* h (/ D d))))))))))
double code(double c0, double w, double h, double D, double d, double M) {
double t_0 = (c0 * 2.0) / w;
double t_1 = (c0 * (d * d)) / ((w * h) * (D * D));
double t_2 = (c0 / (2.0 * w)) * (t_1 + sqrt(((t_1 * t_1) - (M * M))));
double tmp;
if (t_2 <= -4e-7) {
tmp = c0 / ((2.0 * w) / (M + (((t_0 / h) * (d / D)) / (D / d))));
} else if ((t_2 <= 0.0) || !(t_2 <= ((double) INFINITY))) {
tmp = pow(M, 2.0) * (0.25 / (pow((d / D), 2.0) / h));
} else {
tmp = c0 / ((2.0 * w) / (M + ((t_0 * (d / D)) / (h * (D / d)))));
}
return tmp;
}
public static double code(double c0, double w, double h, double D, double d, double M) {
double t_0 = (c0 * 2.0) / w;
double t_1 = (c0 * (d * d)) / ((w * h) * (D * D));
double t_2 = (c0 / (2.0 * w)) * (t_1 + Math.sqrt(((t_1 * t_1) - (M * M))));
double tmp;
if (t_2 <= -4e-7) {
tmp = c0 / ((2.0 * w) / (M + (((t_0 / h) * (d / D)) / (D / d))));
} else if ((t_2 <= 0.0) || !(t_2 <= Double.POSITIVE_INFINITY)) {
tmp = Math.pow(M, 2.0) * (0.25 / (Math.pow((d / D), 2.0) / h));
} else {
tmp = c0 / ((2.0 * w) / (M + ((t_0 * (d / D)) / (h * (D / d)))));
}
return tmp;
}
def code(c0, w, h, D, d, M): t_0 = (c0 * 2.0) / w t_1 = (c0 * (d * d)) / ((w * h) * (D * D)) t_2 = (c0 / (2.0 * w)) * (t_1 + math.sqrt(((t_1 * t_1) - (M * M)))) tmp = 0 if t_2 <= -4e-7: tmp = c0 / ((2.0 * w) / (M + (((t_0 / h) * (d / D)) / (D / d)))) elif (t_2 <= 0.0) or not (t_2 <= math.inf): tmp = math.pow(M, 2.0) * (0.25 / (math.pow((d / D), 2.0) / h)) else: tmp = c0 / ((2.0 * w) / (M + ((t_0 * (d / D)) / (h * (D / d))))) return tmp
function code(c0, w, h, D, d, M) t_0 = Float64(Float64(c0 * 2.0) / w) t_1 = Float64(Float64(c0 * Float64(d * d)) / Float64(Float64(w * h) * Float64(D * D))) t_2 = Float64(Float64(c0 / Float64(2.0 * w)) * Float64(t_1 + sqrt(Float64(Float64(t_1 * t_1) - Float64(M * M))))) tmp = 0.0 if (t_2 <= -4e-7) tmp = Float64(c0 / Float64(Float64(2.0 * w) / Float64(M + Float64(Float64(Float64(t_0 / h) * Float64(d / D)) / Float64(D / d))))); elseif ((t_2 <= 0.0) || !(t_2 <= Inf)) tmp = Float64((M ^ 2.0) * Float64(0.25 / Float64((Float64(d / D) ^ 2.0) / h))); else tmp = Float64(c0 / Float64(Float64(2.0 * w) / Float64(M + Float64(Float64(t_0 * Float64(d / D)) / Float64(h * Float64(D / d)))))); end return tmp end
function tmp_2 = code(c0, w, h, D, d, M) t_0 = (c0 * 2.0) / w; t_1 = (c0 * (d * d)) / ((w * h) * (D * D)); t_2 = (c0 / (2.0 * w)) * (t_1 + sqrt(((t_1 * t_1) - (M * M)))); tmp = 0.0; if (t_2 <= -4e-7) tmp = c0 / ((2.0 * w) / (M + (((t_0 / h) * (d / D)) / (D / d)))); elseif ((t_2 <= 0.0) || ~((t_2 <= Inf))) tmp = (M ^ 2.0) * (0.25 / (((d / D) ^ 2.0) / h)); else tmp = c0 / ((2.0 * w) / (M + ((t_0 * (d / D)) / (h * (D / d))))); end tmp_2 = tmp; end
code[c0_, w_, h_, D_, d_, M_] := Block[{t$95$0 = N[(N[(c0 * 2.0), $MachinePrecision] / w), $MachinePrecision]}, Block[{t$95$1 = N[(N[(c0 * N[(d * d), $MachinePrecision]), $MachinePrecision] / N[(N[(w * h), $MachinePrecision] * N[(D * D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(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]}, If[LessEqual[t$95$2, -4e-7], N[(c0 / N[(N[(2.0 * w), $MachinePrecision] / N[(M + N[(N[(N[(t$95$0 / h), $MachinePrecision] * N[(d / D), $MachinePrecision]), $MachinePrecision] / N[(D / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[t$95$2, 0.0], N[Not[LessEqual[t$95$2, Infinity]], $MachinePrecision]], N[(N[Power[M, 2.0], $MachinePrecision] * N[(0.25 / N[(N[Power[N[(d / D), $MachinePrecision], 2.0], $MachinePrecision] / h), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(c0 / N[(N[(2.0 * w), $MachinePrecision] / N[(M + N[(N[(t$95$0 * N[(d / D), $MachinePrecision]), $MachinePrecision] / N[(h * N[(D / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{c0 \cdot 2}{w}\\
t_1 := \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)}\\
t_2 := \frac{c0}{2 \cdot w} \cdot \left(t_1 + \sqrt{t_1 \cdot t_1 - M \cdot M}\right)\\
\mathbf{if}\;t_2 \leq -4 \cdot 10^{-7}:\\
\;\;\;\;\frac{c0}{\frac{2 \cdot w}{M + \frac{\frac{t_0}{h} \cdot \frac{d}{D}}{\frac{D}{d}}}}\\
\mathbf{elif}\;t_2 \leq 0 \lor \neg \left(t_2 \leq \infty\right):\\
\;\;\;\;{M}^{2} \cdot \frac{0.25}{\frac{{\left(\frac{d}{D}\right)}^{2}}{h}}\\
\mathbf{else}:\\
\;\;\;\;\frac{c0}{\frac{2 \cdot w}{M + \frac{t_0 \cdot \frac{d}{D}}{h \cdot \frac{D}{d}}}}\\
\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))))) < -3.9999999999999998e-7Initial program 67.9%
Applied egg-rr73.4%
fma-udef73.4%
+-commutative73.4%
*-commutative73.4%
Applied egg-rr73.4%
fma-udef73.4%
*-commutative73.4%
+-commutative73.4%
associate-+r+73.4%
distribute-lft-out73.4%
count-273.4%
associate-/r*77.5%
Simplified77.5%
*-commutative77.5%
unpow277.5%
clear-num77.5%
div-inv77.5%
associate-*r/81.6%
associate-*r/81.6%
associate-*r/81.6%
Applied egg-rr81.6%
if -3.9999999999999998e-7 < (*.f64 (/.f64 c0 (*.f64 2 w)) (+.f64 (/.f64 (*.f64 c0 (*.f64 d d)) (*.f64 (*.f64 w h) (*.f64 D D))) (sqrt.f64 (-.f64 (*.f64 (/.f64 (*.f64 c0 (*.f64 d d)) (*.f64 (*.f64 w h) (*.f64 D D))) (/.f64 (*.f64 c0 (*.f64 d d)) (*.f64 (*.f64 w h) (*.f64 D D)))) (*.f64 M M))))) < 0.0 or +inf.0 < (*.f64 (/.f64 c0 (*.f64 2 w)) (+.f64 (/.f64 (*.f64 c0 (*.f64 d d)) (*.f64 (*.f64 w h) (*.f64 D D))) (sqrt.f64 (-.f64 (*.f64 (/.f64 (*.f64 c0 (*.f64 d d)) (*.f64 (*.f64 w h) (*.f64 D D))) (/.f64 (*.f64 c0 (*.f64 d d)) (*.f64 (*.f64 w h) (*.f64 D D)))) (*.f64 M M))))) Initial program 2.9%
Simplified3.6%
Taylor expanded in c0 around -inf 7.4%
fma-def7.4%
Simplified9.8%
Taylor expanded in c0 around 0 42.0%
associate-*r/42.0%
associate-/l*41.7%
associate-/r*40.2%
unpow240.2%
unpow240.2%
frac-times54.6%
unpow254.6%
*-commutative54.6%
Applied egg-rr54.6%
associate-/r*53.7%
associate-/r/53.8%
Simplified53.8%
if 0.0 < (*.f64 (/.f64 c0 (*.f64 2 w)) (+.f64 (/.f64 (*.f64 c0 (*.f64 d d)) (*.f64 (*.f64 w h) (*.f64 D D))) (sqrt.f64 (-.f64 (*.f64 (/.f64 (*.f64 c0 (*.f64 d d)) (*.f64 (*.f64 w h) (*.f64 D D))) (/.f64 (*.f64 c0 (*.f64 d d)) (*.f64 (*.f64 w h) (*.f64 D D)))) (*.f64 M M))))) < +inf.0Initial program 84.7%
Applied egg-rr84.4%
fma-udef84.4%
+-commutative84.4%
*-commutative84.4%
Applied egg-rr84.4%
fma-udef84.4%
*-commutative84.4%
+-commutative84.4%
associate-+r+84.4%
distribute-lft-out84.4%
count-284.4%
associate-/r*84.5%
Simplified84.5%
*-commutative84.5%
associate-*r/84.5%
unpow284.5%
clear-num84.6%
div-inv84.6%
frac-times87.3%
associate-*r/87.3%
Applied egg-rr87.3%
Final simplification63.7%
(FPCore (c0 w h D d M)
:precision binary64
(let* ((t_0 (pow (/ d D) 2.0))
(t_1 (/ (* c0 2.0) w))
(t_2 (/ (* c0 (* d d)) (* (* w h) (* D D))))
(t_3 (* (/ c0 (* 2.0 w)) (+ t_2 (sqrt (- (* t_2 t_2) (* M M)))))))
(if (<= t_3 -4e-7)
(/ c0 (/ (* 2.0 w) (+ M (/ (* (/ t_1 h) (/ d D)) (/ D d)))))
(if (<= t_3 0.0)
(* (pow M 2.0) (/ 0.25 (/ t_0 h)))
(if (<= t_3 INFINITY)
(/ c0 (/ (* 2.0 w) (+ M (/ (* t_1 (/ d D)) (* h (/ D d))))))
(* (/ 0.25 t_0) (* h (pow M 2.0))))))))
double code(double c0, double w, double h, double D, double d, double M) {
double t_0 = pow((d / D), 2.0);
double t_1 = (c0 * 2.0) / w;
double t_2 = (c0 * (d * d)) / ((w * h) * (D * D));
double t_3 = (c0 / (2.0 * w)) * (t_2 + sqrt(((t_2 * t_2) - (M * M))));
double tmp;
if (t_3 <= -4e-7) {
tmp = c0 / ((2.0 * w) / (M + (((t_1 / h) * (d / D)) / (D / d))));
} else if (t_3 <= 0.0) {
tmp = pow(M, 2.0) * (0.25 / (t_0 / h));
} else if (t_3 <= ((double) INFINITY)) {
tmp = c0 / ((2.0 * w) / (M + ((t_1 * (d / D)) / (h * (D / d)))));
} else {
tmp = (0.25 / t_0) * (h * pow(M, 2.0));
}
return tmp;
}
public static double code(double c0, double w, double h, double D, double d, double M) {
double t_0 = Math.pow((d / D), 2.0);
double t_1 = (c0 * 2.0) / w;
double t_2 = (c0 * (d * d)) / ((w * h) * (D * D));
double t_3 = (c0 / (2.0 * w)) * (t_2 + Math.sqrt(((t_2 * t_2) - (M * M))));
double tmp;
if (t_3 <= -4e-7) {
tmp = c0 / ((2.0 * w) / (M + (((t_1 / h) * (d / D)) / (D / d))));
} else if (t_3 <= 0.0) {
tmp = Math.pow(M, 2.0) * (0.25 / (t_0 / h));
} else if (t_3 <= Double.POSITIVE_INFINITY) {
tmp = c0 / ((2.0 * w) / (M + ((t_1 * (d / D)) / (h * (D / d)))));
} else {
tmp = (0.25 / t_0) * (h * Math.pow(M, 2.0));
}
return tmp;
}
def code(c0, w, h, D, d, M): t_0 = math.pow((d / D), 2.0) t_1 = (c0 * 2.0) / w t_2 = (c0 * (d * d)) / ((w * h) * (D * D)) t_3 = (c0 / (2.0 * w)) * (t_2 + math.sqrt(((t_2 * t_2) - (M * M)))) tmp = 0 if t_3 <= -4e-7: tmp = c0 / ((2.0 * w) / (M + (((t_1 / h) * (d / D)) / (D / d)))) elif t_3 <= 0.0: tmp = math.pow(M, 2.0) * (0.25 / (t_0 / h)) elif t_3 <= math.inf: tmp = c0 / ((2.0 * w) / (M + ((t_1 * (d / D)) / (h * (D / d))))) else: tmp = (0.25 / t_0) * (h * math.pow(M, 2.0)) return tmp
function code(c0, w, h, D, d, M) t_0 = Float64(d / D) ^ 2.0 t_1 = Float64(Float64(c0 * 2.0) / w) t_2 = Float64(Float64(c0 * Float64(d * d)) / Float64(Float64(w * h) * Float64(D * D))) t_3 = Float64(Float64(c0 / Float64(2.0 * w)) * Float64(t_2 + sqrt(Float64(Float64(t_2 * t_2) - Float64(M * M))))) tmp = 0.0 if (t_3 <= -4e-7) tmp = Float64(c0 / Float64(Float64(2.0 * w) / Float64(M + Float64(Float64(Float64(t_1 / h) * Float64(d / D)) / Float64(D / d))))); elseif (t_3 <= 0.0) tmp = Float64((M ^ 2.0) * Float64(0.25 / Float64(t_0 / h))); elseif (t_3 <= Inf) tmp = Float64(c0 / Float64(Float64(2.0 * w) / Float64(M + Float64(Float64(t_1 * Float64(d / D)) / Float64(h * Float64(D / d)))))); else tmp = Float64(Float64(0.25 / t_0) * Float64(h * (M ^ 2.0))); end return tmp end
function tmp_2 = code(c0, w, h, D, d, M) t_0 = (d / D) ^ 2.0; t_1 = (c0 * 2.0) / w; t_2 = (c0 * (d * d)) / ((w * h) * (D * D)); t_3 = (c0 / (2.0 * w)) * (t_2 + sqrt(((t_2 * t_2) - (M * M)))); tmp = 0.0; if (t_3 <= -4e-7) tmp = c0 / ((2.0 * w) / (M + (((t_1 / h) * (d / D)) / (D / d)))); elseif (t_3 <= 0.0) tmp = (M ^ 2.0) * (0.25 / (t_0 / h)); elseif (t_3 <= Inf) tmp = c0 / ((2.0 * w) / (M + ((t_1 * (d / D)) / (h * (D / d))))); else tmp = (0.25 / t_0) * (h * (M ^ 2.0)); end tmp_2 = tmp; end
code[c0_, w_, h_, D_, d_, M_] := Block[{t$95$0 = N[Power[N[(d / D), $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$1 = N[(N[(c0 * 2.0), $MachinePrecision] / w), $MachinePrecision]}, Block[{t$95$2 = N[(N[(c0 * N[(d * d), $MachinePrecision]), $MachinePrecision] / N[(N[(w * h), $MachinePrecision] * N[(D * D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(N[(c0 / N[(2.0 * w), $MachinePrecision]), $MachinePrecision] * N[(t$95$2 + N[Sqrt[N[(N[(t$95$2 * t$95$2), $MachinePrecision] - N[(M * M), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$3, -4e-7], N[(c0 / N[(N[(2.0 * w), $MachinePrecision] / N[(M + N[(N[(N[(t$95$1 / h), $MachinePrecision] * N[(d / D), $MachinePrecision]), $MachinePrecision] / N[(D / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$3, 0.0], N[(N[Power[M, 2.0], $MachinePrecision] * N[(0.25 / N[(t$95$0 / h), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$3, Infinity], N[(c0 / N[(N[(2.0 * w), $MachinePrecision] / N[(M + N[(N[(t$95$1 * N[(d / D), $MachinePrecision]), $MachinePrecision] / N[(h * N[(D / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(0.25 / t$95$0), $MachinePrecision] * N[(h * N[Power[M, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\left(\frac{d}{D}\right)}^{2}\\
t_1 := \frac{c0 \cdot 2}{w}\\
t_2 := \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)}\\
t_3 := \frac{c0}{2 \cdot w} \cdot \left(t_2 + \sqrt{t_2 \cdot t_2 - M \cdot M}\right)\\
\mathbf{if}\;t_3 \leq -4 \cdot 10^{-7}:\\
\;\;\;\;\frac{c0}{\frac{2 \cdot w}{M + \frac{\frac{t_1}{h} \cdot \frac{d}{D}}{\frac{D}{d}}}}\\
\mathbf{elif}\;t_3 \leq 0:\\
\;\;\;\;{M}^{2} \cdot \frac{0.25}{\frac{t_0}{h}}\\
\mathbf{elif}\;t_3 \leq \infty:\\
\;\;\;\;\frac{c0}{\frac{2 \cdot w}{M + \frac{t_1 \cdot \frac{d}{D}}{h \cdot \frac{D}{d}}}}\\
\mathbf{else}:\\
\;\;\;\;\frac{0.25}{t_0} \cdot \left(h \cdot {M}^{2}\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))))) < -3.9999999999999998e-7Initial program 67.9%
Applied egg-rr73.4%
fma-udef73.4%
+-commutative73.4%
*-commutative73.4%
Applied egg-rr73.4%
fma-udef73.4%
*-commutative73.4%
+-commutative73.4%
associate-+r+73.4%
distribute-lft-out73.4%
count-273.4%
associate-/r*77.5%
Simplified77.5%
*-commutative77.5%
unpow277.5%
clear-num77.5%
div-inv77.5%
associate-*r/81.6%
associate-*r/81.6%
associate-*r/81.6%
Applied egg-rr81.6%
if -3.9999999999999998e-7 < (*.f64 (/.f64 c0 (*.f64 2 w)) (+.f64 (/.f64 (*.f64 c0 (*.f64 d d)) (*.f64 (*.f64 w h) (*.f64 D D))) (sqrt.f64 (-.f64 (*.f64 (/.f64 (*.f64 c0 (*.f64 d d)) (*.f64 (*.f64 w h) (*.f64 D D))) (/.f64 (*.f64 c0 (*.f64 d d)) (*.f64 (*.f64 w h) (*.f64 D D)))) (*.f64 M M))))) < 0.0Initial program 45.8%
Simplified35.8%
Taylor expanded in c0 around -inf 72.3%
fma-def72.3%
Simplified63.4%
Taylor expanded in c0 around 0 81.5%
associate-*r/81.5%
associate-/l*79.4%
associate-/r*72.9%
unpow272.9%
unpow272.9%
frac-times72.9%
unpow272.9%
*-commutative72.9%
Applied egg-rr72.9%
associate-/r*73.1%
associate-/r/75.0%
Simplified75.0%
if 0.0 < (*.f64 (/.f64 c0 (*.f64 2 w)) (+.f64 (/.f64 (*.f64 c0 (*.f64 d d)) (*.f64 (*.f64 w h) (*.f64 D D))) (sqrt.f64 (-.f64 (*.f64 (/.f64 (*.f64 c0 (*.f64 d d)) (*.f64 (*.f64 w h) (*.f64 D D))) (/.f64 (*.f64 c0 (*.f64 d d)) (*.f64 (*.f64 w h) (*.f64 D D)))) (*.f64 M M))))) < +inf.0Initial program 84.7%
Applied egg-rr84.4%
fma-udef84.4%
+-commutative84.4%
*-commutative84.4%
Applied egg-rr84.4%
fma-udef84.4%
*-commutative84.4%
+-commutative84.4%
associate-+r+84.4%
distribute-lft-out84.4%
count-284.4%
associate-/r*84.5%
Simplified84.5%
*-commutative84.5%
associate-*r/84.5%
unpow284.5%
clear-num84.6%
div-inv84.6%
frac-times87.3%
associate-*r/87.3%
Applied egg-rr87.3%
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%
Simplified1.4%
Taylor expanded in c0 around -inf 3.0%
fma-def3.0%
Simplified6.2%
Taylor expanded in c0 around 0 39.3%
associate-*r/39.3%
associate-/l*39.2%
associate-/r*38.0%
unpow238.0%
unpow238.0%
frac-times53.4%
unpow253.4%
*-commutative53.4%
Applied egg-rr53.4%
associate-/r/53.9%
Simplified53.9%
Final simplification64.7%
(FPCore (c0 w h D d M)
:precision binary64
(let* ((t_0 (/ (* c0 2.0) w))
(t_1 (/ (* c0 (* d d)) (* (* w h) (* D D))))
(t_2 (* (/ c0 (* 2.0 w)) (+ t_1 (sqrt (- (* t_1 t_1) (* M M)))))))
(if (<= t_2 -4e-7)
(/ c0 (/ (* 2.0 w) (+ M (/ (* (/ t_0 h) (/ d D)) (/ D d)))))
(if (<= t_2 0.0)
(* 0.25 (* (/ (* (pow D 2.0) (pow M 2.0)) d) (/ h d)))
(if (<= t_2 INFINITY)
(/ c0 (/ (* 2.0 w) (+ M (/ (* t_0 (/ d D)) (* h (/ D d))))))
(* (/ 0.25 (pow (/ d D) 2.0)) (* h (pow M 2.0))))))))
double code(double c0, double w, double h, double D, double d, double M) {
double t_0 = (c0 * 2.0) / w;
double t_1 = (c0 * (d * d)) / ((w * h) * (D * D));
double t_2 = (c0 / (2.0 * w)) * (t_1 + sqrt(((t_1 * t_1) - (M * M))));
double tmp;
if (t_2 <= -4e-7) {
tmp = c0 / ((2.0 * w) / (M + (((t_0 / h) * (d / D)) / (D / d))));
} else if (t_2 <= 0.0) {
tmp = 0.25 * (((pow(D, 2.0) * pow(M, 2.0)) / d) * (h / d));
} else if (t_2 <= ((double) INFINITY)) {
tmp = c0 / ((2.0 * w) / (M + ((t_0 * (d / D)) / (h * (D / d)))));
} else {
tmp = (0.25 / pow((d / D), 2.0)) * (h * pow(M, 2.0));
}
return tmp;
}
public static double code(double c0, double w, double h, double D, double d, double M) {
double t_0 = (c0 * 2.0) / w;
double t_1 = (c0 * (d * d)) / ((w * h) * (D * D));
double t_2 = (c0 / (2.0 * w)) * (t_1 + Math.sqrt(((t_1 * t_1) - (M * M))));
double tmp;
if (t_2 <= -4e-7) {
tmp = c0 / ((2.0 * w) / (M + (((t_0 / h) * (d / D)) / (D / d))));
} else if (t_2 <= 0.0) {
tmp = 0.25 * (((Math.pow(D, 2.0) * Math.pow(M, 2.0)) / d) * (h / d));
} else if (t_2 <= Double.POSITIVE_INFINITY) {
tmp = c0 / ((2.0 * w) / (M + ((t_0 * (d / D)) / (h * (D / d)))));
} else {
tmp = (0.25 / Math.pow((d / D), 2.0)) * (h * Math.pow(M, 2.0));
}
return tmp;
}
def code(c0, w, h, D, d, M): t_0 = (c0 * 2.0) / w t_1 = (c0 * (d * d)) / ((w * h) * (D * D)) t_2 = (c0 / (2.0 * w)) * (t_1 + math.sqrt(((t_1 * t_1) - (M * M)))) tmp = 0 if t_2 <= -4e-7: tmp = c0 / ((2.0 * w) / (M + (((t_0 / h) * (d / D)) / (D / d)))) elif t_2 <= 0.0: tmp = 0.25 * (((math.pow(D, 2.0) * math.pow(M, 2.0)) / d) * (h / d)) elif t_2 <= math.inf: tmp = c0 / ((2.0 * w) / (M + ((t_0 * (d / D)) / (h * (D / d))))) else: tmp = (0.25 / math.pow((d / D), 2.0)) * (h * math.pow(M, 2.0)) return tmp
function code(c0, w, h, D, d, M) t_0 = Float64(Float64(c0 * 2.0) / w) t_1 = Float64(Float64(c0 * Float64(d * d)) / Float64(Float64(w * h) * Float64(D * D))) t_2 = Float64(Float64(c0 / Float64(2.0 * w)) * Float64(t_1 + sqrt(Float64(Float64(t_1 * t_1) - Float64(M * M))))) tmp = 0.0 if (t_2 <= -4e-7) tmp = Float64(c0 / Float64(Float64(2.0 * w) / Float64(M + Float64(Float64(Float64(t_0 / h) * Float64(d / D)) / Float64(D / d))))); elseif (t_2 <= 0.0) tmp = Float64(0.25 * Float64(Float64(Float64((D ^ 2.0) * (M ^ 2.0)) / d) * Float64(h / d))); elseif (t_2 <= Inf) tmp = Float64(c0 / Float64(Float64(2.0 * w) / Float64(M + Float64(Float64(t_0 * Float64(d / D)) / Float64(h * Float64(D / d)))))); else tmp = Float64(Float64(0.25 / (Float64(d / D) ^ 2.0)) * Float64(h * (M ^ 2.0))); end return tmp end
function tmp_2 = code(c0, w, h, D, d, M) t_0 = (c0 * 2.0) / w; t_1 = (c0 * (d * d)) / ((w * h) * (D * D)); t_2 = (c0 / (2.0 * w)) * (t_1 + sqrt(((t_1 * t_1) - (M * M)))); tmp = 0.0; if (t_2 <= -4e-7) tmp = c0 / ((2.0 * w) / (M + (((t_0 / h) * (d / D)) / (D / d)))); elseif (t_2 <= 0.0) tmp = 0.25 * ((((D ^ 2.0) * (M ^ 2.0)) / d) * (h / d)); elseif (t_2 <= Inf) tmp = c0 / ((2.0 * w) / (M + ((t_0 * (d / D)) / (h * (D / d))))); else tmp = (0.25 / ((d / D) ^ 2.0)) * (h * (M ^ 2.0)); end tmp_2 = tmp; end
code[c0_, w_, h_, D_, d_, M_] := Block[{t$95$0 = N[(N[(c0 * 2.0), $MachinePrecision] / w), $MachinePrecision]}, Block[{t$95$1 = N[(N[(c0 * N[(d * d), $MachinePrecision]), $MachinePrecision] / N[(N[(w * h), $MachinePrecision] * N[(D * D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(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]}, If[LessEqual[t$95$2, -4e-7], N[(c0 / N[(N[(2.0 * w), $MachinePrecision] / N[(M + N[(N[(N[(t$95$0 / h), $MachinePrecision] * N[(d / D), $MachinePrecision]), $MachinePrecision] / N[(D / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 0.0], N[(0.25 * N[(N[(N[(N[Power[D, 2.0], $MachinePrecision] * N[Power[M, 2.0], $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision] * N[(h / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, Infinity], N[(c0 / N[(N[(2.0 * w), $MachinePrecision] / N[(M + N[(N[(t$95$0 * N[(d / D), $MachinePrecision]), $MachinePrecision] / N[(h * N[(D / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(0.25 / N[Power[N[(d / D), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h * N[Power[M, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{c0 \cdot 2}{w}\\
t_1 := \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)}\\
t_2 := \frac{c0}{2 \cdot w} \cdot \left(t_1 + \sqrt{t_1 \cdot t_1 - M \cdot M}\right)\\
\mathbf{if}\;t_2 \leq -4 \cdot 10^{-7}:\\
\;\;\;\;\frac{c0}{\frac{2 \cdot w}{M + \frac{\frac{t_0}{h} \cdot \frac{d}{D}}{\frac{D}{d}}}}\\
\mathbf{elif}\;t_2 \leq 0:\\
\;\;\;\;0.25 \cdot \left(\frac{{D}^{2} \cdot {M}^{2}}{d} \cdot \frac{h}{d}\right)\\
\mathbf{elif}\;t_2 \leq \infty:\\
\;\;\;\;\frac{c0}{\frac{2 \cdot w}{M + \frac{t_0 \cdot \frac{d}{D}}{h \cdot \frac{D}{d}}}}\\
\mathbf{else}:\\
\;\;\;\;\frac{0.25}{{\left(\frac{d}{D}\right)}^{2}} \cdot \left(h \cdot {M}^{2}\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))))) < -3.9999999999999998e-7Initial program 67.9%
Applied egg-rr73.4%
fma-udef73.4%
+-commutative73.4%
*-commutative73.4%
Applied egg-rr73.4%
fma-udef73.4%
*-commutative73.4%
+-commutative73.4%
associate-+r+73.4%
distribute-lft-out73.4%
count-273.4%
associate-/r*77.5%
Simplified77.5%
*-commutative77.5%
unpow277.5%
clear-num77.5%
div-inv77.5%
associate-*r/81.6%
associate-*r/81.6%
associate-*r/81.6%
Applied egg-rr81.6%
if -3.9999999999999998e-7 < (*.f64 (/.f64 c0 (*.f64 2 w)) (+.f64 (/.f64 (*.f64 c0 (*.f64 d d)) (*.f64 (*.f64 w h) (*.f64 D D))) (sqrt.f64 (-.f64 (*.f64 (/.f64 (*.f64 c0 (*.f64 d d)) (*.f64 (*.f64 w h) (*.f64 D D))) (/.f64 (*.f64 c0 (*.f64 d d)) (*.f64 (*.f64 w h) (*.f64 D D)))) (*.f64 M M))))) < 0.0Initial program 45.8%
Simplified35.8%
Taylor expanded in c0 around -inf 72.3%
fma-def72.3%
Simplified63.4%
Taylor expanded in c0 around 0 81.5%
associate-*r*81.7%
unpow281.7%
times-frac82.2%
Applied egg-rr82.2%
if 0.0 < (*.f64 (/.f64 c0 (*.f64 2 w)) (+.f64 (/.f64 (*.f64 c0 (*.f64 d d)) (*.f64 (*.f64 w h) (*.f64 D D))) (sqrt.f64 (-.f64 (*.f64 (/.f64 (*.f64 c0 (*.f64 d d)) (*.f64 (*.f64 w h) (*.f64 D D))) (/.f64 (*.f64 c0 (*.f64 d d)) (*.f64 (*.f64 w h) (*.f64 D D)))) (*.f64 M M))))) < +inf.0Initial program 84.7%
Applied egg-rr84.4%
fma-udef84.4%
+-commutative84.4%
*-commutative84.4%
Applied egg-rr84.4%
fma-udef84.4%
*-commutative84.4%
+-commutative84.4%
associate-+r+84.4%
distribute-lft-out84.4%
count-284.4%
associate-/r*84.5%
Simplified84.5%
*-commutative84.5%
associate-*r/84.5%
unpow284.5%
clear-num84.6%
div-inv84.6%
frac-times87.3%
associate-*r/87.3%
Applied egg-rr87.3%
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%
Simplified1.4%
Taylor expanded in c0 around -inf 3.0%
fma-def3.0%
Simplified6.2%
Taylor expanded in c0 around 0 39.3%
associate-*r/39.3%
associate-/l*39.2%
associate-/r*38.0%
unpow238.0%
unpow238.0%
frac-times53.4%
unpow253.4%
*-commutative53.4%
Applied egg-rr53.4%
associate-/r/53.9%
Simplified53.9%
Final simplification65.0%
(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 (/ (* 2.0 w) (+ M (/ (* (/ (/ (* c0 2.0) w) h) (/ d D)) (/ D d)))))
(/ c0 (log1p (expm1 (/ w (/ M 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 tmp;
if (((c0 / (2.0 * w)) * (t_0 + sqrt(((t_0 * t_0) - (M * M))))) <= ((double) INFINITY)) {
tmp = c0 / ((2.0 * w) / (M + (((((c0 * 2.0) / w) / h) * (d / D)) / (D / d))));
} else {
tmp = c0 / log1p(expm1((w / (M / 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 tmp;
if (((c0 / (2.0 * w)) * (t_0 + Math.sqrt(((t_0 * t_0) - (M * M))))) <= Double.POSITIVE_INFINITY) {
tmp = c0 / ((2.0 * w) / (M + (((((c0 * 2.0) / w) / h) * (d / D)) / (D / d))));
} else {
tmp = c0 / Math.log1p(Math.expm1((w / (M / 2.0))));
}
return tmp;
}
def code(c0, w, h, D, d, M): t_0 = (c0 * (d * d)) / ((w * h) * (D * D)) tmp = 0 if ((c0 / (2.0 * w)) * (t_0 + math.sqrt(((t_0 * t_0) - (M * M))))) <= math.inf: tmp = c0 / ((2.0 * w) / (M + (((((c0 * 2.0) / w) / h) * (d / D)) / (D / d)))) else: tmp = c0 / math.log1p(math.expm1((w / (M / 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))) 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(Float64(2.0 * w) / Float64(M + Float64(Float64(Float64(Float64(Float64(c0 * 2.0) / w) / h) * Float64(d / D)) / Float64(D / d))))); else tmp = Float64(c0 / log1p(expm1(Float64(w / Float64(M / 2.0))))); 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[(2.0 * w), $MachinePrecision] / N[(M + N[(N[(N[(N[(N[(c0 * 2.0), $MachinePrecision] / w), $MachinePrecision] / h), $MachinePrecision] * N[(d / D), $MachinePrecision]), $MachinePrecision] / N[(D / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(c0 / N[Log[1 + N[(Exp[N[(w / N[(M / 2.0), $MachinePrecision]), $MachinePrecision]] - 1), $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:\\
\;\;\;\;\frac{c0}{\frac{2 \cdot w}{M + \frac{\frac{\frac{c0 \cdot 2}{w}}{h} \cdot \frac{d}{D}}{\frac{D}{d}}}}\\
\mathbf{else}:\\
\;\;\;\;\frac{c0}{\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{w}{\frac{M}{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%
Applied egg-rr70.5%
fma-udef70.5%
+-commutative70.5%
*-commutative70.5%
Applied egg-rr70.5%
fma-udef70.5%
*-commutative70.5%
+-commutative70.5%
associate-+r+70.5%
distribute-lft-out70.5%
count-270.5%
associate-/r*72.6%
Simplified72.6%
*-commutative72.6%
unpow272.6%
clear-num72.6%
div-inv72.6%
associate-*r/76.7%
associate-*r/76.7%
associate-*r/76.7%
Applied egg-rr76.7%
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%
Applied egg-rr26.3%
Taylor expanded in w around inf 20.5%
log1p-expm1-u36.8%
associate-*r/36.8%
*-commutative36.8%
associate-/l*36.8%
Applied egg-rr36.8%
Final simplification51.6%
(FPCore (c0 w h D d M) :precision binary64 (if (or (<= w -1.9e+20) (not (<= w 1.65e+115))) (* (/ c0 (* 2.0 w)) (* c0 0.0)) (/ c0 (/ (* 2.0 w) (+ M (/ (* (/ (* c0 2.0) w) (/ d D)) (* h (/ D d))))))))
double code(double c0, double w, double h, double D, double d, double M) {
double tmp;
if ((w <= -1.9e+20) || !(w <= 1.65e+115)) {
tmp = (c0 / (2.0 * w)) * (c0 * 0.0);
} else {
tmp = c0 / ((2.0 * w) / (M + ((((c0 * 2.0) / w) * (d / D)) / (h * (D / d)))));
}
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 ((w <= (-1.9d+20)) .or. (.not. (w <= 1.65d+115))) then
tmp = (c0 / (2.0d0 * w)) * (c0 * 0.0d0)
else
tmp = c0 / ((2.0d0 * w) / (m + ((((c0 * 2.0d0) / w) * (d_1 / d)) / (h * (d / d_1)))))
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 ((w <= -1.9e+20) || !(w <= 1.65e+115)) {
tmp = (c0 / (2.0 * w)) * (c0 * 0.0);
} else {
tmp = c0 / ((2.0 * w) / (M + ((((c0 * 2.0) / w) * (d / D)) / (h * (D / d)))));
}
return tmp;
}
def code(c0, w, h, D, d, M): tmp = 0 if (w <= -1.9e+20) or not (w <= 1.65e+115): tmp = (c0 / (2.0 * w)) * (c0 * 0.0) else: tmp = c0 / ((2.0 * w) / (M + ((((c0 * 2.0) / w) * (d / D)) / (h * (D / d))))) return tmp
function code(c0, w, h, D, d, M) tmp = 0.0 if ((w <= -1.9e+20) || !(w <= 1.65e+115)) tmp = Float64(Float64(c0 / Float64(2.0 * w)) * Float64(c0 * 0.0)); else tmp = Float64(c0 / Float64(Float64(2.0 * w) / Float64(M + Float64(Float64(Float64(Float64(c0 * 2.0) / w) * Float64(d / D)) / Float64(h * Float64(D / d)))))); end return tmp end
function tmp_2 = code(c0, w, h, D, d, M) tmp = 0.0; if ((w <= -1.9e+20) || ~((w <= 1.65e+115))) tmp = (c0 / (2.0 * w)) * (c0 * 0.0); else tmp = c0 / ((2.0 * w) / (M + ((((c0 * 2.0) / w) * (d / D)) / (h * (D / d))))); end tmp_2 = tmp; end
code[c0_, w_, h_, D_, d_, M_] := If[Or[LessEqual[w, -1.9e+20], N[Not[LessEqual[w, 1.65e+115]], $MachinePrecision]], N[(N[(c0 / N[(2.0 * w), $MachinePrecision]), $MachinePrecision] * N[(c0 * 0.0), $MachinePrecision]), $MachinePrecision], N[(c0 / N[(N[(2.0 * w), $MachinePrecision] / N[(M + N[(N[(N[(N[(c0 * 2.0), $MachinePrecision] / w), $MachinePrecision] * N[(d / D), $MachinePrecision]), $MachinePrecision] / N[(h * N[(D / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;w \leq -1.9 \cdot 10^{+20} \lor \neg \left(w \leq 1.65 \cdot 10^{+115}\right):\\
\;\;\;\;\frac{c0}{2 \cdot w} \cdot \left(c0 \cdot 0\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{c0}{\frac{2 \cdot w}{M + \frac{\frac{c0 \cdot 2}{w} \cdot \frac{d}{D}}{h \cdot \frac{D}{d}}}}\\
\end{array}
\end{array}
if w < -1.9e20 or 1.65000000000000003e115 < w Initial program 14.8%
Simplified16.3%
Taylor expanded in c0 around -inf 11.2%
associate-*r*11.2%
neg-mul-111.2%
distribute-lft1-in11.2%
metadata-eval11.2%
*-commutative11.2%
*-commutative11.2%
associate-/l/9.8%
unpow29.8%
/-rgt-identity9.8%
associate-*r/18.3%
unpow218.3%
associate-/l/21.1%
associate-*r/19.7%
/-rgt-identity19.7%
associate-*l/23.9%
unpow223.9%
*-commutative23.9%
Simplified23.9%
Taylor expanded in d around 0 48.2%
if -1.9e20 < w < 1.65000000000000003e115Initial program 31.3%
Applied egg-rr48.3%
fma-udef48.3%
+-commutative48.3%
*-commutative48.3%
Applied egg-rr48.3%
fma-udef48.3%
*-commutative48.3%
+-commutative48.3%
associate-+r+48.3%
distribute-lft-out48.3%
count-248.3%
associate-/r*49.9%
Simplified49.9%
*-commutative49.9%
associate-*r/49.9%
unpow249.9%
clear-num50.0%
div-inv50.0%
frac-times52.6%
associate-*r/52.6%
Applied egg-rr52.6%
Final simplification51.4%
(FPCore (c0 w h D d M) :precision binary64 (/ c0 (/ (* 2.0 w) (+ M (/ (* (/ (/ (* c0 2.0) w) h) (/ d D)) (/ D d))))))
double code(double c0, double w, double h, double D, double d, double M) {
return c0 / ((2.0 * w) / (M + (((((c0 * 2.0) / w) / h) * (d / D)) / (D / d))));
}
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) / (m + (((((c0 * 2.0d0) / w) / h) * (d_1 / d)) / (d / d_1))))
end function
public static double code(double c0, double w, double h, double D, double d, double M) {
return c0 / ((2.0 * w) / (M + (((((c0 * 2.0) / w) / h) * (d / D)) / (D / d))));
}
def code(c0, w, h, D, d, M): return c0 / ((2.0 * w) / (M + (((((c0 * 2.0) / w) / h) * (d / D)) / (D / d))))
function code(c0, w, h, D, d, M) return Float64(c0 / Float64(Float64(2.0 * w) / Float64(M + Float64(Float64(Float64(Float64(Float64(c0 * 2.0) / w) / h) * Float64(d / D)) / Float64(D / d))))) end
function tmp = code(c0, w, h, D, d, M) tmp = c0 / ((2.0 * w) / (M + (((((c0 * 2.0) / w) / h) * (d / D)) / (D / d)))); end
code[c0_, w_, h_, D_, d_, M_] := N[(c0 / N[(N[(2.0 * w), $MachinePrecision] / N[(M + N[(N[(N[(N[(N[(c0 * 2.0), $MachinePrecision] / w), $MachinePrecision] / h), $MachinePrecision] * N[(d / D), $MachinePrecision]), $MachinePrecision] / N[(D / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{c0}{\frac{2 \cdot w}{M + \frac{\frac{\frac{c0 \cdot 2}{w}}{h} \cdot \frac{d}{D}}{\frac{D}{d}}}}
\end{array}
Initial program 26.7%
Applied egg-rr42.7%
fma-udef42.7%
+-commutative42.7%
*-commutative42.7%
Applied egg-rr42.7%
fma-udef42.7%
*-commutative42.7%
+-commutative42.7%
associate-+r+42.7%
distribute-lft-out42.7%
count-242.7%
associate-/r*44.2%
Simplified44.2%
*-commutative44.2%
unpow244.2%
clear-num44.2%
div-inv44.2%
associate-*r/49.1%
associate-*r/49.1%
associate-*r/49.1%
Applied egg-rr49.1%
Final simplification49.1%
(FPCore (c0 w h D d M) :precision binary64 (if (or (<= w -4.6e-206) (not (<= w 1.25e-50))) (* (/ c0 (* 2.0 w)) (* c0 0.0)) (* M (* (/ c0 w) 0.5))))
double code(double c0, double w, double h, double D, double d, double M) {
double tmp;
if ((w <= -4.6e-206) || !(w <= 1.25e-50)) {
tmp = (c0 / (2.0 * w)) * (c0 * 0.0);
} else {
tmp = M * ((c0 / w) * 0.5);
}
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 ((w <= (-4.6d-206)) .or. (.not. (w <= 1.25d-50))) then
tmp = (c0 / (2.0d0 * w)) * (c0 * 0.0d0)
else
tmp = m * ((c0 / w) * 0.5d0)
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 ((w <= -4.6e-206) || !(w <= 1.25e-50)) {
tmp = (c0 / (2.0 * w)) * (c0 * 0.0);
} else {
tmp = M * ((c0 / w) * 0.5);
}
return tmp;
}
def code(c0, w, h, D, d, M): tmp = 0 if (w <= -4.6e-206) or not (w <= 1.25e-50): tmp = (c0 / (2.0 * w)) * (c0 * 0.0) else: tmp = M * ((c0 / w) * 0.5) return tmp
function code(c0, w, h, D, d, M) tmp = 0.0 if ((w <= -4.6e-206) || !(w <= 1.25e-50)) tmp = Float64(Float64(c0 / Float64(2.0 * w)) * Float64(c0 * 0.0)); else tmp = Float64(M * Float64(Float64(c0 / w) * 0.5)); end return tmp end
function tmp_2 = code(c0, w, h, D, d, M) tmp = 0.0; if ((w <= -4.6e-206) || ~((w <= 1.25e-50))) tmp = (c0 / (2.0 * w)) * (c0 * 0.0); else tmp = M * ((c0 / w) * 0.5); end tmp_2 = tmp; end
code[c0_, w_, h_, D_, d_, M_] := If[Or[LessEqual[w, -4.6e-206], N[Not[LessEqual[w, 1.25e-50]], $MachinePrecision]], N[(N[(c0 / N[(2.0 * w), $MachinePrecision]), $MachinePrecision] * N[(c0 * 0.0), $MachinePrecision]), $MachinePrecision], N[(M * N[(N[(c0 / w), $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;w \leq -4.6 \cdot 10^{-206} \lor \neg \left(w \leq 1.25 \cdot 10^{-50}\right):\\
\;\;\;\;\frac{c0}{2 \cdot w} \cdot \left(c0 \cdot 0\right)\\
\mathbf{else}:\\
\;\;\;\;M \cdot \left(\frac{c0}{w} \cdot 0.5\right)\\
\end{array}
\end{array}
if w < -4.6e-206 or 1.24999999999999992e-50 < w Initial program 21.3%
Simplified22.0%
Taylor expanded in c0 around -inf 6.7%
associate-*r*6.7%
neg-mul-16.7%
distribute-lft1-in6.7%
metadata-eval6.7%
*-commutative6.7%
*-commutative6.7%
associate-/l/6.1%
unpow26.1%
/-rgt-identity6.1%
associate-*r/10.8%
unpow210.8%
associate-/l/12.1%
associate-*r/12.1%
/-rgt-identity12.1%
associate-*l/14.1%
unpow214.1%
*-commutative14.1%
Simplified14.1%
Taylor expanded in d around 0 36.2%
if -4.6e-206 < w < 1.24999999999999992e-50Initial program 34.9%
Applied egg-rr50.5%
Taylor expanded in w around inf 20.3%
associate-*r/20.3%
*-commutative20.3%
associate-/r/21.2%
*-un-lft-identity21.2%
metadata-eval21.2%
*-commutative21.2%
times-frac21.2%
metadata-eval21.2%
metadata-eval21.2%
Applied egg-rr21.2%
Final simplification30.3%
(FPCore (c0 w h D d M) :precision binary64 (* 0.5 (/ M (/ w c0))))
double code(double c0, double w, double h, double D, double d, double M) {
return 0.5 * (M / (w / c0));
}
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 / (w / c0))
end function
public static double code(double c0, double w, double h, double D, double d, double M) {
return 0.5 * (M / (w / c0));
}
def code(c0, w, h, D, d, M): return 0.5 * (M / (w / c0))
function code(c0, w, h, D, d, M) return Float64(0.5 * Float64(M / Float64(w / c0))) end
function tmp = code(c0, w, h, D, d, M) tmp = 0.5 * (M / (w / c0)); end
code[c0_, w_, h_, D_, d_, M_] := N[(0.5 * N[(M / N[(w / c0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
0.5 \cdot \frac{M}{\frac{w}{c0}}
\end{array}
Initial program 26.7%
Applied egg-rr42.7%
fma-udef42.7%
+-commutative42.7%
*-commutative42.7%
Applied egg-rr42.7%
fma-udef42.7%
*-commutative42.7%
+-commutative42.7%
associate-+r+42.7%
distribute-lft-out42.7%
count-242.7%
associate-/r*44.2%
Simplified44.2%
Taylor expanded in c0 around 0 17.5%
associate-/l*17.2%
Simplified17.2%
Final simplification17.2%
(FPCore (c0 w h D d M) :precision binary64 (* M (* (/ c0 w) 0.5)))
double code(double c0, double w, double h, double D, double d, double M) {
return M * ((c0 / w) * 0.5);
}
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 = m * ((c0 / w) * 0.5d0)
end function
public static double code(double c0, double w, double h, double D, double d, double M) {
return M * ((c0 / w) * 0.5);
}
def code(c0, w, h, D, d, M): return M * ((c0 / w) * 0.5)
function code(c0, w, h, D, d, M) return Float64(M * Float64(Float64(c0 / w) * 0.5)) end
function tmp = code(c0, w, h, D, d, M) tmp = M * ((c0 / w) * 0.5); end
code[c0_, w_, h_, D_, d_, M_] := N[(M * N[(N[(c0 / w), $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
M \cdot \left(\frac{c0}{w} \cdot 0.5\right)
\end{array}
Initial program 26.7%
Applied egg-rr42.7%
Taylor expanded in w around inf 18.3%
associate-*r/18.3%
*-commutative18.3%
associate-/r/17.2%
*-un-lft-identity17.2%
metadata-eval17.2%
*-commutative17.2%
times-frac17.2%
metadata-eval17.2%
metadata-eval17.2%
Applied egg-rr17.2%
Final simplification17.2%
herbie shell --seed 2023301
(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))))))