
(FPCore (c0 w h D d M) :precision binary64 (let* ((t_0 (/ (* c0 (* d d)) (* (* w h) (* D D))))) (* (/ c0 (* 2.0 w)) (+ t_0 (sqrt (- (* t_0 t_0) (* M M)))))))
double code(double c0, double w, double h, double D, double d, double M) {
double t_0 = (c0 * (d * d)) / ((w * h) * (D * D));
return (c0 / (2.0 * w)) * (t_0 + sqrt(((t_0 * t_0) - (M * M))));
}
real(8) function code(c0, w, h, d, d_1, m)
real(8), intent (in) :: c0
real(8), intent (in) :: w
real(8), intent (in) :: h
real(8), intent (in) :: d
real(8), intent (in) :: d_1
real(8), intent (in) :: m
real(8) :: t_0
t_0 = (c0 * (d_1 * d_1)) / ((w * h) * (d * d))
code = (c0 / (2.0d0 * w)) * (t_0 + sqrt(((t_0 * t_0) - (m * m))))
end function
public static double code(double c0, double w, double h, double D, double d, double M) {
double t_0 = (c0 * (d * d)) / ((w * h) * (D * D));
return (c0 / (2.0 * w)) * (t_0 + Math.sqrt(((t_0 * t_0) - (M * M))));
}
def code(c0, w, h, D, d, M): t_0 = (c0 * (d * d)) / ((w * h) * (D * D)) return (c0 / (2.0 * w)) * (t_0 + math.sqrt(((t_0 * t_0) - (M * M))))
function code(c0, w, h, D, d, M) t_0 = Float64(Float64(c0 * Float64(d * d)) / Float64(Float64(w * h) * Float64(D * D))) return Float64(Float64(c0 / Float64(2.0 * w)) * Float64(t_0 + sqrt(Float64(Float64(t_0 * t_0) - Float64(M * M))))) end
function tmp = code(c0, w, h, D, d, M) t_0 = (c0 * (d * d)) / ((w * h) * (D * D)); tmp = (c0 / (2.0 * w)) * (t_0 + sqrt(((t_0 * t_0) - (M * M)))); end
code[c0_, w_, h_, D_, d_, M_] := Block[{t$95$0 = N[(N[(c0 * N[(d * d), $MachinePrecision]), $MachinePrecision] / N[(N[(w * h), $MachinePrecision] * N[(D * D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, N[(N[(c0 / N[(2.0 * w), $MachinePrecision]), $MachinePrecision] * N[(t$95$0 + N[Sqrt[N[(N[(t$95$0 * t$95$0), $MachinePrecision] - N[(M * M), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)}\\
\frac{c0}{2 \cdot w} \cdot \left(t\_0 + \sqrt{t\_0 \cdot t\_0 - M \cdot M}\right)
\end{array}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 5 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (c0 w h D d M) :precision binary64 (let* ((t_0 (/ (* c0 (* d d)) (* (* w h) (* D D))))) (* (/ c0 (* 2.0 w)) (+ t_0 (sqrt (- (* t_0 t_0) (* M M)))))))
double code(double c0, double w, double h, double D, double d, double M) {
double t_0 = (c0 * (d * d)) / ((w * h) * (D * D));
return (c0 / (2.0 * w)) * (t_0 + sqrt(((t_0 * t_0) - (M * M))));
}
real(8) function code(c0, w, h, d, d_1, m)
real(8), intent (in) :: c0
real(8), intent (in) :: w
real(8), intent (in) :: h
real(8), intent (in) :: d
real(8), intent (in) :: d_1
real(8), intent (in) :: m
real(8) :: t_0
t_0 = (c0 * (d_1 * d_1)) / ((w * h) * (d * d))
code = (c0 / (2.0d0 * w)) * (t_0 + sqrt(((t_0 * t_0) - (m * m))))
end function
public static double code(double c0, double w, double h, double D, double d, double M) {
double t_0 = (c0 * (d * d)) / ((w * h) * (D * D));
return (c0 / (2.0 * w)) * (t_0 + Math.sqrt(((t_0 * t_0) - (M * M))));
}
def code(c0, w, h, D, d, M): t_0 = (c0 * (d * d)) / ((w * h) * (D * D)) return (c0 / (2.0 * w)) * (t_0 + math.sqrt(((t_0 * t_0) - (M * M))))
function code(c0, w, h, D, d, M) t_0 = Float64(Float64(c0 * Float64(d * d)) / Float64(Float64(w * h) * Float64(D * D))) return Float64(Float64(c0 / Float64(2.0 * w)) * Float64(t_0 + sqrt(Float64(Float64(t_0 * t_0) - Float64(M * M))))) end
function tmp = code(c0, w, h, D, d, M) t_0 = (c0 * (d * d)) / ((w * h) * (D * D)); tmp = (c0 / (2.0 * w)) * (t_0 + sqrt(((t_0 * t_0) - (M * M)))); end
code[c0_, w_, h_, D_, d_, M_] := Block[{t$95$0 = N[(N[(c0 * N[(d * d), $MachinePrecision]), $MachinePrecision] / N[(N[(w * h), $MachinePrecision] * N[(D * D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, N[(N[(c0 / N[(2.0 * w), $MachinePrecision]), $MachinePrecision] * N[(t$95$0 + N[Sqrt[N[(N[(t$95$0 * t$95$0), $MachinePrecision] - N[(M * M), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)}\\
\frac{c0}{2 \cdot w} \cdot \left(t\_0 + \sqrt{t\_0 \cdot t\_0 - M \cdot M}\right)
\end{array}
\end{array}
(FPCore (c0 w h D d M)
:precision binary64
(let* ((t_0 (/ (* c0 (* d d)) (* (* w h) (* D D))))
(t_1 (* (/ c0 (* 2.0 w)) (+ t_0 (sqrt (- (* t_0 t_0) (* M M)))))))
(if (<= t_1 INFINITY)
t_1
(* 0.25 (/ (* (pow D 2.0) (* h (pow M 2.0))) (pow d 2.0))))))
double code(double c0, double w, double h, double D, double d, double M) {
double t_0 = (c0 * (d * d)) / ((w * h) * (D * D));
double t_1 = (c0 / (2.0 * w)) * (t_0 + sqrt(((t_0 * t_0) - (M * M))));
double tmp;
if (t_1 <= ((double) INFINITY)) {
tmp = t_1;
} else {
tmp = 0.25 * ((pow(D, 2.0) * (h * pow(M, 2.0))) / pow(d, 2.0));
}
return tmp;
}
public static double code(double c0, double w, double h, double D, double d, double M) {
double t_0 = (c0 * (d * d)) / ((w * h) * (D * D));
double t_1 = (c0 / (2.0 * w)) * (t_0 + Math.sqrt(((t_0 * t_0) - (M * M))));
double tmp;
if (t_1 <= Double.POSITIVE_INFINITY) {
tmp = t_1;
} else {
tmp = 0.25 * ((Math.pow(D, 2.0) * (h * Math.pow(M, 2.0))) / Math.pow(d, 2.0));
}
return tmp;
}
def code(c0, w, h, D, d, M): t_0 = (c0 * (d * d)) / ((w * h) * (D * D)) t_1 = (c0 / (2.0 * w)) * (t_0 + math.sqrt(((t_0 * t_0) - (M * M)))) tmp = 0 if t_1 <= math.inf: tmp = t_1 else: tmp = 0.25 * ((math.pow(D, 2.0) * (h * math.pow(M, 2.0))) / math.pow(d, 2.0)) return tmp
function code(c0, w, h, D, d, M) t_0 = Float64(Float64(c0 * Float64(d * d)) / Float64(Float64(w * h) * Float64(D * D))) 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 <= Inf) tmp = t_1; else tmp = Float64(0.25 * Float64(Float64((D ^ 2.0) * Float64(h * (M ^ 2.0))) / (d ^ 2.0))); end return tmp end
function tmp_2 = code(c0, w, h, D, d, M) t_0 = (c0 * (d * d)) / ((w * h) * (D * D)); t_1 = (c0 / (2.0 * w)) * (t_0 + sqrt(((t_0 * t_0) - (M * M)))); tmp = 0.0; if (t_1 <= Inf) tmp = t_1; else tmp = 0.25 * (((D ^ 2.0) * (h * (M ^ 2.0))) / (d ^ 2.0)); end tmp_2 = tmp; end
code[c0_, w_, h_, D_, d_, M_] := Block[{t$95$0 = N[(N[(c0 * N[(d * d), $MachinePrecision]), $MachinePrecision] / N[(N[(w * h), $MachinePrecision] * N[(D * D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, 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, Infinity], t$95$1, N[(0.25 * N[(N[(N[Power[D, 2.0], $MachinePrecision] * N[(h * N[Power[M, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Power[d, 2.0], $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)}\\
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 \infty:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;0.25 \cdot \frac{{D}^{2} \cdot \left(h \cdot {M}^{2}\right)}{{d}^{2}}\\
\end{array}
\end{array}
if (*.f64 (/.f64 c0 (*.f64 #s(literal 2 binary64) w)) (+.f64 (/.f64 (*.f64 c0 (*.f64 d d)) (*.f64 (*.f64 w h) (*.f64 D D))) (sqrt.f64 (-.f64 (*.f64 (/.f64 (*.f64 c0 (*.f64 d d)) (*.f64 (*.f64 w h) (*.f64 D D))) (/.f64 (*.f64 c0 (*.f64 d d)) (*.f64 (*.f64 w h) (*.f64 D D)))) (*.f64 M M))))) < +inf.0Initial program 76.2%
if +inf.0 < (*.f64 (/.f64 c0 (*.f64 #s(literal 2 binary64) w)) (+.f64 (/.f64 (*.f64 c0 (*.f64 d d)) (*.f64 (*.f64 w h) (*.f64 D D))) (sqrt.f64 (-.f64 (*.f64 (/.f64 (*.f64 c0 (*.f64 d d)) (*.f64 (*.f64 w h) (*.f64 D D))) (/.f64 (*.f64 c0 (*.f64 d d)) (*.f64 (*.f64 w h) (*.f64 D D)))) (*.f64 M M))))) Initial program 0.0%
Simplified27.6%
fma-undefine27.6%
associate-*r/18.4%
*-commutative18.4%
associate-*r*17.6%
associate-*r*13.1%
associate-/l*12.4%
frac-times12.4%
Applied egg-rr9.3%
*-lft-identity9.3%
associate-*l/9.4%
associate-/l*9.4%
Simplified9.4%
pow1/29.4%
*-un-lft-identity9.4%
unpow-prod-down9.4%
metadata-eval9.4%
pow-prod-down0.0%
pow-prod-up2.2%
metadata-eval2.2%
metadata-eval2.2%
pow1/22.2%
*-commutative2.2%
Applied egg-rr2.2%
mul-1-neg2.2%
associate-*r/2.2%
times-frac2.2%
Simplified2.2%
Taylor expanded in c0 around inf 40.0%
Final simplification51.7%
(FPCore (c0 w h D d M)
:precision binary64
(let* ((t_0 (/ (* c0 (* d d)) (* (* w h) (* D D))))
(t_1 (* (/ c0 (* 2.0 w)) (+ t_0 (sqrt (- (* t_0 t_0) (* M M)))))))
(if (<= t_1 INFINITY) t_1 0.0)))
double code(double c0, double w, double h, double D, double d, double M) {
double t_0 = (c0 * (d * d)) / ((w * h) * (D * D));
double t_1 = (c0 / (2.0 * w)) * (t_0 + sqrt(((t_0 * t_0) - (M * M))));
double tmp;
if (t_1 <= ((double) INFINITY)) {
tmp = t_1;
} else {
tmp = 0.0;
}
return tmp;
}
public static double code(double c0, double w, double h, double D, double d, double M) {
double t_0 = (c0 * (d * d)) / ((w * h) * (D * D));
double t_1 = (c0 / (2.0 * w)) * (t_0 + Math.sqrt(((t_0 * t_0) - (M * M))));
double tmp;
if (t_1 <= Double.POSITIVE_INFINITY) {
tmp = t_1;
} else {
tmp = 0.0;
}
return tmp;
}
def code(c0, w, h, D, d, M): t_0 = (c0 * (d * d)) / ((w * h) * (D * D)) t_1 = (c0 / (2.0 * w)) * (t_0 + math.sqrt(((t_0 * t_0) - (M * M)))) tmp = 0 if t_1 <= math.inf: tmp = t_1 else: tmp = 0.0 return tmp
function code(c0, w, h, D, d, M) t_0 = Float64(Float64(c0 * Float64(d * d)) / Float64(Float64(w * h) * Float64(D * D))) 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 <= Inf) tmp = t_1; else tmp = 0.0; end return tmp end
function tmp_2 = code(c0, w, h, D, d, M) t_0 = (c0 * (d * d)) / ((w * h) * (D * D)); t_1 = (c0 / (2.0 * w)) * (t_0 + sqrt(((t_0 * t_0) - (M * M)))); tmp = 0.0; if (t_1 <= Inf) tmp = t_1; else tmp = 0.0; end tmp_2 = tmp; end
code[c0_, w_, h_, D_, d_, M_] := Block[{t$95$0 = N[(N[(c0 * N[(d * d), $MachinePrecision]), $MachinePrecision] / N[(N[(w * h), $MachinePrecision] * N[(D * D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, 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, Infinity], t$95$1, 0.0]]]
\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)}\\
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 \infty:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if (*.f64 (/.f64 c0 (*.f64 #s(literal 2 binary64) w)) (+.f64 (/.f64 (*.f64 c0 (*.f64 d d)) (*.f64 (*.f64 w h) (*.f64 D D))) (sqrt.f64 (-.f64 (*.f64 (/.f64 (*.f64 c0 (*.f64 d d)) (*.f64 (*.f64 w h) (*.f64 D D))) (/.f64 (*.f64 c0 (*.f64 d d)) (*.f64 (*.f64 w h) (*.f64 D D)))) (*.f64 M M))))) < +inf.0Initial program 76.2%
if +inf.0 < (*.f64 (/.f64 c0 (*.f64 #s(literal 2 binary64) w)) (+.f64 (/.f64 (*.f64 c0 (*.f64 d d)) (*.f64 (*.f64 w h) (*.f64 D D))) (sqrt.f64 (-.f64 (*.f64 (/.f64 (*.f64 c0 (*.f64 d d)) (*.f64 (*.f64 w h) (*.f64 D D))) (/.f64 (*.f64 c0 (*.f64 d d)) (*.f64 (*.f64 w h) (*.f64 D D)))) (*.f64 M M))))) Initial program 0.0%
Simplified27.6%
*-commutative27.6%
associate-*r*26.0%
associate-*r*21.9%
add-cube-cbrt21.9%
pow321.9%
associate-*r*26.0%
associate-*r*27.6%
*-commutative27.6%
*-commutative27.6%
associate-*r*26.0%
associate-*r*21.9%
associate-*l*26.2%
pow226.2%
Applied egg-rr26.2%
Taylor expanded in c0 around -inf 0.6%
associate-/l*0.6%
distribute-lft1-in0.6%
metadata-eval0.6%
mul0-lft26.7%
Simplified26.7%
Taylor expanded in c0 around 0 39.7%
(FPCore (c0 w h D d M)
:precision binary64
(let* ((t_0 (/ c0 (* w h))) (t_1 (* t_0 (/ (* d d) (* D D)))))
(if (or (<= c0 -7.8e+226) (not (<= c0 3.6e+206)))
(*
(/ c0 (* 2.0 w))
(+ (sqrt (- (* t_1 t_1) (* M M))) (* t_0 (* (/ d D) (/ d D)))))
0.0)))
double code(double c0, double w, double h, double D, double d, double M) {
double t_0 = c0 / (w * h);
double t_1 = t_0 * ((d * d) / (D * D));
double tmp;
if ((c0 <= -7.8e+226) || !(c0 <= 3.6e+206)) {
tmp = (c0 / (2.0 * w)) * (sqrt(((t_1 * t_1) - (M * M))) + (t_0 * ((d / D) * (d / D))));
} else {
tmp = 0.0;
}
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) :: tmp
t_0 = c0 / (w * h)
t_1 = t_0 * ((d_1 * d_1) / (d * d))
if ((c0 <= (-7.8d+226)) .or. (.not. (c0 <= 3.6d+206))) then
tmp = (c0 / (2.0d0 * w)) * (sqrt(((t_1 * t_1) - (m * m))) + (t_0 * ((d_1 / d) * (d_1 / d))))
else
tmp = 0.0d0
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 / (w * h);
double t_1 = t_0 * ((d * d) / (D * D));
double tmp;
if ((c0 <= -7.8e+226) || !(c0 <= 3.6e+206)) {
tmp = (c0 / (2.0 * w)) * (Math.sqrt(((t_1 * t_1) - (M * M))) + (t_0 * ((d / D) * (d / D))));
} else {
tmp = 0.0;
}
return tmp;
}
def code(c0, w, h, D, d, M): t_0 = c0 / (w * h) t_1 = t_0 * ((d * d) / (D * D)) tmp = 0 if (c0 <= -7.8e+226) or not (c0 <= 3.6e+206): tmp = (c0 / (2.0 * w)) * (math.sqrt(((t_1 * t_1) - (M * M))) + (t_0 * ((d / D) * (d / D)))) else: tmp = 0.0 return tmp
function code(c0, w, h, D, d, M) t_0 = Float64(c0 / Float64(w * h)) t_1 = Float64(t_0 * Float64(Float64(d * d) / Float64(D * D))) tmp = 0.0 if ((c0 <= -7.8e+226) || !(c0 <= 3.6e+206)) tmp = Float64(Float64(c0 / Float64(2.0 * w)) * Float64(sqrt(Float64(Float64(t_1 * t_1) - Float64(M * M))) + Float64(t_0 * Float64(Float64(d / D) * Float64(d / D))))); else tmp = 0.0; end return tmp end
function tmp_2 = code(c0, w, h, D, d, M) t_0 = c0 / (w * h); t_1 = t_0 * ((d * d) / (D * D)); tmp = 0.0; if ((c0 <= -7.8e+226) || ~((c0 <= 3.6e+206))) tmp = (c0 / (2.0 * w)) * (sqrt(((t_1 * t_1) - (M * M))) + (t_0 * ((d / D) * (d / D)))); else tmp = 0.0; end tmp_2 = tmp; end
code[c0_, w_, h_, D_, d_, M_] := Block[{t$95$0 = N[(c0 / N[(w * h), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 * N[(N[(d * d), $MachinePrecision] / N[(D * D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[c0, -7.8e+226], N[Not[LessEqual[c0, 3.6e+206]], $MachinePrecision]], N[(N[(c0 / N[(2.0 * w), $MachinePrecision]), $MachinePrecision] * N[(N[Sqrt[N[(N[(t$95$1 * t$95$1), $MachinePrecision] - N[(M * M), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] + N[(t$95$0 * N[(N[(d / D), $MachinePrecision] * N[(d / D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 0.0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{c0}{w \cdot h}\\
t_1 := t\_0 \cdot \frac{d \cdot d}{D \cdot D}\\
\mathbf{if}\;c0 \leq -7.8 \cdot 10^{+226} \lor \neg \left(c0 \leq 3.6 \cdot 10^{+206}\right):\\
\;\;\;\;\frac{c0}{2 \cdot w} \cdot \left(\sqrt{t\_1 \cdot t\_1 - M \cdot M} + t\_0 \cdot \left(\frac{d}{D} \cdot \frac{d}{D}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if c0 < -7.79999999999999967e226 or 3.60000000000000028e206 < c0 Initial program 36.3%
Simplified37.9%
times-frac37.8%
Applied egg-rr37.8%
if -7.79999999999999967e226 < c0 < 3.60000000000000028e206Initial program 21.2%
Simplified38.8%
*-commutative38.8%
associate-*r*37.3%
associate-*r*34.8%
add-cube-cbrt34.8%
pow334.8%
associate-*r*37.4%
associate-*r*38.8%
*-commutative38.8%
*-commutative38.8%
associate-*r*37.4%
associate-*r*34.8%
associate-*l*37.0%
pow237.0%
Applied egg-rr37.0%
Taylor expanded in c0 around -inf 6.3%
associate-/l*6.3%
distribute-lft1-in6.3%
metadata-eval6.3%
mul0-lft29.5%
Simplified29.5%
Taylor expanded in c0 around 0 37.1%
Final simplification37.2%
(FPCore (c0 w h D d M)
:precision binary64
(let* ((t_0 (/ c0 (* w h)))
(t_1 (* t_0 (/ (* d d) (* D D))))
(t_2 (sqrt (- (* t_1 t_1) (* M M))))
(t_3 (/ c0 (* 2.0 w))))
(if (<= c0 -1.8e+228)
(* t_3 (+ t_1 t_2))
(if (<= c0 7e+205) 0.0 (* t_3 (+ t_2 (* t_0 (* (/ d D) (/ d D)))))))))
double code(double c0, double w, double h, double D, double d, double M) {
double t_0 = c0 / (w * h);
double t_1 = t_0 * ((d * d) / (D * D));
double t_2 = sqrt(((t_1 * t_1) - (M * M)));
double t_3 = c0 / (2.0 * w);
double tmp;
if (c0 <= -1.8e+228) {
tmp = t_3 * (t_1 + t_2);
} else if (c0 <= 7e+205) {
tmp = 0.0;
} else {
tmp = t_3 * (t_2 + (t_0 * ((d / D) * (d / D))));
}
return tmp;
}
real(8) function code(c0, w, h, d, d_1, m)
real(8), intent (in) :: c0
real(8), intent (in) :: w
real(8), intent (in) :: h
real(8), intent (in) :: d
real(8), intent (in) :: d_1
real(8), intent (in) :: m
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: tmp
t_0 = c0 / (w * h)
t_1 = t_0 * ((d_1 * d_1) / (d * d))
t_2 = sqrt(((t_1 * t_1) - (m * m)))
t_3 = c0 / (2.0d0 * w)
if (c0 <= (-1.8d+228)) then
tmp = t_3 * (t_1 + t_2)
else if (c0 <= 7d+205) then
tmp = 0.0d0
else
tmp = t_3 * (t_2 + (t_0 * ((d_1 / d) * (d_1 / d))))
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 / (w * h);
double t_1 = t_0 * ((d * d) / (D * D));
double t_2 = Math.sqrt(((t_1 * t_1) - (M * M)));
double t_3 = c0 / (2.0 * w);
double tmp;
if (c0 <= -1.8e+228) {
tmp = t_3 * (t_1 + t_2);
} else if (c0 <= 7e+205) {
tmp = 0.0;
} else {
tmp = t_3 * (t_2 + (t_0 * ((d / D) * (d / D))));
}
return tmp;
}
def code(c0, w, h, D, d, M): t_0 = c0 / (w * h) t_1 = t_0 * ((d * d) / (D * D)) t_2 = math.sqrt(((t_1 * t_1) - (M * M))) t_3 = c0 / (2.0 * w) tmp = 0 if c0 <= -1.8e+228: tmp = t_3 * (t_1 + t_2) elif c0 <= 7e+205: tmp = 0.0 else: tmp = t_3 * (t_2 + (t_0 * ((d / D) * (d / D)))) return tmp
function code(c0, w, h, D, d, M) t_0 = Float64(c0 / Float64(w * h)) t_1 = Float64(t_0 * Float64(Float64(d * d) / Float64(D * D))) t_2 = sqrt(Float64(Float64(t_1 * t_1) - Float64(M * M))) t_3 = Float64(c0 / Float64(2.0 * w)) tmp = 0.0 if (c0 <= -1.8e+228) tmp = Float64(t_3 * Float64(t_1 + t_2)); elseif (c0 <= 7e+205) tmp = 0.0; else tmp = Float64(t_3 * Float64(t_2 + Float64(t_0 * Float64(Float64(d / D) * Float64(d / D))))); end return tmp end
function tmp_2 = code(c0, w, h, D, d, M) t_0 = c0 / (w * h); t_1 = t_0 * ((d * d) / (D * D)); t_2 = sqrt(((t_1 * t_1) - (M * M))); t_3 = c0 / (2.0 * w); tmp = 0.0; if (c0 <= -1.8e+228) tmp = t_3 * (t_1 + t_2); elseif (c0 <= 7e+205) tmp = 0.0; else tmp = t_3 * (t_2 + (t_0 * ((d / D) * (d / D)))); end tmp_2 = tmp; end
code[c0_, w_, h_, D_, d_, M_] := Block[{t$95$0 = N[(c0 / N[(w * h), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 * N[(N[(d * d), $MachinePrecision] / N[(D * D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Sqrt[N[(N[(t$95$1 * t$95$1), $MachinePrecision] - N[(M * M), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[(c0 / N[(2.0 * w), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[c0, -1.8e+228], N[(t$95$3 * N[(t$95$1 + t$95$2), $MachinePrecision]), $MachinePrecision], If[LessEqual[c0, 7e+205], 0.0, N[(t$95$3 * N[(t$95$2 + N[(t$95$0 * N[(N[(d / D), $MachinePrecision] * N[(d / D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{c0}{w \cdot h}\\
t_1 := t\_0 \cdot \frac{d \cdot d}{D \cdot D}\\
t_2 := \sqrt{t\_1 \cdot t\_1 - M \cdot M}\\
t_3 := \frac{c0}{2 \cdot w}\\
\mathbf{if}\;c0 \leq -1.8 \cdot 10^{+228}:\\
\;\;\;\;t\_3 \cdot \left(t\_1 + t\_2\right)\\
\mathbf{elif}\;c0 \leq 7 \cdot 10^{+205}:\\
\;\;\;\;0\\
\mathbf{else}:\\
\;\;\;\;t\_3 \cdot \left(t\_2 + t\_0 \cdot \left(\frac{d}{D} \cdot \frac{d}{D}\right)\right)\\
\end{array}
\end{array}
if c0 < -1.8e228Initial program 30.9%
Simplified30.9%
if -1.8e228 < c0 < 6.9999999999999996e205Initial program 21.2%
Simplified38.8%
*-commutative38.8%
associate-*r*37.3%
associate-*r*34.8%
add-cube-cbrt34.8%
pow334.8%
associate-*r*37.4%
associate-*r*38.8%
*-commutative38.8%
*-commutative38.8%
associate-*r*37.4%
associate-*r*34.8%
associate-*l*37.0%
pow237.0%
Applied egg-rr37.0%
Taylor expanded in c0 around -inf 6.3%
associate-/l*6.3%
distribute-lft1-in6.3%
metadata-eval6.3%
mul0-lft29.5%
Simplified29.5%
Taylor expanded in c0 around 0 37.1%
if 6.9999999999999996e205 < c0 Initial program 40.9%
Simplified43.8%
times-frac43.8%
Applied egg-rr43.8%
Final simplification37.3%
(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 24.7%
Simplified42.5%
*-commutative42.5%
associate-*r*41.3%
associate-*r*38.6%
add-cube-cbrt38.6%
pow338.6%
associate-*r*41.3%
associate-*r*42.5%
*-commutative42.5%
*-commutative42.5%
associate-*r*41.3%
associate-*r*38.6%
associate-*l*41.2%
pow241.2%
Applied egg-rr41.2%
Taylor expanded in c0 around -inf 4.9%
associate-/l*4.9%
distribute-lft1-in4.9%
metadata-eval4.9%
mul0-lft22.7%
Simplified22.7%
Taylor expanded in c0 around 0 31.8%
herbie shell --seed 2024151
(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))))))