
(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 (/ 1.0 (/ d D)))
(t_1 (/ c0 (* 2.0 w)))
(t_2 (* t_1 (* 2.0 (/ (/ (/ c0 w) h) (* t_0 t_0)))))
(t_3 (/ (* c0 (* d d)) (* (* w h) (* D D))))
(t_4 (* t_1 (+ t_3 (sqrt (- (* t_3 t_3) (* M M)))))))
(if (<= t_4 -5e-95)
t_2
(if (<= t_4 0.0)
(* -0.5 (* -0.5 (/ (* h (* (pow D 2.0) (pow M 2.0))) (pow d 2.0))))
(if (<= t_4 INFINITY)
t_2
(* -0.5 (/ (pow M 2.0) (* (/ (pow (/ d D) 2.0) h) -2.0))))))))
double code(double c0, double w, double h, double D, double d, double M) {
double t_0 = 1.0 / (d / D);
double t_1 = c0 / (2.0 * w);
double t_2 = t_1 * (2.0 * (((c0 / w) / h) / (t_0 * t_0)));
double t_3 = (c0 * (d * d)) / ((w * h) * (D * D));
double t_4 = t_1 * (t_3 + sqrt(((t_3 * t_3) - (M * M))));
double tmp;
if (t_4 <= -5e-95) {
tmp = t_2;
} else if (t_4 <= 0.0) {
tmp = -0.5 * (-0.5 * ((h * (pow(D, 2.0) * pow(M, 2.0))) / pow(d, 2.0)));
} else if (t_4 <= ((double) INFINITY)) {
tmp = t_2;
} else {
tmp = -0.5 * (pow(M, 2.0) / ((pow((d / D), 2.0) / h) * -2.0));
}
return tmp;
}
public static double code(double c0, double w, double h, double D, double d, double M) {
double t_0 = 1.0 / (d / D);
double t_1 = c0 / (2.0 * w);
double t_2 = t_1 * (2.0 * (((c0 / w) / h) / (t_0 * t_0)));
double t_3 = (c0 * (d * d)) / ((w * h) * (D * D));
double t_4 = t_1 * (t_3 + Math.sqrt(((t_3 * t_3) - (M * M))));
double tmp;
if (t_4 <= -5e-95) {
tmp = t_2;
} else if (t_4 <= 0.0) {
tmp = -0.5 * (-0.5 * ((h * (Math.pow(D, 2.0) * Math.pow(M, 2.0))) / Math.pow(d, 2.0)));
} else if (t_4 <= Double.POSITIVE_INFINITY) {
tmp = t_2;
} else {
tmp = -0.5 * (Math.pow(M, 2.0) / ((Math.pow((d / D), 2.0) / h) * -2.0));
}
return tmp;
}
def code(c0, w, h, D, d, M): t_0 = 1.0 / (d / D) t_1 = c0 / (2.0 * w) t_2 = t_1 * (2.0 * (((c0 / w) / h) / (t_0 * t_0))) t_3 = (c0 * (d * d)) / ((w * h) * (D * D)) t_4 = t_1 * (t_3 + math.sqrt(((t_3 * t_3) - (M * M)))) tmp = 0 if t_4 <= -5e-95: tmp = t_2 elif t_4 <= 0.0: tmp = -0.5 * (-0.5 * ((h * (math.pow(D, 2.0) * math.pow(M, 2.0))) / math.pow(d, 2.0))) elif t_4 <= math.inf: tmp = t_2 else: tmp = -0.5 * (math.pow(M, 2.0) / ((math.pow((d / D), 2.0) / h) * -2.0)) return tmp
function code(c0, w, h, D, d, M) t_0 = Float64(1.0 / Float64(d / D)) t_1 = Float64(c0 / Float64(2.0 * w)) t_2 = Float64(t_1 * Float64(2.0 * Float64(Float64(Float64(c0 / w) / h) / Float64(t_0 * t_0)))) t_3 = Float64(Float64(c0 * Float64(d * d)) / Float64(Float64(w * h) * Float64(D * D))) t_4 = Float64(t_1 * Float64(t_3 + sqrt(Float64(Float64(t_3 * t_3) - Float64(M * M))))) tmp = 0.0 if (t_4 <= -5e-95) tmp = t_2; elseif (t_4 <= 0.0) tmp = Float64(-0.5 * Float64(-0.5 * Float64(Float64(h * Float64((D ^ 2.0) * (M ^ 2.0))) / (d ^ 2.0)))); elseif (t_4 <= Inf) tmp = t_2; else tmp = Float64(-0.5 * Float64((M ^ 2.0) / Float64(Float64((Float64(d / D) ^ 2.0) / h) * -2.0))); end return tmp end
function tmp_2 = code(c0, w, h, D, d, M) t_0 = 1.0 / (d / D); t_1 = c0 / (2.0 * w); t_2 = t_1 * (2.0 * (((c0 / w) / h) / (t_0 * t_0))); t_3 = (c0 * (d * d)) / ((w * h) * (D * D)); t_4 = t_1 * (t_3 + sqrt(((t_3 * t_3) - (M * M)))); tmp = 0.0; if (t_4 <= -5e-95) tmp = t_2; elseif (t_4 <= 0.0) tmp = -0.5 * (-0.5 * ((h * ((D ^ 2.0) * (M ^ 2.0))) / (d ^ 2.0))); elseif (t_4 <= Inf) tmp = t_2; else tmp = -0.5 * ((M ^ 2.0) / ((((d / D) ^ 2.0) / h) * -2.0)); end tmp_2 = tmp; end
code[c0_, w_, h_, D_, d_, M_] := Block[{t$95$0 = N[(1.0 / N[(d / D), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(c0 / N[(2.0 * w), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(t$95$1 * N[(2.0 * N[(N[(N[(c0 / w), $MachinePrecision] / h), $MachinePrecision] / N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(N[(c0 * N[(d * d), $MachinePrecision]), $MachinePrecision] / N[(N[(w * h), $MachinePrecision] * N[(D * D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$4 = N[(t$95$1 * 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, -5e-95], t$95$2, If[LessEqual[t$95$4, 0.0], N[(-0.5 * N[(-0.5 * N[(N[(h * N[(N[Power[D, 2.0], $MachinePrecision] * N[Power[M, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Power[d, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$4, Infinity], t$95$2, N[(-0.5 * N[(N[Power[M, 2.0], $MachinePrecision] / N[(N[(N[Power[N[(d / D), $MachinePrecision], 2.0], $MachinePrecision] / h), $MachinePrecision] * -2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{1}{\frac{d}{D}}\\
t_1 := \frac{c0}{2 \cdot w}\\
t_2 := t_1 \cdot \left(2 \cdot \frac{\frac{\frac{c0}{w}}{h}}{t_0 \cdot t_0}\right)\\
t_3 := \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)}\\
t_4 := t_1 \cdot \left(t_3 + \sqrt{t_3 \cdot t_3 - M \cdot M}\right)\\
\mathbf{if}\;t_4 \leq -5 \cdot 10^{-95}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;t_4 \leq 0:\\
\;\;\;\;-0.5 \cdot \left(-0.5 \cdot \frac{h \cdot \left({D}^{2} \cdot {M}^{2}\right)}{{d}^{2}}\right)\\
\mathbf{elif}\;t_4 \leq \infty:\\
\;\;\;\;t_2\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{{M}^{2}}{\frac{{\left(\frac{d}{D}\right)}^{2}}{h} \cdot -2}\\
\end{array}
\end{array}
if (*.f64 (/.f64 c0 (*.f64 2 w)) (+.f64 (/.f64 (*.f64 c0 (*.f64 d d)) (*.f64 (*.f64 w h) (*.f64 D D))) (sqrt.f64 (-.f64 (*.f64 (/.f64 (*.f64 c0 (*.f64 d d)) (*.f64 (*.f64 w h) (*.f64 D D))) (/.f64 (*.f64 c0 (*.f64 d d)) (*.f64 (*.f64 w h) (*.f64 D D)))) (*.f64 M M))))) < -4.9999999999999998e-95 or -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 77.5%
Simplified76.0%
Taylor expanded in c0 around inf 78.7%
*-commutative78.7%
associate-/l/77.4%
associate-*l/75.9%
associate-/l*77.3%
*-commutative77.3%
Simplified77.3%
expm1-log1p-u77.1%
expm1-udef73.3%
clear-num73.3%
unpow273.3%
unpow273.3%
frac-times73.3%
pow273.3%
pow-flip73.3%
metadata-eval73.3%
Applied egg-rr73.3%
expm1-def81.9%
expm1-log1p82.2%
Simplified82.2%
associate-/l/84.7%
div-inv84.6%
Applied egg-rr84.6%
associate-*r/84.7%
*-rgt-identity84.7%
Simplified84.7%
metadata-eval84.7%
pow-prod-up84.7%
unpow-184.7%
unpow-184.7%
Applied egg-rr84.7%
if -4.9999999999999998e-95 < (*.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 59.6%
Simplified59.4%
Applied egg-rr31.9%
associate--r-37.7%
+-inverses37.7%
*-commutative37.7%
Simplified37.8%
Taylor expanded in c0 around -inf 54.3%
associate-/r*54.3%
associate-*r/54.3%
neg-mul-154.3%
associate-/r*54.3%
Simplified54.3%
Taylor expanded in d around 0 68.5%
*-commutative68.5%
*-commutative68.5%
associate-*l*68.6%
*-commutative68.6%
Simplified68.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%
Simplified2.5%
Applied egg-rr3.5%
associate--r-5.9%
+-inverses27.6%
*-commutative27.6%
Simplified23.2%
Taylor expanded in c0 around -inf 31.1%
associate-/r*27.5%
associate-*r/27.5%
neg-mul-127.5%
associate-/r*28.2%
Simplified28.2%
Taylor expanded in w around 0 42.9%
sub-neg42.9%
mul-1-neg42.9%
distribute-rgt-out42.9%
associate-/r*43.3%
unpow243.3%
unpow243.3%
times-frac51.0%
unpow251.0%
metadata-eval51.0%
Simplified51.0%
Final simplification62.1%
(FPCore (c0 w h D d M)
:precision binary64
(let* ((t_0 (/ 1.0 (/ d D)))
(t_1 (/ c0 (* 2.0 w)))
(t_2 (/ (* c0 (* d d)) (* (* w h) (* D D)))))
(if (<= (* t_1 (+ t_2 (sqrt (- (* t_2 t_2) (* M M))))) INFINITY)
(* t_1 (* 2.0 (/ (/ (/ c0 w) h) (* t_0 t_0))))
(* -0.5 (/ (pow M 2.0) (* (/ (pow (/ d D) 2.0) h) -2.0))))))
double code(double c0, double w, double h, double D, double d, double M) {
double t_0 = 1.0 / (d / D);
double t_1 = c0 / (2.0 * w);
double t_2 = (c0 * (d * d)) / ((w * h) * (D * D));
double tmp;
if ((t_1 * (t_2 + sqrt(((t_2 * t_2) - (M * M))))) <= ((double) INFINITY)) {
tmp = t_1 * (2.0 * (((c0 / w) / h) / (t_0 * t_0)));
} else {
tmp = -0.5 * (pow(M, 2.0) / ((pow((d / D), 2.0) / h) * -2.0));
}
return tmp;
}
public static double code(double c0, double w, double h, double D, double d, double M) {
double t_0 = 1.0 / (d / D);
double t_1 = c0 / (2.0 * w);
double t_2 = (c0 * (d * d)) / ((w * h) * (D * D));
double tmp;
if ((t_1 * (t_2 + Math.sqrt(((t_2 * t_2) - (M * M))))) <= Double.POSITIVE_INFINITY) {
tmp = t_1 * (2.0 * (((c0 / w) / h) / (t_0 * t_0)));
} else {
tmp = -0.5 * (Math.pow(M, 2.0) / ((Math.pow((d / D), 2.0) / h) * -2.0));
}
return tmp;
}
def code(c0, w, h, D, d, M): t_0 = 1.0 / (d / D) t_1 = c0 / (2.0 * w) t_2 = (c0 * (d * d)) / ((w * h) * (D * D)) tmp = 0 if (t_1 * (t_2 + math.sqrt(((t_2 * t_2) - (M * M))))) <= math.inf: tmp = t_1 * (2.0 * (((c0 / w) / h) / (t_0 * t_0))) else: tmp = -0.5 * (math.pow(M, 2.0) / ((math.pow((d / D), 2.0) / h) * -2.0)) return tmp
function code(c0, w, h, D, d, M) t_0 = Float64(1.0 / Float64(d / D)) t_1 = Float64(c0 / Float64(2.0 * w)) t_2 = Float64(Float64(c0 * Float64(d * d)) / Float64(Float64(w * h) * Float64(D * D))) tmp = 0.0 if (Float64(t_1 * Float64(t_2 + sqrt(Float64(Float64(t_2 * t_2) - Float64(M * M))))) <= Inf) tmp = Float64(t_1 * Float64(2.0 * Float64(Float64(Float64(c0 / w) / h) / Float64(t_0 * t_0)))); else tmp = Float64(-0.5 * Float64((M ^ 2.0) / Float64(Float64((Float64(d / D) ^ 2.0) / h) * -2.0))); end return tmp end
function tmp_2 = code(c0, w, h, D, d, M) t_0 = 1.0 / (d / D); t_1 = c0 / (2.0 * w); t_2 = (c0 * (d * d)) / ((w * h) * (D * D)); tmp = 0.0; if ((t_1 * (t_2 + sqrt(((t_2 * t_2) - (M * M))))) <= Inf) tmp = t_1 * (2.0 * (((c0 / w) / h) / (t_0 * t_0))); else tmp = -0.5 * ((M ^ 2.0) / ((((d / D) ^ 2.0) / h) * -2.0)); end tmp_2 = tmp; end
code[c0_, w_, h_, D_, d_, M_] := Block[{t$95$0 = N[(1.0 / N[(d / D), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(c0 / N[(2.0 * w), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(c0 * N[(d * d), $MachinePrecision]), $MachinePrecision] / N[(N[(w * h), $MachinePrecision] * N[(D * D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(t$95$1 * N[(t$95$2 + N[Sqrt[N[(N[(t$95$2 * t$95$2), $MachinePrecision] - N[(M * M), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], Infinity], N[(t$95$1 * N[(2.0 * N[(N[(N[(c0 / w), $MachinePrecision] / h), $MachinePrecision] / N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-0.5 * N[(N[Power[M, 2.0], $MachinePrecision] / N[(N[(N[Power[N[(d / D), $MachinePrecision], 2.0], $MachinePrecision] / h), $MachinePrecision] * -2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{1}{\frac{d}{D}}\\
t_1 := \frac{c0}{2 \cdot w}\\
t_2 := \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)}\\
\mathbf{if}\;t_1 \cdot \left(t_2 + \sqrt{t_2 \cdot t_2 - M \cdot M}\right) \leq \infty:\\
\;\;\;\;t_1 \cdot \left(2 \cdot \frac{\frac{\frac{c0}{w}}{h}}{t_0 \cdot t_0}\right)\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{{M}^{2}}{\frac{{\left(\frac{d}{D}\right)}^{2}}{h} \cdot -2}\\
\end{array}
\end{array}
if (*.f64 (/.f64 c0 (*.f64 2 w)) (+.f64 (/.f64 (*.f64 c0 (*.f64 d d)) (*.f64 (*.f64 w h) (*.f64 D D))) (sqrt.f64 (-.f64 (*.f64 (/.f64 (*.f64 c0 (*.f64 d d)) (*.f64 (*.f64 w h) (*.f64 D D))) (/.f64 (*.f64 c0 (*.f64 d d)) (*.f64 (*.f64 w h) (*.f64 D D)))) (*.f64 M M))))) < +inf.0Initial program 74.4%
Simplified73.1%
Taylor expanded in c0 around inf 71.9%
*-commutative71.9%
associate-/l/70.8%
associate-*l/69.6%
associate-/l*71.0%
*-commutative71.0%
Simplified71.0%
expm1-log1p-u70.8%
expm1-udef64.3%
clear-num64.3%
unpow264.3%
unpow264.3%
frac-times65.3%
pow265.3%
pow-flip65.3%
metadata-eval65.3%
Applied egg-rr65.3%
expm1-def75.7%
expm1-log1p76.0%
Simplified76.0%
associate-/l/77.0%
div-inv77.0%
Applied egg-rr77.0%
associate-*r/77.0%
*-rgt-identity77.0%
Simplified77.0%
metadata-eval77.0%
pow-prod-up77.0%
unpow-177.0%
unpow-177.0%
Applied egg-rr77.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%
Simplified2.5%
Applied egg-rr3.5%
associate--r-5.9%
+-inverses27.6%
*-commutative27.6%
Simplified23.2%
Taylor expanded in c0 around -inf 31.1%
associate-/r*27.5%
associate-*r/27.5%
neg-mul-127.5%
associate-/r*28.2%
Simplified28.2%
Taylor expanded in w around 0 42.9%
sub-neg42.9%
mul-1-neg42.9%
distribute-rgt-out42.9%
associate-/r*43.3%
unpow243.3%
unpow243.3%
times-frac51.0%
unpow251.0%
metadata-eval51.0%
Simplified51.0%
Final simplification60.4%
(FPCore (c0 w h D d M)
:precision binary64
(let* ((t_0 (/ 1.0 (/ d D)))
(t_1 (/ c0 (* 2.0 w)))
(t_2 (/ (* c0 (* d d)) (* (* w h) (* D D)))))
(if (<= (* t_1 (+ t_2 (sqrt (- (* t_2 t_2) (* M M))))) INFINITY)
(* t_1 (* 2.0 (/ (/ (/ c0 w) h) (* t_0 t_0))))
0.0)))
double code(double c0, double w, double h, double D, double d, double M) {
double t_0 = 1.0 / (d / D);
double t_1 = c0 / (2.0 * w);
double t_2 = (c0 * (d * d)) / ((w * h) * (D * D));
double tmp;
if ((t_1 * (t_2 + sqrt(((t_2 * t_2) - (M * M))))) <= ((double) INFINITY)) {
tmp = t_1 * (2.0 * (((c0 / w) / h) / (t_0 * t_0)));
} 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 = 1.0 / (d / D);
double t_1 = c0 / (2.0 * w);
double t_2 = (c0 * (d * d)) / ((w * h) * (D * D));
double tmp;
if ((t_1 * (t_2 + Math.sqrt(((t_2 * t_2) - (M * M))))) <= Double.POSITIVE_INFINITY) {
tmp = t_1 * (2.0 * (((c0 / w) / h) / (t_0 * t_0)));
} else {
tmp = 0.0;
}
return tmp;
}
def code(c0, w, h, D, d, M): t_0 = 1.0 / (d / D) t_1 = c0 / (2.0 * w) t_2 = (c0 * (d * d)) / ((w * h) * (D * D)) tmp = 0 if (t_1 * (t_2 + math.sqrt(((t_2 * t_2) - (M * M))))) <= math.inf: tmp = t_1 * (2.0 * (((c0 / w) / h) / (t_0 * t_0))) else: tmp = 0.0 return tmp
function code(c0, w, h, D, d, M) t_0 = Float64(1.0 / Float64(d / D)) t_1 = Float64(c0 / Float64(2.0 * w)) t_2 = Float64(Float64(c0 * Float64(d * d)) / Float64(Float64(w * h) * Float64(D * D))) tmp = 0.0 if (Float64(t_1 * Float64(t_2 + sqrt(Float64(Float64(t_2 * t_2) - Float64(M * M))))) <= Inf) tmp = Float64(t_1 * Float64(2.0 * Float64(Float64(Float64(c0 / w) / h) / Float64(t_0 * t_0)))); else tmp = 0.0; end return tmp end
function tmp_2 = code(c0, w, h, D, d, M) t_0 = 1.0 / (d / D); t_1 = c0 / (2.0 * w); t_2 = (c0 * (d * d)) / ((w * h) * (D * D)); tmp = 0.0; if ((t_1 * (t_2 + sqrt(((t_2 * t_2) - (M * M))))) <= Inf) tmp = t_1 * (2.0 * (((c0 / w) / h) / (t_0 * t_0))); else tmp = 0.0; end tmp_2 = tmp; end
code[c0_, w_, h_, D_, d_, M_] := Block[{t$95$0 = N[(1.0 / N[(d / D), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(c0 / N[(2.0 * w), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(c0 * N[(d * d), $MachinePrecision]), $MachinePrecision] / N[(N[(w * h), $MachinePrecision] * N[(D * D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(t$95$1 * N[(t$95$2 + N[Sqrt[N[(N[(t$95$2 * t$95$2), $MachinePrecision] - N[(M * M), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], Infinity], N[(t$95$1 * N[(2.0 * N[(N[(N[(c0 / w), $MachinePrecision] / h), $MachinePrecision] / N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 0.0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{1}{\frac{d}{D}}\\
t_1 := \frac{c0}{2 \cdot w}\\
t_2 := \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)}\\
\mathbf{if}\;t_1 \cdot \left(t_2 + \sqrt{t_2 \cdot t_2 - M \cdot M}\right) \leq \infty:\\
\;\;\;\;t_1 \cdot \left(2 \cdot \frac{\frac{\frac{c0}{w}}{h}}{t_0 \cdot t_0}\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.4%
Simplified73.1%
Taylor expanded in c0 around inf 71.9%
*-commutative71.9%
associate-/l/70.8%
associate-*l/69.6%
associate-/l*71.0%
*-commutative71.0%
Simplified71.0%
expm1-log1p-u70.8%
expm1-udef64.3%
clear-num64.3%
unpow264.3%
unpow264.3%
frac-times65.3%
pow265.3%
pow-flip65.3%
metadata-eval65.3%
Applied egg-rr65.3%
expm1-def75.7%
expm1-log1p76.0%
Simplified76.0%
associate-/l/77.0%
div-inv77.0%
Applied egg-rr77.0%
associate-*r/77.0%
*-rgt-identity77.0%
Simplified77.0%
metadata-eval77.0%
pow-prod-up77.0%
unpow-177.0%
unpow-177.0%
Applied egg-rr77.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%
Simplified2.5%
Taylor expanded in c0 around -inf 1.9%
mul-1-neg1.9%
distribute-lft-in1.2%
Simplified32.8%
Taylor expanded in c0 around 0 40.5%
Final simplification53.6%
(FPCore (c0 w h D d M) :precision binary64 (if (<= w 8.5e+98) (* (/ c0 (* 2.0 w)) (* 2.0 (/ (/ c0 (* w h)) (* (/ 1.0 (/ d D)) (/ D d))))) 0.0))
double code(double c0, double w, double h, double D, double d, double M) {
double tmp;
if (w <= 8.5e+98) {
tmp = (c0 / (2.0 * w)) * (2.0 * ((c0 / (w * h)) / ((1.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) :: tmp
if (w <= 8.5d+98) then
tmp = (c0 / (2.0d0 * w)) * (2.0d0 * ((c0 / (w * h)) / ((1.0d0 / (d_1 / d)) * (d / d_1))))
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 tmp;
if (w <= 8.5e+98) {
tmp = (c0 / (2.0 * w)) * (2.0 * ((c0 / (w * h)) / ((1.0 / (d / D)) * (D / d))));
} else {
tmp = 0.0;
}
return tmp;
}
def code(c0, w, h, D, d, M): tmp = 0 if w <= 8.5e+98: tmp = (c0 / (2.0 * w)) * (2.0 * ((c0 / (w * h)) / ((1.0 / (d / D)) * (D / d)))) else: tmp = 0.0 return tmp
function code(c0, w, h, D, d, M) tmp = 0.0 if (w <= 8.5e+98) tmp = Float64(Float64(c0 / Float64(2.0 * w)) * Float64(2.0 * Float64(Float64(c0 / Float64(w * h)) / Float64(Float64(1.0 / Float64(d / D)) * Float64(D / d))))); else tmp = 0.0; end return tmp end
function tmp_2 = code(c0, w, h, D, d, M) tmp = 0.0; if (w <= 8.5e+98) tmp = (c0 / (2.0 * w)) * (2.0 * ((c0 / (w * h)) / ((1.0 / (d / D)) * (D / d)))); else tmp = 0.0; end tmp_2 = tmp; end
code[c0_, w_, h_, D_, d_, M_] := If[LessEqual[w, 8.5e+98], N[(N[(c0 / N[(2.0 * w), $MachinePrecision]), $MachinePrecision] * N[(2.0 * N[(N[(c0 / N[(w * h), $MachinePrecision]), $MachinePrecision] / N[(N[(1.0 / N[(d / D), $MachinePrecision]), $MachinePrecision] * N[(D / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 0.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;w \leq 8.5 \cdot 10^{+98}:\\
\;\;\;\;\frac{c0}{2 \cdot w} \cdot \left(2 \cdot \frac{\frac{c0}{w \cdot h}}{\frac{1}{\frac{d}{D}} \cdot \frac{D}{d}}\right)\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if w < 8.4999999999999996e98Initial program 28.8%
Simplified29.2%
Taylor expanded in c0 around inf 37.5%
*-commutative37.5%
associate-/l/37.0%
associate-*l/37.0%
associate-/l*37.5%
*-commutative37.5%
Simplified37.5%
expm1-log1p-u37.5%
expm1-udef34.1%
clear-num34.1%
unpow234.1%
unpow234.1%
frac-times42.0%
pow242.0%
pow-flip42.0%
metadata-eval42.0%
Applied egg-rr42.0%
expm1-def46.7%
expm1-log1p46.9%
Simplified46.9%
metadata-eval49.3%
pow-prod-up49.3%
unpow-149.3%
unpow-149.3%
Applied egg-rr46.9%
Taylor expanded in d around 0 46.9%
if 8.4999999999999996e98 < w Initial program 16.9%
Simplified21.3%
Taylor expanded in c0 around -inf 11.9%
mul-1-neg11.9%
distribute-lft-in9.6%
Simplified45.5%
Taylor expanded in c0 around 0 45.5%
Final simplification46.7%
(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 26.7%
Simplified27.9%
Taylor expanded in c0 around -inf 5.1%
mul-1-neg5.1%
distribute-lft-in4.6%
Simplified25.7%
Taylor expanded in c0 around 0 30.6%
Final simplification30.6%
herbie shell --seed 2023314
(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))))))