
(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}
(FPCore (c0 w h D d M)
:precision binary64
(let* ((t_0 (/ w (/ d D)))
(t_1 (/ c0 (* 2.0 w)))
(t_2 (/ (* c0 (* d d)) (* (* w h) (* D D))))
(t_3 (* t_1 (+ t_2 (sqrt (- (* t_2 t_2) (* M M)))))))
(if (<= t_3 -4e-42)
(* t_1 (* 2.0 (/ c0 (* (/ h (/ d D)) t_0))))
(if (or (<= t_3 0.0) (not (<= t_3 INFINITY)))
(* 0.25 (/ (* h (* (* D M) (* D M))) (pow d 2.0)))
(* t_1 (* 2.0 (/ c0 (* t_0 (/ (* h D) d)))))))))
double code(double c0, double w, double h, double D, double d, double M) {
double t_0 = w / (d / D);
double t_1 = c0 / (2.0 * w);
double t_2 = (c0 * (d * d)) / ((w * h) * (D * D));
double t_3 = t_1 * (t_2 + sqrt(((t_2 * t_2) - (M * M))));
double tmp;
if (t_3 <= -4e-42) {
tmp = t_1 * (2.0 * (c0 / ((h / (d / D)) * t_0)));
} else if ((t_3 <= 0.0) || !(t_3 <= ((double) INFINITY))) {
tmp = 0.25 * ((h * ((D * M) * (D * M))) / pow(d, 2.0));
} else {
tmp = t_1 * (2.0 * (c0 / (t_0 * ((h * D) / d))));
}
return tmp;
}
public static double code(double c0, double w, double h, double D, double d, double M) {
double t_0 = w / (d / D);
double t_1 = c0 / (2.0 * w);
double t_2 = (c0 * (d * d)) / ((w * h) * (D * D));
double t_3 = t_1 * (t_2 + Math.sqrt(((t_2 * t_2) - (M * M))));
double tmp;
if (t_3 <= -4e-42) {
tmp = t_1 * (2.0 * (c0 / ((h / (d / D)) * t_0)));
} else if ((t_3 <= 0.0) || !(t_3 <= Double.POSITIVE_INFINITY)) {
tmp = 0.25 * ((h * ((D * M) * (D * M))) / Math.pow(d, 2.0));
} else {
tmp = t_1 * (2.0 * (c0 / (t_0 * ((h * D) / d))));
}
return tmp;
}
def code(c0, w, h, D, d, M): t_0 = w / (d / D) t_1 = c0 / (2.0 * w) t_2 = (c0 * (d * d)) / ((w * h) * (D * D)) t_3 = t_1 * (t_2 + math.sqrt(((t_2 * t_2) - (M * M)))) tmp = 0 if t_3 <= -4e-42: tmp = t_1 * (2.0 * (c0 / ((h / (d / D)) * t_0))) elif (t_3 <= 0.0) or not (t_3 <= math.inf): tmp = 0.25 * ((h * ((D * M) * (D * M))) / math.pow(d, 2.0)) else: tmp = t_1 * (2.0 * (c0 / (t_0 * ((h * D) / d)))) return tmp
function code(c0, w, h, D, d, M) t_0 = Float64(w / 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))) t_3 = Float64(t_1 * Float64(t_2 + sqrt(Float64(Float64(t_2 * t_2) - Float64(M * M))))) tmp = 0.0 if (t_3 <= -4e-42) tmp = Float64(t_1 * Float64(2.0 * Float64(c0 / Float64(Float64(h / Float64(d / D)) * t_0)))); elseif ((t_3 <= 0.0) || !(t_3 <= Inf)) tmp = Float64(0.25 * Float64(Float64(h * Float64(Float64(D * M) * Float64(D * M))) / (d ^ 2.0))); else tmp = Float64(t_1 * Float64(2.0 * Float64(c0 / Float64(t_0 * Float64(Float64(h * D) / d))))); end return tmp end
function tmp_2 = code(c0, w, h, D, d, M) t_0 = w / (d / D); t_1 = c0 / (2.0 * w); t_2 = (c0 * (d * d)) / ((w * h) * (D * D)); t_3 = t_1 * (t_2 + sqrt(((t_2 * t_2) - (M * M)))); tmp = 0.0; if (t_3 <= -4e-42) tmp = t_1 * (2.0 * (c0 / ((h / (d / D)) * t_0))); elseif ((t_3 <= 0.0) || ~((t_3 <= Inf))) tmp = 0.25 * ((h * ((D * M) * (D * M))) / (d ^ 2.0)); else tmp = t_1 * (2.0 * (c0 / (t_0 * ((h * D) / d)))); end tmp_2 = tmp; end
code[c0_, w_, h_, D_, d_, M_] := Block[{t$95$0 = N[(w / 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]}, Block[{t$95$3 = 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]}, If[LessEqual[t$95$3, -4e-42], N[(t$95$1 * N[(2.0 * N[(c0 / N[(N[(h / N[(d / D), $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[t$95$3, 0.0], N[Not[LessEqual[t$95$3, Infinity]], $MachinePrecision]], N[(0.25 * N[(N[(h * N[(N[(D * M), $MachinePrecision] * N[(D * M), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Power[d, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$1 * N[(2.0 * N[(c0 / N[(t$95$0 * N[(N[(h * D), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{w}{\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)}\\
t_3 := t_1 \cdot \left(t_2 + \sqrt{t_2 \cdot t_2 - M \cdot M}\right)\\
\mathbf{if}\;t_3 \leq -4 \cdot 10^{-42}:\\
\;\;\;\;t_1 \cdot \left(2 \cdot \frac{c0}{\frac{h}{\frac{d}{D}} \cdot t_0}\right)\\
\mathbf{elif}\;t_3 \leq 0 \lor \neg \left(t_3 \leq \infty\right):\\
\;\;\;\;0.25 \cdot \frac{h \cdot \left(\left(D \cdot M\right) \cdot \left(D \cdot M\right)\right)}{{d}^{2}}\\
\mathbf{else}:\\
\;\;\;\;t_1 \cdot \left(2 \cdot \frac{c0}{t_0 \cdot \frac{h \cdot D}{d}}\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))))) < -4.00000000000000015e-42Initial program 82.5%
times-frac82.5%
Simplified82.5%
Taylor expanded in c0 around inf 82.5%
*-commutative82.5%
*-commutative82.5%
associate-*r*81.5%
associate-/r*81.5%
associate-*l/81.5%
times-frac84.8%
unpow284.8%
associate-*r/84.8%
unpow284.8%
associate-/l/86.3%
associate-*r/86.3%
associate-/r*84.0%
associate-*l/84.1%
unpow284.1%
associate-*l/84.0%
associate-/l*84.1%
*-commutative84.1%
Simplified84.1%
unpow284.1%
Applied egg-rr84.1%
times-frac88.6%
Applied egg-rr88.6%
if -4.00000000000000015e-42 < (*.f64 (/.f64 c0 (*.f64 2 w)) (+.f64 (/.f64 (*.f64 c0 (*.f64 d d)) (*.f64 (*.f64 w h) (*.f64 D D))) (sqrt.f64 (-.f64 (*.f64 (/.f64 (*.f64 c0 (*.f64 d d)) (*.f64 (*.f64 w h) (*.f64 D D))) (/.f64 (*.f64 c0 (*.f64 d d)) (*.f64 (*.f64 w h) (*.f64 D D)))) (*.f64 M M))))) < 0.0 or +inf.0 < (*.f64 (/.f64 c0 (*.f64 2 w)) (+.f64 (/.f64 (*.f64 c0 (*.f64 d d)) (*.f64 (*.f64 w h) (*.f64 D D))) (sqrt.f64 (-.f64 (*.f64 (/.f64 (*.f64 c0 (*.f64 d d)) (*.f64 (*.f64 w h) (*.f64 D D))) (/.f64 (*.f64 c0 (*.f64 d d)) (*.f64 (*.f64 w h) (*.f64 D D)))) (*.f64 M M))))) Initial program 2.4%
times-frac0.3%
Simplified2.0%
Taylor expanded in c0 around -inf 5.5%
Simplified26.9%
Taylor expanded in c0 around 0 35.7%
*-commutative35.7%
*-commutative35.7%
associate-*l*37.9%
unpow237.9%
unpow237.9%
swap-sqr49.9%
unpow249.9%
*-commutative49.9%
Simplified49.9%
unpow249.9%
Applied egg-rr49.9%
if 0.0 < (*.f64 (/.f64 c0 (*.f64 2 w)) (+.f64 (/.f64 (*.f64 c0 (*.f64 d d)) (*.f64 (*.f64 w h) (*.f64 D D))) (sqrt.f64 (-.f64 (*.f64 (/.f64 (*.f64 c0 (*.f64 d d)) (*.f64 (*.f64 w h) (*.f64 D D))) (/.f64 (*.f64 c0 (*.f64 d d)) (*.f64 (*.f64 w h) (*.f64 D D)))) (*.f64 M M))))) < +inf.0Initial program 82.1%
times-frac78.4%
Simplified78.4%
Taylor expanded in c0 around inf 84.1%
*-commutative84.1%
*-commutative84.1%
associate-*r*84.0%
associate-/r*80.5%
associate-*l/80.5%
times-frac80.3%
unpow280.3%
associate-*r/83.7%
unpow283.7%
associate-/l/83.8%
associate-*r/80.4%
associate-/r*80.4%
associate-*l/83.9%
unpow283.9%
associate-*l/87.6%
associate-/l*87.3%
*-commutative87.3%
Simplified87.3%
unpow287.3%
Applied egg-rr87.3%
times-frac90.8%
Applied egg-rr90.8%
Taylor expanded in h around 0 90.9%
Final simplification60.6%
(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 (pow (* (/ d D) (sqrt (/ 1.0 (/ h (/ c0 w))))) 2.0)))
(* 0.25 (/ (* h (* (* D M) (* D M))) (pow d 2.0))))))
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 * pow(((d / D) * sqrt((1.0 / (h / (c0 / w))))), 2.0));
} else {
tmp = 0.25 * ((h * ((D * M) * (D * M))) / 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 / (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.pow(((d / D) * Math.sqrt((1.0 / (h / (c0 / w))))), 2.0));
} else {
tmp = 0.25 * ((h * ((D * M) * (D * M))) / Math.pow(d, 2.0));
}
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 * math.pow(((d / D) * math.sqrt((1.0 / (h / (c0 / w))))), 2.0)) else: tmp = 0.25 * ((h * ((D * M) * (D * M))) / math.pow(d, 2.0)) 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(d / D) * sqrt(Float64(1.0 / Float64(h / Float64(c0 / w))))) ^ 2.0))); else tmp = Float64(0.25 * Float64(Float64(h * Float64(Float64(D * M) * Float64(D * M))) / (d ^ 2.0))); 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 * (((d / D) * sqrt((1.0 / (h / (c0 / w))))) ^ 2.0)); else tmp = 0.25 * ((h * ((D * M) * (D * M))) / (d ^ 2.0)); 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[Power[N[(N[(d / D), $MachinePrecision] * N[Sqrt[N[(1.0 / N[(h / N[(c0 / w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.25 * N[(N[(h * N[(N[(D * M), $MachinePrecision] * N[(D * M), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Power[d, 2.0], $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 {\left(\frac{d}{D} \cdot \sqrt{\frac{1}{\frac{h}{\frac{c0}{w}}}}\right)}^{2}\right)\\
\mathbf{else}:\\
\;\;\;\;0.25 \cdot \frac{h \cdot \left(\left(D \cdot M\right) \cdot \left(D \cdot M\right)\right)}{{d}^{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 75.6%
times-frac69.6%
Simplified70.8%
Taylor expanded in c0 around inf 74.0%
*-commutative74.0%
*-commutative74.0%
associate-*r*74.5%
associate-/r*73.2%
associate-*l/73.2%
times-frac72.5%
unpow272.5%
associate-*r/74.8%
unpow274.8%
associate-/l/75.5%
associate-*r/74.4%
associate-/r*73.2%
associate-*l/74.4%
unpow274.4%
associate-*l/76.9%
associate-/l*75.6%
*-commutative75.6%
Simplified75.6%
associate-/r/74.4%
*-commutative74.4%
add-sqr-sqrt74.0%
pow274.0%
*-commutative74.0%
sqrt-prod74.0%
sqrt-pow180.8%
metadata-eval80.8%
pow180.8%
*-commutative80.8%
Applied egg-rr80.8%
clear-num80.0%
inv-pow80.0%
Applied egg-rr80.0%
unpow-180.0%
associate-/l*81.2%
Simplified81.2%
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%
Simplified1.3%
Taylor expanded in c0 around -inf 3.0%
Simplified25.2%
Taylor expanded in c0 around 0 34.7%
*-commutative34.7%
*-commutative34.7%
associate-*l*37.0%
unpow237.0%
unpow237.0%
swap-sqr48.7%
unpow248.7%
*-commutative48.7%
Simplified48.7%
unpow248.7%
Applied egg-rr48.7%
Final simplification59.0%
(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 (pow (* (/ d D) (sqrt (/ c0 (* w h)))) 2.0)))
(* 0.25 (/ (* h (* (* D M) (* D M))) (pow d 2.0))))))
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 * pow(((d / D) * sqrt((c0 / (w * h)))), 2.0));
} else {
tmp = 0.25 * ((h * ((D * M) * (D * M))) / 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 / (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.pow(((d / D) * Math.sqrt((c0 / (w * h)))), 2.0));
} else {
tmp = 0.25 * ((h * ((D * M) * (D * M))) / Math.pow(d, 2.0));
}
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 * math.pow(((d / D) * math.sqrt((c0 / (w * h)))), 2.0)) else: tmp = 0.25 * ((h * ((D * M) * (D * M))) / math.pow(d, 2.0)) 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(d / D) * sqrt(Float64(c0 / Float64(w * h)))) ^ 2.0))); else tmp = Float64(0.25 * Float64(Float64(h * Float64(Float64(D * M) * Float64(D * M))) / (d ^ 2.0))); 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 * (((d / D) * sqrt((c0 / (w * h)))) ^ 2.0)); else tmp = 0.25 * ((h * ((D * M) * (D * M))) / (d ^ 2.0)); 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[Power[N[(N[(d / D), $MachinePrecision] * N[Sqrt[N[(c0 / N[(w * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.25 * N[(N[(h * N[(N[(D * M), $MachinePrecision] * N[(D * M), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Power[d, 2.0], $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 {\left(\frac{d}{D} \cdot \sqrt{\frac{c0}{w \cdot h}}\right)}^{2}\right)\\
\mathbf{else}:\\
\;\;\;\;0.25 \cdot \frac{h \cdot \left(\left(D \cdot M\right) \cdot \left(D \cdot M\right)\right)}{{d}^{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 75.6%
times-frac69.6%
Simplified70.8%
Taylor expanded in c0 around inf 74.0%
*-commutative74.0%
*-commutative74.0%
associate-*r*74.5%
associate-/r*73.2%
associate-*l/73.2%
times-frac72.5%
unpow272.5%
associate-*r/74.8%
unpow274.8%
associate-/l/75.5%
associate-*r/74.4%
associate-/r*73.2%
associate-*l/74.4%
unpow274.4%
associate-*l/76.9%
associate-/l*75.6%
*-commutative75.6%
Simplified75.6%
associate-/r/74.4%
*-commutative74.4%
add-sqr-sqrt74.0%
pow274.0%
*-commutative74.0%
sqrt-prod74.0%
sqrt-pow180.8%
metadata-eval80.8%
pow180.8%
*-commutative80.8%
Applied egg-rr80.8%
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%
Simplified1.3%
Taylor expanded in c0 around -inf 3.0%
Simplified25.2%
Taylor expanded in c0 around 0 34.7%
*-commutative34.7%
*-commutative34.7%
associate-*l*37.0%
unpow237.0%
unpow237.0%
swap-sqr48.7%
unpow248.7%
*-commutative48.7%
Simplified48.7%
unpow248.7%
Applied egg-rr48.7%
Final simplification58.9%
(FPCore (c0 w h D d M) :precision binary64 (if (<= M 2.25e-123) 0.0 (* (/ c0 (* 2.0 w)) (* 2.0 (/ c0 (* (/ h d) (* D (* D (/ w d)))))))))
double code(double c0, double w, double h, double D, double d, double M) {
double tmp;
if (M <= 2.25e-123) {
tmp = 0.0;
} else {
tmp = (c0 / (2.0 * w)) * (2.0 * (c0 / ((h / d) * (D * (D * (w / 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) :: tmp
if (m <= 2.25d-123) then
tmp = 0.0d0
else
tmp = (c0 / (2.0d0 * w)) * (2.0d0 * (c0 / ((h / d_1) * (d * (d * (w / d_1))))))
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 <= 2.25e-123) {
tmp = 0.0;
} else {
tmp = (c0 / (2.0 * w)) * (2.0 * (c0 / ((h / d) * (D * (D * (w / d))))));
}
return tmp;
}
def code(c0, w, h, D, d, M): tmp = 0 if M <= 2.25e-123: tmp = 0.0 else: tmp = (c0 / (2.0 * w)) * (2.0 * (c0 / ((h / d) * (D * (D * (w / d)))))) return tmp
function code(c0, w, h, D, d, M) tmp = 0.0 if (M <= 2.25e-123) tmp = 0.0; else tmp = Float64(Float64(c0 / Float64(2.0 * w)) * Float64(2.0 * Float64(c0 / Float64(Float64(h / d) * Float64(D * Float64(D * Float64(w / d))))))); end return tmp end
function tmp_2 = code(c0, w, h, D, d, M) tmp = 0.0; if (M <= 2.25e-123) tmp = 0.0; else tmp = (c0 / (2.0 * w)) * (2.0 * (c0 / ((h / d) * (D * (D * (w / d)))))); end tmp_2 = tmp; end
code[c0_, w_, h_, D_, d_, M_] := If[LessEqual[M, 2.25e-123], 0.0, N[(N[(c0 / N[(2.0 * w), $MachinePrecision]), $MachinePrecision] * N[(2.0 * N[(c0 / N[(N[(h / d), $MachinePrecision] * N[(D * N[(D * N[(w / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;M \leq 2.25 \cdot 10^{-123}:\\
\;\;\;\;0\\
\mathbf{else}:\\
\;\;\;\;\frac{c0}{2 \cdot w} \cdot \left(2 \cdot \frac{c0}{\frac{h}{d} \cdot \left(D \cdot \left(D \cdot \frac{w}{d}\right)\right)}\right)\\
\end{array}
\end{array}
if M < 2.24999999999999997e-123Initial program 25.6%
times-frac23.3%
Simplified25.2%
Taylor expanded in c0 around -inf 5.1%
associate-*r*5.1%
neg-mul-15.1%
distribute-lft1-in5.1%
metadata-eval5.1%
mul0-lft31.2%
distribute-lft-neg-in31.2%
distribute-rgt-neg-in31.2%
metadata-eval31.2%
mul0-lft5.1%
metadata-eval5.1%
distribute-lft1-in5.1%
distribute-lft-in4.0%
Simplified31.2%
Taylor expanded in c0 around 0 36.3%
if 2.24999999999999997e-123 < M Initial program 20.5%
times-frac19.4%
Simplified19.4%
Taylor expanded in c0 around inf 42.1%
*-commutative42.1%
*-commutative42.1%
associate-*r*42.1%
associate-/r*42.1%
associate-*l/42.1%
times-frac40.9%
unpow240.9%
associate-*r/46.1%
unpow246.1%
associate-/l/49.5%
associate-*r/50.7%
associate-/r*50.7%
associate-*l/51.9%
unpow251.9%
associate-*l/53.2%
associate-/l*53.2%
*-commutative53.2%
Simplified53.2%
unpow253.2%
Applied egg-rr53.2%
times-frac54.6%
Applied egg-rr54.6%
associate-/r/54.3%
associate-*l*50.8%
associate-/r/50.8%
Simplified50.8%
Final simplification41.0%
(FPCore (c0 w h D d M) :precision binary64 (if (<= M 1.95e-100) 0.0 (* (/ c0 (* 2.0 w)) (* 2.0 (/ c0 (* (/ h (/ d D)) (/ w (/ d D))))))))
double code(double c0, double w, double h, double D, double d, double M) {
double tmp;
if (M <= 1.95e-100) {
tmp = 0.0;
} else {
tmp = (c0 / (2.0 * w)) * (2.0 * (c0 / ((h / (d / D)) * (w / (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) :: tmp
if (m <= 1.95d-100) then
tmp = 0.0d0
else
tmp = (c0 / (2.0d0 * w)) * (2.0d0 * (c0 / ((h / (d_1 / d)) * (w / (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 tmp;
if (M <= 1.95e-100) {
tmp = 0.0;
} else {
tmp = (c0 / (2.0 * w)) * (2.0 * (c0 / ((h / (d / D)) * (w / (d / D)))));
}
return tmp;
}
def code(c0, w, h, D, d, M): tmp = 0 if M <= 1.95e-100: tmp = 0.0 else: tmp = (c0 / (2.0 * w)) * (2.0 * (c0 / ((h / (d / D)) * (w / (d / D))))) return tmp
function code(c0, w, h, D, d, M) tmp = 0.0 if (M <= 1.95e-100) tmp = 0.0; else tmp = Float64(Float64(c0 / Float64(2.0 * w)) * Float64(2.0 * Float64(c0 / Float64(Float64(h / Float64(d / D)) * Float64(w / Float64(d / D)))))); end return tmp end
function tmp_2 = code(c0, w, h, D, d, M) tmp = 0.0; if (M <= 1.95e-100) tmp = 0.0; else tmp = (c0 / (2.0 * w)) * (2.0 * (c0 / ((h / (d / D)) * (w / (d / D))))); end tmp_2 = tmp; end
code[c0_, w_, h_, D_, d_, M_] := If[LessEqual[M, 1.95e-100], 0.0, N[(N[(c0 / N[(2.0 * w), $MachinePrecision]), $MachinePrecision] * N[(2.0 * N[(c0 / N[(N[(h / N[(d / D), $MachinePrecision]), $MachinePrecision] * N[(w / N[(d / D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;M \leq 1.95 \cdot 10^{-100}:\\
\;\;\;\;0\\
\mathbf{else}:\\
\;\;\;\;\frac{c0}{2 \cdot w} \cdot \left(2 \cdot \frac{c0}{\frac{h}{\frac{d}{D}} \cdot \frac{w}{\frac{d}{D}}}\right)\\
\end{array}
\end{array}
if M < 1.94999999999999989e-100Initial program 26.1%
times-frac24.0%
Simplified25.7%
Taylor expanded in c0 around -inf 4.9%
associate-*r*4.9%
neg-mul-14.9%
distribute-lft1-in4.9%
metadata-eval4.9%
mul0-lft31.6%
distribute-lft-neg-in31.6%
distribute-rgt-neg-in31.6%
metadata-eval31.6%
mul0-lft4.9%
metadata-eval4.9%
distribute-lft1-in4.9%
distribute-lft-in3.8%
Simplified31.6%
Taylor expanded in c0 around 0 36.4%
if 1.94999999999999989e-100 < M Initial program 18.8%
times-frac17.5%
Simplified17.5%
Taylor expanded in c0 around inf 42.6%
*-commutative42.6%
*-commutative42.6%
associate-*r*42.5%
associate-/r*42.5%
associate-*l/42.5%
times-frac41.3%
unpow241.3%
associate-*r/47.0%
unpow247.0%
associate-/l/50.7%
associate-*r/50.8%
associate-/r*50.7%
associate-*l/52.1%
unpow252.1%
associate-*l/53.4%
associate-/l*53.4%
*-commutative53.4%
Simplified53.4%
unpow253.4%
Applied egg-rr53.4%
times-frac55.1%
Applied egg-rr55.1%
Final simplification42.0%
(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 23.9%
times-frac22.0%
Simplified23.3%
Taylor expanded in c0 around -inf 3.5%
associate-*r*3.5%
neg-mul-13.5%
distribute-lft1-in3.5%
metadata-eval3.5%
mul0-lft28.4%
distribute-lft-neg-in28.4%
distribute-rgt-neg-in28.4%
metadata-eval28.4%
mul0-lft3.5%
metadata-eval3.5%
distribute-lft1-in3.5%
distribute-lft-in2.7%
Simplified28.4%
Taylor expanded in c0 around 0 32.3%
Final simplification32.3%
herbie shell --seed 2023310
(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))))))