
(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 (* c0 (* d d)))
(t_1 (* (* w h) (* D D)))
(t_2 (/ c0 (* 2.0 w)))
(t_3 (/ t_0 t_1))
(t_4 (* t_2 (+ t_3 (sqrt (- (* t_3 t_3) (* M M)))))))
(if (<= t_4 -5e+42)
(/ (* c0 (* 2.0 (/ (* (/ c0 w) (* (/ d D) (/ d D))) h))) (* 2.0 w))
(if (<= t_4 0.0)
(* 0.25 (/ (* D D) (* (/ d h) (/ d (* M M)))))
(if (<= t_4 INFINITY)
(* t_2 (/ (* 2.0 t_0) t_1))
(* 0.25 (* (* M (* h M)) (* (/ D d) (/ D d)))))))))
double code(double c0, double w, double h, double D, double d, double M) {
double t_0 = c0 * (d * d);
double t_1 = (w * h) * (D * D);
double t_2 = c0 / (2.0 * w);
double t_3 = t_0 / t_1;
double t_4 = t_2 * (t_3 + sqrt(((t_3 * t_3) - (M * M))));
double tmp;
if (t_4 <= -5e+42) {
tmp = (c0 * (2.0 * (((c0 / w) * ((d / D) * (d / D))) / h))) / (2.0 * w);
} else if (t_4 <= 0.0) {
tmp = 0.25 * ((D * D) / ((d / h) * (d / (M * M))));
} else if (t_4 <= ((double) INFINITY)) {
tmp = t_2 * ((2.0 * t_0) / t_1);
} else {
tmp = 0.25 * ((M * (h * M)) * ((D / d) * (D / d)));
}
return tmp;
}
public static double code(double c0, double w, double h, double D, double d, double M) {
double t_0 = c0 * (d * d);
double t_1 = (w * h) * (D * D);
double t_2 = c0 / (2.0 * w);
double t_3 = t_0 / t_1;
double t_4 = t_2 * (t_3 + Math.sqrt(((t_3 * t_3) - (M * M))));
double tmp;
if (t_4 <= -5e+42) {
tmp = (c0 * (2.0 * (((c0 / w) * ((d / D) * (d / D))) / h))) / (2.0 * w);
} else if (t_4 <= 0.0) {
tmp = 0.25 * ((D * D) / ((d / h) * (d / (M * M))));
} else if (t_4 <= Double.POSITIVE_INFINITY) {
tmp = t_2 * ((2.0 * t_0) / t_1);
} else {
tmp = 0.25 * ((M * (h * M)) * ((D / d) * (D / d)));
}
return tmp;
}
def code(c0, w, h, D, d, M): t_0 = c0 * (d * d) t_1 = (w * h) * (D * D) t_2 = c0 / (2.0 * w) t_3 = t_0 / t_1 t_4 = t_2 * (t_3 + math.sqrt(((t_3 * t_3) - (M * M)))) tmp = 0 if t_4 <= -5e+42: tmp = (c0 * (2.0 * (((c0 / w) * ((d / D) * (d / D))) / h))) / (2.0 * w) elif t_4 <= 0.0: tmp = 0.25 * ((D * D) / ((d / h) * (d / (M * M)))) elif t_4 <= math.inf: tmp = t_2 * ((2.0 * t_0) / t_1) else: tmp = 0.25 * ((M * (h * M)) * ((D / d) * (D / d))) return tmp
function code(c0, w, h, D, d, M) t_0 = Float64(c0 * Float64(d * d)) t_1 = Float64(Float64(w * h) * Float64(D * D)) t_2 = Float64(c0 / Float64(2.0 * w)) t_3 = Float64(t_0 / t_1) t_4 = Float64(t_2 * Float64(t_3 + sqrt(Float64(Float64(t_3 * t_3) - Float64(M * M))))) tmp = 0.0 if (t_4 <= -5e+42) tmp = Float64(Float64(c0 * Float64(2.0 * Float64(Float64(Float64(c0 / w) * Float64(Float64(d / D) * Float64(d / D))) / h))) / Float64(2.0 * w)); elseif (t_4 <= 0.0) tmp = Float64(0.25 * Float64(Float64(D * D) / Float64(Float64(d / h) * Float64(d / Float64(M * M))))); elseif (t_4 <= Inf) tmp = Float64(t_2 * Float64(Float64(2.0 * t_0) / t_1)); else tmp = Float64(0.25 * Float64(Float64(M * Float64(h * M)) * Float64(Float64(D / d) * Float64(D / d)))); end return tmp end
function tmp_2 = code(c0, w, h, D, d, M) t_0 = c0 * (d * d); t_1 = (w * h) * (D * D); t_2 = c0 / (2.0 * w); t_3 = t_0 / t_1; t_4 = t_2 * (t_3 + sqrt(((t_3 * t_3) - (M * M)))); tmp = 0.0; if (t_4 <= -5e+42) tmp = (c0 * (2.0 * (((c0 / w) * ((d / D) * (d / D))) / h))) / (2.0 * w); elseif (t_4 <= 0.0) tmp = 0.25 * ((D * D) / ((d / h) * (d / (M * M)))); elseif (t_4 <= Inf) tmp = t_2 * ((2.0 * t_0) / t_1); else tmp = 0.25 * ((M * (h * M)) * ((D / d) * (D / d))); end tmp_2 = tmp; end
code[c0_, w_, h_, D_, d_, M_] := Block[{t$95$0 = N[(c0 * N[(d * d), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(w * h), $MachinePrecision] * N[(D * D), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(c0 / N[(2.0 * w), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(t$95$0 / t$95$1), $MachinePrecision]}, Block[{t$95$4 = N[(t$95$2 * 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+42], N[(N[(c0 * N[(2.0 * N[(N[(N[(c0 / w), $MachinePrecision] * N[(N[(d / D), $MachinePrecision] * N[(d / D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / h), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(2.0 * w), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$4, 0.0], N[(0.25 * N[(N[(D * D), $MachinePrecision] / N[(N[(d / h), $MachinePrecision] * N[(d / N[(M * M), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$4, Infinity], N[(t$95$2 * N[(N[(2.0 * t$95$0), $MachinePrecision] / t$95$1), $MachinePrecision]), $MachinePrecision], N[(0.25 * N[(N[(M * N[(h * M), $MachinePrecision]), $MachinePrecision] * N[(N[(D / d), $MachinePrecision] * N[(D / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := c0 \cdot \left(d \cdot d\right)\\
t_1 := \left(w \cdot h\right) \cdot \left(D \cdot D\right)\\
t_2 := \frac{c0}{2 \cdot w}\\
t_3 := \frac{t_0}{t_1}\\
t_4 := t_2 \cdot \left(t_3 + \sqrt{t_3 \cdot t_3 - M \cdot M}\right)\\
\mathbf{if}\;t_4 \leq -5 \cdot 10^{+42}:\\
\;\;\;\;\frac{c0 \cdot \left(2 \cdot \frac{\frac{c0}{w} \cdot \left(\frac{d}{D} \cdot \frac{d}{D}\right)}{h}\right)}{2 \cdot w}\\
\mathbf{elif}\;t_4 \leq 0:\\
\;\;\;\;0.25 \cdot \frac{D \cdot D}{\frac{d}{h} \cdot \frac{d}{M \cdot M}}\\
\mathbf{elif}\;t_4 \leq \infty:\\
\;\;\;\;t_2 \cdot \frac{2 \cdot t_0}{t_1}\\
\mathbf{else}:\\
\;\;\;\;0.25 \cdot \left(\left(M \cdot \left(h \cdot M\right)\right) \cdot \left(\frac{D}{d} \cdot \frac{D}{d}\right)\right)\\
\end{array}
\end{array}
if (*.f64 (/.f64 c0 (*.f64 2 w)) (+.f64 (/.f64 (*.f64 c0 (*.f64 d d)) (*.f64 (*.f64 w h) (*.f64 D D))) (sqrt.f64 (-.f64 (*.f64 (/.f64 (*.f64 c0 (*.f64 d d)) (*.f64 (*.f64 w h) (*.f64 D D))) (/.f64 (*.f64 c0 (*.f64 d d)) (*.f64 (*.f64 w h) (*.f64 D D)))) (*.f64 M M))))) < -5.00000000000000007e42Initial program 84.7%
times-frac78.7%
fma-def78.7%
associate-/r*78.7%
difference-of-squares78.7%
Simplified78.7%
fma-udef78.7%
associate-/l/78.7%
frac-times78.7%
pow278.7%
fma-udef78.7%
associate-/l/78.7%
times-frac78.7%
associate-/l/78.7%
times-frac78.7%
Applied egg-rr78.8%
Taylor expanded in c0 around inf 84.7%
unpow284.7%
times-frac78.8%
unpow278.8%
*-commutative78.8%
associate-/r*84.8%
times-frac84.9%
unpow284.9%
Simplified84.9%
associate-*l/84.9%
associate-*l/91.0%
*-commutative91.0%
Applied egg-rr91.0%
unpow291.0%
Applied egg-rr91.0%
if -5.00000000000000007e42 < (*.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 45.7%
Taylor expanded in c0 around -inf 71.7%
fma-def71.7%
associate-/l*57.9%
*-commutative57.9%
unpow257.9%
unpow257.9%
unpow257.9%
mul-1-neg57.9%
*-commutative57.9%
Simplified58.4%
Taylor expanded in c0 around 0 72.8%
unpow272.8%
associate-/l*72.8%
unpow272.8%
unpow272.8%
Simplified72.8%
times-frac73.5%
Applied egg-rr73.5%
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 78.9%
times-frac76.6%
fma-def76.6%
associate-/r*76.6%
difference-of-squares76.6%
Simplified76.6%
Taylor expanded in c0 around inf 83.0%
associate-*r/83.0%
unpow283.0%
unpow283.0%
Simplified83.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%
Taylor expanded in c0 around -inf 3.4%
fma-def3.4%
associate-/l*4.0%
*-commutative4.0%
unpow24.0%
unpow24.0%
unpow24.0%
mul-1-neg4.0%
*-commutative4.0%
Simplified30.5%
Taylor expanded in c0 around 0 42.5%
unpow242.5%
associate-/l*43.3%
unpow243.3%
unpow243.3%
Simplified43.3%
Taylor expanded in D around 0 42.5%
*-commutative42.5%
unpow242.5%
associate-*r/42.8%
associate-*r*44.1%
unpow244.1%
unpow244.1%
times-frac56.7%
Simplified56.7%
Final simplification66.5%
(FPCore (c0 w h D d M)
:precision binary64
(let* ((t_0 (* M (* h M)))
(t_1
(* (/ c0 (* 2.0 w)) (* 2.0 (* (* (/ d D) (/ d D)) (/ (/ c0 w) h))))))
(if (<= D 9.5e-128)
t_1
(if (<= D 7.6e-96)
(* 0.25 (/ (* D D) (/ (* d d) t_0)))
(if (<= D 8e-61)
(/ (* (* d d) (* c0 c0)) (* h (* (* D D) (* w w))))
(if (<= D 2.6e+170) (* 0.25 (* t_0 (* (/ D d) (/ D d)))) t_1))))))
double code(double c0, double w, double h, double D, double d, double M) {
double t_0 = M * (h * M);
double t_1 = (c0 / (2.0 * w)) * (2.0 * (((d / D) * (d / D)) * ((c0 / w) / h)));
double tmp;
if (D <= 9.5e-128) {
tmp = t_1;
} else if (D <= 7.6e-96) {
tmp = 0.25 * ((D * D) / ((d * d) / t_0));
} else if (D <= 8e-61) {
tmp = ((d * d) * (c0 * c0)) / (h * ((D * D) * (w * w)));
} else if (D <= 2.6e+170) {
tmp = 0.25 * (t_0 * ((D / d) * (D / d)));
} else {
tmp = t_1;
}
return tmp;
}
real(8) function code(c0, w, h, d, d_1, m)
real(8), intent (in) :: c0
real(8), intent (in) :: w
real(8), intent (in) :: h
real(8), intent (in) :: d
real(8), intent (in) :: d_1
real(8), intent (in) :: m
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = m * (h * m)
t_1 = (c0 / (2.0d0 * w)) * (2.0d0 * (((d_1 / d) * (d_1 / d)) * ((c0 / w) / h)))
if (d <= 9.5d-128) then
tmp = t_1
else if (d <= 7.6d-96) then
tmp = 0.25d0 * ((d * d) / ((d_1 * d_1) / t_0))
else if (d <= 8d-61) then
tmp = ((d_1 * d_1) * (c0 * c0)) / (h * ((d * d) * (w * w)))
else if (d <= 2.6d+170) then
tmp = 0.25d0 * (t_0 * ((d / d_1) * (d / d_1)))
else
tmp = t_1
end if
code = tmp
end function
public static double code(double c0, double w, double h, double D, double d, double M) {
double t_0 = M * (h * M);
double t_1 = (c0 / (2.0 * w)) * (2.0 * (((d / D) * (d / D)) * ((c0 / w) / h)));
double tmp;
if (D <= 9.5e-128) {
tmp = t_1;
} else if (D <= 7.6e-96) {
tmp = 0.25 * ((D * D) / ((d * d) / t_0));
} else if (D <= 8e-61) {
tmp = ((d * d) * (c0 * c0)) / (h * ((D * D) * (w * w)));
} else if (D <= 2.6e+170) {
tmp = 0.25 * (t_0 * ((D / d) * (D / d)));
} else {
tmp = t_1;
}
return tmp;
}
def code(c0, w, h, D, d, M): t_0 = M * (h * M) t_1 = (c0 / (2.0 * w)) * (2.0 * (((d / D) * (d / D)) * ((c0 / w) / h))) tmp = 0 if D <= 9.5e-128: tmp = t_1 elif D <= 7.6e-96: tmp = 0.25 * ((D * D) / ((d * d) / t_0)) elif D <= 8e-61: tmp = ((d * d) * (c0 * c0)) / (h * ((D * D) * (w * w))) elif D <= 2.6e+170: tmp = 0.25 * (t_0 * ((D / d) * (D / d))) else: tmp = t_1 return tmp
function code(c0, w, h, D, d, M) t_0 = Float64(M * Float64(h * M)) t_1 = Float64(Float64(c0 / Float64(2.0 * w)) * Float64(2.0 * Float64(Float64(Float64(d / D) * Float64(d / D)) * Float64(Float64(c0 / w) / h)))) tmp = 0.0 if (D <= 9.5e-128) tmp = t_1; elseif (D <= 7.6e-96) tmp = Float64(0.25 * Float64(Float64(D * D) / Float64(Float64(d * d) / t_0))); elseif (D <= 8e-61) tmp = Float64(Float64(Float64(d * d) * Float64(c0 * c0)) / Float64(h * Float64(Float64(D * D) * Float64(w * w)))); elseif (D <= 2.6e+170) tmp = Float64(0.25 * Float64(t_0 * Float64(Float64(D / d) * Float64(D / d)))); else tmp = t_1; end return tmp end
function tmp_2 = code(c0, w, h, D, d, M) t_0 = M * (h * M); t_1 = (c0 / (2.0 * w)) * (2.0 * (((d / D) * (d / D)) * ((c0 / w) / h))); tmp = 0.0; if (D <= 9.5e-128) tmp = t_1; elseif (D <= 7.6e-96) tmp = 0.25 * ((D * D) / ((d * d) / t_0)); elseif (D <= 8e-61) tmp = ((d * d) * (c0 * c0)) / (h * ((D * D) * (w * w))); elseif (D <= 2.6e+170) tmp = 0.25 * (t_0 * ((D / d) * (D / d))); else tmp = t_1; end tmp_2 = tmp; end
code[c0_, w_, h_, D_, d_, M_] := Block[{t$95$0 = N[(M * N[(h * M), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(c0 / N[(2.0 * w), $MachinePrecision]), $MachinePrecision] * N[(2.0 * N[(N[(N[(d / D), $MachinePrecision] * N[(d / D), $MachinePrecision]), $MachinePrecision] * N[(N[(c0 / w), $MachinePrecision] / h), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[D, 9.5e-128], t$95$1, If[LessEqual[D, 7.6e-96], N[(0.25 * N[(N[(D * D), $MachinePrecision] / N[(N[(d * d), $MachinePrecision] / t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[D, 8e-61], N[(N[(N[(d * d), $MachinePrecision] * N[(c0 * c0), $MachinePrecision]), $MachinePrecision] / N[(h * N[(N[(D * D), $MachinePrecision] * N[(w * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[D, 2.6e+170], N[(0.25 * N[(t$95$0 * N[(N[(D / d), $MachinePrecision] * N[(D / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := M \cdot \left(h \cdot M\right)\\
t_1 := \frac{c0}{2 \cdot w} \cdot \left(2 \cdot \left(\left(\frac{d}{D} \cdot \frac{d}{D}\right) \cdot \frac{\frac{c0}{w}}{h}\right)\right)\\
\mathbf{if}\;D \leq 9.5 \cdot 10^{-128}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;D \leq 7.6 \cdot 10^{-96}:\\
\;\;\;\;0.25 \cdot \frac{D \cdot D}{\frac{d \cdot d}{t_0}}\\
\mathbf{elif}\;D \leq 8 \cdot 10^{-61}:\\
\;\;\;\;\frac{\left(d \cdot d\right) \cdot \left(c0 \cdot c0\right)}{h \cdot \left(\left(D \cdot D\right) \cdot \left(w \cdot w\right)\right)}\\
\mathbf{elif}\;D \leq 2.6 \cdot 10^{+170}:\\
\;\;\;\;0.25 \cdot \left(t_0 \cdot \left(\frac{D}{d} \cdot \frac{D}{d}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if D < 9.50000000000000006e-128 or 2.5999999999999998e170 < D Initial program 29.8%
times-frac27.3%
fma-def26.8%
associate-/r*26.8%
difference-of-squares30.5%
Simplified37.9%
fma-udef38.9%
associate-/l/32.0%
frac-times37.9%
pow237.9%
fma-udef37.9%
associate-/l/32.0%
times-frac30.5%
associate-/l/30.4%
times-frac30.5%
Applied egg-rr39.5%
Taylor expanded in c0 around inf 35.1%
unpow235.1%
times-frac33.0%
unpow233.0%
*-commutative33.0%
associate-/r*35.7%
times-frac47.1%
unpow247.1%
Simplified47.1%
unpow248.2%
Applied egg-rr47.1%
if 9.50000000000000006e-128 < D < 7.6000000000000001e-96Initial program 0.4%
Taylor expanded in c0 around -inf 7.9%
fma-def7.9%
associate-/l*7.9%
*-commutative7.9%
unpow27.9%
unpow27.9%
unpow27.9%
mul-1-neg7.9%
*-commutative7.9%
Simplified55.1%
Taylor expanded in c0 around 0 70.5%
unpow270.5%
associate-/l*84.8%
unpow284.8%
unpow284.8%
Simplified84.8%
Taylor expanded in d around 0 84.8%
unpow284.8%
unpow284.8%
associate-*r*92.5%
Simplified92.5%
if 7.6000000000000001e-96 < D < 8.0000000000000003e-61Initial program 22.0%
times-frac22.0%
fma-def22.0%
associate-/r*22.0%
difference-of-squares43.5%
Simplified50.6%
Taylor expanded in c0 around inf 57.7%
unpow257.7%
unpow257.7%
associate-*r*57.7%
unpow257.7%
unpow257.7%
Simplified57.7%
if 8.0000000000000003e-61 < D < 2.5999999999999998e170Initial program 23.7%
Taylor expanded in c0 around -inf 15.4%
fma-def15.4%
associate-/l*15.4%
*-commutative15.4%
unpow215.4%
unpow215.4%
unpow215.4%
mul-1-neg15.4%
*-commutative15.4%
Simplified34.3%
Taylor expanded in c0 around 0 49.7%
unpow249.7%
associate-/l*47.3%
unpow247.3%
unpow247.3%
Simplified47.3%
Taylor expanded in D around 0 49.7%
*-commutative49.7%
unpow249.7%
associate-*r/49.7%
associate-*r*52.4%
unpow252.3%
unpow252.3%
times-frac62.3%
Simplified62.3%
Final simplification52.3%
(FPCore (c0 w h D d M) :precision binary64 (if (or (<= (* M M) 2e-56) (and (not (<= (* M M) 2e+49)) (<= (* M M) 5e+254))) (* 0.25 (* (* M (* h M)) (* (/ D d) (/ D d)))) (* (/ c0 w) (* (* (/ d D) (/ d D)) (/ (/ c0 h) w)))))
double code(double c0, double w, double h, double D, double d, double M) {
double tmp;
if (((M * M) <= 2e-56) || (!((M * M) <= 2e+49) && ((M * M) <= 5e+254))) {
tmp = 0.25 * ((M * (h * M)) * ((D / d) * (D / d)));
} else {
tmp = (c0 / w) * (((d / D) * (d / D)) * ((c0 / h) / 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 (((m * m) <= 2d-56) .or. (.not. ((m * m) <= 2d+49)) .and. ((m * m) <= 5d+254)) then
tmp = 0.25d0 * ((m * (h * m)) * ((d / d_1) * (d / d_1)))
else
tmp = (c0 / w) * (((d_1 / d) * (d_1 / d)) * ((c0 / h) / 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 (((M * M) <= 2e-56) || (!((M * M) <= 2e+49) && ((M * M) <= 5e+254))) {
tmp = 0.25 * ((M * (h * M)) * ((D / d) * (D / d)));
} else {
tmp = (c0 / w) * (((d / D) * (d / D)) * ((c0 / h) / w));
}
return tmp;
}
def code(c0, w, h, D, d, M): tmp = 0 if ((M * M) <= 2e-56) or (not ((M * M) <= 2e+49) and ((M * M) <= 5e+254)): tmp = 0.25 * ((M * (h * M)) * ((D / d) * (D / d))) else: tmp = (c0 / w) * (((d / D) * (d / D)) * ((c0 / h) / w)) return tmp
function code(c0, w, h, D, d, M) tmp = 0.0 if ((Float64(M * M) <= 2e-56) || (!(Float64(M * M) <= 2e+49) && (Float64(M * M) <= 5e+254))) tmp = Float64(0.25 * Float64(Float64(M * Float64(h * M)) * Float64(Float64(D / d) * Float64(D / d)))); else tmp = Float64(Float64(c0 / w) * Float64(Float64(Float64(d / D) * Float64(d / D)) * Float64(Float64(c0 / h) / w))); end return tmp end
function tmp_2 = code(c0, w, h, D, d, M) tmp = 0.0; if (((M * M) <= 2e-56) || (~(((M * M) <= 2e+49)) && ((M * M) <= 5e+254))) tmp = 0.25 * ((M * (h * M)) * ((D / d) * (D / d))); else tmp = (c0 / w) * (((d / D) * (d / D)) * ((c0 / h) / w)); end tmp_2 = tmp; end
code[c0_, w_, h_, D_, d_, M_] := If[Or[LessEqual[N[(M * M), $MachinePrecision], 2e-56], And[N[Not[LessEqual[N[(M * M), $MachinePrecision], 2e+49]], $MachinePrecision], LessEqual[N[(M * M), $MachinePrecision], 5e+254]]], N[(0.25 * N[(N[(M * N[(h * M), $MachinePrecision]), $MachinePrecision] * N[(N[(D / d), $MachinePrecision] * N[(D / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(c0 / w), $MachinePrecision] * N[(N[(N[(d / D), $MachinePrecision] * N[(d / D), $MachinePrecision]), $MachinePrecision] * N[(N[(c0 / h), $MachinePrecision] / w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;M \cdot M \leq 2 \cdot 10^{-56} \lor \neg \left(M \cdot M \leq 2 \cdot 10^{+49}\right) \land M \cdot M \leq 5 \cdot 10^{+254}:\\
\;\;\;\;0.25 \cdot \left(\left(M \cdot \left(h \cdot M\right)\right) \cdot \left(\frac{D}{d} \cdot \frac{D}{d}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{c0}{w} \cdot \left(\left(\frac{d}{D} \cdot \frac{d}{D}\right) \cdot \frac{\frac{c0}{h}}{w}\right)\\
\end{array}
\end{array}
if (*.f64 M M) < 2.0000000000000001e-56 or 1.99999999999999989e49 < (*.f64 M M) < 4.99999999999999994e254Initial program 28.7%
Taylor expanded in c0 around -inf 8.6%
fma-def8.6%
associate-/l*8.7%
*-commutative8.7%
unpow28.7%
unpow28.7%
unpow28.7%
mul-1-neg8.7%
*-commutative8.7%
Simplified30.0%
Taylor expanded in c0 around 0 40.8%
unpow240.8%
associate-/l*41.6%
unpow241.6%
unpow241.6%
Simplified41.6%
Taylor expanded in D around 0 40.8%
*-commutative40.8%
unpow240.8%
associate-*r/41.8%
associate-*r*42.3%
unpow242.3%
unpow242.3%
times-frac50.7%
Simplified50.7%
if 2.0000000000000001e-56 < (*.f64 M M) < 1.99999999999999989e49 or 4.99999999999999994e254 < (*.f64 M M) Initial program 22.6%
times-frac22.6%
fma-def22.6%
associate-/r*22.6%
difference-of-squares42.1%
Simplified44.9%
fma-udef44.9%
associate-/l/42.1%
frac-times44.9%
pow244.9%
fma-udef44.9%
associate-/l/42.1%
times-frac42.1%
associate-/l/42.1%
times-frac42.1%
Applied egg-rr24.0%
Taylor expanded in c0 around inf 48.4%
unpow248.4%
times-frac48.4%
unpow248.4%
*-commutative48.4%
associate-/r*55.4%
times-frac60.9%
unpow260.9%
Simplified60.9%
Taylor expanded in c0 around 0 36.8%
unpow236.8%
*-commutative36.8%
times-frac36.9%
unpow236.9%
unpow236.9%
times-frac41.2%
unpow241.2%
unpow241.2%
times-frac49.7%
associate-*r/45.3%
times-frac59.3%
associate-*r*60.9%
associate-/l/53.9%
*-commutative53.9%
associate-/l/60.9%
Simplified60.9%
unpow261.0%
Applied egg-rr60.9%
Final simplification53.6%
(FPCore (c0 w h D d M) :precision binary64 (if (<= (* M M) 5e+254) (* 0.25 (* (* M (* h M)) (* (/ D d) (/ D d)))) (* (* (/ d D) (/ d D)) (* (/ c0 h) (/ c0 (* w w))))))
double code(double c0, double w, double h, double D, double d, double M) {
double tmp;
if ((M * M) <= 5e+254) {
tmp = 0.25 * ((M * (h * M)) * ((D / d) * (D / d)));
} else {
tmp = ((d / D) * (d / D)) * ((c0 / h) * (c0 / (w * w)));
}
return tmp;
}
real(8) function code(c0, w, h, d, d_1, m)
real(8), intent (in) :: c0
real(8), intent (in) :: w
real(8), intent (in) :: h
real(8), intent (in) :: d
real(8), intent (in) :: d_1
real(8), intent (in) :: m
real(8) :: tmp
if ((m * m) <= 5d+254) then
tmp = 0.25d0 * ((m * (h * m)) * ((d / d_1) * (d / d_1)))
else
tmp = ((d_1 / d) * (d_1 / d)) * ((c0 / h) * (c0 / (w * w)))
end if
code = tmp
end function
public static double code(double c0, double w, double h, double D, double d, double M) {
double tmp;
if ((M * M) <= 5e+254) {
tmp = 0.25 * ((M * (h * M)) * ((D / d) * (D / d)));
} else {
tmp = ((d / D) * (d / D)) * ((c0 / h) * (c0 / (w * w)));
}
return tmp;
}
def code(c0, w, h, D, d, M): tmp = 0 if (M * M) <= 5e+254: tmp = 0.25 * ((M * (h * M)) * ((D / d) * (D / d))) else: tmp = ((d / D) * (d / D)) * ((c0 / h) * (c0 / (w * w))) return tmp
function code(c0, w, h, D, d, M) tmp = 0.0 if (Float64(M * M) <= 5e+254) tmp = Float64(0.25 * Float64(Float64(M * Float64(h * M)) * Float64(Float64(D / d) * Float64(D / d)))); else tmp = Float64(Float64(Float64(d / D) * Float64(d / D)) * Float64(Float64(c0 / h) * Float64(c0 / Float64(w * w)))); end return tmp end
function tmp_2 = code(c0, w, h, D, d, M) tmp = 0.0; if ((M * M) <= 5e+254) tmp = 0.25 * ((M * (h * M)) * ((D / d) * (D / d))); else tmp = ((d / D) * (d / D)) * ((c0 / h) * (c0 / (w * w))); end tmp_2 = tmp; end
code[c0_, w_, h_, D_, d_, M_] := If[LessEqual[N[(M * M), $MachinePrecision], 5e+254], N[(0.25 * N[(N[(M * N[(h * M), $MachinePrecision]), $MachinePrecision] * N[(N[(D / d), $MachinePrecision] * N[(D / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(d / D), $MachinePrecision] * N[(d / D), $MachinePrecision]), $MachinePrecision] * N[(N[(c0 / h), $MachinePrecision] * N[(c0 / N[(w * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;M \cdot M \leq 5 \cdot 10^{+254}:\\
\;\;\;\;0.25 \cdot \left(\left(M \cdot \left(h \cdot M\right)\right) \cdot \left(\frac{D}{d} \cdot \frac{D}{d}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\frac{d}{D} \cdot \frac{d}{D}\right) \cdot \left(\frac{c0}{h} \cdot \frac{c0}{w \cdot w}\right)\\
\end{array}
\end{array}
if (*.f64 M M) < 4.99999999999999994e254Initial program 30.8%
Taylor expanded in c0 around -inf 8.4%
fma-def8.4%
associate-/l*8.4%
*-commutative8.4%
unpow28.4%
unpow28.4%
unpow28.4%
mul-1-neg8.4%
*-commutative8.4%
Simplified29.6%
Taylor expanded in c0 around 0 39.5%
unpow239.5%
associate-/l*40.2%
unpow240.2%
unpow240.2%
Simplified40.2%
Taylor expanded in D around 0 39.5%
*-commutative39.5%
unpow239.5%
associate-*r/40.4%
associate-*r*40.9%
unpow240.9%
unpow240.9%
times-frac48.6%
Simplified48.6%
if 4.99999999999999994e254 < (*.f64 M M) Initial program 12.9%
times-frac12.9%
fma-def12.9%
associate-/r*12.9%
difference-of-squares38.5%
Simplified42.1%
fma-udef42.1%
associate-/l/38.5%
frac-times42.1%
pow242.1%
fma-udef42.1%
associate-/l/38.5%
times-frac38.5%
associate-/l/38.5%
times-frac38.5%
Applied egg-rr12.9%
Taylor expanded in c0 around inf 37.3%
unpow237.3%
times-frac37.4%
unpow237.4%
times-frac42.8%
unpow242.8%
unpow242.8%
*-commutative42.8%
times-frac52.0%
unpow252.0%
Simplified52.0%
unpow259.6%
Applied egg-rr52.0%
Final simplification49.3%
(FPCore (c0 w h D d M) :precision binary64 (* 0.25 (* (* M (* h M)) (* (/ D d) (/ D d)))))
double code(double c0, double w, double h, double D, double d, double M) {
return 0.25 * ((M * (h * M)) * ((D / d) * (D / d)));
}
real(8) function code(c0, w, h, d, d_1, m)
real(8), intent (in) :: c0
real(8), intent (in) :: w
real(8), intent (in) :: h
real(8), intent (in) :: d
real(8), intent (in) :: d_1
real(8), intent (in) :: m
code = 0.25d0 * ((m * (h * m)) * ((d / d_1) * (d / d_1)))
end function
public static double code(double c0, double w, double h, double D, double d, double M) {
return 0.25 * ((M * (h * M)) * ((D / d) * (D / d)));
}
def code(c0, w, h, D, d, M): return 0.25 * ((M * (h * M)) * ((D / d) * (D / d)))
function code(c0, w, h, D, d, M) return Float64(0.25 * Float64(Float64(M * Float64(h * M)) * Float64(Float64(D / d) * Float64(D / d)))) end
function tmp = code(c0, w, h, D, d, M) tmp = 0.25 * ((M * (h * M)) * ((D / d) * (D / d))); end
code[c0_, w_, h_, D_, d_, M_] := N[(0.25 * N[(N[(M * N[(h * M), $MachinePrecision]), $MachinePrecision] * N[(N[(D / d), $MachinePrecision] * N[(D / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
0.25 \cdot \left(\left(M \cdot \left(h \cdot M\right)\right) \cdot \left(\frac{D}{d} \cdot \frac{D}{d}\right)\right)
\end{array}
Initial program 27.0%
Taylor expanded in c0 around -inf 7.0%
fma-def7.0%
associate-/l*7.0%
*-commutative7.0%
unpow27.0%
unpow27.0%
unpow27.0%
mul-1-neg7.0%
*-commutative7.0%
Simplified24.8%
Taylor expanded in c0 around 0 33.4%
unpow233.4%
associate-/l*34.0%
unpow234.0%
unpow234.0%
Simplified34.0%
Taylor expanded in D around 0 33.4%
*-commutative33.4%
unpow233.4%
associate-*r/33.3%
associate-*r*34.1%
unpow234.1%
unpow234.1%
times-frac42.6%
Simplified42.6%
Final simplification42.6%
(FPCore (c0 w h D d M) :precision binary64 (* -0.5 (/ 0.0 w)))
double code(double c0, double w, double h, double D, double d, double M) {
return -0.5 * (0.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 = (-0.5d0) * (0.0d0 / w)
end function
public static double code(double c0, double w, double h, double D, double d, double M) {
return -0.5 * (0.0 / w);
}
def code(c0, w, h, D, d, M): return -0.5 * (0.0 / w)
function code(c0, w, h, D, d, M) return Float64(-0.5 * Float64(0.0 / w)) end
function tmp = code(c0, w, h, D, d, M) tmp = -0.5 * (0.0 / w); end
code[c0_, w_, h_, D_, d_, M_] := N[(-0.5 * N[(0.0 / w), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
-0.5 \cdot \frac{0}{w}
\end{array}
Initial program 27.0%
times-frac25.1%
fma-def24.7%
associate-/r*24.7%
difference-of-squares30.2%
Simplified36.5%
Taylor expanded in c0 around -inf 2.7%
*-commutative2.7%
unpow22.7%
distribute-rgt1-in2.7%
metadata-eval2.7%
mul0-lft24.8%
Simplified24.8%
Taylor expanded in c0 around 0 31.3%
Final simplification31.3%
herbie shell --seed 2023192
(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))))))