
(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 9 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}
D_m = (fabs.f64 D)
d_m = (fabs.f64 d)
(FPCore (c0 w h D_m d_m M)
:precision binary64
(let* ((t_0 (pow (/ d_m D_m) 2.0))
(t_1 (/ (* c0 t_0) (* w h)))
(t_2 (/ c0 (* 2.0 w)))
(t_3 (/ (* c0 (* d_m d_m)) (* (* w h) (* D_m D_m))))
(t_4 (* t_2 (+ t_3 (sqrt (- (* t_3 t_3) (* M M)))))))
(if (<= t_4 -2e-182)
(*
c0
(/
(fma
c0
(* d_m (/ d_m (* D_m (* w (* h D_m)))))
(* (* (/ c0 (* h D_m)) (/ d_m w)) (/ d_m D_m)))
(* 2.0 w)))
(if (<= t_4 2e-141)
(* 0.25 (/ (* (pow D_m 2.0) (* h (pow M 2.0))) (pow d_m 2.0)))
(if (<= t_4 INFINITY)
(*
t_2
(fma
(* (/ d_m D_m) (pow (sqrt (sqrt (/ c0 (* w h)))) 2.0))
(sqrt (- t_1 M))
t_1))
(*
c0
(/
(/ 1.0 (* c0 (* 2.0 (/ t_0 (* h (* w (pow M 2.0)))))))
(* 2.0 w))))))))D_m = fabs(D);
d_m = fabs(d);
double code(double c0, double w, double h, double D_m, double d_m, double M) {
double t_0 = pow((d_m / D_m), 2.0);
double t_1 = (c0 * t_0) / (w * h);
double t_2 = c0 / (2.0 * w);
double t_3 = (c0 * (d_m * d_m)) / ((w * h) * (D_m * D_m));
double t_4 = t_2 * (t_3 + sqrt(((t_3 * t_3) - (M * M))));
double tmp;
if (t_4 <= -2e-182) {
tmp = c0 * (fma(c0, (d_m * (d_m / (D_m * (w * (h * D_m))))), (((c0 / (h * D_m)) * (d_m / w)) * (d_m / D_m))) / (2.0 * w));
} else if (t_4 <= 2e-141) {
tmp = 0.25 * ((pow(D_m, 2.0) * (h * pow(M, 2.0))) / pow(d_m, 2.0));
} else if (t_4 <= ((double) INFINITY)) {
tmp = t_2 * fma(((d_m / D_m) * pow(sqrt(sqrt((c0 / (w * h)))), 2.0)), sqrt((t_1 - M)), t_1);
} else {
tmp = c0 * ((1.0 / (c0 * (2.0 * (t_0 / (h * (w * pow(M, 2.0))))))) / (2.0 * w));
}
return tmp;
}
D_m = abs(D) d_m = abs(d) function code(c0, w, h, D_m, d_m, M) t_0 = Float64(d_m / D_m) ^ 2.0 t_1 = Float64(Float64(c0 * t_0) / Float64(w * h)) t_2 = Float64(c0 / Float64(2.0 * w)) t_3 = Float64(Float64(c0 * Float64(d_m * d_m)) / Float64(Float64(w * h) * Float64(D_m * D_m))) t_4 = Float64(t_2 * Float64(t_3 + sqrt(Float64(Float64(t_3 * t_3) - Float64(M * M))))) tmp = 0.0 if (t_4 <= -2e-182) tmp = Float64(c0 * Float64(fma(c0, Float64(d_m * Float64(d_m / Float64(D_m * Float64(w * Float64(h * D_m))))), Float64(Float64(Float64(c0 / Float64(h * D_m)) * Float64(d_m / w)) * Float64(d_m / D_m))) / Float64(2.0 * w))); elseif (t_4 <= 2e-141) tmp = Float64(0.25 * Float64(Float64((D_m ^ 2.0) * Float64(h * (M ^ 2.0))) / (d_m ^ 2.0))); elseif (t_4 <= Inf) tmp = Float64(t_2 * fma(Float64(Float64(d_m / D_m) * (sqrt(sqrt(Float64(c0 / Float64(w * h)))) ^ 2.0)), sqrt(Float64(t_1 - M)), t_1)); else tmp = Float64(c0 * Float64(Float64(1.0 / Float64(c0 * Float64(2.0 * Float64(t_0 / Float64(h * Float64(w * (M ^ 2.0))))))) / Float64(2.0 * w))); end return tmp end
D_m = N[Abs[D], $MachinePrecision]
d_m = N[Abs[d], $MachinePrecision]
code[c0_, w_, h_, D$95$m_, d$95$m_, M_] := Block[{t$95$0 = N[Power[N[(d$95$m / D$95$m), $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$1 = N[(N[(c0 * t$95$0), $MachinePrecision] / N[(w * h), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(c0 / N[(2.0 * w), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(N[(c0 * N[(d$95$m * d$95$m), $MachinePrecision]), $MachinePrecision] / N[(N[(w * h), $MachinePrecision] * N[(D$95$m * D$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$4 = N[(t$95$2 * N[(t$95$3 + N[Sqrt[N[(N[(t$95$3 * t$95$3), $MachinePrecision] - N[(M * M), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$4, -2e-182], N[(c0 * N[(N[(c0 * N[(d$95$m * N[(d$95$m / N[(D$95$m * N[(w * N[(h * D$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(N[(c0 / N[(h * D$95$m), $MachinePrecision]), $MachinePrecision] * N[(d$95$m / w), $MachinePrecision]), $MachinePrecision] * N[(d$95$m / D$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(2.0 * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$4, 2e-141], N[(0.25 * N[(N[(N[Power[D$95$m, 2.0], $MachinePrecision] * N[(h * N[Power[M, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Power[d$95$m, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$4, Infinity], N[(t$95$2 * N[(N[(N[(d$95$m / D$95$m), $MachinePrecision] * N[Power[N[Sqrt[N[Sqrt[N[(c0 / N[(w * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(t$95$1 - M), $MachinePrecision]], $MachinePrecision] + t$95$1), $MachinePrecision]), $MachinePrecision], N[(c0 * N[(N[(1.0 / N[(c0 * N[(2.0 * N[(t$95$0 / N[(h * N[(w * N[Power[M, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(2.0 * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]]
\begin{array}{l}
D_m = \left|D\right|
\\
d_m = \left|d\right|
\\
\begin{array}{l}
t_0 := {\left(\frac{d\_m}{D\_m}\right)}^{2}\\
t_1 := \frac{c0 \cdot t\_0}{w \cdot h}\\
t_2 := \frac{c0}{2 \cdot w}\\
t_3 := \frac{c0 \cdot \left(d\_m \cdot d\_m\right)}{\left(w \cdot h\right) \cdot \left(D\_m \cdot D\_m\right)}\\
t_4 := t\_2 \cdot \left(t\_3 + \sqrt{t\_3 \cdot t\_3 - M \cdot M}\right)\\
\mathbf{if}\;t\_4 \leq -2 \cdot 10^{-182}:\\
\;\;\;\;c0 \cdot \frac{\mathsf{fma}\left(c0, d\_m \cdot \frac{d\_m}{D\_m \cdot \left(w \cdot \left(h \cdot D\_m\right)\right)}, \left(\frac{c0}{h \cdot D\_m} \cdot \frac{d\_m}{w}\right) \cdot \frac{d\_m}{D\_m}\right)}{2 \cdot w}\\
\mathbf{elif}\;t\_4 \leq 2 \cdot 10^{-141}:\\
\;\;\;\;0.25 \cdot \frac{{D\_m}^{2} \cdot \left(h \cdot {M}^{2}\right)}{{d\_m}^{2}}\\
\mathbf{elif}\;t\_4 \leq \infty:\\
\;\;\;\;t\_2 \cdot \mathsf{fma}\left(\frac{d\_m}{D\_m} \cdot {\left(\sqrt{\sqrt{\frac{c0}{w \cdot h}}}\right)}^{2}, \sqrt{t\_1 - M}, t\_1\right)\\
\mathbf{else}:\\
\;\;\;\;c0 \cdot \frac{\frac{1}{c0 \cdot \left(2 \cdot \frac{t\_0}{h \cdot \left(w \cdot {M}^{2}\right)}\right)}}{2 \cdot w}\\
\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))))) < -2.0000000000000001e-182Initial program 81.5%
Simplified86.8%
Taylor expanded in c0 around inf 81.6%
*-commutative81.6%
*-commutative81.6%
associate-*r*78.9%
times-frac79.0%
*-commutative79.0%
Simplified79.0%
associate-*r/81.6%
*-commutative81.6%
Applied egg-rr81.6%
times-frac84.2%
associate-/r*84.2%
pow284.2%
pow284.2%
frac-times86.8%
associate-*r*89.4%
*-commutative89.4%
Applied egg-rr89.4%
Taylor expanded in c0 around 0 89.4%
associate-*r*89.4%
times-frac89.5%
Simplified89.5%
if -2.0000000000000001e-182 < (*.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))))) < 2.0000000000000001e-141Initial program 53.1%
Simplified16.6%
Applied egg-rr44.6%
associate--r-62.6%
+-inverses68.9%
associate-/l*62.8%
*-commutative62.8%
associate-/l*62.7%
*-commutative62.7%
Simplified62.7%
Taylor expanded in c0 around -inf 62.7%
associate-*r/62.7%
neg-mul-162.7%
associate-*r/62.7%
mul-1-neg62.7%
Simplified62.7%
clear-num62.8%
inv-pow62.8%
sub-div62.8%
*-commutative62.8%
Applied egg-rr62.8%
unpow-162.8%
associate-/l*62.8%
Simplified63.0%
Taylor expanded in c0 around 0 74.9%
if 2.0000000000000001e-141 < (*.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 85.8%
Simplified85.8%
Applied egg-rr94.9%
Taylor expanded in c0 around inf 54.3%
add-sqr-sqrt54.1%
pow254.1%
Applied egg-rr54.1%
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%
Simplified20.7%
Applied egg-rr2.1%
associate--r-3.1%
+-inverses39.8%
associate-/l*40.4%
*-commutative40.4%
associate-/l*39.7%
*-commutative39.7%
Simplified39.7%
Taylor expanded in c0 around -inf 35.4%
associate-*r/35.4%
neg-mul-135.4%
associate-*r/35.4%
mul-1-neg35.4%
Simplified35.4%
clear-num35.4%
inv-pow35.4%
sub-div35.4%
*-commutative35.4%
Applied egg-rr35.4%
unpow-135.4%
associate-/l*36.0%
Simplified48.9%
Taylor expanded in d around 0 36.6%
associate-/r*35.4%
unpow235.4%
unpow235.4%
times-frac44.9%
unpow244.9%
*-commutative44.9%
associate-*l*50.5%
Simplified50.5%
Final simplification58.3%
D_m = (fabs.f64 D)
d_m = (fabs.f64 d)
(FPCore (c0 w h D_m d_m M)
:precision binary64
(let* ((t_0 (pow (/ d_m D_m) 2.0))
(t_1 (/ (* c0 t_0) (* w h)))
(t_2 (/ c0 (* 2.0 w)))
(t_3 (/ (* c0 (* d_m d_m)) (* (* w h) (* D_m D_m))))
(t_4 (* t_2 (+ t_3 (sqrt (- (* t_3 t_3) (* M M)))))))
(if (<= t_4 -2e-182)
(*
c0
(/
(fma
c0
(* d_m (/ d_m (* D_m (* w (* h D_m)))))
(* (* (/ c0 (* h D_m)) (/ d_m w)) (/ d_m D_m)))
(* 2.0 w)))
(if (<= t_4 2e-141)
(* 0.25 (/ (* (pow D_m 2.0) (* h (pow M 2.0))) (pow d_m 2.0)))
(if (<= t_4 INFINITY)
(*
t_2
(fma (* (/ d_m D_m) (sqrt (/ c0 (* w h)))) (sqrt (- t_1 M)) t_1))
(*
c0
(/
(/ 1.0 (* c0 (* 2.0 (/ t_0 (* h (* w (pow M 2.0)))))))
(* 2.0 w))))))))D_m = fabs(D);
d_m = fabs(d);
double code(double c0, double w, double h, double D_m, double d_m, double M) {
double t_0 = pow((d_m / D_m), 2.0);
double t_1 = (c0 * t_0) / (w * h);
double t_2 = c0 / (2.0 * w);
double t_3 = (c0 * (d_m * d_m)) / ((w * h) * (D_m * D_m));
double t_4 = t_2 * (t_3 + sqrt(((t_3 * t_3) - (M * M))));
double tmp;
if (t_4 <= -2e-182) {
tmp = c0 * (fma(c0, (d_m * (d_m / (D_m * (w * (h * D_m))))), (((c0 / (h * D_m)) * (d_m / w)) * (d_m / D_m))) / (2.0 * w));
} else if (t_4 <= 2e-141) {
tmp = 0.25 * ((pow(D_m, 2.0) * (h * pow(M, 2.0))) / pow(d_m, 2.0));
} else if (t_4 <= ((double) INFINITY)) {
tmp = t_2 * fma(((d_m / D_m) * sqrt((c0 / (w * h)))), sqrt((t_1 - M)), t_1);
} else {
tmp = c0 * ((1.0 / (c0 * (2.0 * (t_0 / (h * (w * pow(M, 2.0))))))) / (2.0 * w));
}
return tmp;
}
D_m = abs(D) d_m = abs(d) function code(c0, w, h, D_m, d_m, M) t_0 = Float64(d_m / D_m) ^ 2.0 t_1 = Float64(Float64(c0 * t_0) / Float64(w * h)) t_2 = Float64(c0 / Float64(2.0 * w)) t_3 = Float64(Float64(c0 * Float64(d_m * d_m)) / Float64(Float64(w * h) * Float64(D_m * D_m))) t_4 = Float64(t_2 * Float64(t_3 + sqrt(Float64(Float64(t_3 * t_3) - Float64(M * M))))) tmp = 0.0 if (t_4 <= -2e-182) tmp = Float64(c0 * Float64(fma(c0, Float64(d_m * Float64(d_m / Float64(D_m * Float64(w * Float64(h * D_m))))), Float64(Float64(Float64(c0 / Float64(h * D_m)) * Float64(d_m / w)) * Float64(d_m / D_m))) / Float64(2.0 * w))); elseif (t_4 <= 2e-141) tmp = Float64(0.25 * Float64(Float64((D_m ^ 2.0) * Float64(h * (M ^ 2.0))) / (d_m ^ 2.0))); elseif (t_4 <= Inf) tmp = Float64(t_2 * fma(Float64(Float64(d_m / D_m) * sqrt(Float64(c0 / Float64(w * h)))), sqrt(Float64(t_1 - M)), t_1)); else tmp = Float64(c0 * Float64(Float64(1.0 / Float64(c0 * Float64(2.0 * Float64(t_0 / Float64(h * Float64(w * (M ^ 2.0))))))) / Float64(2.0 * w))); end return tmp end
D_m = N[Abs[D], $MachinePrecision]
d_m = N[Abs[d], $MachinePrecision]
code[c0_, w_, h_, D$95$m_, d$95$m_, M_] := Block[{t$95$0 = N[Power[N[(d$95$m / D$95$m), $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$1 = N[(N[(c0 * t$95$0), $MachinePrecision] / N[(w * h), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(c0 / N[(2.0 * w), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(N[(c0 * N[(d$95$m * d$95$m), $MachinePrecision]), $MachinePrecision] / N[(N[(w * h), $MachinePrecision] * N[(D$95$m * D$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$4 = N[(t$95$2 * N[(t$95$3 + N[Sqrt[N[(N[(t$95$3 * t$95$3), $MachinePrecision] - N[(M * M), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$4, -2e-182], N[(c0 * N[(N[(c0 * N[(d$95$m * N[(d$95$m / N[(D$95$m * N[(w * N[(h * D$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(N[(c0 / N[(h * D$95$m), $MachinePrecision]), $MachinePrecision] * N[(d$95$m / w), $MachinePrecision]), $MachinePrecision] * N[(d$95$m / D$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(2.0 * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$4, 2e-141], N[(0.25 * N[(N[(N[Power[D$95$m, 2.0], $MachinePrecision] * N[(h * N[Power[M, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Power[d$95$m, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$4, Infinity], N[(t$95$2 * N[(N[(N[(d$95$m / D$95$m), $MachinePrecision] * N[Sqrt[N[(c0 / N[(w * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(t$95$1 - M), $MachinePrecision]], $MachinePrecision] + t$95$1), $MachinePrecision]), $MachinePrecision], N[(c0 * N[(N[(1.0 / N[(c0 * N[(2.0 * N[(t$95$0 / N[(h * N[(w * N[Power[M, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(2.0 * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]]
\begin{array}{l}
D_m = \left|D\right|
\\
d_m = \left|d\right|
\\
\begin{array}{l}
t_0 := {\left(\frac{d\_m}{D\_m}\right)}^{2}\\
t_1 := \frac{c0 \cdot t\_0}{w \cdot h}\\
t_2 := \frac{c0}{2 \cdot w}\\
t_3 := \frac{c0 \cdot \left(d\_m \cdot d\_m\right)}{\left(w \cdot h\right) \cdot \left(D\_m \cdot D\_m\right)}\\
t_4 := t\_2 \cdot \left(t\_3 + \sqrt{t\_3 \cdot t\_3 - M \cdot M}\right)\\
\mathbf{if}\;t\_4 \leq -2 \cdot 10^{-182}:\\
\;\;\;\;c0 \cdot \frac{\mathsf{fma}\left(c0, d\_m \cdot \frac{d\_m}{D\_m \cdot \left(w \cdot \left(h \cdot D\_m\right)\right)}, \left(\frac{c0}{h \cdot D\_m} \cdot \frac{d\_m}{w}\right) \cdot \frac{d\_m}{D\_m}\right)}{2 \cdot w}\\
\mathbf{elif}\;t\_4 \leq 2 \cdot 10^{-141}:\\
\;\;\;\;0.25 \cdot \frac{{D\_m}^{2} \cdot \left(h \cdot {M}^{2}\right)}{{d\_m}^{2}}\\
\mathbf{elif}\;t\_4 \leq \infty:\\
\;\;\;\;t\_2 \cdot \mathsf{fma}\left(\frac{d\_m}{D\_m} \cdot \sqrt{\frac{c0}{w \cdot h}}, \sqrt{t\_1 - M}, t\_1\right)\\
\mathbf{else}:\\
\;\;\;\;c0 \cdot \frac{\frac{1}{c0 \cdot \left(2 \cdot \frac{t\_0}{h \cdot \left(w \cdot {M}^{2}\right)}\right)}}{2 \cdot w}\\
\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))))) < -2.0000000000000001e-182Initial program 81.5%
Simplified86.8%
Taylor expanded in c0 around inf 81.6%
*-commutative81.6%
*-commutative81.6%
associate-*r*78.9%
times-frac79.0%
*-commutative79.0%
Simplified79.0%
associate-*r/81.6%
*-commutative81.6%
Applied egg-rr81.6%
times-frac84.2%
associate-/r*84.2%
pow284.2%
pow284.2%
frac-times86.8%
associate-*r*89.4%
*-commutative89.4%
Applied egg-rr89.4%
Taylor expanded in c0 around 0 89.4%
associate-*r*89.4%
times-frac89.5%
Simplified89.5%
if -2.0000000000000001e-182 < (*.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))))) < 2.0000000000000001e-141Initial program 53.1%
Simplified16.6%
Applied egg-rr44.6%
associate--r-62.6%
+-inverses68.9%
associate-/l*62.8%
*-commutative62.8%
associate-/l*62.7%
*-commutative62.7%
Simplified62.7%
Taylor expanded in c0 around -inf 62.7%
associate-*r/62.7%
neg-mul-162.7%
associate-*r/62.7%
mul-1-neg62.7%
Simplified62.7%
clear-num62.8%
inv-pow62.8%
sub-div62.8%
*-commutative62.8%
Applied egg-rr62.8%
unpow-162.8%
associate-/l*62.8%
Simplified63.0%
Taylor expanded in c0 around 0 74.9%
if 2.0000000000000001e-141 < (*.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 85.8%
Simplified85.8%
Applied egg-rr94.9%
Taylor expanded in c0 around inf 54.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%
Simplified20.7%
Applied egg-rr2.1%
associate--r-3.1%
+-inverses39.8%
associate-/l*40.4%
*-commutative40.4%
associate-/l*39.7%
*-commutative39.7%
Simplified39.7%
Taylor expanded in c0 around -inf 35.4%
associate-*r/35.4%
neg-mul-135.4%
associate-*r/35.4%
mul-1-neg35.4%
Simplified35.4%
clear-num35.4%
inv-pow35.4%
sub-div35.4%
*-commutative35.4%
Applied egg-rr35.4%
unpow-135.4%
associate-/l*36.0%
Simplified48.9%
Taylor expanded in d around 0 36.6%
associate-/r*35.4%
unpow235.4%
unpow235.4%
times-frac44.9%
unpow244.9%
*-commutative44.9%
associate-*l*50.5%
Simplified50.5%
Final simplification58.3%
D_m = (fabs.f64 D)
d_m = (fabs.f64 d)
(FPCore (c0 w h D_m d_m M)
:precision binary64
(let* ((t_0 (/ (pow (/ d_m D_m) 2.0) (* h (* w (pow M 2.0)))))
(t_1 (/ (* c0 (* d_m d_m)) (* (* w h) (* D_m D_m))))
(t_2 (* (/ c0 (* 2.0 w)) (+ t_1 (sqrt (- (* t_1 t_1) (* M M)))))))
(if (<= t_2 -2e-182)
(*
c0
(/
(fma
c0
(* d_m (/ d_m (* D_m (* w (* h D_m)))))
(* (* (/ c0 (* h D_m)) (/ d_m w)) (/ d_m D_m)))
(* 2.0 w)))
(if (<= t_2 0.0)
(* c0 (/ (/ 0.5 w) (* t_0 (* c0 2.0))))
(if (<= t_2 INFINITY)
(*
c0
(/ (* 2.0 (/ (* d_m (* (/ d_m D_m) (/ c0 (* w h)))) D_m)) (* 2.0 w)))
(* c0 (/ (/ 1.0 (* c0 (* 2.0 t_0))) (* 2.0 w))))))))D_m = fabs(D);
d_m = fabs(d);
double code(double c0, double w, double h, double D_m, double d_m, double M) {
double t_0 = pow((d_m / D_m), 2.0) / (h * (w * pow(M, 2.0)));
double t_1 = (c0 * (d_m * d_m)) / ((w * h) * (D_m * D_m));
double t_2 = (c0 / (2.0 * w)) * (t_1 + sqrt(((t_1 * t_1) - (M * M))));
double tmp;
if (t_2 <= -2e-182) {
tmp = c0 * (fma(c0, (d_m * (d_m / (D_m * (w * (h * D_m))))), (((c0 / (h * D_m)) * (d_m / w)) * (d_m / D_m))) / (2.0 * w));
} else if (t_2 <= 0.0) {
tmp = c0 * ((0.5 / w) / (t_0 * (c0 * 2.0)));
} else if (t_2 <= ((double) INFINITY)) {
tmp = c0 * ((2.0 * ((d_m * ((d_m / D_m) * (c0 / (w * h)))) / D_m)) / (2.0 * w));
} else {
tmp = c0 * ((1.0 / (c0 * (2.0 * t_0))) / (2.0 * w));
}
return tmp;
}
D_m = abs(D) d_m = abs(d) function code(c0, w, h, D_m, d_m, M) t_0 = Float64((Float64(d_m / D_m) ^ 2.0) / Float64(h * Float64(w * (M ^ 2.0)))) t_1 = Float64(Float64(c0 * Float64(d_m * d_m)) / Float64(Float64(w * h) * Float64(D_m * D_m))) 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 <= -2e-182) tmp = Float64(c0 * Float64(fma(c0, Float64(d_m * Float64(d_m / Float64(D_m * Float64(w * Float64(h * D_m))))), Float64(Float64(Float64(c0 / Float64(h * D_m)) * Float64(d_m / w)) * Float64(d_m / D_m))) / Float64(2.0 * w))); elseif (t_2 <= 0.0) tmp = Float64(c0 * Float64(Float64(0.5 / w) / Float64(t_0 * Float64(c0 * 2.0)))); elseif (t_2 <= Inf) tmp = Float64(c0 * Float64(Float64(2.0 * Float64(Float64(d_m * Float64(Float64(d_m / D_m) * Float64(c0 / Float64(w * h)))) / D_m)) / Float64(2.0 * w))); else tmp = Float64(c0 * Float64(Float64(1.0 / Float64(c0 * Float64(2.0 * t_0))) / Float64(2.0 * w))); end return tmp end
D_m = N[Abs[D], $MachinePrecision]
d_m = N[Abs[d], $MachinePrecision]
code[c0_, w_, h_, D$95$m_, d$95$m_, M_] := Block[{t$95$0 = N[(N[Power[N[(d$95$m / D$95$m), $MachinePrecision], 2.0], $MachinePrecision] / N[(h * N[(w * N[Power[M, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(c0 * N[(d$95$m * d$95$m), $MachinePrecision]), $MachinePrecision] / N[(N[(w * h), $MachinePrecision] * N[(D$95$m * D$95$m), $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, -2e-182], N[(c0 * N[(N[(c0 * N[(d$95$m * N[(d$95$m / N[(D$95$m * N[(w * N[(h * D$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(N[(c0 / N[(h * D$95$m), $MachinePrecision]), $MachinePrecision] * N[(d$95$m / w), $MachinePrecision]), $MachinePrecision] * N[(d$95$m / D$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(2.0 * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 0.0], N[(c0 * N[(N[(0.5 / w), $MachinePrecision] / N[(t$95$0 * N[(c0 * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, Infinity], N[(c0 * N[(N[(2.0 * N[(N[(d$95$m * N[(N[(d$95$m / D$95$m), $MachinePrecision] * N[(c0 / N[(w * h), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / D$95$m), $MachinePrecision]), $MachinePrecision] / N[(2.0 * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(c0 * N[(N[(1.0 / N[(c0 * N[(2.0 * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(2.0 * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
D_m = \left|D\right|
\\
d_m = \left|d\right|
\\
\begin{array}{l}
t_0 := \frac{{\left(\frac{d\_m}{D\_m}\right)}^{2}}{h \cdot \left(w \cdot {M}^{2}\right)}\\
t_1 := \frac{c0 \cdot \left(d\_m \cdot d\_m\right)}{\left(w \cdot h\right) \cdot \left(D\_m \cdot D\_m\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 -2 \cdot 10^{-182}:\\
\;\;\;\;c0 \cdot \frac{\mathsf{fma}\left(c0, d\_m \cdot \frac{d\_m}{D\_m \cdot \left(w \cdot \left(h \cdot D\_m\right)\right)}, \left(\frac{c0}{h \cdot D\_m} \cdot \frac{d\_m}{w}\right) \cdot \frac{d\_m}{D\_m}\right)}{2 \cdot w}\\
\mathbf{elif}\;t\_2 \leq 0:\\
\;\;\;\;c0 \cdot \frac{\frac{0.5}{w}}{t\_0 \cdot \left(c0 \cdot 2\right)}\\
\mathbf{elif}\;t\_2 \leq \infty:\\
\;\;\;\;c0 \cdot \frac{2 \cdot \frac{d\_m \cdot \left(\frac{d\_m}{D\_m} \cdot \frac{c0}{w \cdot h}\right)}{D\_m}}{2 \cdot w}\\
\mathbf{else}:\\
\;\;\;\;c0 \cdot \frac{\frac{1}{c0 \cdot \left(2 \cdot t\_0\right)}}{2 \cdot w}\\
\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))))) < -2.0000000000000001e-182Initial program 81.5%
Simplified86.8%
Taylor expanded in c0 around inf 81.6%
*-commutative81.6%
*-commutative81.6%
associate-*r*78.9%
times-frac79.0%
*-commutative79.0%
Simplified79.0%
associate-*r/81.6%
*-commutative81.6%
Applied egg-rr81.6%
times-frac84.2%
associate-/r*84.2%
pow284.2%
pow284.2%
frac-times86.8%
associate-*r*89.4%
*-commutative89.4%
Applied egg-rr89.4%
Taylor expanded in c0 around 0 89.4%
associate-*r*89.4%
times-frac89.5%
Simplified89.5%
if -2.0000000000000001e-182 < (*.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 55.4%
Simplified17.4%
Applied egg-rr47.6%
associate--r-66.8%
+-inverses73.5%
associate-/l*67.0%
*-commutative67.0%
associate-/l*66.9%
*-commutative66.9%
Simplified66.9%
Taylor expanded in c0 around -inf 66.9%
associate-*r/66.9%
neg-mul-166.9%
associate-*r/66.9%
mul-1-neg66.9%
Simplified66.9%
clear-num67.0%
inv-pow67.0%
sub-div67.0%
*-commutative67.0%
Applied egg-rr67.0%
unpow-167.0%
associate-/l*67.0%
Simplified67.2%
associate-*r/73.4%
associate-/l*73.3%
associate-/l/73.3%
*-commutative73.3%
*-commutative73.3%
Applied egg-rr73.3%
Simplified73.6%
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.2%
Simplified79.1%
Taylor expanded in c0 around inf 86.5%
*-commutative86.5%
*-commutative86.5%
associate-*r*79.4%
times-frac79.3%
*-commutative79.3%
Simplified79.3%
associate-*r/79.3%
*-commutative79.3%
Applied egg-rr79.3%
Taylor expanded in c0 around 0 89.7%
*-commutative89.7%
times-frac88.4%
unpow288.4%
unpow288.4%
times-frac90.7%
unpow290.7%
associate-/r*83.6%
Simplified83.6%
associate-/r*90.7%
unpow290.7%
associate-*l*91.9%
associate-*r/92.0%
*-commutative92.0%
Applied egg-rr92.0%
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%
Simplified20.7%
Applied egg-rr2.1%
associate--r-3.1%
+-inverses39.8%
associate-/l*40.4%
*-commutative40.4%
associate-/l*39.7%
*-commutative39.7%
Simplified39.7%
Taylor expanded in c0 around -inf 35.4%
associate-*r/35.4%
neg-mul-135.4%
associate-*r/35.4%
mul-1-neg35.4%
Simplified35.4%
clear-num35.4%
inv-pow35.4%
sub-div35.4%
*-commutative35.4%
Applied egg-rr35.4%
unpow-135.4%
associate-/l*36.0%
Simplified48.9%
Taylor expanded in d around 0 36.6%
associate-/r*35.4%
unpow235.4%
unpow235.4%
times-frac44.9%
unpow244.9%
*-commutative44.9%
associate-*l*50.5%
Simplified50.5%
Final simplification64.3%
D_m = (fabs.f64 D)
d_m = (fabs.f64 d)
(FPCore (c0 w h D_m d_m M)
:precision binary64
(let* ((t_0 (/ (* c0 (* d_m d_m)) (* (* w h) (* D_m D_m))))
(t_1 (* (/ c0 (* 2.0 w)) (+ t_0 (sqrt (- (* t_0 t_0) (* M M)))))))
(if (<= t_1 -2e-182)
(*
c0
(/
(fma
c0
(* d_m (/ d_m (* D_m (* w (* h D_m)))))
(* (* (/ c0 (* h D_m)) (/ d_m w)) (/ d_m D_m)))
(* 2.0 w)))
(if (<= t_1 0.0)
(* 0.25 (/ (* (pow D_m 2.0) (* h (pow M 2.0))) (pow d_m 2.0)))
(if (<= t_1 INFINITY)
(*
c0
(/ (* 2.0 (/ (* d_m (* (/ d_m D_m) (/ c0 (* w h)))) D_m)) (* 2.0 w)))
(*
c0
(/
(/
1.0
(* c0 (* 2.0 (/ (pow (/ d_m D_m) 2.0) (* h (* w (pow M 2.0)))))))
(* 2.0 w))))))))D_m = fabs(D);
d_m = fabs(d);
double code(double c0, double w, double h, double D_m, double d_m, double M) {
double t_0 = (c0 * (d_m * d_m)) / ((w * h) * (D_m * D_m));
double t_1 = (c0 / (2.0 * w)) * (t_0 + sqrt(((t_0 * t_0) - (M * M))));
double tmp;
if (t_1 <= -2e-182) {
tmp = c0 * (fma(c0, (d_m * (d_m / (D_m * (w * (h * D_m))))), (((c0 / (h * D_m)) * (d_m / w)) * (d_m / D_m))) / (2.0 * w));
} else if (t_1 <= 0.0) {
tmp = 0.25 * ((pow(D_m, 2.0) * (h * pow(M, 2.0))) / pow(d_m, 2.0));
} else if (t_1 <= ((double) INFINITY)) {
tmp = c0 * ((2.0 * ((d_m * ((d_m / D_m) * (c0 / (w * h)))) / D_m)) / (2.0 * w));
} else {
tmp = c0 * ((1.0 / (c0 * (2.0 * (pow((d_m / D_m), 2.0) / (h * (w * pow(M, 2.0))))))) / (2.0 * w));
}
return tmp;
}
D_m = abs(D) d_m = abs(d) function code(c0, w, h, D_m, d_m, M) t_0 = Float64(Float64(c0 * Float64(d_m * d_m)) / Float64(Float64(w * h) * Float64(D_m * D_m))) 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 <= -2e-182) tmp = Float64(c0 * Float64(fma(c0, Float64(d_m * Float64(d_m / Float64(D_m * Float64(w * Float64(h * D_m))))), Float64(Float64(Float64(c0 / Float64(h * D_m)) * Float64(d_m / w)) * Float64(d_m / D_m))) / Float64(2.0 * w))); elseif (t_1 <= 0.0) tmp = Float64(0.25 * Float64(Float64((D_m ^ 2.0) * Float64(h * (M ^ 2.0))) / (d_m ^ 2.0))); elseif (t_1 <= Inf) tmp = Float64(c0 * Float64(Float64(2.0 * Float64(Float64(d_m * Float64(Float64(d_m / D_m) * Float64(c0 / Float64(w * h)))) / D_m)) / Float64(2.0 * w))); else tmp = Float64(c0 * Float64(Float64(1.0 / Float64(c0 * Float64(2.0 * Float64((Float64(d_m / D_m) ^ 2.0) / Float64(h * Float64(w * (M ^ 2.0))))))) / Float64(2.0 * w))); end return tmp end
D_m = N[Abs[D], $MachinePrecision]
d_m = N[Abs[d], $MachinePrecision]
code[c0_, w_, h_, D$95$m_, d$95$m_, M_] := Block[{t$95$0 = N[(N[(c0 * N[(d$95$m * d$95$m), $MachinePrecision]), $MachinePrecision] / N[(N[(w * h), $MachinePrecision] * N[(D$95$m * D$95$m), $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, -2e-182], N[(c0 * N[(N[(c0 * N[(d$95$m * N[(d$95$m / N[(D$95$m * N[(w * N[(h * D$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(N[(c0 / N[(h * D$95$m), $MachinePrecision]), $MachinePrecision] * N[(d$95$m / w), $MachinePrecision]), $MachinePrecision] * N[(d$95$m / D$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(2.0 * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 0.0], N[(0.25 * N[(N[(N[Power[D$95$m, 2.0], $MachinePrecision] * N[(h * N[Power[M, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Power[d$95$m, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, Infinity], N[(c0 * N[(N[(2.0 * N[(N[(d$95$m * N[(N[(d$95$m / D$95$m), $MachinePrecision] * N[(c0 / N[(w * h), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / D$95$m), $MachinePrecision]), $MachinePrecision] / N[(2.0 * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(c0 * N[(N[(1.0 / N[(c0 * N[(2.0 * N[(N[Power[N[(d$95$m / D$95$m), $MachinePrecision], 2.0], $MachinePrecision] / N[(h * N[(w * N[Power[M, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(2.0 * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
D_m = \left|D\right|
\\
d_m = \left|d\right|
\\
\begin{array}{l}
t_0 := \frac{c0 \cdot \left(d\_m \cdot d\_m\right)}{\left(w \cdot h\right) \cdot \left(D\_m \cdot D\_m\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 -2 \cdot 10^{-182}:\\
\;\;\;\;c0 \cdot \frac{\mathsf{fma}\left(c0, d\_m \cdot \frac{d\_m}{D\_m \cdot \left(w \cdot \left(h \cdot D\_m\right)\right)}, \left(\frac{c0}{h \cdot D\_m} \cdot \frac{d\_m}{w}\right) \cdot \frac{d\_m}{D\_m}\right)}{2 \cdot w}\\
\mathbf{elif}\;t\_1 \leq 0:\\
\;\;\;\;0.25 \cdot \frac{{D\_m}^{2} \cdot \left(h \cdot {M}^{2}\right)}{{d\_m}^{2}}\\
\mathbf{elif}\;t\_1 \leq \infty:\\
\;\;\;\;c0 \cdot \frac{2 \cdot \frac{d\_m \cdot \left(\frac{d\_m}{D\_m} \cdot \frac{c0}{w \cdot h}\right)}{D\_m}}{2 \cdot w}\\
\mathbf{else}:\\
\;\;\;\;c0 \cdot \frac{\frac{1}{c0 \cdot \left(2 \cdot \frac{{\left(\frac{d\_m}{D\_m}\right)}^{2}}{h \cdot \left(w \cdot {M}^{2}\right)}\right)}}{2 \cdot w}\\
\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))))) < -2.0000000000000001e-182Initial program 81.5%
Simplified86.8%
Taylor expanded in c0 around inf 81.6%
*-commutative81.6%
*-commutative81.6%
associate-*r*78.9%
times-frac79.0%
*-commutative79.0%
Simplified79.0%
associate-*r/81.6%
*-commutative81.6%
Applied egg-rr81.6%
times-frac84.2%
associate-/r*84.2%
pow284.2%
pow284.2%
frac-times86.8%
associate-*r*89.4%
*-commutative89.4%
Applied egg-rr89.4%
Taylor expanded in c0 around 0 89.4%
associate-*r*89.4%
times-frac89.5%
Simplified89.5%
if -2.0000000000000001e-182 < (*.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 55.4%
Simplified17.4%
Applied egg-rr47.6%
associate--r-66.8%
+-inverses73.5%
associate-/l*67.0%
*-commutative67.0%
associate-/l*66.9%
*-commutative66.9%
Simplified66.9%
Taylor expanded in c0 around -inf 66.9%
associate-*r/66.9%
neg-mul-166.9%
associate-*r/66.9%
mul-1-neg66.9%
Simplified66.9%
clear-num67.0%
inv-pow67.0%
sub-div67.0%
*-commutative67.0%
Applied egg-rr67.0%
unpow-167.0%
associate-/l*67.0%
Simplified67.2%
Taylor expanded in c0 around 0 79.6%
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.2%
Simplified79.1%
Taylor expanded in c0 around inf 86.5%
*-commutative86.5%
*-commutative86.5%
associate-*r*79.4%
times-frac79.3%
*-commutative79.3%
Simplified79.3%
associate-*r/79.3%
*-commutative79.3%
Applied egg-rr79.3%
Taylor expanded in c0 around 0 89.7%
*-commutative89.7%
times-frac88.4%
unpow288.4%
unpow288.4%
times-frac90.7%
unpow290.7%
associate-/r*83.6%
Simplified83.6%
associate-/r*90.7%
unpow290.7%
associate-*l*91.9%
associate-*r/92.0%
*-commutative92.0%
Applied egg-rr92.0%
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%
Simplified20.7%
Applied egg-rr2.1%
associate--r-3.1%
+-inverses39.8%
associate-/l*40.4%
*-commutative40.4%
associate-/l*39.7%
*-commutative39.7%
Simplified39.7%
Taylor expanded in c0 around -inf 35.4%
associate-*r/35.4%
neg-mul-135.4%
associate-*r/35.4%
mul-1-neg35.4%
Simplified35.4%
clear-num35.4%
inv-pow35.4%
sub-div35.4%
*-commutative35.4%
Applied egg-rr35.4%
unpow-135.4%
associate-/l*36.0%
Simplified48.9%
Taylor expanded in d around 0 36.6%
associate-/r*35.4%
unpow235.4%
unpow235.4%
times-frac44.9%
unpow244.9%
*-commutative44.9%
associate-*l*50.5%
Simplified50.5%
Final simplification64.7%
D_m = (fabs.f64 D)
d_m = (fabs.f64 d)
(FPCore (c0 w h D_m d_m M)
:precision binary64
(let* ((t_0 (/ (* c0 (* d_m d_m)) (* (* w h) (* D_m D_m))))
(t_1 (* (/ c0 (* 2.0 w)) (+ t_0 (sqrt (- (* t_0 t_0) (* M M)))))))
(if (<= t_1 -2e-182)
(*
c0
(/
(fma
c0
(* d_m (/ d_m (* D_m (* w (* h D_m)))))
(* (* (/ c0 (* h D_m)) (/ d_m w)) (/ d_m D_m)))
(* 2.0 w)))
(if (or (<= t_1 0.0) (not (<= t_1 INFINITY)))
(*
c0
(/
(* (/ (pow M 2.0) c0) (/ h (* 2.0 (/ (pow (/ d_m D_m) 2.0) w))))
(* 2.0 w)))
(*
c0
(/
(* 2.0 (/ (* d_m (* (/ d_m D_m) (/ c0 (* w h)))) D_m))
(* 2.0 w)))))))D_m = fabs(D);
d_m = fabs(d);
double code(double c0, double w, double h, double D_m, double d_m, double M) {
double t_0 = (c0 * (d_m * d_m)) / ((w * h) * (D_m * D_m));
double t_1 = (c0 / (2.0 * w)) * (t_0 + sqrt(((t_0 * t_0) - (M * M))));
double tmp;
if (t_1 <= -2e-182) {
tmp = c0 * (fma(c0, (d_m * (d_m / (D_m * (w * (h * D_m))))), (((c0 / (h * D_m)) * (d_m / w)) * (d_m / D_m))) / (2.0 * w));
} else if ((t_1 <= 0.0) || !(t_1 <= ((double) INFINITY))) {
tmp = c0 * (((pow(M, 2.0) / c0) * (h / (2.0 * (pow((d_m / D_m), 2.0) / w)))) / (2.0 * w));
} else {
tmp = c0 * ((2.0 * ((d_m * ((d_m / D_m) * (c0 / (w * h)))) / D_m)) / (2.0 * w));
}
return tmp;
}
D_m = abs(D) d_m = abs(d) function code(c0, w, h, D_m, d_m, M) t_0 = Float64(Float64(c0 * Float64(d_m * d_m)) / Float64(Float64(w * h) * Float64(D_m * D_m))) 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 <= -2e-182) tmp = Float64(c0 * Float64(fma(c0, Float64(d_m * Float64(d_m / Float64(D_m * Float64(w * Float64(h * D_m))))), Float64(Float64(Float64(c0 / Float64(h * D_m)) * Float64(d_m / w)) * Float64(d_m / D_m))) / Float64(2.0 * w))); elseif ((t_1 <= 0.0) || !(t_1 <= Inf)) tmp = Float64(c0 * Float64(Float64(Float64((M ^ 2.0) / c0) * Float64(h / Float64(2.0 * Float64((Float64(d_m / D_m) ^ 2.0) / w)))) / Float64(2.0 * w))); else tmp = Float64(c0 * Float64(Float64(2.0 * Float64(Float64(d_m * Float64(Float64(d_m / D_m) * Float64(c0 / Float64(w * h)))) / D_m)) / Float64(2.0 * w))); end return tmp end
D_m = N[Abs[D], $MachinePrecision]
d_m = N[Abs[d], $MachinePrecision]
code[c0_, w_, h_, D$95$m_, d$95$m_, M_] := Block[{t$95$0 = N[(N[(c0 * N[(d$95$m * d$95$m), $MachinePrecision]), $MachinePrecision] / N[(N[(w * h), $MachinePrecision] * N[(D$95$m * D$95$m), $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, -2e-182], N[(c0 * N[(N[(c0 * N[(d$95$m * N[(d$95$m / N[(D$95$m * N[(w * N[(h * D$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(N[(c0 / N[(h * D$95$m), $MachinePrecision]), $MachinePrecision] * N[(d$95$m / w), $MachinePrecision]), $MachinePrecision] * N[(d$95$m / D$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(2.0 * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[t$95$1, 0.0], N[Not[LessEqual[t$95$1, Infinity]], $MachinePrecision]], N[(c0 * N[(N[(N[(N[Power[M, 2.0], $MachinePrecision] / c0), $MachinePrecision] * N[(h / N[(2.0 * N[(N[Power[N[(d$95$m / D$95$m), $MachinePrecision], 2.0], $MachinePrecision] / w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(2.0 * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(c0 * N[(N[(2.0 * N[(N[(d$95$m * N[(N[(d$95$m / D$95$m), $MachinePrecision] * N[(c0 / N[(w * h), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / D$95$m), $MachinePrecision]), $MachinePrecision] / N[(2.0 * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
D_m = \left|D\right|
\\
d_m = \left|d\right|
\\
\begin{array}{l}
t_0 := \frac{c0 \cdot \left(d\_m \cdot d\_m\right)}{\left(w \cdot h\right) \cdot \left(D\_m \cdot D\_m\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 -2 \cdot 10^{-182}:\\
\;\;\;\;c0 \cdot \frac{\mathsf{fma}\left(c0, d\_m \cdot \frac{d\_m}{D\_m \cdot \left(w \cdot \left(h \cdot D\_m\right)\right)}, \left(\frac{c0}{h \cdot D\_m} \cdot \frac{d\_m}{w}\right) \cdot \frac{d\_m}{D\_m}\right)}{2 \cdot w}\\
\mathbf{elif}\;t\_1 \leq 0 \lor \neg \left(t\_1 \leq \infty\right):\\
\;\;\;\;c0 \cdot \frac{\frac{{M}^{2}}{c0} \cdot \frac{h}{2 \cdot \frac{{\left(\frac{d\_m}{D\_m}\right)}^{2}}{w}}}{2 \cdot w}\\
\mathbf{else}:\\
\;\;\;\;c0 \cdot \frac{2 \cdot \frac{d\_m \cdot \left(\frac{d\_m}{D\_m} \cdot \frac{c0}{w \cdot h}\right)}{D\_m}}{2 \cdot w}\\
\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))))) < -2.0000000000000001e-182Initial program 81.5%
Simplified86.8%
Taylor expanded in c0 around inf 81.6%
*-commutative81.6%
*-commutative81.6%
associate-*r*78.9%
times-frac79.0%
*-commutative79.0%
Simplified79.0%
associate-*r/81.6%
*-commutative81.6%
Applied egg-rr81.6%
times-frac84.2%
associate-/r*84.2%
pow284.2%
pow284.2%
frac-times86.8%
associate-*r*89.4%
*-commutative89.4%
Applied egg-rr89.4%
Taylor expanded in c0 around 0 89.4%
associate-*r*89.4%
times-frac89.5%
Simplified89.5%
if -2.0000000000000001e-182 < (*.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 4.7%
Simplified20.4%
Applied egg-rr5.9%
associate--r-8.5%
+-inverses42.7%
associate-/l*42.7%
*-commutative42.7%
associate-/l*42.0%
*-commutative42.0%
Simplified42.0%
Taylor expanded in c0 around -inf 38.0%
associate-*r/38.0%
neg-mul-138.0%
associate-*r/38.0%
mul-1-neg38.0%
Simplified38.0%
Taylor expanded in h around -inf 40.7%
times-frac40.4%
cancel-sign-sub-inv40.4%
metadata-eval40.4%
distribute-rgt1-in40.4%
metadata-eval40.4%
associate-/r*41.5%
unpow241.5%
unpow241.5%
times-frac49.8%
unpow249.8%
Simplified49.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.2%
Simplified79.1%
Taylor expanded in c0 around inf 86.5%
*-commutative86.5%
*-commutative86.5%
associate-*r*79.4%
times-frac79.3%
*-commutative79.3%
Simplified79.3%
associate-*r/79.3%
*-commutative79.3%
Applied egg-rr79.3%
Taylor expanded in c0 around 0 89.7%
*-commutative89.7%
times-frac88.4%
unpow288.4%
unpow288.4%
times-frac90.7%
unpow290.7%
associate-/r*83.6%
Simplified83.6%
associate-/r*90.7%
unpow290.7%
associate-*l*91.9%
associate-*r/92.0%
*-commutative92.0%
Applied egg-rr92.0%
Final simplification62.5%
D_m = (fabs.f64 D)
d_m = (fabs.f64 d)
(FPCore (c0 w h D_m d_m M)
:precision binary64
(let* ((t_0 (/ (* c0 (* d_m d_m)) (* (* w h) (* D_m D_m))))
(t_1 (* (/ c0 (* 2.0 w)) (+ t_0 (sqrt (- (* t_0 t_0) (* M M)))))))
(if (<= t_1 -2e-182)
(*
c0
(/
(fma
c0
(* d_m (/ d_m (* D_m (* w (* h D_m)))))
(* (* (/ c0 (* h D_m)) (/ d_m w)) (/ d_m D_m)))
(* 2.0 w)))
(if (or (<= t_1 0.0) (not (<= t_1 INFINITY)))
(*
c0
(/
(/ 0.5 w)
(* (/ (pow (/ d_m D_m) 2.0) (* h (* w (pow M 2.0)))) (* c0 2.0))))
(*
c0
(/
(* 2.0 (/ (* d_m (* (/ d_m D_m) (/ c0 (* w h)))) D_m))
(* 2.0 w)))))))D_m = fabs(D);
d_m = fabs(d);
double code(double c0, double w, double h, double D_m, double d_m, double M) {
double t_0 = (c0 * (d_m * d_m)) / ((w * h) * (D_m * D_m));
double t_1 = (c0 / (2.0 * w)) * (t_0 + sqrt(((t_0 * t_0) - (M * M))));
double tmp;
if (t_1 <= -2e-182) {
tmp = c0 * (fma(c0, (d_m * (d_m / (D_m * (w * (h * D_m))))), (((c0 / (h * D_m)) * (d_m / w)) * (d_m / D_m))) / (2.0 * w));
} else if ((t_1 <= 0.0) || !(t_1 <= ((double) INFINITY))) {
tmp = c0 * ((0.5 / w) / ((pow((d_m / D_m), 2.0) / (h * (w * pow(M, 2.0)))) * (c0 * 2.0)));
} else {
tmp = c0 * ((2.0 * ((d_m * ((d_m / D_m) * (c0 / (w * h)))) / D_m)) / (2.0 * w));
}
return tmp;
}
D_m = abs(D) d_m = abs(d) function code(c0, w, h, D_m, d_m, M) t_0 = Float64(Float64(c0 * Float64(d_m * d_m)) / Float64(Float64(w * h) * Float64(D_m * D_m))) 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 <= -2e-182) tmp = Float64(c0 * Float64(fma(c0, Float64(d_m * Float64(d_m / Float64(D_m * Float64(w * Float64(h * D_m))))), Float64(Float64(Float64(c0 / Float64(h * D_m)) * Float64(d_m / w)) * Float64(d_m / D_m))) / Float64(2.0 * w))); elseif ((t_1 <= 0.0) || !(t_1 <= Inf)) tmp = Float64(c0 * Float64(Float64(0.5 / w) / Float64(Float64((Float64(d_m / D_m) ^ 2.0) / Float64(h * Float64(w * (M ^ 2.0)))) * Float64(c0 * 2.0)))); else tmp = Float64(c0 * Float64(Float64(2.0 * Float64(Float64(d_m * Float64(Float64(d_m / D_m) * Float64(c0 / Float64(w * h)))) / D_m)) / Float64(2.0 * w))); end return tmp end
D_m = N[Abs[D], $MachinePrecision]
d_m = N[Abs[d], $MachinePrecision]
code[c0_, w_, h_, D$95$m_, d$95$m_, M_] := Block[{t$95$0 = N[(N[(c0 * N[(d$95$m * d$95$m), $MachinePrecision]), $MachinePrecision] / N[(N[(w * h), $MachinePrecision] * N[(D$95$m * D$95$m), $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, -2e-182], N[(c0 * N[(N[(c0 * N[(d$95$m * N[(d$95$m / N[(D$95$m * N[(w * N[(h * D$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(N[(c0 / N[(h * D$95$m), $MachinePrecision]), $MachinePrecision] * N[(d$95$m / w), $MachinePrecision]), $MachinePrecision] * N[(d$95$m / D$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(2.0 * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[t$95$1, 0.0], N[Not[LessEqual[t$95$1, Infinity]], $MachinePrecision]], N[(c0 * N[(N[(0.5 / w), $MachinePrecision] / N[(N[(N[Power[N[(d$95$m / D$95$m), $MachinePrecision], 2.0], $MachinePrecision] / N[(h * N[(w * N[Power[M, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(c0 * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(c0 * N[(N[(2.0 * N[(N[(d$95$m * N[(N[(d$95$m / D$95$m), $MachinePrecision] * N[(c0 / N[(w * h), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / D$95$m), $MachinePrecision]), $MachinePrecision] / N[(2.0 * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
D_m = \left|D\right|
\\
d_m = \left|d\right|
\\
\begin{array}{l}
t_0 := \frac{c0 \cdot \left(d\_m \cdot d\_m\right)}{\left(w \cdot h\right) \cdot \left(D\_m \cdot D\_m\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 -2 \cdot 10^{-182}:\\
\;\;\;\;c0 \cdot \frac{\mathsf{fma}\left(c0, d\_m \cdot \frac{d\_m}{D\_m \cdot \left(w \cdot \left(h \cdot D\_m\right)\right)}, \left(\frac{c0}{h \cdot D\_m} \cdot \frac{d\_m}{w}\right) \cdot \frac{d\_m}{D\_m}\right)}{2 \cdot w}\\
\mathbf{elif}\;t\_1 \leq 0 \lor \neg \left(t\_1 \leq \infty\right):\\
\;\;\;\;c0 \cdot \frac{\frac{0.5}{w}}{\frac{{\left(\frac{d\_m}{D\_m}\right)}^{2}}{h \cdot \left(w \cdot {M}^{2}\right)} \cdot \left(c0 \cdot 2\right)}\\
\mathbf{else}:\\
\;\;\;\;c0 \cdot \frac{2 \cdot \frac{d\_m \cdot \left(\frac{d\_m}{D\_m} \cdot \frac{c0}{w \cdot h}\right)}{D\_m}}{2 \cdot w}\\
\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))))) < -2.0000000000000001e-182Initial program 81.5%
Simplified86.8%
Taylor expanded in c0 around inf 81.6%
*-commutative81.6%
*-commutative81.6%
associate-*r*78.9%
times-frac79.0%
*-commutative79.0%
Simplified79.0%
associate-*r/81.6%
*-commutative81.6%
Applied egg-rr81.6%
times-frac84.2%
associate-/r*84.2%
pow284.2%
pow284.2%
frac-times86.8%
associate-*r*89.4%
*-commutative89.4%
Applied egg-rr89.4%
Taylor expanded in c0 around 0 89.4%
associate-*r*89.4%
times-frac89.5%
Simplified89.5%
if -2.0000000000000001e-182 < (*.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 4.7%
Simplified20.4%
Applied egg-rr5.9%
associate--r-8.5%
+-inverses42.7%
associate-/l*42.7%
*-commutative42.7%
associate-/l*42.0%
*-commutative42.0%
Simplified42.0%
Taylor expanded in c0 around -inf 38.0%
associate-*r/38.0%
neg-mul-138.0%
associate-*r/38.0%
mul-1-neg38.0%
Simplified38.0%
clear-num38.0%
inv-pow38.0%
sub-div38.0%
*-commutative38.0%
Applied egg-rr38.0%
unpow-138.0%
associate-/l*38.6%
Simplified50.5%
associate-*r/51.5%
associate-/l*51.5%
associate-/l/47.3%
*-commutative47.3%
*-commutative47.3%
Applied egg-rr47.3%
Simplified52.5%
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.2%
Simplified79.1%
Taylor expanded in c0 around inf 86.5%
*-commutative86.5%
*-commutative86.5%
associate-*r*79.4%
times-frac79.3%
*-commutative79.3%
Simplified79.3%
associate-*r/79.3%
*-commutative79.3%
Applied egg-rr79.3%
Taylor expanded in c0 around 0 89.7%
*-commutative89.7%
times-frac88.4%
unpow288.4%
unpow288.4%
times-frac90.7%
unpow290.7%
associate-/r*83.6%
Simplified83.6%
associate-/r*90.7%
unpow290.7%
associate-*l*91.9%
associate-*r/92.0%
*-commutative92.0%
Applied egg-rr92.0%
Final simplification64.3%
D_m = (fabs.f64 D)
d_m = (fabs.f64 d)
(FPCore (c0 w h D_m d_m M)
:precision binary64
(let* ((t_0 (/ (pow M 2.0) c0))
(t_1 (pow (/ d_m D_m) 2.0))
(t_2 (/ (* c0 (* d_m d_m)) (* (* w h) (* D_m D_m))))
(t_3 (* (/ c0 (* 2.0 w)) (+ t_2 (sqrt (- (* t_2 t_2) (* M M)))))))
(if (<= t_3 -2e-182)
(*
c0
(/
(fma
c0
(* d_m (/ d_m (* D_m (* w (* h D_m)))))
(* (* (/ c0 (* h D_m)) (/ d_m w)) (/ d_m D_m)))
(* 2.0 w)))
(if (<= t_3 0.0)
(* c0 (/ (* t_0 (/ w (* 2.0 (/ t_1 h)))) (* 2.0 w)))
(if (<= t_3 INFINITY)
(*
c0
(/ (* 2.0 (/ (* d_m (* (/ d_m D_m) (/ c0 (* w h)))) D_m)) (* 2.0 w)))
(* c0 (/ (* t_0 (/ h (* 2.0 (/ t_1 w)))) (* 2.0 w))))))))D_m = fabs(D);
d_m = fabs(d);
double code(double c0, double w, double h, double D_m, double d_m, double M) {
double t_0 = pow(M, 2.0) / c0;
double t_1 = pow((d_m / D_m), 2.0);
double t_2 = (c0 * (d_m * d_m)) / ((w * h) * (D_m * D_m));
double t_3 = (c0 / (2.0 * w)) * (t_2 + sqrt(((t_2 * t_2) - (M * M))));
double tmp;
if (t_3 <= -2e-182) {
tmp = c0 * (fma(c0, (d_m * (d_m / (D_m * (w * (h * D_m))))), (((c0 / (h * D_m)) * (d_m / w)) * (d_m / D_m))) / (2.0 * w));
} else if (t_3 <= 0.0) {
tmp = c0 * ((t_0 * (w / (2.0 * (t_1 / h)))) / (2.0 * w));
} else if (t_3 <= ((double) INFINITY)) {
tmp = c0 * ((2.0 * ((d_m * ((d_m / D_m) * (c0 / (w * h)))) / D_m)) / (2.0 * w));
} else {
tmp = c0 * ((t_0 * (h / (2.0 * (t_1 / w)))) / (2.0 * w));
}
return tmp;
}
D_m = abs(D) d_m = abs(d) function code(c0, w, h, D_m, d_m, M) t_0 = Float64((M ^ 2.0) / c0) t_1 = Float64(d_m / D_m) ^ 2.0 t_2 = Float64(Float64(c0 * Float64(d_m * d_m)) / Float64(Float64(w * h) * Float64(D_m * D_m))) 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 <= -2e-182) tmp = Float64(c0 * Float64(fma(c0, Float64(d_m * Float64(d_m / Float64(D_m * Float64(w * Float64(h * D_m))))), Float64(Float64(Float64(c0 / Float64(h * D_m)) * Float64(d_m / w)) * Float64(d_m / D_m))) / Float64(2.0 * w))); elseif (t_3 <= 0.0) tmp = Float64(c0 * Float64(Float64(t_0 * Float64(w / Float64(2.0 * Float64(t_1 / h)))) / Float64(2.0 * w))); elseif (t_3 <= Inf) tmp = Float64(c0 * Float64(Float64(2.0 * Float64(Float64(d_m * Float64(Float64(d_m / D_m) * Float64(c0 / Float64(w * h)))) / D_m)) / Float64(2.0 * w))); else tmp = Float64(c0 * Float64(Float64(t_0 * Float64(h / Float64(2.0 * Float64(t_1 / w)))) / Float64(2.0 * w))); end return tmp end
D_m = N[Abs[D], $MachinePrecision]
d_m = N[Abs[d], $MachinePrecision]
code[c0_, w_, h_, D$95$m_, d$95$m_, M_] := Block[{t$95$0 = N[(N[Power[M, 2.0], $MachinePrecision] / c0), $MachinePrecision]}, Block[{t$95$1 = N[Power[N[(d$95$m / D$95$m), $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$2 = N[(N[(c0 * N[(d$95$m * d$95$m), $MachinePrecision]), $MachinePrecision] / N[(N[(w * h), $MachinePrecision] * N[(D$95$m * D$95$m), $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, -2e-182], N[(c0 * N[(N[(c0 * N[(d$95$m * N[(d$95$m / N[(D$95$m * N[(w * N[(h * D$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(N[(c0 / N[(h * D$95$m), $MachinePrecision]), $MachinePrecision] * N[(d$95$m / w), $MachinePrecision]), $MachinePrecision] * N[(d$95$m / D$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(2.0 * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$3, 0.0], N[(c0 * N[(N[(t$95$0 * N[(w / N[(2.0 * N[(t$95$1 / h), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(2.0 * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$3, Infinity], N[(c0 * N[(N[(2.0 * N[(N[(d$95$m * N[(N[(d$95$m / D$95$m), $MachinePrecision] * N[(c0 / N[(w * h), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / D$95$m), $MachinePrecision]), $MachinePrecision] / N[(2.0 * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(c0 * N[(N[(t$95$0 * N[(h / N[(2.0 * N[(t$95$1 / w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(2.0 * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]
\begin{array}{l}
D_m = \left|D\right|
\\
d_m = \left|d\right|
\\
\begin{array}{l}
t_0 := \frac{{M}^{2}}{c0}\\
t_1 := {\left(\frac{d\_m}{D\_m}\right)}^{2}\\
t_2 := \frac{c0 \cdot \left(d\_m \cdot d\_m\right)}{\left(w \cdot h\right) \cdot \left(D\_m \cdot D\_m\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 -2 \cdot 10^{-182}:\\
\;\;\;\;c0 \cdot \frac{\mathsf{fma}\left(c0, d\_m \cdot \frac{d\_m}{D\_m \cdot \left(w \cdot \left(h \cdot D\_m\right)\right)}, \left(\frac{c0}{h \cdot D\_m} \cdot \frac{d\_m}{w}\right) \cdot \frac{d\_m}{D\_m}\right)}{2 \cdot w}\\
\mathbf{elif}\;t\_3 \leq 0:\\
\;\;\;\;c0 \cdot \frac{t\_0 \cdot \frac{w}{2 \cdot \frac{t\_1}{h}}}{2 \cdot w}\\
\mathbf{elif}\;t\_3 \leq \infty:\\
\;\;\;\;c0 \cdot \frac{2 \cdot \frac{d\_m \cdot \left(\frac{d\_m}{D\_m} \cdot \frac{c0}{w \cdot h}\right)}{D\_m}}{2 \cdot w}\\
\mathbf{else}:\\
\;\;\;\;c0 \cdot \frac{t\_0 \cdot \frac{h}{2 \cdot \frac{t\_1}{w}}}{2 \cdot w}\\
\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))))) < -2.0000000000000001e-182Initial program 81.5%
Simplified86.8%
Taylor expanded in c0 around inf 81.6%
*-commutative81.6%
*-commutative81.6%
associate-*r*78.9%
times-frac79.0%
*-commutative79.0%
Simplified79.0%
associate-*r/81.6%
*-commutative81.6%
Applied egg-rr81.6%
times-frac84.2%
associate-/r*84.2%
pow284.2%
pow284.2%
frac-times86.8%
associate-*r*89.4%
*-commutative89.4%
Applied egg-rr89.4%
Taylor expanded in c0 around 0 89.4%
associate-*r*89.4%
times-frac89.5%
Simplified89.5%
if -2.0000000000000001e-182 < (*.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 55.4%
Simplified17.4%
Applied egg-rr47.6%
associate--r-66.8%
+-inverses73.5%
associate-/l*67.0%
*-commutative67.0%
associate-/l*66.9%
*-commutative66.9%
Simplified66.9%
Taylor expanded in c0 around -inf 66.9%
associate-*r/66.9%
neg-mul-166.9%
associate-*r/66.9%
mul-1-neg66.9%
Simplified66.9%
Taylor expanded in w around -inf 73.3%
times-frac66.9%
cancel-sign-sub-inv66.9%
metadata-eval66.9%
distribute-rgt1-in66.9%
metadata-eval66.9%
associate-/r*66.8%
unpow266.8%
unpow266.8%
times-frac67.0%
unpow267.0%
Simplified67.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.2%
Simplified79.1%
Taylor expanded in c0 around inf 86.5%
*-commutative86.5%
*-commutative86.5%
associate-*r*79.4%
times-frac79.3%
*-commutative79.3%
Simplified79.3%
associate-*r/79.3%
*-commutative79.3%
Applied egg-rr79.3%
Taylor expanded in c0 around 0 89.7%
*-commutative89.7%
times-frac88.4%
unpow288.4%
unpow288.4%
times-frac90.7%
unpow290.7%
associate-/r*83.6%
Simplified83.6%
associate-/r*90.7%
unpow290.7%
associate-*l*91.9%
associate-*r/92.0%
*-commutative92.0%
Applied egg-rr92.0%
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%
Simplified20.7%
Applied egg-rr2.1%
associate--r-3.1%
+-inverses39.8%
associate-/l*40.4%
*-commutative40.4%
associate-/l*39.7%
*-commutative39.7%
Simplified39.7%
Taylor expanded in c0 around -inf 35.4%
associate-*r/35.4%
neg-mul-135.4%
associate-*r/35.4%
mul-1-neg35.4%
Simplified35.4%
Taylor expanded in h around -inf 38.3%
times-frac38.6%
cancel-sign-sub-inv38.6%
metadata-eval38.6%
distribute-rgt1-in38.6%
metadata-eval38.6%
associate-/r*39.2%
unpow239.2%
unpow239.2%
times-frac48.3%
unpow248.3%
Simplified48.3%
Final simplification62.5%
D_m = (fabs.f64 D)
d_m = (fabs.f64 d)
(FPCore (c0 w h D_m d_m M)
:precision binary64
(let* ((t_0 (/ (* c0 (* d_m d_m)) (* (* w h) (* D_m D_m)))))
(if (<=
(* (/ c0 (* 2.0 w)) (+ t_0 (sqrt (- (* t_0 t_0) (* M M)))))
INFINITY)
(*
c0
(/ (* 2.0 (/ (* d_m (* (/ d_m D_m) (/ c0 (* w h)))) D_m)) (* 2.0 w)))
(* c0 (/ 0.0 (* 2.0 w))))))D_m = fabs(D);
d_m = fabs(d);
double code(double c0, double w, double h, double D_m, double d_m, double M) {
double t_0 = (c0 * (d_m * d_m)) / ((w * h) * (D_m * D_m));
double tmp;
if (((c0 / (2.0 * w)) * (t_0 + sqrt(((t_0 * t_0) - (M * M))))) <= ((double) INFINITY)) {
tmp = c0 * ((2.0 * ((d_m * ((d_m / D_m) * (c0 / (w * h)))) / D_m)) / (2.0 * w));
} else {
tmp = c0 * (0.0 / (2.0 * w));
}
return tmp;
}
D_m = Math.abs(D);
d_m = Math.abs(d);
public static double code(double c0, double w, double h, double D_m, double d_m, double M) {
double t_0 = (c0 * (d_m * d_m)) / ((w * h) * (D_m * D_m));
double tmp;
if (((c0 / (2.0 * w)) * (t_0 + Math.sqrt(((t_0 * t_0) - (M * M))))) <= Double.POSITIVE_INFINITY) {
tmp = c0 * ((2.0 * ((d_m * ((d_m / D_m) * (c0 / (w * h)))) / D_m)) / (2.0 * w));
} else {
tmp = c0 * (0.0 / (2.0 * w));
}
return tmp;
}
D_m = math.fabs(D) d_m = math.fabs(d) def code(c0, w, h, D_m, d_m, M): t_0 = (c0 * (d_m * d_m)) / ((w * h) * (D_m * D_m)) tmp = 0 if ((c0 / (2.0 * w)) * (t_0 + math.sqrt(((t_0 * t_0) - (M * M))))) <= math.inf: tmp = c0 * ((2.0 * ((d_m * ((d_m / D_m) * (c0 / (w * h)))) / D_m)) / (2.0 * w)) else: tmp = c0 * (0.0 / (2.0 * w)) return tmp
D_m = abs(D) d_m = abs(d) function code(c0, w, h, D_m, d_m, M) t_0 = Float64(Float64(c0 * Float64(d_m * d_m)) / Float64(Float64(w * h) * Float64(D_m * D_m))) 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 * Float64(Float64(d_m * Float64(Float64(d_m / D_m) * Float64(c0 / Float64(w * h)))) / D_m)) / Float64(2.0 * w))); else tmp = Float64(c0 * Float64(0.0 / Float64(2.0 * w))); end return tmp end
D_m = abs(D); d_m = abs(d); function tmp_2 = code(c0, w, h, D_m, d_m, M) t_0 = (c0 * (d_m * d_m)) / ((w * h) * (D_m * D_m)); tmp = 0.0; if (((c0 / (2.0 * w)) * (t_0 + sqrt(((t_0 * t_0) - (M * M))))) <= Inf) tmp = c0 * ((2.0 * ((d_m * ((d_m / D_m) * (c0 / (w * h)))) / D_m)) / (2.0 * w)); else tmp = c0 * (0.0 / (2.0 * w)); end tmp_2 = tmp; end
D_m = N[Abs[D], $MachinePrecision]
d_m = N[Abs[d], $MachinePrecision]
code[c0_, w_, h_, D$95$m_, d$95$m_, M_] := Block[{t$95$0 = N[(N[(c0 * N[(d$95$m * d$95$m), $MachinePrecision]), $MachinePrecision] / N[(N[(w * h), $MachinePrecision] * N[(D$95$m * D$95$m), $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 * N[(N[(d$95$m * N[(N[(d$95$m / D$95$m), $MachinePrecision] * N[(c0 / N[(w * h), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / D$95$m), $MachinePrecision]), $MachinePrecision] / N[(2.0 * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(c0 * N[(0.0 / N[(2.0 * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
D_m = \left|D\right|
\\
d_m = \left|d\right|
\\
\begin{array}{l}
t_0 := \frac{c0 \cdot \left(d\_m \cdot d\_m\right)}{\left(w \cdot h\right) \cdot \left(D\_m \cdot D\_m\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{2 \cdot \frac{d\_m \cdot \left(\frac{d\_m}{D\_m} \cdot \frac{c0}{w \cdot h}\right)}{D\_m}}{2 \cdot w}\\
\mathbf{else}:\\
\;\;\;\;c0 \cdot \frac{0}{2 \cdot w}\\
\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 78.6%
Simplified72.3%
Taylor expanded in c0 around inf 72.7%
*-commutative72.7%
*-commutative72.7%
associate-*r*68.4%
times-frac68.4%
*-commutative68.4%
Simplified68.4%
associate-*r/69.2%
*-commutative69.2%
Applied egg-rr69.2%
Taylor expanded in c0 around 0 74.0%
*-commutative74.0%
times-frac74.4%
unpow274.4%
unpow274.4%
times-frac78.4%
unpow278.4%
associate-/r*75.0%
Simplified75.0%
associate-/r*78.4%
unpow278.4%
associate-*l*80.0%
associate-*r/79.1%
*-commutative79.1%
Applied egg-rr79.1%
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%
Simplified20.7%
Taylor expanded in c0 around -inf 1.4%
mul-1-neg1.4%
distribute-lft-in0.1%
mul-1-neg0.1%
distribute-rgt-neg-in0.1%
associate-/l*0.1%
mul-1-neg0.1%
associate-/l*0.1%
distribute-lft1-in0.1%
metadata-eval0.1%
mul0-lft46.6%
metadata-eval46.6%
Simplified46.6%
Final simplification58.5%
D_m = (fabs.f64 D) d_m = (fabs.f64 d) (FPCore (c0 w h D_m d_m M) :precision binary64 (* c0 (/ 0.0 (* 2.0 w))))
D_m = fabs(D);
d_m = fabs(d);
double code(double c0, double w, double h, double D_m, double d_m, double M) {
return c0 * (0.0 / (2.0 * w));
}
D_m = abs(d)
d_m = abs(d)
real(8) function code(c0, w, h, d_m, d_m_1, m)
real(8), intent (in) :: c0
real(8), intent (in) :: w
real(8), intent (in) :: h
real(8), intent (in) :: d_m
real(8), intent (in) :: d_m_1
real(8), intent (in) :: m
code = c0 * (0.0d0 / (2.0d0 * w))
end function
D_m = Math.abs(D);
d_m = Math.abs(d);
public static double code(double c0, double w, double h, double D_m, double d_m, double M) {
return c0 * (0.0 / (2.0 * w));
}
D_m = math.fabs(D) d_m = math.fabs(d) def code(c0, w, h, D_m, d_m, M): return c0 * (0.0 / (2.0 * w))
D_m = abs(D) d_m = abs(d) function code(c0, w, h, D_m, d_m, M) return Float64(c0 * Float64(0.0 / Float64(2.0 * w))) end
D_m = abs(D); d_m = abs(d); function tmp = code(c0, w, h, D_m, d_m, M) tmp = c0 * (0.0 / (2.0 * w)); end
D_m = N[Abs[D], $MachinePrecision] d_m = N[Abs[d], $MachinePrecision] code[c0_, w_, h_, D$95$m_, d$95$m_, M_] := N[(c0 * N[(0.0 / N[(2.0 * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
D_m = \left|D\right|
\\
d_m = \left|d\right|
\\
c0 \cdot \frac{0}{2 \cdot w}
\end{array}
Initial program 28.8%
Simplified39.6%
Taylor expanded in c0 around -inf 4.0%
mul-1-neg4.0%
distribute-lft-in3.1%
mul-1-neg3.1%
distribute-rgt-neg-in3.1%
associate-/l*2.4%
mul-1-neg2.4%
associate-/l*3.5%
distribute-lft1-in3.5%
metadata-eval3.5%
mul0-lft33.4%
metadata-eval33.4%
Simplified33.4%
Final simplification33.4%
herbie shell --seed 2024051
(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))))))