
(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 4 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 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 / 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 / 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 / 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 / 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 / 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 / w), $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}{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 86.2%
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%
Simplified25.0%
associate-*r/15.5%
*-commutative15.5%
associate-*r*13.7%
associate-*r*8.9%
associate-/l*8.2%
frac-times8.7%
associate-*l/10.7%
times-frac19.6%
pow219.6%
Applied egg-rr19.6%
associate-*l/19.5%
*-commutative19.5%
Simplified19.5%
Taylor expanded in c0 around -inf 1.3%
associate-*r/1.3%
distribute-lft-in0.7%
mul-1-neg0.7%
distribute-rgt-neg-in0.7%
associate-/l*0.1%
mul-1-neg0.1%
associate-/l*0.1%
distribute-lft1-in0.1%
metadata-eval0.1%
mul0-lft44.5%
metadata-eval44.5%
Simplified44.5%
Final simplification59.0%
(FPCore (c0 w h D d M)
:precision binary64
(let* ((t_0 (/ c0 (* w h))) (t_1 (* t_0 (/ (* d d) (* D D)))))
(if (or (<= c0 -280000000000.0) (not (<= c0 2.4e+106)))
(*
(/ c0 (* 2.0 w))
(+ (sqrt (- (* t_1 t_1) (* M M))) (* t_0 (* (/ d D) (/ d D)))))
(* c0 (/ 0.0 w)))))
double code(double c0, double w, double h, double D, double d, double M) {
double t_0 = c0 / (w * h);
double t_1 = t_0 * ((d * d) / (D * D));
double tmp;
if ((c0 <= -280000000000.0) || !(c0 <= 2.4e+106)) {
tmp = (c0 / (2.0 * w)) * (sqrt(((t_1 * t_1) - (M * M))) + (t_0 * ((d / D) * (d / D))));
} else {
tmp = c0 * (0.0 / w);
}
return tmp;
}
real(8) function code(c0, w, h, d, d_1, m)
real(8), intent (in) :: c0
real(8), intent (in) :: w
real(8), intent (in) :: h
real(8), intent (in) :: d
real(8), intent (in) :: d_1
real(8), intent (in) :: m
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = c0 / (w * h)
t_1 = t_0 * ((d_1 * d_1) / (d * d))
if ((c0 <= (-280000000000.0d0)) .or. (.not. (c0 <= 2.4d+106))) then
tmp = (c0 / (2.0d0 * w)) * (sqrt(((t_1 * t_1) - (m * m))) + (t_0 * ((d_1 / d) * (d_1 / d))))
else
tmp = c0 * (0.0d0 / w)
end if
code = tmp
end function
public static double code(double c0, double w, double h, double D, double d, double M) {
double t_0 = c0 / (w * h);
double t_1 = t_0 * ((d * d) / (D * D));
double tmp;
if ((c0 <= -280000000000.0) || !(c0 <= 2.4e+106)) {
tmp = (c0 / (2.0 * w)) * (Math.sqrt(((t_1 * t_1) - (M * M))) + (t_0 * ((d / D) * (d / D))));
} else {
tmp = c0 * (0.0 / w);
}
return tmp;
}
def code(c0, w, h, D, d, M): t_0 = c0 / (w * h) t_1 = t_0 * ((d * d) / (D * D)) tmp = 0 if (c0 <= -280000000000.0) or not (c0 <= 2.4e+106): tmp = (c0 / (2.0 * w)) * (math.sqrt(((t_1 * t_1) - (M * M))) + (t_0 * ((d / D) * (d / D)))) else: tmp = c0 * (0.0 / w) return tmp
function code(c0, w, h, D, d, M) t_0 = Float64(c0 / Float64(w * h)) t_1 = Float64(t_0 * Float64(Float64(d * d) / Float64(D * D))) tmp = 0.0 if ((c0 <= -280000000000.0) || !(c0 <= 2.4e+106)) tmp = Float64(Float64(c0 / Float64(2.0 * w)) * Float64(sqrt(Float64(Float64(t_1 * t_1) - Float64(M * M))) + Float64(t_0 * Float64(Float64(d / D) * Float64(d / D))))); else tmp = Float64(c0 * Float64(0.0 / w)); end return tmp end
function tmp_2 = code(c0, w, h, D, d, M) t_0 = c0 / (w * h); t_1 = t_0 * ((d * d) / (D * D)); tmp = 0.0; if ((c0 <= -280000000000.0) || ~((c0 <= 2.4e+106))) tmp = (c0 / (2.0 * w)) * (sqrt(((t_1 * t_1) - (M * M))) + (t_0 * ((d / D) * (d / D)))); else tmp = c0 * (0.0 / w); end tmp_2 = tmp; end
code[c0_, w_, h_, D_, d_, M_] := Block[{t$95$0 = N[(c0 / N[(w * h), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 * N[(N[(d * d), $MachinePrecision] / N[(D * D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[c0, -280000000000.0], N[Not[LessEqual[c0, 2.4e+106]], $MachinePrecision]], N[(N[(c0 / N[(2.0 * w), $MachinePrecision]), $MachinePrecision] * N[(N[Sqrt[N[(N[(t$95$1 * t$95$1), $MachinePrecision] - N[(M * M), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] + N[(t$95$0 * N[(N[(d / D), $MachinePrecision] * N[(d / D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(c0 * N[(0.0 / w), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{c0}{w \cdot h}\\
t_1 := t\_0 \cdot \frac{d \cdot d}{D \cdot D}\\
\mathbf{if}\;c0 \leq -280000000000 \lor \neg \left(c0 \leq 2.4 \cdot 10^{+106}\right):\\
\;\;\;\;\frac{c0}{2 \cdot w} \cdot \left(\sqrt{t\_1 \cdot t\_1 - M \cdot M} + t\_0 \cdot \left(\frac{d}{D} \cdot \frac{d}{D}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;c0 \cdot \frac{0}{w}\\
\end{array}
\end{array}
if c0 < -2.8e11 or 2.4000000000000001e106 < c0 Initial program 35.6%
Simplified36.4%
times-frac35.8%
Applied egg-rr35.8%
if -2.8e11 < c0 < 2.4000000000000001e106Initial program 25.3%
Simplified35.1%
associate-*r/30.0%
*-commutative30.0%
associate-*r*28.6%
associate-*r*26.3%
associate-/l*26.3%
frac-times24.1%
associate-*l/24.2%
times-frac30.1%
pow230.1%
Applied egg-rr30.1%
associate-*l/30.0%
*-commutative30.0%
Simplified30.0%
Taylor expanded in c0 around -inf 4.5%
associate-*r/4.5%
distribute-lft-in4.5%
mul-1-neg4.5%
distribute-rgt-neg-in4.5%
associate-/l*3.2%
mul-1-neg3.2%
associate-/l*5.2%
distribute-lft1-in5.2%
metadata-eval5.2%
mul0-lft42.7%
metadata-eval42.7%
Simplified42.7%
Final simplification39.6%
(FPCore (c0 w h D d M)
:precision binary64
(let* ((t_0 (/ c0 (* w h)))
(t_1 (* t_0 (/ (* d d) (* D D))))
(t_2 (sqrt (- (* t_1 t_1) (* M M))))
(t_3 (/ c0 (* 2.0 w))))
(if (<= c0 -280000000000.0)
(* t_3 (+ t_1 t_2))
(if (<= c0 2.7e+106)
(* c0 (/ 0.0 w))
(* t_3 (+ t_2 (* t_0 (* (/ d D) (/ d D)))))))))
double code(double c0, double w, double h, double D, double d, double M) {
double t_0 = c0 / (w * h);
double t_1 = t_0 * ((d * d) / (D * D));
double t_2 = sqrt(((t_1 * t_1) - (M * M)));
double t_3 = c0 / (2.0 * w);
double tmp;
if (c0 <= -280000000000.0) {
tmp = t_3 * (t_1 + t_2);
} else if (c0 <= 2.7e+106) {
tmp = c0 * (0.0 / w);
} else {
tmp = t_3 * (t_2 + (t_0 * ((d / D) * (d / D))));
}
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) :: t_2
real(8) :: t_3
real(8) :: tmp
t_0 = c0 / (w * h)
t_1 = t_0 * ((d_1 * d_1) / (d * d))
t_2 = sqrt(((t_1 * t_1) - (m * m)))
t_3 = c0 / (2.0d0 * w)
if (c0 <= (-280000000000.0d0)) then
tmp = t_3 * (t_1 + t_2)
else if (c0 <= 2.7d+106) then
tmp = c0 * (0.0d0 / w)
else
tmp = t_3 * (t_2 + (t_0 * ((d_1 / d) * (d_1 / d))))
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 = c0 / (w * h);
double t_1 = t_0 * ((d * d) / (D * D));
double t_2 = Math.sqrt(((t_1 * t_1) - (M * M)));
double t_3 = c0 / (2.0 * w);
double tmp;
if (c0 <= -280000000000.0) {
tmp = t_3 * (t_1 + t_2);
} else if (c0 <= 2.7e+106) {
tmp = c0 * (0.0 / w);
} else {
tmp = t_3 * (t_2 + (t_0 * ((d / D) * (d / D))));
}
return tmp;
}
def code(c0, w, h, D, d, M): t_0 = c0 / (w * h) t_1 = t_0 * ((d * d) / (D * D)) t_2 = math.sqrt(((t_1 * t_1) - (M * M))) t_3 = c0 / (2.0 * w) tmp = 0 if c0 <= -280000000000.0: tmp = t_3 * (t_1 + t_2) elif c0 <= 2.7e+106: tmp = c0 * (0.0 / w) else: tmp = t_3 * (t_2 + (t_0 * ((d / D) * (d / D)))) return tmp
function code(c0, w, h, D, d, M) t_0 = Float64(c0 / Float64(w * h)) t_1 = Float64(t_0 * Float64(Float64(d * d) / Float64(D * D))) t_2 = sqrt(Float64(Float64(t_1 * t_1) - Float64(M * M))) t_3 = Float64(c0 / Float64(2.0 * w)) tmp = 0.0 if (c0 <= -280000000000.0) tmp = Float64(t_3 * Float64(t_1 + t_2)); elseif (c0 <= 2.7e+106) tmp = Float64(c0 * Float64(0.0 / w)); else tmp = Float64(t_3 * Float64(t_2 + Float64(t_0 * Float64(Float64(d / D) * Float64(d / D))))); end return tmp end
function tmp_2 = code(c0, w, h, D, d, M) t_0 = c0 / (w * h); t_1 = t_0 * ((d * d) / (D * D)); t_2 = sqrt(((t_1 * t_1) - (M * M))); t_3 = c0 / (2.0 * w); tmp = 0.0; if (c0 <= -280000000000.0) tmp = t_3 * (t_1 + t_2); elseif (c0 <= 2.7e+106) tmp = c0 * (0.0 / w); else tmp = t_3 * (t_2 + (t_0 * ((d / D) * (d / D)))); end tmp_2 = tmp; end
code[c0_, w_, h_, D_, d_, M_] := Block[{t$95$0 = N[(c0 / N[(w * h), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 * N[(N[(d * d), $MachinePrecision] / N[(D * D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Sqrt[N[(N[(t$95$1 * t$95$1), $MachinePrecision] - N[(M * M), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[(c0 / N[(2.0 * w), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[c0, -280000000000.0], N[(t$95$3 * N[(t$95$1 + t$95$2), $MachinePrecision]), $MachinePrecision], If[LessEqual[c0, 2.7e+106], N[(c0 * N[(0.0 / w), $MachinePrecision]), $MachinePrecision], N[(t$95$3 * N[(t$95$2 + N[(t$95$0 * N[(N[(d / D), $MachinePrecision] * N[(d / D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{c0}{w \cdot h}\\
t_1 := t\_0 \cdot \frac{d \cdot d}{D \cdot D}\\
t_2 := \sqrt{t\_1 \cdot t\_1 - M \cdot M}\\
t_3 := \frac{c0}{2 \cdot w}\\
\mathbf{if}\;c0 \leq -280000000000:\\
\;\;\;\;t\_3 \cdot \left(t\_1 + t\_2\right)\\
\mathbf{elif}\;c0 \leq 2.7 \cdot 10^{+106}:\\
\;\;\;\;c0 \cdot \frac{0}{w}\\
\mathbf{else}:\\
\;\;\;\;t\_3 \cdot \left(t\_2 + t\_0 \cdot \left(\frac{d}{D} \cdot \frac{d}{D}\right)\right)\\
\end{array}
\end{array}
if c0 < -2.8e11Initial program 35.1%
Simplified34.9%
if -2.8e11 < c0 < 2.70000000000000006e106Initial program 25.3%
Simplified35.1%
associate-*r/30.0%
*-commutative30.0%
associate-*r*28.6%
associate-*r*26.3%
associate-/l*26.3%
frac-times24.1%
associate-*l/24.2%
times-frac30.1%
pow230.1%
Applied egg-rr30.1%
associate-*l/30.0%
*-commutative30.0%
Simplified30.0%
Taylor expanded in c0 around -inf 4.5%
associate-*r/4.5%
distribute-lft-in4.5%
mul-1-neg4.5%
distribute-rgt-neg-in4.5%
associate-/l*3.2%
mul-1-neg3.2%
associate-/l*5.2%
distribute-lft1-in5.2%
metadata-eval5.2%
mul0-lft42.7%
metadata-eval42.7%
Simplified42.7%
if 2.70000000000000006e106 < c0 Initial program 36.4%
Simplified38.6%
times-frac38.6%
Applied egg-rr38.6%
Final simplification39.9%
(FPCore (c0 w h D d M) :precision binary64 (* c0 (/ 0.0 w)))
double code(double c0, double w, double h, double D, double d, double M) {
return c0 * (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 = c0 * (0.0d0 / w)
end function
public static double code(double c0, double w, double h, double D, double d, double M) {
return c0 * (0.0 / w);
}
def code(c0, w, h, D, d, M): return c0 * (0.0 / w)
function code(c0, w, h, D, d, M) return Float64(c0 * Float64(0.0 / w)) end
function tmp = code(c0, w, h, D, d, M) tmp = c0 * (0.0 / w); end
code[c0_, w_, h_, D_, d_, M_] := N[(c0 * N[(0.0 / w), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
c0 \cdot \frac{0}{w}
\end{array}
Initial program 30.0%
Simplified43.9%
associate-*r/37.7%
*-commutative37.7%
associate-*r*36.9%
associate-*r*33.0%
associate-/l*32.5%
frac-times31.7%
associate-*l/33.0%
times-frac39.7%
pow239.7%
Applied egg-rr39.7%
associate-*l/39.5%
*-commutative39.5%
Simplified39.5%
Taylor expanded in c0 around -inf 4.6%
associate-*r/4.6%
distribute-lft-in4.2%
mul-1-neg4.2%
distribute-rgt-neg-in4.2%
associate-/l*3.9%
mul-1-neg3.9%
associate-/l*4.1%
distribute-lft1-in4.1%
metadata-eval4.1%
mul0-lft33.5%
metadata-eval33.5%
Simplified33.5%
Final simplification33.5%
herbie shell --seed 2024074
(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))))))