
(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 6 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}
NOTE: D should be positive before calling this function
NOTE: d should be positive before calling this function
(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)))))
(if (<= (* t_0 (+ t_1 (sqrt (- (* t_1 t_1) (* M M))))) INFINITY)
(* t_0 (* 2.0 (exp (+ (log (/ c0 (* w h))) (* 2.0 (log (/ d D)))))))
0.0)))D = abs(D);
d = abs(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 tmp;
if ((t_0 * (t_1 + sqrt(((t_1 * t_1) - (M * M))))) <= ((double) INFINITY)) {
tmp = t_0 * (2.0 * exp((log((c0 / (w * h))) + (2.0 * log((d / D))))));
} else {
tmp = 0.0;
}
return tmp;
}
D = Math.abs(D);
d = Math.abs(d);
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 tmp;
if ((t_0 * (t_1 + Math.sqrt(((t_1 * t_1) - (M * M))))) <= Double.POSITIVE_INFINITY) {
tmp = t_0 * (2.0 * Math.exp((Math.log((c0 / (w * h))) + (2.0 * Math.log((d / D))))));
} else {
tmp = 0.0;
}
return tmp;
}
D = abs(D) d = abs(d) def code(c0, w, h, D, d, M): t_0 = c0 / (2.0 * w) t_1 = (c0 * (d * d)) / ((w * h) * (D * D)) tmp = 0 if (t_0 * (t_1 + math.sqrt(((t_1 * t_1) - (M * M))))) <= math.inf: tmp = t_0 * (2.0 * math.exp((math.log((c0 / (w * h))) + (2.0 * math.log((d / D)))))) else: tmp = 0.0 return tmp
D = abs(D) d = abs(d) function code(c0, w, h, D, d, M) t_0 = Float64(c0 / Float64(2.0 * w)) t_1 = Float64(Float64(c0 * Float64(d * d)) / Float64(Float64(w * h) * Float64(D * D))) tmp = 0.0 if (Float64(t_0 * Float64(t_1 + sqrt(Float64(Float64(t_1 * t_1) - Float64(M * M))))) <= Inf) tmp = Float64(t_0 * Float64(2.0 * exp(Float64(log(Float64(c0 / Float64(w * h))) + Float64(2.0 * log(Float64(d / D))))))); else tmp = 0.0; end return tmp end
D = abs(D) d = abs(d) 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)); tmp = 0.0; if ((t_0 * (t_1 + sqrt(((t_1 * t_1) - (M * M))))) <= Inf) tmp = t_0 * (2.0 * exp((log((c0 / (w * h))) + (2.0 * log((d / D)))))); else tmp = 0.0; end tmp_2 = tmp; end
NOTE: D should be positive before calling this function
NOTE: d should be positive before calling this function
code[c0_, w_, h_, D_, d_, M_] := Block[{t$95$0 = N[(c0 / N[(2.0 * w), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(c0 * N[(d * d), $MachinePrecision]), $MachinePrecision] / N[(N[(w * h), $MachinePrecision] * N[(D * D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(t$95$0 * N[(t$95$1 + N[Sqrt[N[(N[(t$95$1 * t$95$1), $MachinePrecision] - N[(M * M), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], Infinity], N[(t$95$0 * N[(2.0 * N[Exp[N[(N[Log[N[(c0 / N[(w * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] + N[(2.0 * N[Log[N[(d / D), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 0.0]]]
\begin{array}{l}
D = |D|\\
d = |d|\\
\\
\begin{array}{l}
t_0 := \frac{c0}{2 \cdot w}\\
t_1 := \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)}\\
\mathbf{if}\;t_0 \cdot \left(t_1 + \sqrt{t_1 \cdot t_1 - M \cdot M}\right) \leq \infty:\\
\;\;\;\;t_0 \cdot \left(2 \cdot e^{\log \left(\frac{c0}{w \cdot h}\right) + 2 \cdot \log \left(\frac{d}{D}\right)}\right)\\
\mathbf{else}:\\
\;\;\;\;0\\
\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 74.2%
times-frac72.7%
fma-def72.7%
associate-/r*73.2%
difference-of-squares73.2%
Simplified76.2%
Taylor expanded in c0 around inf 79.1%
pow279.1%
times-frac78.2%
unpow278.2%
associate-/l/82.3%
*-commutative82.3%
add-exp-log81.1%
associate-/r*81.1%
associate-/l/77.3%
Applied egg-rr77.3%
log-prod77.2%
associate-/r*77.2%
times-frac81.3%
unpow281.3%
pow-to-exp42.1%
add-log-exp44.4%
Applied egg-rr44.4%
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%
times-frac0.0%
fma-def0.0%
associate-/r*0.1%
difference-of-squares9.8%
Simplified17.0%
Taylor expanded in c0 around -inf 1.2%
associate-*r*1.2%
distribute-rgt1-in1.2%
metadata-eval1.2%
mul0-lft47.6%
metadata-eval47.6%
mul0-lft1.7%
metadata-eval1.7%
distribute-lft1-in1.7%
*-commutative1.7%
distribute-lft1-in1.7%
metadata-eval1.7%
mul0-lft47.6%
Simplified47.6%
Taylor expanded in c0 around 0 53.8%
Final simplification51.3%
NOTE: D should be positive before calling this function
NOTE: d should be positive before calling this function
(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)))))
(if (<= (* t_0 (+ t_1 (sqrt (- (* t_1 t_1) (* M M))))) INFINITY)
(* t_0 (* 2.0 (/ (* c0 (pow (/ d D) 2.0)) (* w h))))
0.0)))D = abs(D);
d = abs(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 tmp;
if ((t_0 * (t_1 + sqrt(((t_1 * t_1) - (M * M))))) <= ((double) INFINITY)) {
tmp = t_0 * (2.0 * ((c0 * pow((d / D), 2.0)) / (w * h)));
} else {
tmp = 0.0;
}
return tmp;
}
D = Math.abs(D);
d = Math.abs(d);
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 tmp;
if ((t_0 * (t_1 + Math.sqrt(((t_1 * t_1) - (M * M))))) <= Double.POSITIVE_INFINITY) {
tmp = t_0 * (2.0 * ((c0 * Math.pow((d / D), 2.0)) / (w * h)));
} else {
tmp = 0.0;
}
return tmp;
}
D = abs(D) d = abs(d) def code(c0, w, h, D, d, M): t_0 = c0 / (2.0 * w) t_1 = (c0 * (d * d)) / ((w * h) * (D * D)) tmp = 0 if (t_0 * (t_1 + math.sqrt(((t_1 * t_1) - (M * M))))) <= math.inf: tmp = t_0 * (2.0 * ((c0 * math.pow((d / D), 2.0)) / (w * h))) else: tmp = 0.0 return tmp
D = abs(D) d = abs(d) function code(c0, w, h, D, d, M) t_0 = Float64(c0 / Float64(2.0 * w)) t_1 = Float64(Float64(c0 * Float64(d * d)) / Float64(Float64(w * h) * Float64(D * D))) tmp = 0.0 if (Float64(t_0 * Float64(t_1 + sqrt(Float64(Float64(t_1 * t_1) - Float64(M * M))))) <= Inf) tmp = Float64(t_0 * Float64(2.0 * Float64(Float64(c0 * (Float64(d / D) ^ 2.0)) / Float64(w * h)))); else tmp = 0.0; end return tmp end
D = abs(D) d = abs(d) 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)); tmp = 0.0; if ((t_0 * (t_1 + sqrt(((t_1 * t_1) - (M * M))))) <= Inf) tmp = t_0 * (2.0 * ((c0 * ((d / D) ^ 2.0)) / (w * h))); else tmp = 0.0; end tmp_2 = tmp; end
NOTE: D should be positive before calling this function
NOTE: d should be positive before calling this function
code[c0_, w_, h_, D_, d_, M_] := Block[{t$95$0 = N[(c0 / N[(2.0 * w), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(c0 * N[(d * d), $MachinePrecision]), $MachinePrecision] / N[(N[(w * h), $MachinePrecision] * N[(D * D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(t$95$0 * N[(t$95$1 + N[Sqrt[N[(N[(t$95$1 * t$95$1), $MachinePrecision] - N[(M * M), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], Infinity], N[(t$95$0 * N[(2.0 * N[(N[(c0 * N[Power[N[(d / D), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / N[(w * h), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 0.0]]]
\begin{array}{l}
D = |D|\\
d = |d|\\
\\
\begin{array}{l}
t_0 := \frac{c0}{2 \cdot w}\\
t_1 := \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)}\\
\mathbf{if}\;t_0 \cdot \left(t_1 + \sqrt{t_1 \cdot t_1 - M \cdot M}\right) \leq \infty:\\
\;\;\;\;t_0 \cdot \left(2 \cdot \frac{c0 \cdot {\left(\frac{d}{D}\right)}^{2}}{w \cdot h}\right)\\
\mathbf{else}:\\
\;\;\;\;0\\
\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 74.2%
times-frac72.7%
fma-def72.7%
associate-/r*73.2%
difference-of-squares73.2%
Simplified76.2%
Taylor expanded in c0 around inf 79.1%
pow279.1%
times-frac78.2%
unpow278.2%
associate-/l/82.3%
*-commutative82.3%
associate-/r*82.3%
associate-/l/78.2%
Applied egg-rr78.2%
times-frac82.9%
unpow282.9%
associate-/r*82.8%
associate-*l/83.1%
Applied egg-rr83.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%
times-frac0.0%
fma-def0.0%
associate-/r*0.1%
difference-of-squares9.8%
Simplified17.0%
Taylor expanded in c0 around -inf 1.2%
associate-*r*1.2%
distribute-rgt1-in1.2%
metadata-eval1.2%
mul0-lft47.6%
metadata-eval47.6%
mul0-lft1.7%
metadata-eval1.7%
distribute-lft1-in1.7%
*-commutative1.7%
distribute-lft1-in1.7%
metadata-eval1.7%
mul0-lft47.6%
Simplified47.6%
Taylor expanded in c0 around 0 53.8%
Final simplification61.9%
NOTE: D should be positive before calling this function
NOTE: d should be positive before calling this function
(FPCore (c0 w h D d M)
:precision binary64
(if (<= (* M M) 2.95e-43)
0.0
(if (<= (* M M) 2e+52)
(* (* (/ d D) (/ d D)) (/ (* c0 c0) (* h (* w w))))
(if (<= (* M M) 8.2e+61)
0.0
(* (/ c0 2.0) (/ (* 2.0 (* (/ c0 (* w h)) (pow (/ d D) 2.0))) w))))))D = abs(D);
d = abs(d);
double code(double c0, double w, double h, double D, double d, double M) {
double tmp;
if ((M * M) <= 2.95e-43) {
tmp = 0.0;
} else if ((M * M) <= 2e+52) {
tmp = ((d / D) * (d / D)) * ((c0 * c0) / (h * (w * w)));
} else if ((M * M) <= 8.2e+61) {
tmp = 0.0;
} else {
tmp = (c0 / 2.0) * ((2.0 * ((c0 / (w * h)) * pow((d / D), 2.0))) / w);
}
return tmp;
}
NOTE: D should be positive before calling this function
NOTE: d should be positive before calling this function
real(8) function code(c0, w, h, d, d_1, m)
real(8), intent (in) :: c0
real(8), intent (in) :: w
real(8), intent (in) :: h
real(8), intent (in) :: d
real(8), intent (in) :: d_1
real(8), intent (in) :: m
real(8) :: tmp
if ((m * m) <= 2.95d-43) then
tmp = 0.0d0
else if ((m * m) <= 2d+52) then
tmp = ((d_1 / d) * (d_1 / d)) * ((c0 * c0) / (h * (w * w)))
else if ((m * m) <= 8.2d+61) then
tmp = 0.0d0
else
tmp = (c0 / 2.0d0) * ((2.0d0 * ((c0 / (w * h)) * ((d_1 / d) ** 2.0d0))) / w)
end if
code = tmp
end function
D = Math.abs(D);
d = Math.abs(d);
public static double code(double c0, double w, double h, double D, double d, double M) {
double tmp;
if ((M * M) <= 2.95e-43) {
tmp = 0.0;
} else if ((M * M) <= 2e+52) {
tmp = ((d / D) * (d / D)) * ((c0 * c0) / (h * (w * w)));
} else if ((M * M) <= 8.2e+61) {
tmp = 0.0;
} else {
tmp = (c0 / 2.0) * ((2.0 * ((c0 / (w * h)) * Math.pow((d / D), 2.0))) / w);
}
return tmp;
}
D = abs(D) d = abs(d) def code(c0, w, h, D, d, M): tmp = 0 if (M * M) <= 2.95e-43: tmp = 0.0 elif (M * M) <= 2e+52: tmp = ((d / D) * (d / D)) * ((c0 * c0) / (h * (w * w))) elif (M * M) <= 8.2e+61: tmp = 0.0 else: tmp = (c0 / 2.0) * ((2.0 * ((c0 / (w * h)) * math.pow((d / D), 2.0))) / w) return tmp
D = abs(D) d = abs(d) function code(c0, w, h, D, d, M) tmp = 0.0 if (Float64(M * M) <= 2.95e-43) tmp = 0.0; elseif (Float64(M * M) <= 2e+52) tmp = Float64(Float64(Float64(d / D) * Float64(d / D)) * Float64(Float64(c0 * c0) / Float64(h * Float64(w * w)))); elseif (Float64(M * M) <= 8.2e+61) tmp = 0.0; else tmp = Float64(Float64(c0 / 2.0) * Float64(Float64(2.0 * Float64(Float64(c0 / Float64(w * h)) * (Float64(d / D) ^ 2.0))) / w)); end return tmp end
D = abs(D) d = abs(d) function tmp_2 = code(c0, w, h, D, d, M) tmp = 0.0; if ((M * M) <= 2.95e-43) tmp = 0.0; elseif ((M * M) <= 2e+52) tmp = ((d / D) * (d / D)) * ((c0 * c0) / (h * (w * w))); elseif ((M * M) <= 8.2e+61) tmp = 0.0; else tmp = (c0 / 2.0) * ((2.0 * ((c0 / (w * h)) * ((d / D) ^ 2.0))) / w); end tmp_2 = tmp; end
NOTE: D should be positive before calling this function NOTE: d should be positive before calling this function code[c0_, w_, h_, D_, d_, M_] := If[LessEqual[N[(M * M), $MachinePrecision], 2.95e-43], 0.0, If[LessEqual[N[(M * M), $MachinePrecision], 2e+52], N[(N[(N[(d / D), $MachinePrecision] * N[(d / D), $MachinePrecision]), $MachinePrecision] * N[(N[(c0 * c0), $MachinePrecision] / N[(h * N[(w * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(M * M), $MachinePrecision], 8.2e+61], 0.0, N[(N[(c0 / 2.0), $MachinePrecision] * N[(N[(2.0 * N[(N[(c0 / N[(w * h), $MachinePrecision]), $MachinePrecision] * N[Power[N[(d / D), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / w), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
D = |D|\\
d = |d|\\
\\
\begin{array}{l}
\mathbf{if}\;M \cdot M \leq 2.95 \cdot 10^{-43}:\\
\;\;\;\;0\\
\mathbf{elif}\;M \cdot M \leq 2 \cdot 10^{+52}:\\
\;\;\;\;\left(\frac{d}{D} \cdot \frac{d}{D}\right) \cdot \frac{c0 \cdot c0}{h \cdot \left(w \cdot w\right)}\\
\mathbf{elif}\;M \cdot M \leq 8.2 \cdot 10^{+61}:\\
\;\;\;\;0\\
\mathbf{else}:\\
\;\;\;\;\frac{c0}{2} \cdot \frac{2 \cdot \left(\frac{c0}{w \cdot h} \cdot {\left(\frac{d}{D}\right)}^{2}\right)}{w}\\
\end{array}
\end{array}
if (*.f64 M M) < 2.94999999999999988e-43 or 2e52 < (*.f64 M M) < 8.19999999999999944e61Initial program 18.3%
times-frac18.2%
fma-def18.3%
associate-/r*18.5%
difference-of-squares18.5%
Simplified24.9%
Taylor expanded in c0 around -inf 4.0%
associate-*r*4.0%
distribute-rgt1-in4.0%
metadata-eval4.0%
mul0-lft48.4%
metadata-eval48.4%
mul0-lft4.6%
metadata-eval4.6%
distribute-lft1-in4.6%
*-commutative4.6%
distribute-lft1-in4.6%
metadata-eval4.6%
mul0-lft48.4%
Simplified48.4%
Taylor expanded in c0 around 0 55.4%
if 2.94999999999999988e-43 < (*.f64 M M) < 2e52Initial program 72.7%
times-frac63.6%
fma-def63.6%
associate-/r*63.6%
difference-of-squares63.6%
Simplified63.6%
Taylor expanded in c0 around inf 72.9%
Taylor expanded in c0 around 0 72.9%
times-frac63.8%
unpow263.8%
unpow263.8%
times-frac73.2%
unpow273.2%
unpow273.2%
unpow273.2%
Simplified73.2%
unpow273.2%
Applied egg-rr73.2%
if 8.19999999999999944e61 < (*.f64 M M) Initial program 17.3%
times-frac17.3%
fma-def17.3%
associate-/r*17.3%
difference-of-squares39.5%
Simplified45.6%
Taylor expanded in c0 around inf 42.6%
associate-*l/43.8%
pow243.8%
times-frac43.7%
unpow243.7%
associate-/l/49.9%
*-commutative49.9%
associate-/r*48.8%
associate-/l/42.5%
Applied egg-rr42.5%
times-frac41.4%
associate-/l/42.6%
*-commutative42.6%
times-frac52.6%
unpow252.6%
Simplified52.6%
Final simplification55.3%
NOTE: D should be positive before calling this function
NOTE: d should be positive before calling this function
(FPCore (c0 w h D d M)
:precision binary64
(let* ((t_0 (* (/ d D) (/ d D))))
(if (<= (* M M) 2.7e-37)
0.0
(if (<= (* M M) 7e+52)
(* t_0 (/ (* c0 c0) (* h (* w w))))
(if (<= (* M M) 5.2e+62)
0.0
(* t_0 (* (/ c0 (* w h)) (/ (* 2.0 (/ c0 2.0)) w))))))))D = abs(D);
d = abs(d);
double code(double c0, double w, double h, double D, double d, double M) {
double t_0 = (d / D) * (d / D);
double tmp;
if ((M * M) <= 2.7e-37) {
tmp = 0.0;
} else if ((M * M) <= 7e+52) {
tmp = t_0 * ((c0 * c0) / (h * (w * w)));
} else if ((M * M) <= 5.2e+62) {
tmp = 0.0;
} else {
tmp = t_0 * ((c0 / (w * h)) * ((2.0 * (c0 / 2.0)) / w));
}
return tmp;
}
NOTE: D should be positive before calling this function
NOTE: d should be positive before calling this function
real(8) function code(c0, w, h, d, d_1, m)
real(8), intent (in) :: c0
real(8), intent (in) :: w
real(8), intent (in) :: h
real(8), intent (in) :: d
real(8), intent (in) :: d_1
real(8), intent (in) :: m
real(8) :: t_0
real(8) :: tmp
t_0 = (d_1 / d) * (d_1 / d)
if ((m * m) <= 2.7d-37) then
tmp = 0.0d0
else if ((m * m) <= 7d+52) then
tmp = t_0 * ((c0 * c0) / (h * (w * w)))
else if ((m * m) <= 5.2d+62) then
tmp = 0.0d0
else
tmp = t_0 * ((c0 / (w * h)) * ((2.0d0 * (c0 / 2.0d0)) / w))
end if
code = tmp
end function
D = Math.abs(D);
d = Math.abs(d);
public static double code(double c0, double w, double h, double D, double d, double M) {
double t_0 = (d / D) * (d / D);
double tmp;
if ((M * M) <= 2.7e-37) {
tmp = 0.0;
} else if ((M * M) <= 7e+52) {
tmp = t_0 * ((c0 * c0) / (h * (w * w)));
} else if ((M * M) <= 5.2e+62) {
tmp = 0.0;
} else {
tmp = t_0 * ((c0 / (w * h)) * ((2.0 * (c0 / 2.0)) / w));
}
return tmp;
}
D = abs(D) d = abs(d) def code(c0, w, h, D, d, M): t_0 = (d / D) * (d / D) tmp = 0 if (M * M) <= 2.7e-37: tmp = 0.0 elif (M * M) <= 7e+52: tmp = t_0 * ((c0 * c0) / (h * (w * w))) elif (M * M) <= 5.2e+62: tmp = 0.0 else: tmp = t_0 * ((c0 / (w * h)) * ((2.0 * (c0 / 2.0)) / w)) return tmp
D = abs(D) d = abs(d) function code(c0, w, h, D, d, M) t_0 = Float64(Float64(d / D) * Float64(d / D)) tmp = 0.0 if (Float64(M * M) <= 2.7e-37) tmp = 0.0; elseif (Float64(M * M) <= 7e+52) tmp = Float64(t_0 * Float64(Float64(c0 * c0) / Float64(h * Float64(w * w)))); elseif (Float64(M * M) <= 5.2e+62) tmp = 0.0; else tmp = Float64(t_0 * Float64(Float64(c0 / Float64(w * h)) * Float64(Float64(2.0 * Float64(c0 / 2.0)) / w))); end return tmp end
D = abs(D) d = abs(d) function tmp_2 = code(c0, w, h, D, d, M) t_0 = (d / D) * (d / D); tmp = 0.0; if ((M * M) <= 2.7e-37) tmp = 0.0; elseif ((M * M) <= 7e+52) tmp = t_0 * ((c0 * c0) / (h * (w * w))); elseif ((M * M) <= 5.2e+62) tmp = 0.0; else tmp = t_0 * ((c0 / (w * h)) * ((2.0 * (c0 / 2.0)) / w)); end tmp_2 = tmp; end
NOTE: D should be positive before calling this function
NOTE: d should be positive before calling this function
code[c0_, w_, h_, D_, d_, M_] := Block[{t$95$0 = N[(N[(d / D), $MachinePrecision] * N[(d / D), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(M * M), $MachinePrecision], 2.7e-37], 0.0, If[LessEqual[N[(M * M), $MachinePrecision], 7e+52], N[(t$95$0 * N[(N[(c0 * c0), $MachinePrecision] / N[(h * N[(w * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(M * M), $MachinePrecision], 5.2e+62], 0.0, N[(t$95$0 * N[(N[(c0 / N[(w * h), $MachinePrecision]), $MachinePrecision] * N[(N[(2.0 * N[(c0 / 2.0), $MachinePrecision]), $MachinePrecision] / w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
D = |D|\\
d = |d|\\
\\
\begin{array}{l}
t_0 := \frac{d}{D} \cdot \frac{d}{D}\\
\mathbf{if}\;M \cdot M \leq 2.7 \cdot 10^{-37}:\\
\;\;\;\;0\\
\mathbf{elif}\;M \cdot M \leq 7 \cdot 10^{+52}:\\
\;\;\;\;t_0 \cdot \frac{c0 \cdot c0}{h \cdot \left(w \cdot w\right)}\\
\mathbf{elif}\;M \cdot M \leq 5.2 \cdot 10^{+62}:\\
\;\;\;\;0\\
\mathbf{else}:\\
\;\;\;\;t_0 \cdot \left(\frac{c0}{w \cdot h} \cdot \frac{2 \cdot \frac{c0}{2}}{w}\right)\\
\end{array}
\end{array}
if (*.f64 M M) < 2.70000000000000016e-37 or 7e52 < (*.f64 M M) < 5.19999999999999968e62Initial program 18.3%
times-frac18.2%
fma-def18.3%
associate-/r*18.5%
difference-of-squares18.5%
Simplified24.9%
Taylor expanded in c0 around -inf 4.0%
associate-*r*4.0%
distribute-rgt1-in4.0%
metadata-eval4.0%
mul0-lft48.4%
metadata-eval48.4%
mul0-lft4.6%
metadata-eval4.6%
distribute-lft1-in4.6%
*-commutative4.6%
distribute-lft1-in4.6%
metadata-eval4.6%
mul0-lft48.4%
Simplified48.4%
Taylor expanded in c0 around 0 55.4%
if 2.70000000000000016e-37 < (*.f64 M M) < 7e52Initial program 72.7%
times-frac63.6%
fma-def63.6%
associate-/r*63.6%
difference-of-squares63.6%
Simplified63.6%
Taylor expanded in c0 around inf 72.9%
Taylor expanded in c0 around 0 72.9%
times-frac63.8%
unpow263.8%
unpow263.8%
times-frac73.2%
unpow273.2%
unpow273.2%
unpow273.2%
Simplified73.2%
unpow273.2%
Applied egg-rr73.2%
if 5.19999999999999968e62 < (*.f64 M M) Initial program 17.3%
times-frac17.3%
fma-def17.3%
associate-/r*17.3%
difference-of-squares39.5%
Simplified45.6%
Taylor expanded in c0 around inf 42.6%
associate-*l/43.8%
pow243.8%
times-frac43.7%
unpow243.7%
associate-/l/49.9%
*-commutative49.9%
associate-/r*48.8%
associate-/l/42.5%
Applied egg-rr42.5%
associate-*r*42.5%
times-frac51.4%
unpow251.4%
*-commutative51.4%
unpow251.4%
times-frac42.5%
unpow242.5%
unpow242.5%
associate-/l/43.7%
*-commutative43.7%
times-frac43.8%
associate-*l/42.6%
associate-*l/42.6%
times-frac42.5%
*-commutative42.5%
Simplified52.4%
unpow246.1%
Applied egg-rr52.4%
Final simplification55.2%
NOTE: D should be positive before calling this function
NOTE: d should be positive before calling this function
(FPCore (c0 w h D d M)
:precision binary64
(if (<= M 2.7e-19)
0.0
(if (or (<= M 1.7e+26) (not (<= M 5.5e+32)))
(* (* (/ d D) (/ d D)) (/ (* c0 c0) (* h (* w w))))
0.0)))D = abs(D);
d = abs(d);
double code(double c0, double w, double h, double D, double d, double M) {
double tmp;
if (M <= 2.7e-19) {
tmp = 0.0;
} else if ((M <= 1.7e+26) || !(M <= 5.5e+32)) {
tmp = ((d / D) * (d / D)) * ((c0 * c0) / (h * (w * w)));
} else {
tmp = 0.0;
}
return tmp;
}
NOTE: D should be positive before calling this function
NOTE: d should be positive before calling this function
real(8) function code(c0, w, h, d, d_1, m)
real(8), intent (in) :: c0
real(8), intent (in) :: w
real(8), intent (in) :: h
real(8), intent (in) :: d
real(8), intent (in) :: d_1
real(8), intent (in) :: m
real(8) :: tmp
if (m <= 2.7d-19) then
tmp = 0.0d0
else if ((m <= 1.7d+26) .or. (.not. (m <= 5.5d+32))) then
tmp = ((d_1 / d) * (d_1 / d)) * ((c0 * c0) / (h * (w * w)))
else
tmp = 0.0d0
end if
code = tmp
end function
D = Math.abs(D);
d = Math.abs(d);
public static double code(double c0, double w, double h, double D, double d, double M) {
double tmp;
if (M <= 2.7e-19) {
tmp = 0.0;
} else if ((M <= 1.7e+26) || !(M <= 5.5e+32)) {
tmp = ((d / D) * (d / D)) * ((c0 * c0) / (h * (w * w)));
} else {
tmp = 0.0;
}
return tmp;
}
D = abs(D) d = abs(d) def code(c0, w, h, D, d, M): tmp = 0 if M <= 2.7e-19: tmp = 0.0 elif (M <= 1.7e+26) or not (M <= 5.5e+32): tmp = ((d / D) * (d / D)) * ((c0 * c0) / (h * (w * w))) else: tmp = 0.0 return tmp
D = abs(D) d = abs(d) function code(c0, w, h, D, d, M) tmp = 0.0 if (M <= 2.7e-19) tmp = 0.0; elseif ((M <= 1.7e+26) || !(M <= 5.5e+32)) tmp = Float64(Float64(Float64(d / D) * Float64(d / D)) * Float64(Float64(c0 * c0) / Float64(h * Float64(w * w)))); else tmp = 0.0; end return tmp end
D = abs(D) d = abs(d) function tmp_2 = code(c0, w, h, D, d, M) tmp = 0.0; if (M <= 2.7e-19) tmp = 0.0; elseif ((M <= 1.7e+26) || ~((M <= 5.5e+32))) tmp = ((d / D) * (d / D)) * ((c0 * c0) / (h * (w * w))); else tmp = 0.0; end tmp_2 = tmp; end
NOTE: D should be positive before calling this function NOTE: d should be positive before calling this function code[c0_, w_, h_, D_, d_, M_] := If[LessEqual[M, 2.7e-19], 0.0, If[Or[LessEqual[M, 1.7e+26], N[Not[LessEqual[M, 5.5e+32]], $MachinePrecision]], N[(N[(N[(d / D), $MachinePrecision] * N[(d / D), $MachinePrecision]), $MachinePrecision] * N[(N[(c0 * c0), $MachinePrecision] / N[(h * N[(w * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 0.0]]
\begin{array}{l}
D = |D|\\
d = |d|\\
\\
\begin{array}{l}
\mathbf{if}\;M \leq 2.7 \cdot 10^{-19}:\\
\;\;\;\;0\\
\mathbf{elif}\;M \leq 1.7 \cdot 10^{+26} \lor \neg \left(M \leq 5.5 \cdot 10^{+32}\right):\\
\;\;\;\;\left(\frac{d}{D} \cdot \frac{d}{D}\right) \cdot \frac{c0 \cdot c0}{h \cdot \left(w \cdot w\right)}\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if M < 2.7000000000000001e-19 or 1.7000000000000001e26 < M < 5.49999999999999984e32Initial program 18.5%
times-frac18.0%
fma-def18.0%
associate-/r*18.2%
difference-of-squares23.5%
Simplified29.9%
Taylor expanded in c0 around -inf 3.1%
associate-*r*3.1%
distribute-rgt1-in3.1%
metadata-eval3.1%
mul0-lft41.7%
metadata-eval41.7%
mul0-lft3.6%
metadata-eval3.6%
distribute-lft1-in3.6%
*-commutative3.6%
distribute-lft1-in3.6%
metadata-eval3.6%
mul0-lft41.7%
Simplified41.7%
Taylor expanded in c0 around 0 47.2%
if 2.7000000000000001e-19 < M < 1.7000000000000001e26 or 5.49999999999999984e32 < M Initial program 28.5%
times-frac28.5%
fma-def28.5%
associate-/r*28.5%
difference-of-squares43.9%
Simplified48.2%
Taylor expanded in c0 around inf 48.8%
Taylor expanded in c0 around 0 44.2%
times-frac46.3%
unpow246.3%
unpow246.3%
times-frac57.2%
unpow257.2%
unpow257.2%
unpow257.2%
Simplified57.2%
unpow257.2%
Applied egg-rr57.2%
Final simplification49.0%
NOTE: D should be positive before calling this function NOTE: d should be positive before calling this function (FPCore (c0 w h D d M) :precision binary64 0.0)
D = abs(D);
d = abs(d);
double code(double c0, double w, double h, double D, double d, double M) {
return 0.0;
}
NOTE: D should be positive before calling this function
NOTE: d should be positive before calling this function
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.0d0
end function
D = Math.abs(D);
d = Math.abs(d);
public static double code(double c0, double w, double h, double D, double d, double M) {
return 0.0;
}
D = abs(D) d = abs(d) def code(c0, w, h, D, d, M): return 0.0
D = abs(D) d = abs(d) function code(c0, w, h, D, d, M) return 0.0 end
D = abs(D) d = abs(d) function tmp = code(c0, w, h, D, d, M) tmp = 0.0; end
NOTE: D should be positive before calling this function NOTE: d should be positive before calling this function code[c0_, w_, h_, D_, d_, M_] := 0.0
\begin{array}{l}
D = |D|\\
d = |d|\\
\\
0
\end{array}
Initial program 20.3%
times-frac19.9%
fma-def19.9%
associate-/r*20.1%
difference-of-squares27.2%
Simplified33.2%
Taylor expanded in c0 around -inf 2.6%
associate-*r*2.6%
distribute-rgt1-in2.6%
metadata-eval2.6%
mul0-lft36.6%
metadata-eval36.6%
mul0-lft3.0%
metadata-eval3.0%
distribute-lft1-in3.0%
*-commutative3.0%
distribute-lft1-in3.0%
metadata-eval3.0%
mul0-lft36.6%
Simplified36.6%
Taylor expanded in c0 around 0 41.2%
Final simplification41.2%
herbie shell --seed 2023258
(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))))))