
(FPCore (c0 w h D d M) :precision binary64 (let* ((t_0 (/ (* c0 (* d d)) (* (* w h) (* D D))))) (* (/ c0 (* 2.0 w)) (+ t_0 (sqrt (- (* t_0 t_0) (* M M)))))))
double code(double c0, double w, double h, double D, double d, double M) {
double t_0 = (c0 * (d * d)) / ((w * h) * (D * D));
return (c0 / (2.0 * w)) * (t_0 + sqrt(((t_0 * t_0) - (M * M))));
}
real(8) function code(c0, w, h, d, d_1, m)
real(8), intent (in) :: c0
real(8), intent (in) :: w
real(8), intent (in) :: h
real(8), intent (in) :: d
real(8), intent (in) :: d_1
real(8), intent (in) :: m
real(8) :: t_0
t_0 = (c0 * (d_1 * d_1)) / ((w * h) * (d * d))
code = (c0 / (2.0d0 * w)) * (t_0 + sqrt(((t_0 * t_0) - (m * m))))
end function
public static double code(double c0, double w, double h, double D, double d, double M) {
double t_0 = (c0 * (d * d)) / ((w * h) * (D * D));
return (c0 / (2.0 * w)) * (t_0 + Math.sqrt(((t_0 * t_0) - (M * M))));
}
def code(c0, w, h, D, d, M): t_0 = (c0 * (d * d)) / ((w * h) * (D * D)) return (c0 / (2.0 * w)) * (t_0 + math.sqrt(((t_0 * t_0) - (M * M))))
function code(c0, w, h, D, d, M) t_0 = Float64(Float64(c0 * Float64(d * d)) / Float64(Float64(w * h) * Float64(D * D))) return Float64(Float64(c0 / Float64(2.0 * w)) * Float64(t_0 + sqrt(Float64(Float64(t_0 * t_0) - Float64(M * M))))) end
function tmp = code(c0, w, h, D, d, M) t_0 = (c0 * (d * d)) / ((w * h) * (D * D)); tmp = (c0 / (2.0 * w)) * (t_0 + sqrt(((t_0 * t_0) - (M * M)))); end
code[c0_, w_, h_, D_, d_, M_] := Block[{t$95$0 = N[(N[(c0 * N[(d * d), $MachinePrecision]), $MachinePrecision] / N[(N[(w * h), $MachinePrecision] * N[(D * D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, N[(N[(c0 / N[(2.0 * w), $MachinePrecision]), $MachinePrecision] * N[(t$95$0 + N[Sqrt[N[(N[(t$95$0 * t$95$0), $MachinePrecision] - N[(M * M), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)}\\
\frac{c0}{2 \cdot w} \cdot \left(t_0 + \sqrt{t_0 \cdot t_0 - M \cdot M}\right)
\end{array}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 7 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (c0 w h D d M) :precision binary64 (let* ((t_0 (/ (* c0 (* d d)) (* (* w h) (* D D))))) (* (/ c0 (* 2.0 w)) (+ t_0 (sqrt (- (* t_0 t_0) (* M M)))))))
double code(double c0, double w, double h, double D, double d, double M) {
double t_0 = (c0 * (d * d)) / ((w * h) * (D * D));
return (c0 / (2.0 * w)) * (t_0 + sqrt(((t_0 * t_0) - (M * M))));
}
real(8) function code(c0, w, h, d, d_1, m)
real(8), intent (in) :: c0
real(8), intent (in) :: w
real(8), intent (in) :: h
real(8), intent (in) :: d
real(8), intent (in) :: d_1
real(8), intent (in) :: m
real(8) :: t_0
t_0 = (c0 * (d_1 * d_1)) / ((w * h) * (d * d))
code = (c0 / (2.0d0 * w)) * (t_0 + sqrt(((t_0 * t_0) - (m * m))))
end function
public static double code(double c0, double w, double h, double D, double d, double M) {
double t_0 = (c0 * (d * d)) / ((w * h) * (D * D));
return (c0 / (2.0 * w)) * (t_0 + Math.sqrt(((t_0 * t_0) - (M * M))));
}
def code(c0, w, h, D, d, M): t_0 = (c0 * (d * d)) / ((w * h) * (D * D)) return (c0 / (2.0 * w)) * (t_0 + math.sqrt(((t_0 * t_0) - (M * M))))
function code(c0, w, h, D, d, M) t_0 = Float64(Float64(c0 * Float64(d * d)) / Float64(Float64(w * h) * Float64(D * D))) return Float64(Float64(c0 / Float64(2.0 * w)) * Float64(t_0 + sqrt(Float64(Float64(t_0 * t_0) - Float64(M * M))))) end
function tmp = code(c0, w, h, D, d, M) t_0 = (c0 * (d * d)) / ((w * h) * (D * D)); tmp = (c0 / (2.0 * w)) * (t_0 + sqrt(((t_0 * t_0) - (M * M)))); end
code[c0_, w_, h_, D_, d_, M_] := Block[{t$95$0 = N[(N[(c0 * N[(d * d), $MachinePrecision]), $MachinePrecision] / N[(N[(w * h), $MachinePrecision] * N[(D * D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, N[(N[(c0 / N[(2.0 * w), $MachinePrecision]), $MachinePrecision] * N[(t$95$0 + N[Sqrt[N[(N[(t$95$0 * t$95$0), $MachinePrecision] - N[(M * M), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)}\\
\frac{c0}{2 \cdot w} \cdot \left(t_0 + \sqrt{t_0 \cdot t_0 - M \cdot M}\right)
\end{array}
\end{array}
(FPCore (c0 w h D d M)
:precision binary64
(let* ((t_0 (/ c0 (* 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.25 (* (* (/ D d) (/ D d)) (* h (* M M)))))))
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.25 * (((D / d) * (D / d)) * (h * (M * M)));
}
return tmp;
}
public static double code(double c0, double w, double h, double D, double d, double M) {
double t_0 = c0 / (2.0 * w);
double t_1 = (c0 * (d * d)) / ((w * h) * (D * D));
double 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.25 * (((D / d) * (D / d)) * (h * (M * M)));
}
return tmp;
}
def code(c0, w, h, D, d, M): t_0 = c0 / (2.0 * w) t_1 = (c0 * (d * d)) / ((w * h) * (D * D)) 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.25 * (((D / d) * (D / d)) * (h * (M * M))) return tmp
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 = Float64(0.25 * Float64(Float64(Float64(D / d) * Float64(D / d)) * Float64(h * Float64(M * M)))); end return tmp end
function tmp_2 = code(c0, w, h, D, d, M) t_0 = c0 / (2.0 * w); t_1 = (c0 * (d * d)) / ((w * h) * (D * D)); 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.25 * (((D / d) * (D / d)) * (h * (M * M))); end tmp_2 = tmp; end
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], N[(0.25 * N[(N[(N[(D / d), $MachinePrecision] * N[(D / d), $MachinePrecision]), $MachinePrecision] * N[(h * N[(M * M), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\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.25 \cdot \left(\left(\frac{D}{d} \cdot \frac{D}{d}\right) \cdot \left(h \cdot \left(M \cdot M\right)\right)\right)\\
\end{array}
\end{array}
if (*.f64 (/.f64 c0 (*.f64 2 w)) (+.f64 (/.f64 (*.f64 c0 (*.f64 d d)) (*.f64 (*.f64 w h) (*.f64 D D))) (sqrt.f64 (-.f64 (*.f64 (/.f64 (*.f64 c0 (*.f64 d d)) (*.f64 (*.f64 w h) (*.f64 D D))) (/.f64 (*.f64 c0 (*.f64 d d)) (*.f64 (*.f64 w h) (*.f64 D D)))) (*.f64 M M))))) < +inf.0Initial program 76.3%
times-frac71.5%
fma-def70.4%
associate-/r*70.4%
difference-of-squares70.4%
Simplified70.4%
fma-udef71.5%
associate-/l/70.4%
frac-times71.7%
pow271.7%
fma-udef71.7%
associate-/l/70.6%
times-frac70.6%
associate-/l/70.6%
times-frac70.6%
Applied egg-rr73.7%
Taylor expanded in c0 around inf 76.9%
times-frac74.1%
unpow274.1%
unpow274.1%
times-frac78.5%
unpow278.5%
*-commutative78.5%
Simplified78.5%
*-commutative78.5%
associate-*r/78.6%
Applied egg-rr78.6%
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%
Taylor expanded in c0 around -inf 1.2%
fma-def1.2%
associate-/l*1.2%
*-commutative1.2%
unpow21.2%
unpow21.2%
unpow21.2%
mul-1-neg1.2%
*-commutative1.2%
Simplified33.2%
Taylor expanded in c0 around 0 47.0%
associate-/l*48.1%
*-commutative48.1%
unpow248.1%
unpow248.1%
*-commutative48.1%
unpow248.1%
Simplified48.1%
Taylor expanded in D around 0 47.0%
unpow247.0%
associate-*l/47.0%
unpow247.0%
unpow247.0%
times-frac59.9%
Simplified59.9%
Final simplification66.2%
(FPCore (c0 w h D d M)
:precision binary64
(let* ((t_0 (/ c0 (* 2.0 w)))
(t_1 (* t_0 (* 2.0 (* (pow (/ d D) 2.0) (/ (/ c0 w) h)))))
(t_2 (* 0.25 (* (* (/ D d) (/ D d)) (* h (* M M))))))
(if (<= M 1.04e-280)
t_1
(if (<= M 6.2e-145)
t_2
(if (<= M 2.7e-117)
(* t_0 (* 2.0 (* (/ c0 (* w h)) (* (/ d D) (/ d D)))))
(if (<= M 0.000108) t_2 t_1))))))
double code(double c0, double w, double h, double D, double d, double M) {
double t_0 = c0 / (2.0 * w);
double t_1 = t_0 * (2.0 * (pow((d / D), 2.0) * ((c0 / w) / h)));
double t_2 = 0.25 * (((D / d) * (D / d)) * (h * (M * M)));
double tmp;
if (M <= 1.04e-280) {
tmp = t_1;
} else if (M <= 6.2e-145) {
tmp = t_2;
} else if (M <= 2.7e-117) {
tmp = t_0 * (2.0 * ((c0 / (w * h)) * ((d / D) * (d / D))));
} else if (M <= 0.000108) {
tmp = t_2;
} else {
tmp = t_1;
}
return tmp;
}
real(8) function code(c0, w, h, d, d_1, m)
real(8), intent (in) :: c0
real(8), intent (in) :: w
real(8), intent (in) :: h
real(8), intent (in) :: d
real(8), intent (in) :: d_1
real(8), intent (in) :: m
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = c0 / (2.0d0 * w)
t_1 = t_0 * (2.0d0 * (((d_1 / d) ** 2.0d0) * ((c0 / w) / h)))
t_2 = 0.25d0 * (((d / d_1) * (d / d_1)) * (h * (m * m)))
if (m <= 1.04d-280) then
tmp = t_1
else if (m <= 6.2d-145) then
tmp = t_2
else if (m <= 2.7d-117) then
tmp = t_0 * (2.0d0 * ((c0 / (w * h)) * ((d_1 / d) * (d_1 / d))))
else if (m <= 0.000108d0) then
tmp = t_2
else
tmp = t_1
end if
code = tmp
end function
public static double code(double c0, double w, double h, double D, double d, double M) {
double t_0 = c0 / (2.0 * w);
double t_1 = t_0 * (2.0 * (Math.pow((d / D), 2.0) * ((c0 / w) / h)));
double t_2 = 0.25 * (((D / d) * (D / d)) * (h * (M * M)));
double tmp;
if (M <= 1.04e-280) {
tmp = t_1;
} else if (M <= 6.2e-145) {
tmp = t_2;
} else if (M <= 2.7e-117) {
tmp = t_0 * (2.0 * ((c0 / (w * h)) * ((d / D) * (d / D))));
} else if (M <= 0.000108) {
tmp = t_2;
} else {
tmp = t_1;
}
return tmp;
}
def code(c0, w, h, D, d, M): t_0 = c0 / (2.0 * w) t_1 = t_0 * (2.0 * (math.pow((d / D), 2.0) * ((c0 / w) / h))) t_2 = 0.25 * (((D / d) * (D / d)) * (h * (M * M))) tmp = 0 if M <= 1.04e-280: tmp = t_1 elif M <= 6.2e-145: tmp = t_2 elif M <= 2.7e-117: tmp = t_0 * (2.0 * ((c0 / (w * h)) * ((d / D) * (d / D)))) elif M <= 0.000108: tmp = t_2 else: tmp = t_1 return tmp
function code(c0, w, h, D, d, M) t_0 = Float64(c0 / Float64(2.0 * w)) t_1 = Float64(t_0 * Float64(2.0 * Float64((Float64(d / D) ^ 2.0) * Float64(Float64(c0 / w) / h)))) t_2 = Float64(0.25 * Float64(Float64(Float64(D / d) * Float64(D / d)) * Float64(h * Float64(M * M)))) tmp = 0.0 if (M <= 1.04e-280) tmp = t_1; elseif (M <= 6.2e-145) tmp = t_2; elseif (M <= 2.7e-117) tmp = Float64(t_0 * Float64(2.0 * Float64(Float64(c0 / Float64(w * h)) * Float64(Float64(d / D) * Float64(d / D))))); elseif (M <= 0.000108) tmp = t_2; else tmp = t_1; end return tmp end
function tmp_2 = code(c0, w, h, D, d, M) t_0 = c0 / (2.0 * w); t_1 = t_0 * (2.0 * (((d / D) ^ 2.0) * ((c0 / w) / h))); t_2 = 0.25 * (((D / d) * (D / d)) * (h * (M * M))); tmp = 0.0; if (M <= 1.04e-280) tmp = t_1; elseif (M <= 6.2e-145) tmp = t_2; elseif (M <= 2.7e-117) tmp = t_0 * (2.0 * ((c0 / (w * h)) * ((d / D) * (d / D)))); elseif (M <= 0.000108) tmp = t_2; else tmp = t_1; end tmp_2 = tmp; end
code[c0_, w_, h_, D_, d_, M_] := Block[{t$95$0 = N[(c0 / N[(2.0 * w), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 * N[(2.0 * N[(N[Power[N[(d / D), $MachinePrecision], 2.0], $MachinePrecision] * N[(N[(c0 / w), $MachinePrecision] / h), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(0.25 * N[(N[(N[(D / d), $MachinePrecision] * N[(D / d), $MachinePrecision]), $MachinePrecision] * N[(h * N[(M * M), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[M, 1.04e-280], t$95$1, If[LessEqual[M, 6.2e-145], t$95$2, If[LessEqual[M, 2.7e-117], N[(t$95$0 * N[(2.0 * N[(N[(c0 / N[(w * h), $MachinePrecision]), $MachinePrecision] * N[(N[(d / D), $MachinePrecision] * N[(d / D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[M, 0.000108], t$95$2, t$95$1]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{c0}{2 \cdot w}\\
t_1 := t_0 \cdot \left(2 \cdot \left({\left(\frac{d}{D}\right)}^{2} \cdot \frac{\frac{c0}{w}}{h}\right)\right)\\
t_2 := 0.25 \cdot \left(\left(\frac{D}{d} \cdot \frac{D}{d}\right) \cdot \left(h \cdot \left(M \cdot M\right)\right)\right)\\
\mathbf{if}\;M \leq 1.04 \cdot 10^{-280}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;M \leq 6.2 \cdot 10^{-145}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;M \leq 2.7 \cdot 10^{-117}:\\
\;\;\;\;t_0 \cdot \left(2 \cdot \left(\frac{c0}{w \cdot h} \cdot \left(\frac{d}{D} \cdot \frac{d}{D}\right)\right)\right)\\
\mathbf{elif}\;M \leq 0.000108:\\
\;\;\;\;t_2\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if M < 1.04000000000000002e-280 or 1.08e-4 < M Initial program 25.7%
times-frac25.2%
fma-def24.7%
associate-/r*24.7%
difference-of-squares31.3%
Simplified34.1%
fma-udef34.6%
associate-/l/32.0%
frac-times34.9%
pow234.9%
fma-udef34.9%
associate-/l/32.1%
times-frac31.5%
associate-/l/31.4%
times-frac31.4%
Applied egg-rr34.6%
Taylor expanded in c0 around inf 33.2%
times-frac33.5%
unpow233.5%
unpow233.5%
times-frac43.8%
unpow243.8%
*-commutative43.8%
Simplified43.8%
expm1-log1p-u42.2%
expm1-udef35.1%
Applied egg-rr35.1%
expm1-def42.2%
expm1-log1p43.8%
associate-/r*44.8%
Simplified44.8%
if 1.04000000000000002e-280 < M < 6.20000000000000001e-145 or 2.70000000000000003e-117 < M < 1.08e-4Initial program 25.1%
Taylor expanded in c0 around -inf 11.2%
fma-def11.2%
associate-/l*11.2%
*-commutative11.2%
unpow211.2%
unpow211.2%
unpow211.2%
mul-1-neg11.2%
*-commutative11.2%
Simplified40.7%
Taylor expanded in c0 around 0 46.4%
associate-/l*48.1%
*-commutative48.1%
unpow248.1%
unpow248.1%
*-commutative48.1%
unpow248.1%
Simplified48.1%
Taylor expanded in D around 0 46.4%
unpow246.4%
associate-*l/48.1%
unpow248.1%
unpow248.1%
times-frac63.0%
Simplified63.0%
if 6.20000000000000001e-145 < M < 2.70000000000000003e-117Initial program 26.7%
times-frac1.7%
fma-def1.7%
associate-/r*1.7%
difference-of-squares1.7%
Simplified1.7%
fma-udef1.7%
associate-/l/1.7%
frac-times2.0%
pow22.0%
fma-udef2.0%
associate-/l/1.7%
times-frac1.7%
associate-/l/1.7%
times-frac1.7%
Applied egg-rr51.7%
Taylor expanded in c0 around inf 26.7%
times-frac1.7%
unpow21.7%
unpow21.7%
times-frac50.8%
unpow250.8%
*-commutative50.8%
Simplified50.8%
unpow250.8%
Applied egg-rr50.8%
Final simplification48.8%
(FPCore (c0 w h D d M)
:precision binary64
(if (or (<= M 8.8e-285)
(not (or (<= M 8e-146) (and (not (<= M 2.8e-117)) (<= M 0.0021)))))
(* (/ c0 (* 2.0 w)) (* 2.0 (* (/ c0 (* w h)) (* (/ d D) (/ d D)))))
(* 0.25 (* (* (/ D d) (/ D d)) (* h (* M M))))))
double code(double c0, double w, double h, double D, double d, double M) {
double tmp;
if ((M <= 8.8e-285) || !((M <= 8e-146) || (!(M <= 2.8e-117) && (M <= 0.0021)))) {
tmp = (c0 / (2.0 * w)) * (2.0 * ((c0 / (w * h)) * ((d / D) * (d / D))));
} else {
tmp = 0.25 * (((D / d) * (D / d)) * (h * (M * M)));
}
return tmp;
}
real(8) function code(c0, w, h, d, d_1, m)
real(8), intent (in) :: c0
real(8), intent (in) :: w
real(8), intent (in) :: h
real(8), intent (in) :: d
real(8), intent (in) :: d_1
real(8), intent (in) :: m
real(8) :: tmp
if ((m <= 8.8d-285) .or. (.not. (m <= 8d-146) .or. (.not. (m <= 2.8d-117)) .and. (m <= 0.0021d0))) then
tmp = (c0 / (2.0d0 * w)) * (2.0d0 * ((c0 / (w * h)) * ((d_1 / d) * (d_1 / d))))
else
tmp = 0.25d0 * (((d / d_1) * (d / d_1)) * (h * (m * m)))
end if
code = tmp
end function
public static double code(double c0, double w, double h, double D, double d, double M) {
double tmp;
if ((M <= 8.8e-285) || !((M <= 8e-146) || (!(M <= 2.8e-117) && (M <= 0.0021)))) {
tmp = (c0 / (2.0 * w)) * (2.0 * ((c0 / (w * h)) * ((d / D) * (d / D))));
} else {
tmp = 0.25 * (((D / d) * (D / d)) * (h * (M * M)));
}
return tmp;
}
def code(c0, w, h, D, d, M): tmp = 0 if (M <= 8.8e-285) or not ((M <= 8e-146) or (not (M <= 2.8e-117) and (M <= 0.0021))): tmp = (c0 / (2.0 * w)) * (2.0 * ((c0 / (w * h)) * ((d / D) * (d / D)))) else: tmp = 0.25 * (((D / d) * (D / d)) * (h * (M * M))) return tmp
function code(c0, w, h, D, d, M) tmp = 0.0 if ((M <= 8.8e-285) || !((M <= 8e-146) || (!(M <= 2.8e-117) && (M <= 0.0021)))) tmp = Float64(Float64(c0 / Float64(2.0 * w)) * Float64(2.0 * Float64(Float64(c0 / Float64(w * h)) * Float64(Float64(d / D) * Float64(d / D))))); else tmp = Float64(0.25 * Float64(Float64(Float64(D / d) * Float64(D / d)) * Float64(h * Float64(M * M)))); end return tmp end
function tmp_2 = code(c0, w, h, D, d, M) tmp = 0.0; if ((M <= 8.8e-285) || ~(((M <= 8e-146) || (~((M <= 2.8e-117)) && (M <= 0.0021))))) tmp = (c0 / (2.0 * w)) * (2.0 * ((c0 / (w * h)) * ((d / D) * (d / D)))); else tmp = 0.25 * (((D / d) * (D / d)) * (h * (M * M))); end tmp_2 = tmp; end
code[c0_, w_, h_, D_, d_, M_] := If[Or[LessEqual[M, 8.8e-285], N[Not[Or[LessEqual[M, 8e-146], And[N[Not[LessEqual[M, 2.8e-117]], $MachinePrecision], LessEqual[M, 0.0021]]]], $MachinePrecision]], N[(N[(c0 / N[(2.0 * w), $MachinePrecision]), $MachinePrecision] * N[(2.0 * N[(N[(c0 / N[(w * h), $MachinePrecision]), $MachinePrecision] * N[(N[(d / D), $MachinePrecision] * N[(d / D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.25 * N[(N[(N[(D / d), $MachinePrecision] * N[(D / d), $MachinePrecision]), $MachinePrecision] * N[(h * N[(M * M), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;M \leq 8.8 \cdot 10^{-285} \lor \neg \left(M \leq 8 \cdot 10^{-146} \lor \neg \left(M \leq 2.8 \cdot 10^{-117}\right) \land M \leq 0.0021\right):\\
\;\;\;\;\frac{c0}{2 \cdot w} \cdot \left(2 \cdot \left(\frac{c0}{w \cdot h} \cdot \left(\frac{d}{D} \cdot \frac{d}{D}\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;0.25 \cdot \left(\left(\frac{D}{d} \cdot \frac{D}{d}\right) \cdot \left(h \cdot \left(M \cdot M\right)\right)\right)\\
\end{array}
\end{array}
if M < 8.7999999999999996e-285 or 8.00000000000000021e-146 < M < 2.8e-117 or 0.00209999999999999987 < M Initial program 25.8%
times-frac24.7%
fma-def24.3%
associate-/r*24.3%
difference-of-squares30.8%
Simplified33.4%
fma-udef33.9%
associate-/l/31.4%
frac-times34.3%
pow234.3%
fma-udef34.3%
associate-/l/31.5%
times-frac30.9%
associate-/l/30.8%
times-frac30.8%
Applied egg-rr34.9%
Taylor expanded in c0 around inf 33.0%
times-frac32.9%
unpow232.9%
unpow232.9%
times-frac43.9%
unpow243.9%
*-commutative43.9%
Simplified43.9%
unpow235.5%
Applied egg-rr43.9%
if 8.7999999999999996e-285 < M < 8.00000000000000021e-146 or 2.8e-117 < M < 0.00209999999999999987Initial program 25.1%
Taylor expanded in c0 around -inf 11.2%
fma-def11.2%
associate-/l*11.2%
*-commutative11.2%
unpow211.2%
unpow211.2%
unpow211.2%
mul-1-neg11.2%
*-commutative11.2%
Simplified40.7%
Taylor expanded in c0 around 0 46.4%
associate-/l*48.1%
*-commutative48.1%
unpow248.1%
unpow248.1%
*-commutative48.1%
unpow248.1%
Simplified48.1%
Taylor expanded in D around 0 46.4%
unpow246.4%
associate-*l/48.1%
unpow248.1%
unpow248.1%
times-frac63.0%
Simplified63.0%
Final simplification48.0%
(FPCore (c0 w h D d M)
:precision binary64
(if (or (<= M 9.6e-285)
(and (not (<= M 1.8e-144))
(or (<= M 1.2e-117) (not (<= M 1.6e+139)))))
(* (* (/ d D) (/ d D)) (* (/ c0 h) (/ c0 (* w w))))
(* 0.25 (* (* (/ D d) (/ D d)) (* h (* M M))))))
double code(double c0, double w, double h, double D, double d, double M) {
double tmp;
if ((M <= 9.6e-285) || (!(M <= 1.8e-144) && ((M <= 1.2e-117) || !(M <= 1.6e+139)))) {
tmp = ((d / D) * (d / D)) * ((c0 / h) * (c0 / (w * w)));
} else {
tmp = 0.25 * (((D / d) * (D / d)) * (h * (M * M)));
}
return tmp;
}
real(8) function code(c0, w, h, d, d_1, m)
real(8), intent (in) :: c0
real(8), intent (in) :: w
real(8), intent (in) :: h
real(8), intent (in) :: d
real(8), intent (in) :: d_1
real(8), intent (in) :: m
real(8) :: tmp
if ((m <= 9.6d-285) .or. (.not. (m <= 1.8d-144)) .and. (m <= 1.2d-117) .or. (.not. (m <= 1.6d+139))) then
tmp = ((d_1 / d) * (d_1 / d)) * ((c0 / h) * (c0 / (w * w)))
else
tmp = 0.25d0 * (((d / d_1) * (d / d_1)) * (h * (m * m)))
end if
code = tmp
end function
public static double code(double c0, double w, double h, double D, double d, double M) {
double tmp;
if ((M <= 9.6e-285) || (!(M <= 1.8e-144) && ((M <= 1.2e-117) || !(M <= 1.6e+139)))) {
tmp = ((d / D) * (d / D)) * ((c0 / h) * (c0 / (w * w)));
} else {
tmp = 0.25 * (((D / d) * (D / d)) * (h * (M * M)));
}
return tmp;
}
def code(c0, w, h, D, d, M): tmp = 0 if (M <= 9.6e-285) or (not (M <= 1.8e-144) and ((M <= 1.2e-117) or not (M <= 1.6e+139))): tmp = ((d / D) * (d / D)) * ((c0 / h) * (c0 / (w * w))) else: tmp = 0.25 * (((D / d) * (D / d)) * (h * (M * M))) return tmp
function code(c0, w, h, D, d, M) tmp = 0.0 if ((M <= 9.6e-285) || (!(M <= 1.8e-144) && ((M <= 1.2e-117) || !(M <= 1.6e+139)))) tmp = Float64(Float64(Float64(d / D) * Float64(d / D)) * Float64(Float64(c0 / h) * Float64(c0 / Float64(w * w)))); else tmp = Float64(0.25 * Float64(Float64(Float64(D / d) * Float64(D / d)) * Float64(h * Float64(M * M)))); end return tmp end
function tmp_2 = code(c0, w, h, D, d, M) tmp = 0.0; if ((M <= 9.6e-285) || (~((M <= 1.8e-144)) && ((M <= 1.2e-117) || ~((M <= 1.6e+139))))) tmp = ((d / D) * (d / D)) * ((c0 / h) * (c0 / (w * w))); else tmp = 0.25 * (((D / d) * (D / d)) * (h * (M * M))); end tmp_2 = tmp; end
code[c0_, w_, h_, D_, d_, M_] := If[Or[LessEqual[M, 9.6e-285], And[N[Not[LessEqual[M, 1.8e-144]], $MachinePrecision], Or[LessEqual[M, 1.2e-117], N[Not[LessEqual[M, 1.6e+139]], $MachinePrecision]]]], N[(N[(N[(d / D), $MachinePrecision] * N[(d / D), $MachinePrecision]), $MachinePrecision] * N[(N[(c0 / h), $MachinePrecision] * N[(c0 / N[(w * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.25 * N[(N[(N[(D / d), $MachinePrecision] * N[(D / d), $MachinePrecision]), $MachinePrecision] * N[(h * N[(M * M), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;M \leq 9.6 \cdot 10^{-285} \lor \neg \left(M \leq 1.8 \cdot 10^{-144}\right) \land \left(M \leq 1.2 \cdot 10^{-117} \lor \neg \left(M \leq 1.6 \cdot 10^{+139}\right)\right):\\
\;\;\;\;\left(\frac{d}{D} \cdot \frac{d}{D}\right) \cdot \left(\frac{c0}{h} \cdot \frac{c0}{w \cdot w}\right)\\
\mathbf{else}:\\
\;\;\;\;0.25 \cdot \left(\left(\frac{D}{d} \cdot \frac{D}{d}\right) \cdot \left(h \cdot \left(M \cdot M\right)\right)\right)\\
\end{array}
\end{array}
if M < 9.6000000000000001e-285 or 1.8e-144 < M < 1.20000000000000007e-117 or 1.6000000000000001e139 < M Initial program 23.8%
times-frac22.6%
fma-def22.0%
associate-/r*22.0%
difference-of-squares29.5%
Simplified32.6%
fma-udef33.1%
associate-/l/30.2%
frac-times33.5%
pow233.5%
fma-udef33.5%
associate-/l/30.4%
times-frac29.7%
associate-/l/29.6%
times-frac29.6%
Applied egg-rr33.2%
Taylor expanded in c0 around inf 24.8%
times-frac25.3%
unpow225.3%
unpow225.3%
times-frac33.7%
unpow233.7%
unpow233.7%
*-commutative33.7%
unpow233.7%
Simplified33.7%
Taylor expanded in c0 around 0 33.7%
associate-/r*34.2%
unpow234.2%
associate-*r/37.8%
unpow237.8%
associate-*l/36.0%
Simplified36.0%
unpow236.0%
Applied egg-rr36.0%
if 9.6000000000000001e-285 < M < 1.8e-144 or 1.20000000000000007e-117 < M < 1.6000000000000001e139Initial program 29.7%
Taylor expanded in c0 around -inf 7.7%
fma-def7.7%
associate-/l*7.7%
*-commutative7.7%
unpow27.7%
unpow27.7%
unpow27.7%
mul-1-neg7.7%
*-commutative7.7%
Simplified31.7%
Taylor expanded in c0 around 0 41.8%
associate-/l*41.8%
*-commutative41.8%
unpow241.8%
unpow241.8%
*-commutative41.8%
unpow241.8%
Simplified41.8%
Taylor expanded in D around 0 41.8%
unpow241.8%
associate-*l/41.9%
unpow241.9%
unpow241.9%
times-frac54.5%
Simplified54.5%
Final simplification41.8%
(FPCore (c0 w h D d M) :precision binary64 (if (or (<= (* D D) 5e-230) (not (<= (* D D) 2.5e-169))) (* 0.25 (* (* (/ D d) (/ D d)) (* h (* M M)))) (* (* (/ d D) (/ d D)) (/ (* c0 c0) (* h (* w w))))))
double code(double c0, double w, double h, double D, double d, double M) {
double tmp;
if (((D * D) <= 5e-230) || !((D * D) <= 2.5e-169)) {
tmp = 0.25 * (((D / d) * (D / d)) * (h * (M * M)));
} else {
tmp = ((d / D) * (d / D)) * ((c0 * c0) / (h * (w * w)));
}
return tmp;
}
real(8) function code(c0, w, h, d, d_1, m)
real(8), intent (in) :: c0
real(8), intent (in) :: w
real(8), intent (in) :: h
real(8), intent (in) :: d
real(8), intent (in) :: d_1
real(8), intent (in) :: m
real(8) :: tmp
if (((d * d) <= 5d-230) .or. (.not. ((d * d) <= 2.5d-169))) then
tmp = 0.25d0 * (((d / d_1) * (d / d_1)) * (h * (m * m)))
else
tmp = ((d_1 / d) * (d_1 / d)) * ((c0 * c0) / (h * (w * w)))
end if
code = tmp
end function
public static double code(double c0, double w, double h, double D, double d, double M) {
double tmp;
if (((D * D) <= 5e-230) || !((D * D) <= 2.5e-169)) {
tmp = 0.25 * (((D / d) * (D / d)) * (h * (M * M)));
} else {
tmp = ((d / D) * (d / D)) * ((c0 * c0) / (h * (w * w)));
}
return tmp;
}
def code(c0, w, h, D, d, M): tmp = 0 if ((D * D) <= 5e-230) or not ((D * D) <= 2.5e-169): tmp = 0.25 * (((D / d) * (D / d)) * (h * (M * M))) else: tmp = ((d / D) * (d / D)) * ((c0 * c0) / (h * (w * w))) return tmp
function code(c0, w, h, D, d, M) tmp = 0.0 if ((Float64(D * D) <= 5e-230) || !(Float64(D * D) <= 2.5e-169)) tmp = Float64(0.25 * Float64(Float64(Float64(D / d) * Float64(D / d)) * Float64(h * Float64(M * M)))); else tmp = Float64(Float64(Float64(d / D) * Float64(d / D)) * Float64(Float64(c0 * c0) / Float64(h * Float64(w * w)))); end return tmp end
function tmp_2 = code(c0, w, h, D, d, M) tmp = 0.0; if (((D * D) <= 5e-230) || ~(((D * D) <= 2.5e-169))) tmp = 0.25 * (((D / d) * (D / d)) * (h * (M * M))); else tmp = ((d / D) * (d / D)) * ((c0 * c0) / (h * (w * w))); end tmp_2 = tmp; end
code[c0_, w_, h_, D_, d_, M_] := If[Or[LessEqual[N[(D * D), $MachinePrecision], 5e-230], N[Not[LessEqual[N[(D * D), $MachinePrecision], 2.5e-169]], $MachinePrecision]], N[(0.25 * N[(N[(N[(D / d), $MachinePrecision] * N[(D / d), $MachinePrecision]), $MachinePrecision] * N[(h * N[(M * M), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $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]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;D \cdot D \leq 5 \cdot 10^{-230} \lor \neg \left(D \cdot D \leq 2.5 \cdot 10^{-169}\right):\\
\;\;\;\;0.25 \cdot \left(\left(\frac{D}{d} \cdot \frac{D}{d}\right) \cdot \left(h \cdot \left(M \cdot M\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\frac{d}{D} \cdot \frac{d}{D}\right) \cdot \frac{c0 \cdot c0}{h \cdot \left(w \cdot w\right)}\\
\end{array}
\end{array}
if (*.f64 D D) < 5.00000000000000035e-230 or 2.5000000000000001e-169 < (*.f64 D D) Initial program 23.4%
Taylor expanded in c0 around -inf 3.6%
fma-def3.6%
associate-/l*3.1%
*-commutative3.1%
unpow23.1%
unpow23.1%
unpow23.1%
mul-1-neg3.1%
*-commutative3.1%
Simplified26.8%
Taylor expanded in c0 around 0 36.3%
associate-/l*37.1%
*-commutative37.1%
unpow237.1%
unpow237.1%
*-commutative37.1%
unpow237.1%
Simplified37.1%
Taylor expanded in D around 0 36.3%
unpow236.3%
associate-*l/37.1%
unpow237.1%
unpow237.1%
times-frac46.9%
Simplified46.9%
if 5.00000000000000035e-230 < (*.f64 D D) < 2.5000000000000001e-169Initial program 53.2%
times-frac47.9%
fma-def47.9%
associate-/r*47.9%
difference-of-squares63.7%
Simplified63.7%
fma-udef63.7%
associate-/l/63.7%
frac-times63.9%
pow263.9%
fma-udef63.9%
associate-/l/63.9%
times-frac63.9%
associate-/l/63.9%
times-frac63.9%
Applied egg-rr48.1%
Taylor expanded in c0 around inf 58.5%
times-frac68.4%
unpow268.4%
unpow268.4%
times-frac68.7%
unpow268.7%
unpow268.7%
*-commutative68.7%
unpow268.7%
Simplified68.7%
unpow268.6%
Applied egg-rr68.7%
Final simplification48.5%
(FPCore (c0 w h D d M) :precision binary64 (* 0.25 (* (* (/ D d) (/ D d)) (* h (* M M)))))
double code(double c0, double w, double h, double D, double d, double M) {
return 0.25 * (((D / d) * (D / d)) * (h * (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
code = 0.25d0 * (((d / d_1) * (d / d_1)) * (h * (m * m)))
end function
public static double code(double c0, double w, double h, double D, double d, double M) {
return 0.25 * (((D / d) * (D / d)) * (h * (M * M)));
}
def code(c0, w, h, D, d, M): return 0.25 * (((D / d) * (D / d)) * (h * (M * M)))
function code(c0, w, h, D, d, M) return Float64(0.25 * Float64(Float64(Float64(D / d) * Float64(D / d)) * Float64(h * Float64(M * M)))) end
function tmp = code(c0, w, h, D, d, M) tmp = 0.25 * (((D / d) * (D / d)) * (h * (M * M))); end
code[c0_, w_, h_, D_, d_, M_] := N[(0.25 * N[(N[(N[(D / d), $MachinePrecision] * N[(D / d), $MachinePrecision]), $MachinePrecision] * N[(h * N[(M * M), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
0.25 \cdot \left(\left(\frac{D}{d} \cdot \frac{D}{d}\right) \cdot \left(h \cdot \left(M \cdot M\right)\right)\right)
\end{array}
Initial program 25.6%
Taylor expanded in c0 around -inf 4.9%
fma-def4.9%
associate-/l*4.5%
*-commutative4.5%
unpow24.5%
unpow24.5%
unpow24.5%
mul-1-neg4.5%
*-commutative4.5%
Simplified26.5%
Taylor expanded in c0 around 0 36.1%
associate-/l*36.8%
*-commutative36.8%
unpow236.8%
unpow236.8%
*-commutative36.8%
unpow236.8%
Simplified36.8%
Taylor expanded in D around 0 36.1%
unpow236.1%
associate-*l/36.0%
unpow236.0%
unpow236.0%
times-frac45.1%
Simplified45.1%
Final simplification45.1%
(FPCore (c0 w h D d M) :precision binary64 0.0)
double code(double c0, double w, double h, double D, double d, double M) {
return 0.0;
}
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
public static double code(double c0, double w, double h, double D, double d, double M) {
return 0.0;
}
def code(c0, w, h, D, d, M): return 0.0
function code(c0, w, h, D, d, M) return 0.0 end
function tmp = code(c0, w, h, D, d, M) tmp = 0.0; end
code[c0_, w_, h_, D_, d_, M_] := 0.0
\begin{array}{l}
\\
0
\end{array}
Initial program 25.6%
times-frac24.0%
fma-def23.7%
associate-/r*23.7%
difference-of-squares28.8%
Simplified31.7%
Taylor expanded in c0 around -inf 4.5%
mul-1-neg4.5%
*-commutative4.5%
distribute-rgt1-in4.5%
metadata-eval4.5%
mul0-lft32.3%
distribute-rgt-neg-in32.3%
metadata-eval32.3%
Simplified32.3%
Taylor expanded in c0 around 0 38.6%
Final simplification38.6%
herbie shell --seed 2023234
(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))))))