
(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 5 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)) (* (* 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.3%
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%
Simplified23.2%
Taylor expanded in c0 around -inf 1.5%
mul-1-neg1.5%
distribute-lft-in0.8%
mul-1-neg0.8%
distribute-rgt-neg-in0.8%
associate-/l*0.1%
mul-1-neg0.1%
associate-/l*0.1%
distribute-lft1-in0.1%
metadata-eval0.1%
mul0-lft42.3%
metadata-eval42.3%
Simplified42.3%
Final simplification53.5%
(FPCore (c0 w h D d M)
:precision binary64
(let* ((t_0 (* c0 (/ 0.0 (* 2.0 w))))
(t_1
(*
c0
(/
(fma
c0
(* d (/ d (* D (* w (* h D)))))
(* c0 (* (/ d (* h D)) (/ d (* w D)))))
(* 2.0 w)))))
(if (<= c0 -7.2e-207)
t_1
(if (<= c0 1.05e-105)
t_0
(if (<= c0 2.4e-96)
t_1
(if (<= c0 2.45e-5)
t_0
(*
c0
(/
(fma
c0
(* d (/ d (* D (* (* w h) D))))
(* c0 (/ (* (/ d D) (/ d D)) (* w h))))
(* 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 = c0 * (fma(c0, (d * (d / (D * (w * (h * D))))), (c0 * ((d / (h * D)) * (d / (w * D))))) / (2.0 * w));
double tmp;
if (c0 <= -7.2e-207) {
tmp = t_1;
} else if (c0 <= 1.05e-105) {
tmp = t_0;
} else if (c0 <= 2.4e-96) {
tmp = t_1;
} else if (c0 <= 2.45e-5) {
tmp = t_0;
} else {
tmp = c0 * (fma(c0, (d * (d / (D * ((w * h) * D)))), (c0 * (((d / D) * (d / D)) / (w * h)))) / (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(c0 * Float64(fma(c0, Float64(d * Float64(d / Float64(D * Float64(w * Float64(h * D))))), Float64(c0 * Float64(Float64(d / Float64(h * D)) * Float64(d / Float64(w * D))))) / Float64(2.0 * w))) tmp = 0.0 if (c0 <= -7.2e-207) tmp = t_1; elseif (c0 <= 1.05e-105) tmp = t_0; elseif (c0 <= 2.4e-96) tmp = t_1; elseif (c0 <= 2.45e-5) tmp = t_0; else tmp = Float64(c0 * Float64(fma(c0, Float64(d * Float64(d / Float64(D * Float64(Float64(w * h) * D)))), Float64(c0 * Float64(Float64(Float64(d / D) * Float64(d / D)) / Float64(w * h)))) / 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[(c0 * N[(N[(c0 * N[(d * N[(d / N[(D * N[(w * N[(h * D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(c0 * N[(N[(d / N[(h * D), $MachinePrecision]), $MachinePrecision] * N[(d / N[(w * D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(2.0 * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[c0, -7.2e-207], t$95$1, If[LessEqual[c0, 1.05e-105], t$95$0, If[LessEqual[c0, 2.4e-96], t$95$1, If[LessEqual[c0, 2.45e-5], t$95$0, N[(c0 * N[(N[(c0 * N[(d * N[(d / N[(D * N[(N[(w * h), $MachinePrecision] * D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(c0 * N[(N[(N[(d / D), $MachinePrecision] * N[(d / D), $MachinePrecision]), $MachinePrecision] / N[(w * h), $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}\\
t_1 := c0 \cdot \frac{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, c0 \cdot \left(\frac{d}{h \cdot D} \cdot \frac{d}{w \cdot D}\right)\right)}{2 \cdot w}\\
\mathbf{if}\;c0 \leq -7.2 \cdot 10^{-207}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;c0 \leq 1.05 \cdot 10^{-105}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;c0 \leq 2.4 \cdot 10^{-96}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;c0 \leq 2.45 \cdot 10^{-5}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;c0 \cdot \frac{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(\left(w \cdot h\right) \cdot D\right)}, c0 \cdot \frac{\frac{d}{D} \cdot \frac{d}{D}}{w \cdot h}\right)}{2 \cdot w}\\
\end{array}
\end{array}
if c0 < -7.1999999999999993e-207 or 1.05e-105 < c0 < 2.40000000000000019e-96Initial program 28.5%
Simplified49.4%
Taylor expanded in c0 around inf 39.2%
associate-/l*41.1%
associate-/r*42.0%
Simplified42.0%
pow242.0%
pow242.0%
frac-times49.2%
Applied egg-rr49.2%
times-frac52.4%
Applied egg-rr52.4%
associate-/l/51.5%
associate-/l/50.8%
Simplified50.8%
if -7.1999999999999993e-207 < c0 < 1.05e-105 or 2.40000000000000019e-96 < c0 < 2.45e-5Initial program 14.1%
Simplified19.5%
Taylor expanded in c0 around -inf 6.3%
mul-1-neg6.3%
distribute-lft-in6.3%
mul-1-neg6.3%
distribute-rgt-neg-in6.3%
associate-/l*5.0%
mul-1-neg5.0%
associate-/l*6.3%
distribute-lft1-in6.3%
metadata-eval6.3%
mul0-lft50.6%
metadata-eval50.6%
Simplified50.6%
if 2.45e-5 < c0 Initial program 32.8%
Simplified41.3%
Taylor expanded in c0 around inf 45.9%
associate-/l*46.0%
associate-/r*46.0%
Simplified46.0%
pow246.0%
pow246.0%
frac-times48.8%
Applied egg-rr48.8%
Taylor expanded in w around 0 48.6%
Final simplification50.1%
(FPCore (c0 w h D d M)
:precision binary64
(if (or (<= c0 -2.15e-203) (not (<= c0 1.55e-7)))
(*
c0
(/
(fma
c0
(* d (/ d (* D (* (* w h) D))))
(* c0 (/ (* (/ d D) (/ d D)) (* 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 tmp;
if ((c0 <= -2.15e-203) || !(c0 <= 1.55e-7)) {
tmp = c0 * (fma(c0, (d * (d / (D * ((w * h) * D)))), (c0 * (((d / D) * (d / D)) / (w * h)))) / (2.0 * w));
} else {
tmp = c0 * (0.0 / (2.0 * w));
}
return tmp;
}
function code(c0, w, h, D, d, M) tmp = 0.0 if ((c0 <= -2.15e-203) || !(c0 <= 1.55e-7)) tmp = Float64(c0 * Float64(fma(c0, Float64(d * Float64(d / Float64(D * Float64(Float64(w * h) * D)))), Float64(c0 * Float64(Float64(Float64(d / D) * Float64(d / D)) / Float64(w * h)))) / Float64(2.0 * w))); else tmp = Float64(c0 * Float64(0.0 / Float64(2.0 * w))); end return tmp end
code[c0_, w_, h_, D_, d_, M_] := If[Or[LessEqual[c0, -2.15e-203], N[Not[LessEqual[c0, 1.55e-7]], $MachinePrecision]], N[(c0 * N[(N[(c0 * N[(d * N[(d / N[(D * N[(N[(w * h), $MachinePrecision] * D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(c0 * N[(N[(N[(d / D), $MachinePrecision] * N[(d / D), $MachinePrecision]), $MachinePrecision] / N[(w * h), $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}
\mathbf{if}\;c0 \leq -2.15 \cdot 10^{-203} \lor \neg \left(c0 \leq 1.55 \cdot 10^{-7}\right):\\
\;\;\;\;c0 \cdot \frac{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(\left(w \cdot h\right) \cdot D\right)}, c0 \cdot \frac{\frac{d}{D} \cdot \frac{d}{D}}{w \cdot h}\right)}{2 \cdot w}\\
\mathbf{else}:\\
\;\;\;\;c0 \cdot \frac{0}{2 \cdot w}\\
\end{array}
\end{array}
if c0 < -2.15000000000000014e-203 or 1.55e-7 < c0 Initial program 29.9%
Simplified44.9%
Taylor expanded in c0 around inf 41.4%
associate-/l*42.5%
associate-/r*43.1%
Simplified43.1%
pow243.1%
pow243.1%
frac-times48.2%
Applied egg-rr48.2%
Taylor expanded in w around 0 48.3%
if -2.15000000000000014e-203 < c0 < 1.55e-7Initial program 15.9%
Simplified25.1%
Taylor expanded in c0 around -inf 6.0%
mul-1-neg6.0%
distribute-lft-in6.0%
mul-1-neg6.0%
distribute-rgt-neg-in6.0%
associate-/l*4.7%
mul-1-neg4.7%
associate-/l*6.0%
distribute-lft1-in6.0%
metadata-eval6.0%
mul0-lft47.2%
metadata-eval47.2%
Simplified47.2%
Final simplification48.0%
(FPCore (c0 w h D d M)
:precision binary64
(if (or (<= c0 -5.1e-204) (not (<= c0 7.2e-107)))
(*
c0
(/
(fma
c0
(* d (/ d (* D (* w (* h D)))))
(* c0 (* (/ (/ d D) h) (/ (/ d D) w))))
(* 2.0 w)))
(* c0 (/ 0.0 (* 2.0 w)))))
double code(double c0, double w, double h, double D, double d, double M) {
double tmp;
if ((c0 <= -5.1e-204) || !(c0 <= 7.2e-107)) {
tmp = c0 * (fma(c0, (d * (d / (D * (w * (h * D))))), (c0 * (((d / D) / h) * ((d / D) / w)))) / (2.0 * w));
} else {
tmp = c0 * (0.0 / (2.0 * w));
}
return tmp;
}
function code(c0, w, h, D, d, M) tmp = 0.0 if ((c0 <= -5.1e-204) || !(c0 <= 7.2e-107)) tmp = Float64(c0 * Float64(fma(c0, Float64(d * Float64(d / Float64(D * Float64(w * Float64(h * D))))), Float64(c0 * Float64(Float64(Float64(d / D) / h) * Float64(Float64(d / D) / w)))) / Float64(2.0 * w))); else tmp = Float64(c0 * Float64(0.0 / Float64(2.0 * w))); end return tmp end
code[c0_, w_, h_, D_, d_, M_] := If[Or[LessEqual[c0, -5.1e-204], N[Not[LessEqual[c0, 7.2e-107]], $MachinePrecision]], N[(c0 * N[(N[(c0 * N[(d * N[(d / N[(D * N[(w * N[(h * D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(c0 * N[(N[(N[(d / D), $MachinePrecision] / h), $MachinePrecision] * N[(N[(d / D), $MachinePrecision] / w), $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}
\mathbf{if}\;c0 \leq -5.1 \cdot 10^{-204} \lor \neg \left(c0 \leq 7.2 \cdot 10^{-107}\right):\\
\;\;\;\;c0 \cdot \frac{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, c0 \cdot \left(\frac{\frac{d}{D}}{h} \cdot \frac{\frac{d}{D}}{w}\right)\right)}{2 \cdot w}\\
\mathbf{else}:\\
\;\;\;\;c0 \cdot \frac{0}{2 \cdot w}\\
\end{array}
\end{array}
if c0 < -5.10000000000000027e-204 or 7.19999999999999953e-107 < c0 Initial program 29.0%
Simplified44.6%
Taylor expanded in c0 around inf 39.4%
associate-/l*40.4%
associate-/r*40.9%
Simplified40.9%
pow240.9%
pow240.9%
frac-times46.5%
Applied egg-rr46.5%
times-frac48.8%
Applied egg-rr48.8%
if -5.10000000000000027e-204 < c0 < 7.19999999999999953e-107Initial program 13.3%
Simplified16.5%
Taylor expanded in c0 around -inf 8.6%
mul-1-neg8.6%
distribute-lft-in8.6%
mul-1-neg8.6%
distribute-rgt-neg-in8.6%
associate-/l*6.8%
mul-1-neg6.8%
associate-/l*8.6%
distribute-lft1-in8.6%
metadata-eval8.6%
mul0-lft54.2%
metadata-eval54.2%
Simplified54.2%
Final simplification49.8%
(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 26.1%
Simplified39.5%
Taylor expanded in c0 around -inf 4.4%
mul-1-neg4.4%
distribute-lft-in3.9%
mul-1-neg3.9%
distribute-rgt-neg-in3.9%
associate-/l*2.7%
mul-1-neg2.7%
associate-/l*3.4%
distribute-lft1-in3.4%
metadata-eval3.4%
mul0-lft31.3%
metadata-eval31.3%
Simplified31.3%
Final simplification31.3%
herbie shell --seed 2024131
(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))))))