
(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 (* 2.0 w)))
(t_1 (* (* w h) (* D D)))
(t_2 (* (* d d) (/ c0 t_1)))
(t_3 (pow t_2 2.0))
(t_4 (/ (* c0 (* d d)) t_1))
(t_5 (* t_0 (+ t_4 (sqrt (- (* t_4 t_4) (* M M))))))
(t_6 (pow (/ d D) 2.0)))
(if (<= t_5 -2e-251)
(* t_0 (/ (- (* c0 (/ t_6 w)) (* t_6 (/ c0 (* w (cbrt -1.0))))) h))
(if (<= t_5 0.0)
(* t_0 (/ (+ (* M M) (- t_3 t_3)) (- t_2 (sqrt (- t_3 (* M M))))))
(if (<= t_5 INFINITY)
(* (/ c0 w) (* (* d d) (/ c0 (* D (* (* w h) D)))))
(* t_0 (fma 0.0 c0 (* (/ 0.5 c0) (/ (* w (* M (* h M))) t_6)))))))))
double code(double c0, double w, double h, double D, double d, double M) {
double t_0 = c0 / (2.0 * w);
double t_1 = (w * h) * (D * D);
double t_2 = (d * d) * (c0 / t_1);
double t_3 = pow(t_2, 2.0);
double t_4 = (c0 * (d * d)) / t_1;
double t_5 = t_0 * (t_4 + sqrt(((t_4 * t_4) - (M * M))));
double t_6 = pow((d / D), 2.0);
double tmp;
if (t_5 <= -2e-251) {
tmp = t_0 * (((c0 * (t_6 / w)) - (t_6 * (c0 / (w * cbrt(-1.0))))) / h);
} else if (t_5 <= 0.0) {
tmp = t_0 * (((M * M) + (t_3 - t_3)) / (t_2 - sqrt((t_3 - (M * M)))));
} else if (t_5 <= ((double) INFINITY)) {
tmp = (c0 / w) * ((d * d) * (c0 / (D * ((w * h) * D))));
} else {
tmp = t_0 * fma(0.0, c0, ((0.5 / c0) * ((w * (M * (h * M))) / t_6)));
}
return tmp;
}
function code(c0, w, h, D, d, M) t_0 = Float64(c0 / Float64(2.0 * w)) t_1 = Float64(Float64(w * h) * Float64(D * D)) t_2 = Float64(Float64(d * d) * Float64(c0 / t_1)) t_3 = t_2 ^ 2.0 t_4 = Float64(Float64(c0 * Float64(d * d)) / t_1) t_5 = Float64(t_0 * Float64(t_4 + sqrt(Float64(Float64(t_4 * t_4) - Float64(M * M))))) t_6 = Float64(d / D) ^ 2.0 tmp = 0.0 if (t_5 <= -2e-251) tmp = Float64(t_0 * Float64(Float64(Float64(c0 * Float64(t_6 / w)) - Float64(t_6 * Float64(c0 / Float64(w * cbrt(-1.0))))) / h)); elseif (t_5 <= 0.0) tmp = Float64(t_0 * Float64(Float64(Float64(M * M) + Float64(t_3 - t_3)) / Float64(t_2 - sqrt(Float64(t_3 - Float64(M * M)))))); elseif (t_5 <= Inf) tmp = Float64(Float64(c0 / w) * Float64(Float64(d * d) * Float64(c0 / Float64(D * Float64(Float64(w * h) * D))))); else tmp = Float64(t_0 * fma(0.0, c0, Float64(Float64(0.5 / c0) * Float64(Float64(w * Float64(M * Float64(h * M))) / t_6)))); end return 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[(w * h), $MachinePrecision] * N[(D * D), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(d * d), $MachinePrecision] * N[(c0 / t$95$1), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[Power[t$95$2, 2.0], $MachinePrecision]}, Block[{t$95$4 = N[(N[(c0 * N[(d * d), $MachinePrecision]), $MachinePrecision] / t$95$1), $MachinePrecision]}, Block[{t$95$5 = N[(t$95$0 * N[(t$95$4 + N[Sqrt[N[(N[(t$95$4 * t$95$4), $MachinePrecision] - N[(M * M), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$6 = N[Power[N[(d / D), $MachinePrecision], 2.0], $MachinePrecision]}, If[LessEqual[t$95$5, -2e-251], N[(t$95$0 * N[(N[(N[(c0 * N[(t$95$6 / w), $MachinePrecision]), $MachinePrecision] - N[(t$95$6 * N[(c0 / N[(w * N[Power[-1.0, 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / h), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$5, 0.0], N[(t$95$0 * N[(N[(N[(M * M), $MachinePrecision] + N[(t$95$3 - t$95$3), $MachinePrecision]), $MachinePrecision] / N[(t$95$2 - N[Sqrt[N[(t$95$3 - N[(M * M), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$5, Infinity], N[(N[(c0 / w), $MachinePrecision] * N[(N[(d * d), $MachinePrecision] * N[(c0 / N[(D * N[(N[(w * h), $MachinePrecision] * D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$0 * N[(0.0 * c0 + N[(N[(0.5 / c0), $MachinePrecision] * N[(N[(w * N[(M * N[(h * M), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / t$95$6), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{c0}{2 \cdot w}\\
t_1 := \left(w \cdot h\right) \cdot \left(D \cdot D\right)\\
t_2 := \left(d \cdot d\right) \cdot \frac{c0}{t_1}\\
t_3 := {t_2}^{2}\\
t_4 := \frac{c0 \cdot \left(d \cdot d\right)}{t_1}\\
t_5 := t_0 \cdot \left(t_4 + \sqrt{t_4 \cdot t_4 - M \cdot M}\right)\\
t_6 := {\left(\frac{d}{D}\right)}^{2}\\
\mathbf{if}\;t_5 \leq -2 \cdot 10^{-251}:\\
\;\;\;\;t_0 \cdot \frac{c0 \cdot \frac{t_6}{w} - t_6 \cdot \frac{c0}{w \cdot \sqrt[3]{-1}}}{h}\\
\mathbf{elif}\;t_5 \leq 0:\\
\;\;\;\;t_0 \cdot \frac{M \cdot M + \left(t_3 - t_3\right)}{t_2 - \sqrt{t_3 - M \cdot M}}\\
\mathbf{elif}\;t_5 \leq \infty:\\
\;\;\;\;\frac{c0}{w} \cdot \left(\left(d \cdot d\right) \cdot \frac{c0}{D \cdot \left(\left(w \cdot h\right) \cdot D\right)}\right)\\
\mathbf{else}:\\
\;\;\;\;t_0 \cdot \mathsf{fma}\left(0, c0, \frac{0.5}{c0} \cdot \frac{w \cdot \left(M \cdot \left(h \cdot M\right)\right)}{t_6}\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))))) < -2.00000000000000003e-251Initial program 74.2%
times-frac70.1%
fma-def70.1%
associate-/r*70.1%
difference-of-squares70.1%
Simplified72.1%
Taylor expanded in c0 around inf 72.3%
times-frac72.3%
associate-*l/72.3%
associate-*r/72.3%
unpow272.3%
associate-/l/72.3%
unpow272.3%
Simplified72.3%
add-cbrt-cube66.1%
*-commutative66.1%
*-commutative66.1%
*-commutative66.1%
Applied egg-rr66.1%
associate-*l*66.1%
cube-unmult66.1%
associate-*r*66.1%
*-commutative66.1%
associate-*l*66.1%
*-commutative66.1%
Simplified66.1%
Taylor expanded in h around -inf 78.3%
associate-*r/78.3%
Simplified80.5%
if -2.00000000000000003e-251 < (*.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 52.3%
times-frac37.3%
fma-def26.4%
associate-/r*26.4%
difference-of-squares26.4%
Simplified26.1%
fma-udef52.4%
associate-/l/52.4%
times-frac36.5%
fma-udef36.5%
associate-/l/36.5%
times-frac41.1%
associate-/l/41.1%
times-frac52.3%
Applied egg-rr51.0%
Simplified77.6%
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 72.0%
times-frac69.0%
fma-def69.0%
associate-/r*69.0%
difference-of-squares69.0%
Simplified74.1%
Taylor expanded in c0 around inf 74.2%
times-frac74.4%
unpow274.4%
unpow274.4%
*-commutative74.4%
times-frac77.1%
unpow277.1%
Simplified77.1%
expm1-log1p-u76.4%
expm1-udef71.6%
*-commutative71.6%
associate-*r*71.6%
Applied egg-rr71.6%
expm1-def76.4%
expm1-log1p77.1%
associate-*l/75.1%
times-frac77.2%
associate-*l*77.2%
*-commutative77.2%
unpow277.2%
times-frac74.5%
unpow274.5%
times-frac74.3%
unpow274.3%
*-commutative74.3%
associate-/l*74.3%
Simplified74.6%
Taylor expanded in d around 0 74.3%
unpow274.3%
associate-*r/76.9%
unpow276.9%
associate-*r*79.6%
Simplified79.6%
if +inf.0 < (*.f64 (/.f64 c0 (*.f64 2 w)) (+.f64 (/.f64 (*.f64 c0 (*.f64 d d)) (*.f64 (*.f64 w h) (*.f64 D D))) (sqrt.f64 (-.f64 (*.f64 (/.f64 (*.f64 c0 (*.f64 d d)) (*.f64 (*.f64 w h) (*.f64 D D))) (/.f64 (*.f64 c0 (*.f64 d d)) (*.f64 (*.f64 w h) (*.f64 D D)))) (*.f64 M M))))) Initial program 0.0%
associate-*l/0.0%
*-commutative0.0%
fma-def0.0%
associate-*l*0.0%
*-commutative0.0%
associate-*r*0.0%
associate-*l*0.1%
*-commutative0.1%
Simplified4.0%
fma-udef4.0%
associate-*l*3.3%
associate-/l/2.6%
associate-/l/2.6%
*-commutative2.6%
Applied egg-rr2.6%
fma-def2.7%
associate-/r*2.7%
*-commutative2.7%
fma-def2.7%
Simplified4.1%
Taylor expanded in c0 around -inf 2.0%
+-commutative2.0%
associate-*r*2.0%
*-commutative2.0%
fma-def2.0%
Simplified51.1%
Final simplification61.4%
(FPCore (c0 w h D d M)
:precision binary64
(let* ((t_0 (pow (/ d D) 2.0))
(t_1 (/ c0 (* 2.0 w)))
(t_2 (/ (* c0 (* d d)) (* (* w h) (* D D)))))
(if (<= (* t_1 (+ t_2 (sqrt (- (* t_2 t_2) (* M M))))) INFINITY)
(* t_1 (/ (- (* c0 (/ t_0 w)) (* t_0 (/ c0 (* w (cbrt -1.0))))) h))
(* t_1 (fma 0.0 c0 (* (/ 0.5 c0) (/ (* w (* M (* h M))) t_0)))))))
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 / (2.0 * w);
double t_2 = (c0 * (d * d)) / ((w * h) * (D * D));
double tmp;
if ((t_1 * (t_2 + sqrt(((t_2 * t_2) - (M * M))))) <= ((double) INFINITY)) {
tmp = t_1 * (((c0 * (t_0 / w)) - (t_0 * (c0 / (w * cbrt(-1.0))))) / h);
} else {
tmp = t_1 * fma(0.0, c0, ((0.5 / c0) * ((w * (M * (h * M))) / t_0)));
}
return tmp;
}
function code(c0, w, h, D, d, M) t_0 = Float64(d / D) ^ 2.0 t_1 = Float64(c0 / Float64(2.0 * w)) t_2 = Float64(Float64(c0 * Float64(d * d)) / Float64(Float64(w * h) * Float64(D * D))) tmp = 0.0 if (Float64(t_1 * Float64(t_2 + sqrt(Float64(Float64(t_2 * t_2) - Float64(M * M))))) <= Inf) tmp = Float64(t_1 * Float64(Float64(Float64(c0 * Float64(t_0 / w)) - Float64(t_0 * Float64(c0 / Float64(w * cbrt(-1.0))))) / h)); else tmp = Float64(t_1 * fma(0.0, c0, Float64(Float64(0.5 / c0) * Float64(Float64(w * Float64(M * Float64(h * M))) / t_0)))); end return 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[(c0 / N[(2.0 * w), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(c0 * N[(d * d), $MachinePrecision]), $MachinePrecision] / N[(N[(w * h), $MachinePrecision] * N[(D * D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(t$95$1 * N[(t$95$2 + N[Sqrt[N[(N[(t$95$2 * t$95$2), $MachinePrecision] - N[(M * M), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], Infinity], N[(t$95$1 * N[(N[(N[(c0 * N[(t$95$0 / w), $MachinePrecision]), $MachinePrecision] - N[(t$95$0 * N[(c0 / N[(w * N[Power[-1.0, 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / h), $MachinePrecision]), $MachinePrecision], N[(t$95$1 * N[(0.0 * c0 + N[(N[(0.5 / c0), $MachinePrecision] * N[(N[(w * N[(M * N[(h * M), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\left(\frac{d}{D}\right)}^{2}\\
t_1 := \frac{c0}{2 \cdot w}\\
t_2 := \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)}\\
\mathbf{if}\;t_1 \cdot \left(t_2 + \sqrt{t_2 \cdot t_2 - M \cdot M}\right) \leq \infty:\\
\;\;\;\;t_1 \cdot \frac{c0 \cdot \frac{t_0}{w} - t_0 \cdot \frac{c0}{w \cdot \sqrt[3]{-1}}}{h}\\
\mathbf{else}:\\
\;\;\;\;t_1 \cdot \mathsf{fma}\left(0, c0, \frac{0.5}{c0} \cdot \frac{w \cdot \left(M \cdot \left(h \cdot M\right)\right)}{t_0}\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))))) < +inf.0Initial program 71.2%
times-frac66.5%
fma-def65.4%
associate-/r*65.4%
difference-of-squares65.4%
Simplified68.4%
Taylor expanded in c0 around inf 66.6%
times-frac68.6%
associate-*l/67.6%
associate-*r/68.6%
unpow268.6%
associate-/l/67.6%
unpow267.6%
Simplified67.6%
add-cbrt-cube63.5%
*-commutative63.5%
*-commutative63.5%
*-commutative63.5%
Applied egg-rr63.5%
associate-*l*63.5%
cube-unmult63.5%
associate-*r*63.5%
*-commutative63.5%
associate-*l*63.5%
*-commutative63.5%
Simplified63.5%
Taylor expanded in h around -inf 73.1%
associate-*r/73.1%
Simplified74.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%
associate-*l/0.0%
*-commutative0.0%
fma-def0.0%
associate-*l*0.0%
*-commutative0.0%
associate-*r*0.0%
associate-*l*0.1%
*-commutative0.1%
Simplified4.0%
fma-udef4.0%
associate-*l*3.3%
associate-/l/2.6%
associate-/l/2.6%
*-commutative2.6%
Applied egg-rr2.6%
fma-def2.7%
associate-/r*2.7%
*-commutative2.7%
fma-def2.7%
Simplified4.1%
Taylor expanded in c0 around -inf 2.0%
+-commutative2.0%
associate-*r*2.0%
*-commutative2.0%
fma-def2.0%
Simplified51.1%
Final simplification59.3%
(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)
(* (/ c0 w) (* (* d d) (/ c0 (* D (* (* w h) D)))))
(*
t_0
(fma 0.0 c0 (* (/ 0.5 c0) (/ (* w (* M (* h M))) (pow (/ d 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 = (c0 / w) * ((d * d) * (c0 / (D * ((w * h) * D))));
} else {
tmp = t_0 * fma(0.0, c0, ((0.5 / c0) * ((w * (M * (h * M))) / pow((d / 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(Float64(c0 / w) * Float64(Float64(d * d) * Float64(c0 / Float64(D * Float64(Float64(w * h) * D))))); else tmp = Float64(t_0 * fma(0.0, c0, Float64(Float64(0.5 / c0) * Float64(Float64(w * Float64(M * Float64(h * M))) / (Float64(d / D) ^ 2.0))))); end return 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[(N[(c0 / w), $MachinePrecision] * N[(N[(d * d), $MachinePrecision] * N[(c0 / N[(D * N[(N[(w * h), $MachinePrecision] * D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$0 * N[(0.0 * c0 + N[(N[(0.5 / c0), $MachinePrecision] * N[(N[(w * N[(M * N[(h * M), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Power[N[(d / D), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $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:\\
\;\;\;\;\frac{c0}{w} \cdot \left(\left(d \cdot d\right) \cdot \frac{c0}{D \cdot \left(\left(w \cdot h\right) \cdot D\right)}\right)\\
\mathbf{else}:\\
\;\;\;\;t_0 \cdot \mathsf{fma}\left(0, c0, \frac{0.5}{c0} \cdot \frac{w \cdot \left(M \cdot \left(h \cdot M\right)\right)}{{\left(\frac{d}{D}\right)}^{2}}\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))))) < +inf.0Initial program 71.2%
times-frac66.5%
fma-def65.4%
associate-/r*65.4%
difference-of-squares65.4%
Simplified68.4%
Taylor expanded in c0 around inf 70.7%
times-frac68.6%
unpow268.6%
unpow268.6%
*-commutative68.6%
times-frac72.8%
unpow272.8%
Simplified72.8%
expm1-log1p-u34.1%
expm1-udef31.6%
*-commutative31.6%
associate-*r*31.6%
Applied egg-rr31.6%
expm1-def34.1%
expm1-log1p72.8%
associate-*l/71.0%
times-frac72.9%
associate-*l*72.9%
*-commutative72.9%
unpow272.9%
times-frac68.7%
unpow268.7%
times-frac70.7%
unpow270.7%
*-commutative70.7%
associate-/l*70.7%
Simplified70.9%
Taylor expanded in d around 0 70.7%
unpow270.7%
associate-*r/71.6%
unpow271.6%
associate-*r*73.7%
Simplified73.7%
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%
associate-*l/0.0%
*-commutative0.0%
fma-def0.0%
associate-*l*0.0%
*-commutative0.0%
associate-*r*0.0%
associate-*l*0.1%
*-commutative0.1%
Simplified4.0%
fma-udef4.0%
associate-*l*3.3%
associate-/l/2.6%
associate-/l/2.6%
*-commutative2.6%
Applied egg-rr2.6%
fma-def2.7%
associate-/r*2.7%
*-commutative2.7%
fma-def2.7%
Simplified4.1%
Taylor expanded in c0 around -inf 2.0%
+-commutative2.0%
associate-*r*2.0%
*-commutative2.0%
fma-def2.0%
Simplified51.1%
Final simplification59.2%
(FPCore (c0 w h D d M)
:precision binary64
(let* ((t_0 (/ (* c0 (* d d)) (* (* w h) (* D D)))))
(if (<=
(* (/ c0 (* 2.0 w)) (+ t_0 (sqrt (- (* t_0 t_0) (* M M)))))
INFINITY)
(* (/ c0 w) (* (* d d) (/ c0 (* D (* (* w h) D)))))
0.0)))
double code(double c0, double w, double h, double D, double d, double M) {
double t_0 = (c0 * (d * d)) / ((w * h) * (D * D));
double tmp;
if (((c0 / (2.0 * w)) * (t_0 + sqrt(((t_0 * t_0) - (M * M))))) <= ((double) INFINITY)) {
tmp = (c0 / w) * ((d * d) * (c0 / (D * ((w * h) * D))));
} else {
tmp = 0.0;
}
return tmp;
}
public static double code(double c0, double w, double h, double D, double d, double M) {
double t_0 = (c0 * (d * d)) / ((w * h) * (D * D));
double tmp;
if (((c0 / (2.0 * w)) * (t_0 + Math.sqrt(((t_0 * t_0) - (M * M))))) <= Double.POSITIVE_INFINITY) {
tmp = (c0 / w) * ((d * d) * (c0 / (D * ((w * h) * D))));
} else {
tmp = 0.0;
}
return tmp;
}
def code(c0, w, h, D, d, M): t_0 = (c0 * (d * d)) / ((w * h) * (D * D)) tmp = 0 if ((c0 / (2.0 * w)) * (t_0 + math.sqrt(((t_0 * t_0) - (M * M))))) <= math.inf: tmp = (c0 / w) * ((d * d) * (c0 / (D * ((w * h) * D)))) else: tmp = 0.0 return tmp
function code(c0, w, h, D, d, M) t_0 = Float64(Float64(c0 * Float64(d * d)) / Float64(Float64(w * h) * Float64(D * D))) 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(Float64(c0 / w) * Float64(Float64(d * d) * Float64(c0 / Float64(D * Float64(Float64(w * h) * D))))); else tmp = 0.0; end return tmp end
function tmp_2 = code(c0, w, h, D, d, M) t_0 = (c0 * (d * d)) / ((w * h) * (D * D)); tmp = 0.0; if (((c0 / (2.0 * w)) * (t_0 + sqrt(((t_0 * t_0) - (M * M))))) <= Inf) tmp = (c0 / w) * ((d * d) * (c0 / (D * ((w * h) * D)))); else tmp = 0.0; end tmp_2 = tmp; end
code[c0_, w_, h_, D_, d_, M_] := Block[{t$95$0 = N[(N[(c0 * N[(d * d), $MachinePrecision]), $MachinePrecision] / N[(N[(w * h), $MachinePrecision] * N[(D * D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, 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[(N[(c0 / w), $MachinePrecision] * N[(N[(d * d), $MachinePrecision] * N[(c0 / N[(D * N[(N[(w * h), $MachinePrecision] * D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 0.0]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)}\\
\mathbf{if}\;\frac{c0}{2 \cdot w} \cdot \left(t_0 + \sqrt{t_0 \cdot t_0 - M \cdot M}\right) \leq \infty:\\
\;\;\;\;\frac{c0}{w} \cdot \left(\left(d \cdot d\right) \cdot \frac{c0}{D \cdot \left(\left(w \cdot h\right) \cdot D\right)}\right)\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if (*.f64 (/.f64 c0 (*.f64 2 w)) (+.f64 (/.f64 (*.f64 c0 (*.f64 d d)) (*.f64 (*.f64 w h) (*.f64 D D))) (sqrt.f64 (-.f64 (*.f64 (/.f64 (*.f64 c0 (*.f64 d d)) (*.f64 (*.f64 w h) (*.f64 D D))) (/.f64 (*.f64 c0 (*.f64 d d)) (*.f64 (*.f64 w h) (*.f64 D D)))) (*.f64 M M))))) < +inf.0Initial program 71.2%
times-frac66.5%
fma-def65.4%
associate-/r*65.4%
difference-of-squares65.4%
Simplified68.4%
Taylor expanded in c0 around inf 70.7%
times-frac68.6%
unpow268.6%
unpow268.6%
*-commutative68.6%
times-frac72.8%
unpow272.8%
Simplified72.8%
expm1-log1p-u34.1%
expm1-udef31.6%
*-commutative31.6%
associate-*r*31.6%
Applied egg-rr31.6%
expm1-def34.1%
expm1-log1p72.8%
associate-*l/71.0%
times-frac72.9%
associate-*l*72.9%
*-commutative72.9%
unpow272.9%
times-frac68.7%
unpow268.7%
times-frac70.7%
unpow270.7%
*-commutative70.7%
associate-/l*70.7%
Simplified70.9%
Taylor expanded in d around 0 70.7%
unpow270.7%
associate-*r/71.6%
unpow271.6%
associate-*r*73.7%
Simplified73.7%
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%
fma-def0.0%
associate-/r*0.1%
difference-of-squares6.8%
Simplified15.8%
Taylor expanded in c0 around -inf 1.9%
associate-*r*1.9%
distribute-rgt1-in1.9%
metadata-eval1.9%
mul0-lft45.7%
metadata-eval45.7%
mul0-lft2.5%
metadata-eval2.5%
distribute-lft1-in2.5%
*-commutative2.5%
distribute-lft1-in2.5%
metadata-eval2.5%
mul0-lft45.7%
Simplified45.7%
Taylor expanded in c0 around 0 49.6%
Final simplification58.2%
(FPCore (c0 w h D d M)
:precision binary64
(if (<= w -6e-150)
0.0
(if (<= w 1.22e-18)
(/ (* (* d d) (* c0 c0)) (* (* D D) (* h (* w w))))
0.0)))
double code(double c0, double w, double h, double D, double d, double M) {
double tmp;
if (w <= -6e-150) {
tmp = 0.0;
} else if (w <= 1.22e-18) {
tmp = ((d * d) * (c0 * c0)) / ((D * D) * (h * (w * w)));
} else {
tmp = 0.0;
}
return tmp;
}
real(8) function code(c0, w, h, d, d_1, m)
real(8), intent (in) :: c0
real(8), intent (in) :: w
real(8), intent (in) :: h
real(8), intent (in) :: d
real(8), intent (in) :: d_1
real(8), intent (in) :: m
real(8) :: tmp
if (w <= (-6d-150)) then
tmp = 0.0d0
else if (w <= 1.22d-18) then
tmp = ((d_1 * d_1) * (c0 * c0)) / ((d * d) * (h * (w * w)))
else
tmp = 0.0d0
end if
code = tmp
end function
public static double code(double c0, double w, double h, double D, double d, double M) {
double tmp;
if (w <= -6e-150) {
tmp = 0.0;
} else if (w <= 1.22e-18) {
tmp = ((d * d) * (c0 * c0)) / ((D * D) * (h * (w * w)));
} else {
tmp = 0.0;
}
return tmp;
}
def code(c0, w, h, D, d, M): tmp = 0 if w <= -6e-150: tmp = 0.0 elif w <= 1.22e-18: tmp = ((d * d) * (c0 * c0)) / ((D * D) * (h * (w * w))) else: tmp = 0.0 return tmp
function code(c0, w, h, D, d, M) tmp = 0.0 if (w <= -6e-150) tmp = 0.0; elseif (w <= 1.22e-18) tmp = Float64(Float64(Float64(d * d) * Float64(c0 * c0)) / Float64(Float64(D * D) * Float64(h * Float64(w * w)))); else tmp = 0.0; end return tmp end
function tmp_2 = code(c0, w, h, D, d, M) tmp = 0.0; if (w <= -6e-150) tmp = 0.0; elseif (w <= 1.22e-18) tmp = ((d * d) * (c0 * c0)) / ((D * D) * (h * (w * w))); else tmp = 0.0; end tmp_2 = tmp; end
code[c0_, w_, h_, D_, d_, M_] := If[LessEqual[w, -6e-150], 0.0, If[LessEqual[w, 1.22e-18], N[(N[(N[(d * d), $MachinePrecision] * N[(c0 * c0), $MachinePrecision]), $MachinePrecision] / N[(N[(D * D), $MachinePrecision] * N[(h * N[(w * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 0.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;w \leq -6 \cdot 10^{-150}:\\
\;\;\;\;0\\
\mathbf{elif}\;w \leq 1.22 \cdot 10^{-18}:\\
\;\;\;\;\frac{\left(d \cdot d\right) \cdot \left(c0 \cdot c0\right)}{\left(D \cdot D\right) \cdot \left(h \cdot \left(w \cdot w\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if w < -6.0000000000000003e-150 or 1.2200000000000001e-18 < w Initial program 18.0%
times-frac16.5%
fma-def15.9%
associate-/r*15.9%
difference-of-squares19.1%
Simplified25.5%
Taylor expanded in c0 around -inf 4.5%
associate-*r*4.5%
distribute-rgt1-in4.5%
metadata-eval4.5%
mul0-lft42.9%
metadata-eval42.9%
mul0-lft5.1%
metadata-eval5.1%
distribute-lft1-in5.1%
*-commutative5.1%
distribute-lft1-in5.1%
metadata-eval5.1%
mul0-lft42.9%
Simplified42.9%
Taylor expanded in c0 around 0 44.2%
if -6.0000000000000003e-150 < w < 1.2200000000000001e-18Initial program 37.7%
times-frac35.6%
fma-def35.6%
associate-/r*35.6%
difference-of-squares41.8%
Simplified49.3%
Taylor expanded in c0 around inf 45.8%
times-frac47.3%
unpow247.3%
unpow247.3%
*-commutative47.3%
times-frac59.0%
unpow259.0%
Simplified59.0%
expm1-log1p-u27.7%
expm1-udef26.7%
*-commutative26.7%
associate-*r*26.7%
Applied egg-rr26.7%
expm1-def27.7%
expm1-log1p59.0%
associate-*l/58.0%
times-frac59.0%
associate-*l*59.0%
*-commutative59.0%
unpow259.0%
times-frac47.3%
unpow247.3%
times-frac45.8%
unpow245.8%
*-commutative45.8%
associate-/l*45.8%
Simplified58.1%
Taylor expanded in c0 around 0 38.1%
unpow238.1%
*-commutative38.1%
unpow238.1%
unpow238.1%
*-commutative38.1%
unpow238.1%
Simplified38.1%
Final simplification41.8%
(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 25.6%
times-frac23.9%
fma-def23.5%
associate-/r*23.5%
difference-of-squares27.9%
Simplified34.7%
Taylor expanded in c0 around -inf 2.8%
associate-*r*2.8%
distribute-rgt1-in2.8%
metadata-eval2.8%
mul0-lft32.0%
metadata-eval32.0%
mul0-lft3.6%
metadata-eval3.6%
distribute-lft1-in3.6%
*-commutative3.6%
distribute-lft1-in3.6%
metadata-eval3.6%
mul0-lft32.0%
Simplified32.0%
Taylor expanded in c0 around 0 35.0%
Final simplification35.0%
herbie shell --seed 2023182
(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))))))