
(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 (/ 0.0 (* 2.0 w)))))
(if (<= (* M M) 1e-320)
t_0
(if (<= (* M M) 6e-46)
(*
c0
(/
(fma
c0
(* d (/ d (* D (* h (* w D)))))
(* (* c0 (/ d (* (* w h) D))) (/ d D)))
(* 2.0 w)))
(if (<= (* M M) 3.1e+113)
t_0
(*
c0
(/
(fma
c0
(* d (/ d (* D (* w (* h D)))))
(* (/ d D) (/ (* d (/ c0 w)) (* h D))))
(* 2.0 w))))))))
double code(double c0, double w, double h, double D, double d, double M) {
double t_0 = c0 * (0.0 / (2.0 * w));
double tmp;
if ((M * M) <= 1e-320) {
tmp = t_0;
} else if ((M * M) <= 6e-46) {
tmp = c0 * (fma(c0, (d * (d / (D * (h * (w * D))))), ((c0 * (d / ((w * h) * D))) * (d / D))) / (2.0 * w));
} else if ((M * M) <= 3.1e+113) {
tmp = t_0;
} else {
tmp = c0 * (fma(c0, (d * (d / (D * (w * (h * D))))), ((d / D) * ((d * (c0 / w)) / (h * D)))) / (2.0 * w));
}
return tmp;
}
function code(c0, w, h, D, d, M) t_0 = Float64(c0 * Float64(0.0 / Float64(2.0 * w))) tmp = 0.0 if (Float64(M * M) <= 1e-320) tmp = t_0; elseif (Float64(M * M) <= 6e-46) tmp = Float64(c0 * Float64(fma(c0, Float64(d * Float64(d / Float64(D * Float64(h * Float64(w * D))))), Float64(Float64(c0 * Float64(d / Float64(Float64(w * h) * D))) * Float64(d / D))) / Float64(2.0 * w))); elseif (Float64(M * M) <= 3.1e+113) tmp = t_0; else tmp = Float64(c0 * Float64(fma(c0, Float64(d * Float64(d / Float64(D * Float64(w * Float64(h * D))))), Float64(Float64(d / D) * Float64(Float64(d * Float64(c0 / w)) / Float64(h * D)))) / Float64(2.0 * w))); end return tmp end
code[c0_, w_, h_, D_, d_, M_] := Block[{t$95$0 = N[(c0 * N[(0.0 / N[(2.0 * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(M * M), $MachinePrecision], 1e-320], t$95$0, If[LessEqual[N[(M * M), $MachinePrecision], 6e-46], N[(c0 * N[(N[(c0 * N[(d * N[(d / N[(D * N[(h * N[(w * D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(c0 * N[(d / N[(N[(w * h), $MachinePrecision] * D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(d / D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(2.0 * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(M * M), $MachinePrecision], 3.1e+113], t$95$0, N[(c0 * N[(N[(c0 * N[(d * N[(d / N[(D * N[(w * N[(h * D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(d / D), $MachinePrecision] * N[(N[(d * N[(c0 / w), $MachinePrecision]), $MachinePrecision] / N[(h * D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(2.0 * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := c0 \cdot \frac{0}{2 \cdot w}\\
\mathbf{if}\;M \cdot M \leq 10^{-320}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;M \cdot M \leq 6 \cdot 10^{-46}:\\
\;\;\;\;c0 \cdot \frac{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(h \cdot \left(w \cdot D\right)\right)}, \left(c0 \cdot \frac{d}{\left(w \cdot h\right) \cdot D}\right) \cdot \frac{d}{D}\right)}{2 \cdot w}\\
\mathbf{elif}\;M \cdot M \leq 3.1 \cdot 10^{+113}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;c0 \cdot \frac{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, \frac{d}{D} \cdot \frac{d \cdot \frac{c0}{w}}{h \cdot D}\right)}{2 \cdot w}\\
\end{array}
\end{array}
if (*.f64 M M) < 9.99989e-321 or 5.99999999999999975e-46 < (*.f64 M M) < 3.09999999999999991e113Initial program 19.5%
Simplified23.7%
Taylor expanded in c0 around -inf 11.7%
distribute-lft-in10.7%
mul-1-neg10.7%
distribute-rgt-neg-in10.7%
associate-/l*8.1%
mul-1-neg8.1%
associate-/l*9.7%
distribute-lft1-in9.7%
metadata-eval9.7%
mul0-lft54.7%
metadata-eval54.7%
Simplified54.7%
if 9.99989e-321 < (*.f64 M M) < 5.99999999999999975e-46Initial program 39.4%
Simplified51.5%
Taylor expanded in c0 around -inf 9.6%
associate-*r/9.6%
neg-mul-19.6%
distribute-lft-neg-in9.6%
Simplified9.6%
*-commutative9.6%
add-sqr-sqrt4.7%
sqrt-unprod17.3%
sqr-neg17.3%
sqrt-unprod14.3%
add-sqr-sqrt38.5%
frac-times39.3%
unpow239.3%
unpow239.3%
frac-times46.1%
pow246.1%
*-commutative46.1%
*-commutative46.1%
pow246.1%
associate-*r*54.2%
*-commutative54.2%
frac-times55.1%
*-commutative55.1%
associate-*r*53.4%
Applied egg-rr53.4%
Taylor expanded in c0 around 0 55.1%
associate-/l*58.1%
Simplified58.1%
clear-num58.1%
un-div-inv58.0%
Applied egg-rr58.0%
associate-/r/58.1%
associate-*r*59.5%
*-commutative59.5%
associate-*r*59.6%
Simplified59.6%
if 3.09999999999999991e113 < (*.f64 M M) Initial program 11.7%
Simplified43.7%
Taylor expanded in c0 around -inf 1.3%
associate-*r/1.3%
neg-mul-11.3%
distribute-lft-neg-in1.3%
Simplified1.3%
*-commutative1.3%
add-sqr-sqrt0.0%
sqrt-unprod20.2%
sqr-neg20.2%
sqrt-unprod22.5%
add-sqr-sqrt40.2%
frac-times40.1%
unpow240.1%
unpow240.1%
frac-times48.3%
pow248.3%
*-commutative48.3%
*-commutative48.3%
pow248.3%
associate-*r*51.7%
*-commutative51.7%
frac-times51.7%
*-commutative51.7%
associate-*r*53.9%
Applied egg-rr53.9%
*-commutative53.9%
*-un-lft-identity53.9%
times-frac54.0%
Applied egg-rr54.0%
associate-/r*54.0%
frac-times54.1%
*-un-lft-identity54.1%
Applied egg-rr54.1%
Final simplification55.7%
(FPCore (c0 w h D d M)
:precision binary64
(let* ((t_0 (/ (* c0 (* d d)) (* (* w h) (* D D))))
(t_1 (* (/ c0 (* 2.0 w)) (+ t_0 (sqrt (- (* t_0 t_0) (* M M)))))))
(if (<= t_1 INFINITY) t_1 (* 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)) / ((w * h) * (D * D));
double t_1 = (c0 / (2.0 * w)) * (t_0 + sqrt(((t_0 * t_0) - (M * M))));
double tmp;
if (t_1 <= ((double) INFINITY)) {
tmp = t_1;
} 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)) / ((w * h) * (D * D));
double t_1 = (c0 / (2.0 * w)) * (t_0 + Math.sqrt(((t_0 * t_0) - (M * M))));
double tmp;
if (t_1 <= Double.POSITIVE_INFINITY) {
tmp = t_1;
} else {
tmp = c0 * (0.0 / (2.0 * w));
}
return tmp;
}
def code(c0, w, h, D, d, M): t_0 = (c0 * (d * d)) / ((w * h) * (D * D)) t_1 = (c0 / (2.0 * w)) * (t_0 + math.sqrt(((t_0 * t_0) - (M * M)))) tmp = 0 if t_1 <= math.inf: tmp = t_1 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(w * h) * Float64(D * D))) t_1 = Float64(Float64(c0 / Float64(2.0 * w)) * Float64(t_0 + sqrt(Float64(Float64(t_0 * t_0) - Float64(M * M))))) tmp = 0.0 if (t_1 <= Inf) tmp = t_1; 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)) / ((w * h) * (D * D)); t_1 = (c0 / (2.0 * w)) * (t_0 + sqrt(((t_0 * t_0) - (M * M)))); tmp = 0.0; if (t_1 <= Inf) tmp = t_1; 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[(w * h), $MachinePrecision] * N[(D * D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = 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]}, If[LessEqual[t$95$1, Infinity], t$95$1, 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(w \cdot h\right) \cdot \left(D \cdot D\right)}\\
t_1 := \frac{c0}{2 \cdot w} \cdot \left(t\_0 + \sqrt{t\_0 \cdot t\_0 - M \cdot M}\right)\\
\mathbf{if}\;t\_1 \leq \infty:\\
\;\;\;\;t\_1\\
\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 74.6%
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%
Simplified26.0%
Taylor expanded in c0 around -inf 1.7%
distribute-lft-in1.2%
mul-1-neg1.2%
distribute-rgt-neg-in1.2%
associate-/l*1.1%
mul-1-neg1.1%
associate-/l*0.6%
distribute-lft1-in0.6%
metadata-eval0.6%
mul0-lft44.6%
metadata-eval44.6%
Simplified44.6%
Final simplification53.4%
(FPCore (c0 w h D d M)
:precision binary64
(if (or (<= M 2.3e-159) (and (not (<= M 6e-23)) (<= M 6.5e+56)))
(* c0 (/ 0.0 (* 2.0 w)))
(*
c0
(/
(fma
c0
(* d (/ d (* D (* w (* h D)))))
(* (* c0 (/ d (* (* w h) D))) (/ d D)))
(* 2.0 w)))))
double code(double c0, double w, double h, double D, double d, double M) {
double tmp;
if ((M <= 2.3e-159) || (!(M <= 6e-23) && (M <= 6.5e+56))) {
tmp = c0 * (0.0 / (2.0 * w));
} else {
tmp = c0 * (fma(c0, (d * (d / (D * (w * (h * D))))), ((c0 * (d / ((w * h) * D))) * (d / D))) / (2.0 * w));
}
return tmp;
}
function code(c0, w, h, D, d, M) tmp = 0.0 if ((M <= 2.3e-159) || (!(M <= 6e-23) && (M <= 6.5e+56))) tmp = Float64(c0 * Float64(0.0 / Float64(2.0 * w))); else tmp = Float64(c0 * Float64(fma(c0, Float64(d * Float64(d / Float64(D * Float64(w * Float64(h * D))))), Float64(Float64(c0 * Float64(d / Float64(Float64(w * h) * D))) * Float64(d / D))) / Float64(2.0 * w))); end return tmp end
code[c0_, w_, h_, D_, d_, M_] := If[Or[LessEqual[M, 2.3e-159], And[N[Not[LessEqual[M, 6e-23]], $MachinePrecision], LessEqual[M, 6.5e+56]]], N[(c0 * N[(0.0 / N[(2.0 * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(c0 * N[(N[(c0 * N[(d * N[(d / N[(D * N[(w * N[(h * D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(c0 * N[(d / N[(N[(w * h), $MachinePrecision] * D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(d / D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(2.0 * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;M \leq 2.3 \cdot 10^{-159} \lor \neg \left(M \leq 6 \cdot 10^{-23}\right) \land M \leq 6.5 \cdot 10^{+56}:\\
\;\;\;\;c0 \cdot \frac{0}{2 \cdot w}\\
\mathbf{else}:\\
\;\;\;\;c0 \cdot \frac{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, \left(c0 \cdot \frac{d}{\left(w \cdot h\right) \cdot D}\right) \cdot \frac{d}{D}\right)}{2 \cdot w}\\
\end{array}
\end{array}
if M < 2.29999999999999978e-159 or 6.00000000000000006e-23 < M < 6.5000000000000001e56Initial program 23.9%
Simplified32.5%
Taylor expanded in c0 around -inf 7.9%
distribute-lft-in7.3%
mul-1-neg7.3%
distribute-rgt-neg-in7.3%
associate-/l*5.7%
mul-1-neg5.7%
associate-/l*6.6%
distribute-lft1-in6.6%
metadata-eval6.6%
mul0-lft41.7%
metadata-eval41.7%
Simplified41.7%
if 2.29999999999999978e-159 < M < 6.00000000000000006e-23 or 6.5000000000000001e56 < M Initial program 17.9%
Simplified47.7%
Taylor expanded in c0 around -inf 6.1%
associate-*r/6.1%
neg-mul-16.1%
distribute-lft-neg-in6.1%
Simplified6.1%
*-commutative6.1%
add-sqr-sqrt2.3%
sqrt-unprod17.7%
sqr-neg17.7%
sqrt-unprod17.8%
add-sqr-sqrt38.4%
frac-times38.9%
unpow238.9%
unpow238.9%
frac-times48.4%
pow248.4%
*-commutative48.4%
*-commutative48.4%
pow248.4%
associate-*r*53.4%
*-commutative53.4%
frac-times55.4%
*-commutative55.4%
associate-*r*56.4%
Applied egg-rr56.4%
Taylor expanded in c0 around 0 55.4%
associate-/l*55.4%
Simplified55.4%
Final simplification46.4%
(FPCore (c0 w h D d M)
:precision binary64
(let* ((t_0 (* c0 (/ 0.0 (* 2.0 w))))
(t_1 (* w (* h D)))
(t_2 (* d (/ d (* D t_1)))))
(if (<= M 3.5e-159)
t_0
(if (<= M 7.6e-23)
(* c0 (/ (fma c0 t_2 (* (* c0 (/ d (* (* w h) D))) (/ d D))) (* 2.0 w)))
(if (<= M 5.5e+56)
t_0
(* c0 (/ (fma c0 t_2 (* (/ d D) (/ (* c0 d) t_1))) (* 2.0 w))))))))
double code(double c0, double w, double h, double D, double d, double M) {
double t_0 = c0 * (0.0 / (2.0 * w));
double t_1 = w * (h * D);
double t_2 = d * (d / (D * t_1));
double tmp;
if (M <= 3.5e-159) {
tmp = t_0;
} else if (M <= 7.6e-23) {
tmp = c0 * (fma(c0, t_2, ((c0 * (d / ((w * h) * D))) * (d / D))) / (2.0 * w));
} else if (M <= 5.5e+56) {
tmp = t_0;
} else {
tmp = c0 * (fma(c0, t_2, ((d / D) * ((c0 * d) / t_1))) / (2.0 * w));
}
return tmp;
}
function code(c0, w, h, D, d, M) t_0 = Float64(c0 * Float64(0.0 / Float64(2.0 * w))) t_1 = Float64(w * Float64(h * D)) t_2 = Float64(d * Float64(d / Float64(D * t_1))) tmp = 0.0 if (M <= 3.5e-159) tmp = t_0; elseif (M <= 7.6e-23) tmp = Float64(c0 * Float64(fma(c0, t_2, Float64(Float64(c0 * Float64(d / Float64(Float64(w * h) * D))) * Float64(d / D))) / Float64(2.0 * w))); elseif (M <= 5.5e+56) tmp = t_0; else tmp = Float64(c0 * Float64(fma(c0, t_2, Float64(Float64(d / D) * Float64(Float64(c0 * d) / t_1))) / Float64(2.0 * w))); end return tmp end
code[c0_, w_, h_, D_, d_, M_] := Block[{t$95$0 = N[(c0 * N[(0.0 / N[(2.0 * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(w * N[(h * D), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(d * N[(d / N[(D * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[M, 3.5e-159], t$95$0, If[LessEqual[M, 7.6e-23], N[(c0 * N[(N[(c0 * t$95$2 + N[(N[(c0 * N[(d / N[(N[(w * h), $MachinePrecision] * D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(d / D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(2.0 * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[M, 5.5e+56], t$95$0, N[(c0 * N[(N[(c0 * t$95$2 + N[(N[(d / D), $MachinePrecision] * N[(N[(c0 * d), $MachinePrecision] / t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(2.0 * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := c0 \cdot \frac{0}{2 \cdot w}\\
t_1 := w \cdot \left(h \cdot D\right)\\
t_2 := d \cdot \frac{d}{D \cdot t\_1}\\
\mathbf{if}\;M \leq 3.5 \cdot 10^{-159}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;M \leq 7.6 \cdot 10^{-23}:\\
\;\;\;\;c0 \cdot \frac{\mathsf{fma}\left(c0, t\_2, \left(c0 \cdot \frac{d}{\left(w \cdot h\right) \cdot D}\right) \cdot \frac{d}{D}\right)}{2 \cdot w}\\
\mathbf{elif}\;M \leq 5.5 \cdot 10^{+56}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;c0 \cdot \frac{\mathsf{fma}\left(c0, t\_2, \frac{d}{D} \cdot \frac{c0 \cdot d}{t\_1}\right)}{2 \cdot w}\\
\end{array}
\end{array}
if M < 3.50000000000000002e-159 or 7.60000000000000023e-23 < M < 5.5000000000000002e56Initial program 23.9%
Simplified32.5%
Taylor expanded in c0 around -inf 7.9%
distribute-lft-in7.3%
mul-1-neg7.3%
distribute-rgt-neg-in7.3%
associate-/l*5.7%
mul-1-neg5.7%
associate-/l*6.6%
distribute-lft1-in6.6%
metadata-eval6.6%
mul0-lft41.7%
metadata-eval41.7%
Simplified41.7%
if 3.50000000000000002e-159 < M < 7.60000000000000023e-23Initial program 30.9%
Simplified53.6%
Taylor expanded in c0 around -inf 12.3%
associate-*r/12.3%
neg-mul-112.3%
distribute-lft-neg-in12.3%
Simplified12.3%
*-commutative12.3%
add-sqr-sqrt5.9%
sqrt-unprod18.0%
sqr-neg18.0%
sqrt-unprod12.4%
add-sqr-sqrt34.4%
frac-times35.8%
unpow235.8%
unpow235.8%
frac-times45.3%
pow245.3%
*-commutative45.3%
*-commutative45.3%
pow245.3%
associate-*r*55.1%
*-commutative55.1%
frac-times60.2%
*-commutative60.2%
associate-*r*56.9%
Applied egg-rr56.9%
Taylor expanded in c0 around 0 60.2%
associate-/l*60.3%
Simplified60.3%
if 5.5000000000000002e56 < M Initial program 9.6%
Simplified43.8%
Taylor expanded in c0 around -inf 2.1%
associate-*r/2.1%
neg-mul-12.1%
distribute-lft-neg-in2.1%
Simplified2.1%
*-commutative2.1%
add-sqr-sqrt0.0%
sqrt-unprod17.5%
sqr-neg17.5%
sqrt-unprod21.3%
add-sqr-sqrt41.0%
frac-times40.9%
unpow240.9%
unpow240.9%
frac-times50.4%
pow250.4%
*-commutative50.4%
*-commutative50.4%
pow250.4%
associate-*r*52.3%
*-commutative52.3%
frac-times52.3%
*-commutative52.3%
associate-*r*56.1%
Applied egg-rr56.1%
Final simplification47.2%
(FPCore (c0 w h D d M)
:precision binary64
(let* ((t_0 (* d (/ d (* D (* w (* h D)))))) (t_1 (* c0 (/ 0.0 (* 2.0 w)))))
(if (<= M 4.5e-159)
t_1
(if (<= M 1.28e-23)
(* c0 (/ (fma c0 t_0 (* (* c0 (/ d (* (* w h) D))) (/ d D))) (* 2.0 w)))
(if (<= M 6.6e+56)
t_1
(*
c0
(/
(fma c0 t_0 (* (/ d D) (/ (* d (/ c0 w)) (* h D))))
(* 2.0 w))))))))
double code(double c0, double w, double h, double D, double d, double M) {
double t_0 = d * (d / (D * (w * (h * D))));
double t_1 = c0 * (0.0 / (2.0 * w));
double tmp;
if (M <= 4.5e-159) {
tmp = t_1;
} else if (M <= 1.28e-23) {
tmp = c0 * (fma(c0, t_0, ((c0 * (d / ((w * h) * D))) * (d / D))) / (2.0 * w));
} else if (M <= 6.6e+56) {
tmp = t_1;
} else {
tmp = c0 * (fma(c0, t_0, ((d / D) * ((d * (c0 / w)) / (h * D)))) / (2.0 * w));
}
return tmp;
}
function code(c0, w, h, D, d, M) t_0 = Float64(d * Float64(d / Float64(D * Float64(w * Float64(h * D))))) t_1 = Float64(c0 * Float64(0.0 / Float64(2.0 * w))) tmp = 0.0 if (M <= 4.5e-159) tmp = t_1; elseif (M <= 1.28e-23) tmp = Float64(c0 * Float64(fma(c0, t_0, Float64(Float64(c0 * Float64(d / Float64(Float64(w * h) * D))) * Float64(d / D))) / Float64(2.0 * w))); elseif (M <= 6.6e+56) tmp = t_1; else tmp = Float64(c0 * Float64(fma(c0, t_0, Float64(Float64(d / D) * Float64(Float64(d * Float64(c0 / w)) / Float64(h * D)))) / Float64(2.0 * w))); end return tmp end
code[c0_, w_, h_, D_, d_, M_] := Block[{t$95$0 = N[(d * N[(d / N[(D * N[(w * N[(h * D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(c0 * N[(0.0 / N[(2.0 * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[M, 4.5e-159], t$95$1, If[LessEqual[M, 1.28e-23], N[(c0 * N[(N[(c0 * t$95$0 + N[(N[(c0 * N[(d / N[(N[(w * h), $MachinePrecision] * D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(d / D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(2.0 * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[M, 6.6e+56], t$95$1, N[(c0 * N[(N[(c0 * t$95$0 + N[(N[(d / D), $MachinePrecision] * N[(N[(d * N[(c0 / w), $MachinePrecision]), $MachinePrecision] / N[(h * D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(2.0 * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}\\
t_1 := c0 \cdot \frac{0}{2 \cdot w}\\
\mathbf{if}\;M \leq 4.5 \cdot 10^{-159}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;M \leq 1.28 \cdot 10^{-23}:\\
\;\;\;\;c0 \cdot \frac{\mathsf{fma}\left(c0, t\_0, \left(c0 \cdot \frac{d}{\left(w \cdot h\right) \cdot D}\right) \cdot \frac{d}{D}\right)}{2 \cdot w}\\
\mathbf{elif}\;M \leq 6.6 \cdot 10^{+56}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;c0 \cdot \frac{\mathsf{fma}\left(c0, t\_0, \frac{d}{D} \cdot \frac{d \cdot \frac{c0}{w}}{h \cdot D}\right)}{2 \cdot w}\\
\end{array}
\end{array}
if M < 4.49999999999999989e-159 or 1.28000000000000005e-23 < M < 6.60000000000000004e56Initial program 23.9%
Simplified32.5%
Taylor expanded in c0 around -inf 7.9%
distribute-lft-in7.3%
mul-1-neg7.3%
distribute-rgt-neg-in7.3%
associate-/l*5.7%
mul-1-neg5.7%
associate-/l*6.6%
distribute-lft1-in6.6%
metadata-eval6.6%
mul0-lft41.7%
metadata-eval41.7%
Simplified41.7%
if 4.49999999999999989e-159 < M < 1.28000000000000005e-23Initial program 30.9%
Simplified53.6%
Taylor expanded in c0 around -inf 12.3%
associate-*r/12.3%
neg-mul-112.3%
distribute-lft-neg-in12.3%
Simplified12.3%
*-commutative12.3%
add-sqr-sqrt5.9%
sqrt-unprod18.0%
sqr-neg18.0%
sqrt-unprod12.4%
add-sqr-sqrt34.4%
frac-times35.8%
unpow235.8%
unpow235.8%
frac-times45.3%
pow245.3%
*-commutative45.3%
*-commutative45.3%
pow245.3%
associate-*r*55.1%
*-commutative55.1%
frac-times60.2%
*-commutative60.2%
associate-*r*56.9%
Applied egg-rr56.9%
Taylor expanded in c0 around 0 60.2%
associate-/l*60.3%
Simplified60.3%
if 6.60000000000000004e56 < M Initial program 9.6%
Simplified43.8%
Taylor expanded in c0 around -inf 2.1%
associate-*r/2.1%
neg-mul-12.1%
distribute-lft-neg-in2.1%
Simplified2.1%
*-commutative2.1%
add-sqr-sqrt0.0%
sqrt-unprod17.5%
sqr-neg17.5%
sqrt-unprod21.3%
add-sqr-sqrt41.0%
frac-times40.9%
unpow240.9%
unpow240.9%
frac-times50.4%
pow250.4%
*-commutative50.4%
*-commutative50.4%
pow250.4%
associate-*r*52.3%
*-commutative52.3%
frac-times52.3%
*-commutative52.3%
associate-*r*56.1%
Applied egg-rr56.1%
*-commutative56.1%
*-un-lft-identity56.1%
times-frac56.1%
Applied egg-rr56.1%
associate-/r*56.2%
frac-times56.2%
*-un-lft-identity56.2%
Applied egg-rr56.2%
Final simplification47.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%
Simplified37.6%
Taylor expanded in c0 around -inf 6.5%
distribute-lft-in6.1%
mul-1-neg6.1%
distribute-rgt-neg-in6.1%
associate-/l*5.8%
mul-1-neg5.8%
associate-/l*5.7%
distribute-lft1-in5.7%
metadata-eval5.7%
mul0-lft37.1%
metadata-eval37.1%
Simplified37.1%
Final simplification37.1%
herbie shell --seed 2024075
(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))))))