
(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 (pow (/ d D) 2.0))
(t_1 (/ (* c0 (* d d)) (* (* D D) (* w h))))
(t_2 (* (/ c0 (* 2.0 w)) (+ t_1 (sqrt (- (* t_1 t_1) (* M M)))))))
(if (<= t_2 -1e-246)
(* c0 (/ (/ 1.0 (/ h (* 2.0 (/ (* c0 t_0) w)))) (* 2.0 w)))
(if (<= t_2 0.0)
(*
c0
(/
(/
(pow M 2.0)
(+
(* c0 (/ t_0 (* w h)))
(/ (* (/ c0 h) (/ (pow d 2.0) w)) (pow D 2.0))))
(* 2.0 w)))
(if (<= t_2 INFINITY)
(*
c0
(/ (* 2.0 (/ (* c0 (pow d 2.0)) (* (* w h) (pow D 2.0)))) (* 2.0 w)))
(* c0 (/ 0.0 (* 2.0 w))))))))
double code(double c0, double w, double h, double D, double d, double M) {
double t_0 = pow((d / D), 2.0);
double t_1 = (c0 * (d * d)) / ((D * D) * (w * h));
double t_2 = (c0 / (2.0 * w)) * (t_1 + sqrt(((t_1 * t_1) - (M * M))));
double tmp;
if (t_2 <= -1e-246) {
tmp = c0 * ((1.0 / (h / (2.0 * ((c0 * t_0) / w)))) / (2.0 * w));
} else if (t_2 <= 0.0) {
tmp = c0 * ((pow(M, 2.0) / ((c0 * (t_0 / (w * h))) + (((c0 / h) * (pow(d, 2.0) / w)) / pow(D, 2.0)))) / (2.0 * w));
} else if (t_2 <= ((double) INFINITY)) {
tmp = c0 * ((2.0 * ((c0 * pow(d, 2.0)) / ((w * h) * pow(D, 2.0)))) / (2.0 * w));
} else {
tmp = c0 * (0.0 / (2.0 * w));
}
return tmp;
}
public static double code(double c0, double w, double h, double D, double d, double M) {
double t_0 = Math.pow((d / D), 2.0);
double t_1 = (c0 * (d * d)) / ((D * D) * (w * h));
double t_2 = (c0 / (2.0 * w)) * (t_1 + Math.sqrt(((t_1 * t_1) - (M * M))));
double tmp;
if (t_2 <= -1e-246) {
tmp = c0 * ((1.0 / (h / (2.0 * ((c0 * t_0) / w)))) / (2.0 * w));
} else if (t_2 <= 0.0) {
tmp = c0 * ((Math.pow(M, 2.0) / ((c0 * (t_0 / (w * h))) + (((c0 / h) * (Math.pow(d, 2.0) / w)) / Math.pow(D, 2.0)))) / (2.0 * w));
} else if (t_2 <= Double.POSITIVE_INFINITY) {
tmp = c0 * ((2.0 * ((c0 * Math.pow(d, 2.0)) / ((w * h) * Math.pow(D, 2.0)))) / (2.0 * w));
} else {
tmp = c0 * (0.0 / (2.0 * w));
}
return tmp;
}
def code(c0, w, h, D, d, M): t_0 = math.pow((d / D), 2.0) t_1 = (c0 * (d * d)) / ((D * D) * (w * h)) t_2 = (c0 / (2.0 * w)) * (t_1 + math.sqrt(((t_1 * t_1) - (M * M)))) tmp = 0 if t_2 <= -1e-246: tmp = c0 * ((1.0 / (h / (2.0 * ((c0 * t_0) / w)))) / (2.0 * w)) elif t_2 <= 0.0: tmp = c0 * ((math.pow(M, 2.0) / ((c0 * (t_0 / (w * h))) + (((c0 / h) * (math.pow(d, 2.0) / w)) / math.pow(D, 2.0)))) / (2.0 * w)) elif t_2 <= math.inf: tmp = c0 * ((2.0 * ((c0 * math.pow(d, 2.0)) / ((w * h) * math.pow(D, 2.0)))) / (2.0 * w)) else: tmp = c0 * (0.0 / (2.0 * w)) return tmp
function code(c0, w, h, D, d, M) t_0 = Float64(d / D) ^ 2.0 t_1 = Float64(Float64(c0 * Float64(d * d)) / Float64(Float64(D * D) * Float64(w * h))) t_2 = Float64(Float64(c0 / Float64(2.0 * w)) * Float64(t_1 + sqrt(Float64(Float64(t_1 * t_1) - Float64(M * M))))) tmp = 0.0 if (t_2 <= -1e-246) tmp = Float64(c0 * Float64(Float64(1.0 / Float64(h / Float64(2.0 * Float64(Float64(c0 * t_0) / w)))) / Float64(2.0 * w))); elseif (t_2 <= 0.0) tmp = Float64(c0 * Float64(Float64((M ^ 2.0) / Float64(Float64(c0 * Float64(t_0 / Float64(w * h))) + Float64(Float64(Float64(c0 / h) * Float64((d ^ 2.0) / w)) / (D ^ 2.0)))) / Float64(2.0 * w))); elseif (t_2 <= Inf) tmp = Float64(c0 * Float64(Float64(2.0 * Float64(Float64(c0 * (d ^ 2.0)) / Float64(Float64(w * h) * (D ^ 2.0)))) / Float64(2.0 * w))); else tmp = Float64(c0 * Float64(0.0 / Float64(2.0 * w))); end return tmp end
function tmp_2 = code(c0, w, h, D, d, M) t_0 = (d / D) ^ 2.0; t_1 = (c0 * (d * d)) / ((D * D) * (w * h)); t_2 = (c0 / (2.0 * w)) * (t_1 + sqrt(((t_1 * t_1) - (M * M)))); tmp = 0.0; if (t_2 <= -1e-246) tmp = c0 * ((1.0 / (h / (2.0 * ((c0 * t_0) / w)))) / (2.0 * w)); elseif (t_2 <= 0.0) tmp = c0 * (((M ^ 2.0) / ((c0 * (t_0 / (w * h))) + (((c0 / h) * ((d ^ 2.0) / w)) / (D ^ 2.0)))) / (2.0 * w)); elseif (t_2 <= Inf) tmp = c0 * ((2.0 * ((c0 * (d ^ 2.0)) / ((w * h) * (D ^ 2.0)))) / (2.0 * w)); else tmp = c0 * (0.0 / (2.0 * w)); end tmp_2 = tmp; end
code[c0_, w_, h_, D_, d_, M_] := Block[{t$95$0 = N[Power[N[(d / D), $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$1 = N[(N[(c0 * N[(d * d), $MachinePrecision]), $MachinePrecision] / N[(N[(D * D), $MachinePrecision] * N[(w * h), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(c0 / N[(2.0 * w), $MachinePrecision]), $MachinePrecision] * N[(t$95$1 + N[Sqrt[N[(N[(t$95$1 * t$95$1), $MachinePrecision] - N[(M * M), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, -1e-246], N[(c0 * N[(N[(1.0 / N[(h / N[(2.0 * N[(N[(c0 * t$95$0), $MachinePrecision] / w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(2.0 * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 0.0], N[(c0 * N[(N[(N[Power[M, 2.0], $MachinePrecision] / N[(N[(c0 * N[(t$95$0 / N[(w * h), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(N[(c0 / h), $MachinePrecision] * N[(N[Power[d, 2.0], $MachinePrecision] / w), $MachinePrecision]), $MachinePrecision] / N[Power[D, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(2.0 * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, Infinity], N[(c0 * N[(N[(2.0 * N[(N[(c0 * N[Power[d, 2.0], $MachinePrecision]), $MachinePrecision] / N[(N[(w * h), $MachinePrecision] * N[Power[D, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(2.0 * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(c0 * N[(0.0 / N[(2.0 * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\left(\frac{d}{D}\right)}^{2}\\
t_1 := \frac{c0 \cdot \left(d \cdot d\right)}{\left(D \cdot D\right) \cdot \left(w \cdot h\right)}\\
t_2 := \frac{c0}{2 \cdot w} \cdot \left(t\_1 + \sqrt{t\_1 \cdot t\_1 - M \cdot M}\right)\\
\mathbf{if}\;t\_2 \leq -1 \cdot 10^{-246}:\\
\;\;\;\;c0 \cdot \frac{\frac{1}{\frac{h}{2 \cdot \frac{c0 \cdot t\_0}{w}}}}{2 \cdot w}\\
\mathbf{elif}\;t\_2 \leq 0:\\
\;\;\;\;c0 \cdot \frac{\frac{{M}^{2}}{c0 \cdot \frac{t\_0}{w \cdot h} + \frac{\frac{c0}{h} \cdot \frac{{d}^{2}}{w}}{{D}^{2}}}}{2 \cdot w}\\
\mathbf{elif}\;t\_2 \leq \infty:\\
\;\;\;\;c0 \cdot \frac{2 \cdot \frac{c0 \cdot {d}^{2}}{\left(w \cdot h\right) \cdot {D}^{2}}}{2 \cdot w}\\
\mathbf{else}:\\
\;\;\;\;c0 \cdot \frac{0}{2 \cdot w}\\
\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))))) < -9.99999999999999956e-247Initial program 87.5%
Simplified80.9%
Taylor expanded in h around 0 16.6%
Simplified87.5%
Taylor expanded in w around 0 87.5%
clear-num87.6%
inv-pow87.6%
Applied egg-rr90.8%
unpow-190.8%
associate-*l/90.8%
Simplified90.8%
if -9.99999999999999956e-247 < (*.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))))) < -0.0Initial program 33.6%
Simplified12.7%
Applied egg-rr13.1%
associate--r-57.8%
+-inverses57.8%
associate-*l/57.8%
associate-/l*58.2%
*-commutative58.2%
sub-neg58.2%
Simplified47.8%
Taylor expanded in c0 around -inf 58.6%
mul-1-neg58.6%
times-frac58.6%
Simplified58.6%
associate-*l/58.6%
*-commutative58.6%
Applied egg-rr58.6%
associate-*r/58.6%
*-commutative58.6%
times-frac68.2%
Simplified68.2%
if -0.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))))) < +inf.0Initial program 73.4%
Simplified73.5%
Taylor expanded in c0 around inf 78.7%
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%
Simplified18.8%
Taylor expanded in c0 around -inf 1.3%
distribute-lft-in0.6%
mul-1-neg0.6%
distribute-rgt-neg-in0.6%
associate-/l*0.1%
mul-1-neg0.1%
associate-/l*0.1%
distribute-lft1-in0.1%
metadata-eval0.1%
mul0-lft36.9%
metadata-eval36.9%
Simplified36.9%
Final simplification50.3%
(FPCore (c0 w h D d M)
:precision binary64
(let* ((t_0 (/ (* c0 (pow d 2.0)) (* (* w h) (pow D 2.0))))
(t_1 (pow (/ d D) 2.0))
(t_2 (/ (* c0 (* d d)) (* (* D D) (* w h))))
(t_3 (* (/ c0 (* 2.0 w)) (+ t_2 (sqrt (- (* t_2 t_2) (* M M)))))))
(if (<= t_3 -1e-246)
(* c0 (/ (/ 1.0 (/ h (* 2.0 (/ (* c0 t_1) w)))) (* 2.0 w)))
(if (<= t_3 0.0)
(* c0 (/ (/ (pow M 2.0) (+ t_0 (* t_1 (/ c0 (* w h))))) (* 2.0 w)))
(if (<= t_3 INFINITY)
(* c0 (/ (* 2.0 t_0) (* 2.0 w)))
(* c0 (/ 0.0 (* 2.0 w))))))))
double code(double c0, double w, double h, double D, double d, double M) {
double t_0 = (c0 * pow(d, 2.0)) / ((w * h) * pow(D, 2.0));
double t_1 = pow((d / D), 2.0);
double t_2 = (c0 * (d * d)) / ((D * D) * (w * h));
double t_3 = (c0 / (2.0 * w)) * (t_2 + sqrt(((t_2 * t_2) - (M * M))));
double tmp;
if (t_3 <= -1e-246) {
tmp = c0 * ((1.0 / (h / (2.0 * ((c0 * t_1) / w)))) / (2.0 * w));
} else if (t_3 <= 0.0) {
tmp = c0 * ((pow(M, 2.0) / (t_0 + (t_1 * (c0 / (w * h))))) / (2.0 * w));
} else if (t_3 <= ((double) INFINITY)) {
tmp = c0 * ((2.0 * t_0) / (2.0 * w));
} else {
tmp = c0 * (0.0 / (2.0 * w));
}
return tmp;
}
public static double code(double c0, double w, double h, double D, double d, double M) {
double t_0 = (c0 * Math.pow(d, 2.0)) / ((w * h) * Math.pow(D, 2.0));
double t_1 = Math.pow((d / D), 2.0);
double t_2 = (c0 * (d * d)) / ((D * D) * (w * h));
double t_3 = (c0 / (2.0 * w)) * (t_2 + Math.sqrt(((t_2 * t_2) - (M * M))));
double tmp;
if (t_3 <= -1e-246) {
tmp = c0 * ((1.0 / (h / (2.0 * ((c0 * t_1) / w)))) / (2.0 * w));
} else if (t_3 <= 0.0) {
tmp = c0 * ((Math.pow(M, 2.0) / (t_0 + (t_1 * (c0 / (w * h))))) / (2.0 * w));
} else if (t_3 <= Double.POSITIVE_INFINITY) {
tmp = c0 * ((2.0 * t_0) / (2.0 * w));
} else {
tmp = c0 * (0.0 / (2.0 * w));
}
return tmp;
}
def code(c0, w, h, D, d, M): t_0 = (c0 * math.pow(d, 2.0)) / ((w * h) * math.pow(D, 2.0)) t_1 = math.pow((d / D), 2.0) t_2 = (c0 * (d * d)) / ((D * D) * (w * h)) t_3 = (c0 / (2.0 * w)) * (t_2 + math.sqrt(((t_2 * t_2) - (M * M)))) tmp = 0 if t_3 <= -1e-246: tmp = c0 * ((1.0 / (h / (2.0 * ((c0 * t_1) / w)))) / (2.0 * w)) elif t_3 <= 0.0: tmp = c0 * ((math.pow(M, 2.0) / (t_0 + (t_1 * (c0 / (w * h))))) / (2.0 * w)) elif t_3 <= math.inf: tmp = c0 * ((2.0 * t_0) / (2.0 * w)) else: tmp = c0 * (0.0 / (2.0 * w)) return tmp
function code(c0, w, h, D, d, M) t_0 = Float64(Float64(c0 * (d ^ 2.0)) / Float64(Float64(w * h) * (D ^ 2.0))) t_1 = Float64(d / D) ^ 2.0 t_2 = Float64(Float64(c0 * Float64(d * d)) / Float64(Float64(D * D) * Float64(w * h))) t_3 = Float64(Float64(c0 / Float64(2.0 * w)) * Float64(t_2 + sqrt(Float64(Float64(t_2 * t_2) - Float64(M * M))))) tmp = 0.0 if (t_3 <= -1e-246) tmp = Float64(c0 * Float64(Float64(1.0 / Float64(h / Float64(2.0 * Float64(Float64(c0 * t_1) / w)))) / Float64(2.0 * w))); elseif (t_3 <= 0.0) tmp = Float64(c0 * Float64(Float64((M ^ 2.0) / Float64(t_0 + Float64(t_1 * Float64(c0 / Float64(w * h))))) / Float64(2.0 * w))); elseif (t_3 <= Inf) tmp = Float64(c0 * Float64(Float64(2.0 * t_0) / Float64(2.0 * w))); else tmp = Float64(c0 * Float64(0.0 / Float64(2.0 * w))); end return tmp end
function tmp_2 = code(c0, w, h, D, d, M) t_0 = (c0 * (d ^ 2.0)) / ((w * h) * (D ^ 2.0)); t_1 = (d / D) ^ 2.0; t_2 = (c0 * (d * d)) / ((D * D) * (w * h)); t_3 = (c0 / (2.0 * w)) * (t_2 + sqrt(((t_2 * t_2) - (M * M)))); tmp = 0.0; if (t_3 <= -1e-246) tmp = c0 * ((1.0 / (h / (2.0 * ((c0 * t_1) / w)))) / (2.0 * w)); elseif (t_3 <= 0.0) tmp = c0 * (((M ^ 2.0) / (t_0 + (t_1 * (c0 / (w * h))))) / (2.0 * w)); elseif (t_3 <= Inf) tmp = c0 * ((2.0 * t_0) / (2.0 * w)); else tmp = c0 * (0.0 / (2.0 * w)); end tmp_2 = tmp; end
code[c0_, w_, h_, D_, d_, M_] := Block[{t$95$0 = N[(N[(c0 * N[Power[d, 2.0], $MachinePrecision]), $MachinePrecision] / N[(N[(w * h), $MachinePrecision] * N[Power[D, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Power[N[(d / D), $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$2 = N[(N[(c0 * N[(d * d), $MachinePrecision]), $MachinePrecision] / N[(N[(D * D), $MachinePrecision] * N[(w * h), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(N[(c0 / N[(2.0 * w), $MachinePrecision]), $MachinePrecision] * 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, -1e-246], N[(c0 * N[(N[(1.0 / N[(h / N[(2.0 * N[(N[(c0 * t$95$1), $MachinePrecision] / w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(2.0 * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$3, 0.0], N[(c0 * N[(N[(N[Power[M, 2.0], $MachinePrecision] / N[(t$95$0 + N[(t$95$1 * N[(c0 / N[(w * h), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(2.0 * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$3, Infinity], N[(c0 * N[(N[(2.0 * t$95$0), $MachinePrecision] / N[(2.0 * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(c0 * N[(0.0 / N[(2.0 * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{c0 \cdot {d}^{2}}{\left(w \cdot h\right) \cdot {D}^{2}}\\
t_1 := {\left(\frac{d}{D}\right)}^{2}\\
t_2 := \frac{c0 \cdot \left(d \cdot d\right)}{\left(D \cdot D\right) \cdot \left(w \cdot h\right)}\\
t_3 := \frac{c0}{2 \cdot w} \cdot \left(t\_2 + \sqrt{t\_2 \cdot t\_2 - M \cdot M}\right)\\
\mathbf{if}\;t\_3 \leq -1 \cdot 10^{-246}:\\
\;\;\;\;c0 \cdot \frac{\frac{1}{\frac{h}{2 \cdot \frac{c0 \cdot t\_1}{w}}}}{2 \cdot w}\\
\mathbf{elif}\;t\_3 \leq 0:\\
\;\;\;\;c0 \cdot \frac{\frac{{M}^{2}}{t\_0 + t\_1 \cdot \frac{c0}{w \cdot h}}}{2 \cdot w}\\
\mathbf{elif}\;t\_3 \leq \infty:\\
\;\;\;\;c0 \cdot \frac{2 \cdot t\_0}{2 \cdot w}\\
\mathbf{else}:\\
\;\;\;\;c0 \cdot \frac{0}{2 \cdot w}\\
\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))))) < -9.99999999999999956e-247Initial program 87.5%
Simplified80.9%
Taylor expanded in h around 0 16.6%
Simplified87.5%
Taylor expanded in w around 0 87.5%
clear-num87.6%
inv-pow87.6%
Applied egg-rr90.8%
unpow-190.8%
associate-*l/90.8%
Simplified90.8%
if -9.99999999999999956e-247 < (*.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))))) < -0.0Initial program 33.6%
Simplified12.7%
Applied egg-rr13.1%
associate--r-57.8%
+-inverses57.8%
associate-*l/57.8%
associate-/l*58.2%
*-commutative58.2%
sub-neg58.2%
Simplified47.8%
div-inv47.9%
+-lft-identity47.9%
associate-*r/47.9%
*-commutative47.9%
associate-*l/47.9%
associate-/r*57.9%
Applied egg-rr57.7%
associate-*r/57.8%
*-rgt-identity57.8%
associate-/l/47.9%
fma-neg47.9%
associate-/l/47.8%
Simplified47.8%
Taylor expanded in c0 around -inf 68.0%
*-commutative68.0%
neg-mul-168.0%
distribute-neg-frac268.0%
*-commutative68.0%
Simplified68.0%
if -0.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))))) < +inf.0Initial program 73.4%
Simplified73.5%
Taylor expanded in c0 around inf 78.7%
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%
Simplified18.8%
Taylor expanded in c0 around -inf 1.3%
distribute-lft-in0.6%
mul-1-neg0.6%
distribute-rgt-neg-in0.6%
associate-/l*0.1%
mul-1-neg0.1%
associate-/l*0.1%
distribute-lft1-in0.1%
metadata-eval0.1%
mul0-lft36.9%
metadata-eval36.9%
Simplified36.9%
Final simplification50.3%
(FPCore (c0 w h D d M)
:precision binary64
(let* ((t_0 (/ (* c0 (* d d)) (* (* D D) (* w h)))))
(if (<=
(* (/ c0 (* 2.0 w)) (+ t_0 (sqrt (- (* t_0 t_0) (* M M)))))
INFINITY)
(*
c0
(/ (* 2.0 (/ (* c0 (pow d 2.0)) (* (* w h) (pow D 2.0)))) (* 2.0 w)))
(* c0 (/ 0.0 (* 2.0 w))))))
double code(double c0, double w, double h, double D, double d, double M) {
double t_0 = (c0 * (d * d)) / ((D * D) * (w * h));
double tmp;
if (((c0 / (2.0 * w)) * (t_0 + sqrt(((t_0 * t_0) - (M * M))))) <= ((double) INFINITY)) {
tmp = c0 * ((2.0 * ((c0 * pow(d, 2.0)) / ((w * h) * pow(D, 2.0)))) / (2.0 * w));
} else {
tmp = c0 * (0.0 / (2.0 * w));
}
return tmp;
}
public static double code(double c0, double w, double h, double D, double d, double M) {
double t_0 = (c0 * (d * d)) / ((D * D) * (w * h));
double tmp;
if (((c0 / (2.0 * w)) * (t_0 + Math.sqrt(((t_0 * t_0) - (M * M))))) <= Double.POSITIVE_INFINITY) {
tmp = c0 * ((2.0 * ((c0 * Math.pow(d, 2.0)) / ((w * h) * Math.pow(D, 2.0)))) / (2.0 * w));
} else {
tmp = c0 * (0.0 / (2.0 * w));
}
return tmp;
}
def code(c0, w, h, D, d, M): t_0 = (c0 * (d * d)) / ((D * D) * (w * h)) tmp = 0 if ((c0 / (2.0 * w)) * (t_0 + math.sqrt(((t_0 * t_0) - (M * M))))) <= math.inf: tmp = c0 * ((2.0 * ((c0 * math.pow(d, 2.0)) / ((w * h) * math.pow(D, 2.0)))) / (2.0 * w)) else: tmp = c0 * (0.0 / (2.0 * w)) return tmp
function code(c0, w, h, D, d, M) t_0 = Float64(Float64(c0 * Float64(d * d)) / Float64(Float64(D * D) * Float64(w * h))) tmp = 0.0 if (Float64(Float64(c0 / Float64(2.0 * w)) * Float64(t_0 + sqrt(Float64(Float64(t_0 * t_0) - Float64(M * M))))) <= Inf) tmp = Float64(c0 * Float64(Float64(2.0 * Float64(Float64(c0 * (d ^ 2.0)) / Float64(Float64(w * h) * (D ^ 2.0)))) / Float64(2.0 * w))); else tmp = Float64(c0 * Float64(0.0 / Float64(2.0 * w))); end return tmp end
function tmp_2 = code(c0, w, h, D, d, M) t_0 = (c0 * (d * d)) / ((D * D) * (w * h)); tmp = 0.0; if (((c0 / (2.0 * w)) * (t_0 + sqrt(((t_0 * t_0) - (M * M))))) <= Inf) tmp = c0 * ((2.0 * ((c0 * (d ^ 2.0)) / ((w * h) * (D ^ 2.0)))) / (2.0 * w)); else tmp = c0 * (0.0 / (2.0 * w)); 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[(D * D), $MachinePrecision] * N[(w * h), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[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], Infinity], N[(c0 * N[(N[(2.0 * N[(N[(c0 * N[Power[d, 2.0], $MachinePrecision]), $MachinePrecision] / N[(N[(w * h), $MachinePrecision] * N[Power[D, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(2.0 * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(c0 * N[(0.0 / N[(2.0 * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{c0 \cdot \left(d \cdot d\right)}{\left(D \cdot D\right) \cdot \left(w \cdot h\right)}\\
\mathbf{if}\;\frac{c0}{2 \cdot w} \cdot \left(t\_0 + \sqrt{t\_0 \cdot t\_0 - M \cdot M}\right) \leq \infty:\\
\;\;\;\;c0 \cdot \frac{2 \cdot \frac{c0 \cdot {d}^{2}}{\left(w \cdot h\right) \cdot {D}^{2}}}{2 \cdot w}\\
\mathbf{else}:\\
\;\;\;\;c0 \cdot \frac{0}{2 \cdot w}\\
\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 73.8%
Simplified68.4%
Taylor expanded in c0 around inf 74.9%
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%
Simplified18.8%
Taylor expanded in c0 around -inf 1.3%
distribute-lft-in0.6%
mul-1-neg0.6%
distribute-rgt-neg-in0.6%
associate-/l*0.1%
mul-1-neg0.1%
associate-/l*0.1%
distribute-lft1-in0.1%
metadata-eval0.1%
mul0-lft36.9%
metadata-eval36.9%
Simplified36.9%
Final simplification48.2%
(FPCore (c0 w h D d M)
:precision binary64
(let* ((t_0 (/ (* c0 (* d d)) (* (* D D) (* w h)))))
(if (<=
(* (/ c0 (* 2.0 w)) (+ t_0 (sqrt (- (* t_0 t_0) (* M M)))))
INFINITY)
(* c0 (/ (* 2.0 (/ (* c0 (pow (/ d D) 2.0)) (* w h))) (* 2.0 w)))
(* c0 (/ 0.0 (* 2.0 w))))))
double code(double c0, double w, double h, double D, double d, double M) {
double t_0 = (c0 * (d * d)) / ((D * D) * (w * h));
double tmp;
if (((c0 / (2.0 * w)) * (t_0 + sqrt(((t_0 * t_0) - (M * M))))) <= ((double) INFINITY)) {
tmp = c0 * ((2.0 * ((c0 * pow((d / D), 2.0)) / (w * h))) / (2.0 * w));
} else {
tmp = c0 * (0.0 / (2.0 * w));
}
return tmp;
}
public static double code(double c0, double w, double h, double D, double d, double M) {
double t_0 = (c0 * (d * d)) / ((D * D) * (w * h));
double tmp;
if (((c0 / (2.0 * w)) * (t_0 + Math.sqrt(((t_0 * t_0) - (M * M))))) <= Double.POSITIVE_INFINITY) {
tmp = c0 * ((2.0 * ((c0 * Math.pow((d / D), 2.0)) / (w * h))) / (2.0 * w));
} else {
tmp = c0 * (0.0 / (2.0 * w));
}
return tmp;
}
def code(c0, w, h, D, d, M): t_0 = (c0 * (d * d)) / ((D * D) * (w * h)) tmp = 0 if ((c0 / (2.0 * w)) * (t_0 + math.sqrt(((t_0 * t_0) - (M * M))))) <= math.inf: tmp = c0 * ((2.0 * ((c0 * math.pow((d / D), 2.0)) / (w * h))) / (2.0 * w)) else: tmp = c0 * (0.0 / (2.0 * w)) return tmp
function code(c0, w, h, D, d, M) t_0 = Float64(Float64(c0 * Float64(d * d)) / Float64(Float64(D * D) * Float64(w * h))) tmp = 0.0 if (Float64(Float64(c0 / Float64(2.0 * w)) * Float64(t_0 + sqrt(Float64(Float64(t_0 * t_0) - Float64(M * M))))) <= Inf) tmp = Float64(c0 * Float64(Float64(2.0 * Float64(Float64(c0 * (Float64(d / D) ^ 2.0)) / Float64(w * h))) / Float64(2.0 * w))); else tmp = Float64(c0 * Float64(0.0 / Float64(2.0 * w))); end return tmp end
function tmp_2 = code(c0, w, h, D, d, M) t_0 = (c0 * (d * d)) / ((D * D) * (w * h)); tmp = 0.0; if (((c0 / (2.0 * w)) * (t_0 + sqrt(((t_0 * t_0) - (M * M))))) <= Inf) tmp = c0 * ((2.0 * ((c0 * ((d / D) ^ 2.0)) / (w * h))) / (2.0 * w)); else tmp = c0 * (0.0 / (2.0 * w)); 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[(D * D), $MachinePrecision] * N[(w * h), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[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], Infinity], N[(c0 * N[(N[(2.0 * N[(N[(c0 * N[Power[N[(d / D), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / N[(w * h), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(2.0 * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(c0 * N[(0.0 / N[(2.0 * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{c0 \cdot \left(d \cdot d\right)}{\left(D \cdot D\right) \cdot \left(w \cdot h\right)}\\
\mathbf{if}\;\frac{c0}{2 \cdot w} \cdot \left(t\_0 + \sqrt{t\_0 \cdot t\_0 - M \cdot M}\right) \leq \infty:\\
\;\;\;\;c0 \cdot \frac{2 \cdot \frac{c0 \cdot {\left(\frac{d}{D}\right)}^{2}}{w \cdot h}}{2 \cdot w}\\
\mathbf{else}:\\
\;\;\;\;c0 \cdot \frac{0}{2 \cdot w}\\
\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 73.8%
Simplified68.4%
Taylor expanded in h around 0 25.1%
Simplified74.7%
Taylor expanded in w around 0 74.7%
div-inv74.7%
Applied egg-rr74.7%
associate-*r/74.7%
*-rgt-identity74.7%
associate-/l*74.7%
*-commutative74.7%
associate-*r/74.6%
*-rgt-identity74.6%
associate-*r/74.6%
associate-*l/69.3%
associate-*r/69.3%
*-rgt-identity69.3%
associate-/r*74.6%
*-commutative74.6%
associate-*l/74.9%
times-frac69.3%
Simplified69.3%
frac-times74.9%
*-commutative74.9%
Applied egg-rr74.9%
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%
Simplified18.8%
Taylor expanded in c0 around -inf 1.3%
distribute-lft-in0.6%
mul-1-neg0.6%
distribute-rgt-neg-in0.6%
associate-/l*0.1%
mul-1-neg0.1%
associate-/l*0.1%
distribute-lft1-in0.1%
metadata-eval0.1%
mul0-lft36.9%
metadata-eval36.9%
Simplified36.9%
Final simplification48.2%
(FPCore (c0 w h D d M) :precision binary64 (if (<= w 1.16e-32) (* c0 (* (pow (/ d D) 2.0) (/ (/ c0 (* w h)) w))) (* c0 (/ 0.0 (* 2.0 w)))))
double code(double c0, double w, double h, double D, double d, double M) {
double tmp;
if (w <= 1.16e-32) {
tmp = c0 * (pow((d / D), 2.0) * ((c0 / (w * h)) / w));
} else {
tmp = c0 * (0.0 / (2.0 * 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 (w <= 1.16d-32) then
tmp = c0 * (((d_1 / d) ** 2.0d0) * ((c0 / (w * h)) / w))
else
tmp = c0 * (0.0d0 / (2.0d0 * 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 (w <= 1.16e-32) {
tmp = c0 * (Math.pow((d / D), 2.0) * ((c0 / (w * h)) / w));
} else {
tmp = c0 * (0.0 / (2.0 * w));
}
return tmp;
}
def code(c0, w, h, D, d, M): tmp = 0 if w <= 1.16e-32: tmp = c0 * (math.pow((d / D), 2.0) * ((c0 / (w * h)) / w)) else: tmp = c0 * (0.0 / (2.0 * w)) return tmp
function code(c0, w, h, D, d, M) tmp = 0.0 if (w <= 1.16e-32) tmp = Float64(c0 * Float64((Float64(d / D) ^ 2.0) * Float64(Float64(c0 / Float64(w * h)) / w))); else tmp = Float64(c0 * Float64(0.0 / Float64(2.0 * w))); end return tmp end
function tmp_2 = code(c0, w, h, D, d, M) tmp = 0.0; if (w <= 1.16e-32) tmp = c0 * (((d / D) ^ 2.0) * ((c0 / (w * h)) / w)); else tmp = c0 * (0.0 / (2.0 * w)); end tmp_2 = tmp; end
code[c0_, w_, h_, D_, d_, M_] := If[LessEqual[w, 1.16e-32], N[(c0 * N[(N[Power[N[(d / D), $MachinePrecision], 2.0], $MachinePrecision] * N[(N[(c0 / N[(w * h), $MachinePrecision]), $MachinePrecision] / w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(c0 * N[(0.0 / N[(2.0 * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;w \leq 1.16 \cdot 10^{-32}:\\
\;\;\;\;c0 \cdot \left({\left(\frac{d}{D}\right)}^{2} \cdot \frac{\frac{c0}{w \cdot h}}{w}\right)\\
\mathbf{else}:\\
\;\;\;\;c0 \cdot \frac{0}{2 \cdot w}\\
\end{array}
\end{array}
if w < 1.16000000000000001e-32Initial program 23.2%
Simplified36.2%
Taylor expanded in h around 0 7.7%
Simplified32.5%
Taylor expanded in w around 0 33.1%
div-inv33.1%
Applied egg-rr44.7%
associate-*r/44.8%
*-rgt-identity44.8%
associate-/l*44.8%
*-commutative44.8%
associate-*r/44.2%
*-rgt-identity44.2%
associate-*r/44.2%
associate-*l/41.8%
associate-*r/41.8%
*-rgt-identity41.8%
associate-/r*44.5%
*-commutative44.5%
associate-*l/44.1%
times-frac41.8%
Simplified41.8%
Applied egg-rr44.5%
unpow144.5%
*-lft-identity44.5%
associate-/l*44.4%
*-commutative44.4%
Simplified44.4%
if 1.16000000000000001e-32 < w Initial program 15.9%
Simplified21.1%
Taylor expanded in c0 around -inf 6.9%
distribute-lft-in4.7%
mul-1-neg4.7%
distribute-rgt-neg-in4.7%
associate-/l*2.5%
mul-1-neg2.5%
associate-/l*2.6%
distribute-lft1-in2.6%
metadata-eval2.6%
mul0-lft47.2%
metadata-eval47.2%
Simplified47.2%
Final simplification44.9%
(FPCore (c0 w h D d M) :precision binary64 (if (<= w 3.6e+162) (* c0 (/ (* (pow (/ d D) 2.0) (/ c0 (* w h))) w)) (* c0 (/ 0.0 (* 2.0 w)))))
double code(double c0, double w, double h, double D, double d, double M) {
double tmp;
if (w <= 3.6e+162) {
tmp = c0 * ((pow((d / D), 2.0) * (c0 / (w * h))) / w);
} else {
tmp = c0 * (0.0 / (2.0 * 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 (w <= 3.6d+162) then
tmp = c0 * ((((d_1 / d) ** 2.0d0) * (c0 / (w * h))) / w)
else
tmp = c0 * (0.0d0 / (2.0d0 * 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 (w <= 3.6e+162) {
tmp = c0 * ((Math.pow((d / D), 2.0) * (c0 / (w * h))) / w);
} else {
tmp = c0 * (0.0 / (2.0 * w));
}
return tmp;
}
def code(c0, w, h, D, d, M): tmp = 0 if w <= 3.6e+162: tmp = c0 * ((math.pow((d / D), 2.0) * (c0 / (w * h))) / w) else: tmp = c0 * (0.0 / (2.0 * w)) return tmp
function code(c0, w, h, D, d, M) tmp = 0.0 if (w <= 3.6e+162) tmp = Float64(c0 * Float64(Float64((Float64(d / D) ^ 2.0) * Float64(c0 / Float64(w * h))) / w)); else tmp = Float64(c0 * Float64(0.0 / Float64(2.0 * w))); end return tmp end
function tmp_2 = code(c0, w, h, D, d, M) tmp = 0.0; if (w <= 3.6e+162) tmp = c0 * ((((d / D) ^ 2.0) * (c0 / (w * h))) / w); else tmp = c0 * (0.0 / (2.0 * w)); end tmp_2 = tmp; end
code[c0_, w_, h_, D_, d_, M_] := If[LessEqual[w, 3.6e+162], N[(c0 * N[(N[(N[Power[N[(d / D), $MachinePrecision], 2.0], $MachinePrecision] * N[(c0 / N[(w * h), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / w), $MachinePrecision]), $MachinePrecision], N[(c0 * N[(0.0 / N[(2.0 * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;w \leq 3.6 \cdot 10^{+162}:\\
\;\;\;\;c0 \cdot \frac{{\left(\frac{d}{D}\right)}^{2} \cdot \frac{c0}{w \cdot h}}{w}\\
\mathbf{else}:\\
\;\;\;\;c0 \cdot \frac{0}{2 \cdot w}\\
\end{array}
\end{array}
if w < 3.59999999999999994e162Initial program 22.4%
Simplified34.2%
Taylor expanded in h around 0 7.6%
Simplified31.0%
Taylor expanded in w around 0 32.0%
div-inv32.0%
Applied egg-rr43.7%
associate-*r/43.7%
*-rgt-identity43.7%
associate-/l*43.7%
*-commutative43.7%
associate-*r/43.6%
*-rgt-identity43.6%
associate-*r/43.6%
associate-*l/41.2%
associate-*r/41.2%
*-rgt-identity41.2%
associate-/r*43.8%
*-commutative43.8%
associate-*l/43.1%
times-frac41.2%
Simplified41.2%
times-frac41.2%
metadata-eval41.2%
frac-times43.1%
associate-*l/43.8%
*-commutative43.8%
*-commutative43.8%
Applied egg-rr43.8%
if 3.59999999999999994e162 < w Initial program 13.7%
Simplified21.7%
Taylor expanded in c0 around -inf 7.3%
distribute-lft-in7.3%
mul-1-neg7.3%
distribute-rgt-neg-in7.3%
associate-/l*7.2%
mul-1-neg7.2%
associate-/l*7.6%
distribute-lft1-in7.6%
metadata-eval7.6%
mul0-lft68.0%
metadata-eval68.0%
Simplified68.0%
Final simplification45.2%
(FPCore (c0 w h D d M) :precision binary64 (* c0 (/ 0.0 (* 2.0 w))))
double code(double c0, double w, double h, double D, double d, double M) {
return c0 * (0.0 / (2.0 * w));
}
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 = c0 * (0.0d0 / (2.0d0 * w))
end function
public static double code(double c0, double w, double h, double D, double d, double M) {
return c0 * (0.0 / (2.0 * w));
}
def code(c0, w, h, D, d, M): return c0 * (0.0 / (2.0 * w))
function code(c0, w, h, D, d, M) return Float64(c0 * Float64(0.0 / Float64(2.0 * w))) end
function tmp = code(c0, w, h, D, d, M) tmp = c0 * (0.0 / (2.0 * w)); end
code[c0_, w_, h_, D_, d_, M_] := N[(c0 * N[(0.0 / N[(2.0 * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
c0 \cdot \frac{0}{2 \cdot w}
\end{array}
Initial program 21.9%
Simplified33.5%
Taylor expanded in c0 around -inf 2.4%
distribute-lft-in1.9%
mul-1-neg1.9%
distribute-rgt-neg-in1.9%
associate-/l*2.0%
mul-1-neg2.0%
associate-/l*1.6%
distribute-lft1-in1.6%
metadata-eval1.6%
mul0-lft27.8%
metadata-eval27.8%
Simplified27.8%
Final simplification27.8%
herbie shell --seed 2024079
(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))))))