
(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 (* w h)) (pow (/ d D) 2.0)))
(t_1 (/ (* c0 (* d d)) (* (* w h) (* D D)))))
(if (<=
(* (/ c0 (* 2.0 w)) (+ t_1 (sqrt (- (* t_1 t_1) (* M M)))))
INFINITY)
(* c0 (/ (+ t_0 (sqrt (- (pow t_0 2.0) (pow M 2.0)))) (* 2.0 w)))
0.0)))
double code(double c0, double w, double h, double D, double d, double M) {
double t_0 = (c0 / (w * h)) * pow((d / D), 2.0);
double t_1 = (c0 * (d * d)) / ((w * h) * (D * D));
double tmp;
if (((c0 / (2.0 * w)) * (t_1 + sqrt(((t_1 * t_1) - (M * M))))) <= ((double) INFINITY)) {
tmp = c0 * ((t_0 + sqrt((pow(t_0, 2.0) - pow(M, 2.0)))) / (2.0 * w));
} 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 / (w * h)) * Math.pow((d / D), 2.0);
double t_1 = (c0 * (d * d)) / ((w * h) * (D * D));
double tmp;
if (((c0 / (2.0 * w)) * (t_1 + Math.sqrt(((t_1 * t_1) - (M * M))))) <= Double.POSITIVE_INFINITY) {
tmp = c0 * ((t_0 + Math.sqrt((Math.pow(t_0, 2.0) - Math.pow(M, 2.0)))) / (2.0 * w));
} else {
tmp = 0.0;
}
return tmp;
}
def code(c0, w, h, D, d, M): t_0 = (c0 / (w * h)) * math.pow((d / D), 2.0) t_1 = (c0 * (d * d)) / ((w * h) * (D * D)) tmp = 0 if ((c0 / (2.0 * w)) * (t_1 + math.sqrt(((t_1 * t_1) - (M * M))))) <= math.inf: tmp = c0 * ((t_0 + math.sqrt((math.pow(t_0, 2.0) - math.pow(M, 2.0)))) / (2.0 * w)) else: tmp = 0.0 return tmp
function code(c0, w, h, D, d, M) t_0 = Float64(Float64(c0 / Float64(w * h)) * (Float64(d / D) ^ 2.0)) t_1 = 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_1 + sqrt(Float64(Float64(t_1 * t_1) - Float64(M * M))))) <= Inf) tmp = Float64(c0 * Float64(Float64(t_0 + sqrt(Float64((t_0 ^ 2.0) - (M ^ 2.0)))) / Float64(2.0 * w))); else tmp = 0.0; end return tmp end
function tmp_2 = code(c0, w, h, D, d, M) t_0 = (c0 / (w * h)) * ((d / D) ^ 2.0); t_1 = (c0 * (d * d)) / ((w * h) * (D * D)); tmp = 0.0; if (((c0 / (2.0 * w)) * (t_1 + sqrt(((t_1 * t_1) - (M * M))))) <= Inf) tmp = c0 * ((t_0 + sqrt(((t_0 ^ 2.0) - (M ^ 2.0)))) / (2.0 * w)); else tmp = 0.0; end tmp_2 = tmp; end
code[c0_, w_, h_, D_, d_, M_] := Block[{t$95$0 = N[(N[(c0 / N[(w * h), $MachinePrecision]), $MachinePrecision] * N[Power[N[(d / D), $MachinePrecision], 2.0], $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[(N[(c0 / N[(2.0 * w), $MachinePrecision]), $MachinePrecision] * 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[(c0 * N[(N[(t$95$0 + N[Sqrt[N[(N[Power[t$95$0, 2.0], $MachinePrecision] - N[Power[M, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(2.0 * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 0.0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{c0}{w \cdot h} \cdot {\left(\frac{d}{D}\right)}^{2}\\
t_1 := \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\_1 + \sqrt{t\_1 \cdot t\_1 - M \cdot M}\right) \leq \infty:\\
\;\;\;\;c0 \cdot \frac{t\_0 + \sqrt{{t\_0}^{2} - {M}^{2}}}{2 \cdot w}\\
\mathbf{else}:\\
\;\;\;\;0\\
\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 78.4%
Simplified73.6%
fma-undefine78.3%
associate-*r/78.3%
*-commutative78.3%
associate-*r*79.5%
associate-*r*76.1%
associate-/l*72.6%
frac-times71.2%
times-frac73.4%
pow273.4%
Applied egg-rr79.4%
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%
Simplified2.3%
distribute-lft-in2.3%
*-commutative2.3%
times-frac2.3%
pow22.3%
*-commutative2.3%
Applied egg-rr13.3%
Taylor expanded in c0 around -inf 0.7%
mul-1-neg0.7%
Simplified0.7%
fma-define0.8%
distribute-rgt-neg-out0.8%
pow20.8%
*-commutative0.8%
*-commutative0.8%
frac-times1.4%
pow21.4%
frac-times2.2%
pow22.2%
Applied egg-rr3.7%
+-inverses43.4%
Simplified43.4%
Final simplification54.8%
(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 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 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 = 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 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 = 0.0;
}
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 = 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))) 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 = 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)); 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 = 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]}, 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, 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)}\\
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}:\\
\;\;\;\;0\\
\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 78.4%
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%
Simplified2.3%
distribute-lft-in2.3%
*-commutative2.3%
times-frac2.3%
pow22.3%
*-commutative2.3%
Applied egg-rr13.3%
Taylor expanded in c0 around -inf 0.7%
mul-1-neg0.7%
Simplified0.7%
fma-define0.8%
distribute-rgt-neg-out0.8%
pow20.8%
*-commutative0.8%
*-commutative0.8%
frac-times1.4%
pow21.4%
frac-times2.2%
pow22.2%
Applied egg-rr3.7%
+-inverses43.4%
Simplified43.4%
Final simplification54.5%
(FPCore (c0 w h D d M)
:precision binary64
(if (<= (* M M) 6e-192)
0.0
(if (or (<= (* M M) 2e-123) (not (<= (* M M) 2e-57)))
(* c0 (/ (* 2.0 (* (/ c0 (* w h)) (pow (/ d D) 2.0))) (* 2.0 w)))
0.0)))
double code(double c0, double w, double h, double D, double d, double M) {
double tmp;
if ((M * M) <= 6e-192) {
tmp = 0.0;
} else if (((M * M) <= 2e-123) || !((M * M) <= 2e-57)) {
tmp = c0 * ((2.0 * ((c0 / (w * h)) * pow((d / D), 2.0))) / (2.0 * 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 ((m * m) <= 6d-192) then
tmp = 0.0d0
else if (((m * m) <= 2d-123) .or. (.not. ((m * m) <= 2d-57))) then
tmp = c0 * ((2.0d0 * ((c0 / (w * h)) * ((d_1 / d) ** 2.0d0))) / (2.0d0 * 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 ((M * M) <= 6e-192) {
tmp = 0.0;
} else if (((M * M) <= 2e-123) || !((M * M) <= 2e-57)) {
tmp = c0 * ((2.0 * ((c0 / (w * h)) * Math.pow((d / D), 2.0))) / (2.0 * w));
} else {
tmp = 0.0;
}
return tmp;
}
def code(c0, w, h, D, d, M): tmp = 0 if (M * M) <= 6e-192: tmp = 0.0 elif ((M * M) <= 2e-123) or not ((M * M) <= 2e-57): tmp = c0 * ((2.0 * ((c0 / (w * h)) * math.pow((d / D), 2.0))) / (2.0 * w)) else: tmp = 0.0 return tmp
function code(c0, w, h, D, d, M) tmp = 0.0 if (Float64(M * M) <= 6e-192) tmp = 0.0; elseif ((Float64(M * M) <= 2e-123) || !(Float64(M * M) <= 2e-57)) tmp = Float64(c0 * Float64(Float64(2.0 * Float64(Float64(c0 / Float64(w * h)) * (Float64(d / D) ^ 2.0))) / Float64(2.0 * w))); else tmp = 0.0; end return tmp end
function tmp_2 = code(c0, w, h, D, d, M) tmp = 0.0; if ((M * M) <= 6e-192) tmp = 0.0; elseif (((M * M) <= 2e-123) || ~(((M * M) <= 2e-57))) tmp = c0 * ((2.0 * ((c0 / (w * h)) * ((d / D) ^ 2.0))) / (2.0 * w)); else tmp = 0.0; end tmp_2 = tmp; end
code[c0_, w_, h_, D_, d_, M_] := If[LessEqual[N[(M * M), $MachinePrecision], 6e-192], 0.0, If[Or[LessEqual[N[(M * M), $MachinePrecision], 2e-123], N[Not[LessEqual[N[(M * M), $MachinePrecision], 2e-57]], $MachinePrecision]], N[(c0 * N[(N[(2.0 * N[(N[(c0 / N[(w * h), $MachinePrecision]), $MachinePrecision] * N[Power[N[(d / D), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(2.0 * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 0.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;M \cdot M \leq 6 \cdot 10^{-192}:\\
\;\;\;\;0\\
\mathbf{elif}\;M \cdot M \leq 2 \cdot 10^{-123} \lor \neg \left(M \cdot M \leq 2 \cdot 10^{-57}\right):\\
\;\;\;\;c0 \cdot \frac{2 \cdot \left(\frac{c0}{w \cdot h} \cdot {\left(\frac{d}{D}\right)}^{2}\right)}{2 \cdot w}\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if (*.f64 M M) < 5.9999999999999998e-192 or 2.0000000000000001e-123 < (*.f64 M M) < 1.99999999999999991e-57Initial program 26.6%
Simplified25.9%
distribute-lft-in25.1%
*-commutative25.1%
times-frac25.2%
pow225.2%
*-commutative25.2%
Applied egg-rr37.1%
Taylor expanded in c0 around -inf 5.6%
mul-1-neg5.6%
Simplified5.6%
fma-define4.3%
distribute-rgt-neg-out4.3%
pow24.3%
*-commutative4.3%
*-commutative4.3%
frac-times4.4%
pow24.4%
frac-times6.9%
pow26.9%
Applied egg-rr11.7%
+-inverses54.2%
Simplified54.2%
if 5.9999999999999998e-192 < (*.f64 M M) < 2.0000000000000001e-123 or 1.99999999999999991e-57 < (*.f64 M M) Initial program 22.9%
Simplified42.1%
Taylor expanded in c0 around inf 39.4%
associate-/l*40.3%
Simplified40.3%
Taylor expanded in c0 around 0 39.4%
*-commutative39.4%
*-commutative39.4%
times-frac41.8%
unpow241.8%
unpow241.8%
times-frac48.5%
unpow248.5%
Simplified48.5%
Final simplification51.5%
(FPCore (c0 w h D d M) :precision binary64 (if (<= M 2.2e+47) 0.0 (* 0.5 (* M (/ c0 w)))))
double code(double c0, double w, double h, double D, double d, double M) {
double tmp;
if (M <= 2.2e+47) {
tmp = 0.0;
} else {
tmp = 0.5 * (M * (c0 / w));
}
return tmp;
}
real(8) function code(c0, w, h, d, d_1, m)
real(8), intent (in) :: c0
real(8), intent (in) :: w
real(8), intent (in) :: h
real(8), intent (in) :: d
real(8), intent (in) :: d_1
real(8), intent (in) :: m
real(8) :: tmp
if (m <= 2.2d+47) then
tmp = 0.0d0
else
tmp = 0.5d0 * (m * (c0 / w))
end if
code = tmp
end function
public static double code(double c0, double w, double h, double D, double d, double M) {
double tmp;
if (M <= 2.2e+47) {
tmp = 0.0;
} else {
tmp = 0.5 * (M * (c0 / w));
}
return tmp;
}
def code(c0, w, h, D, d, M): tmp = 0 if M <= 2.2e+47: tmp = 0.0 else: tmp = 0.5 * (M * (c0 / w)) return tmp
function code(c0, w, h, D, d, M) tmp = 0.0 if (M <= 2.2e+47) tmp = 0.0; else tmp = Float64(0.5 * Float64(M * Float64(c0 / w))); end return tmp end
function tmp_2 = code(c0, w, h, D, d, M) tmp = 0.0; if (M <= 2.2e+47) tmp = 0.0; else tmp = 0.5 * (M * (c0 / w)); end tmp_2 = tmp; end
code[c0_, w_, h_, D_, d_, M_] := If[LessEqual[M, 2.2e+47], 0.0, N[(0.5 * N[(M * N[(c0 / w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;M \leq 2.2 \cdot 10^{+47}:\\
\;\;\;\;0\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(M \cdot \frac{c0}{w}\right)\\
\end{array}
\end{array}
if M < 2.1999999999999999e47Initial program 25.7%
Simplified26.6%
distribute-lft-in26.1%
*-commutative26.1%
times-frac26.2%
pow226.2%
*-commutative26.2%
Applied egg-rr35.9%
Taylor expanded in c0 around -inf 4.1%
mul-1-neg4.1%
Simplified4.1%
fma-define3.3%
distribute-rgt-neg-out3.3%
pow23.3%
*-commutative3.3%
*-commutative3.3%
frac-times3.8%
pow23.8%
frac-times4.5%
pow24.5%
Applied egg-rr7.8%
+-inverses42.0%
Simplified42.0%
if 2.1999999999999999e47 < M Initial program 20.2%
Simplified40.5%
*-un-lft-identity40.5%
fma-undefine40.5%
associate-*r/40.5%
*-commutative40.5%
associate-*r*40.5%
associate-*r*35.5%
associate-/l*35.5%
frac-times35.3%
fma-define35.3%
Applied egg-rr42.9%
fma-undefine42.8%
sqrt-prod42.8%
add-log-exp42.8%
fma-undefine42.8%
add-log-exp42.8%
Applied egg-rr51.4%
Taylor expanded in c0 around 0 37.2%
associate-/l*31.8%
Simplified31.8%
Final simplification40.4%
(FPCore (c0 w h D d M) :precision binary64 (if (<= M 1.8e+47) 0.0 (* 0.5 (/ (* c0 M) w))))
double code(double c0, double w, double h, double D, double d, double M) {
double tmp;
if (M <= 1.8e+47) {
tmp = 0.0;
} else {
tmp = 0.5 * ((c0 * M) / w);
}
return tmp;
}
real(8) function code(c0, w, h, d, d_1, m)
real(8), intent (in) :: c0
real(8), intent (in) :: w
real(8), intent (in) :: h
real(8), intent (in) :: d
real(8), intent (in) :: d_1
real(8), intent (in) :: m
real(8) :: tmp
if (m <= 1.8d+47) then
tmp = 0.0d0
else
tmp = 0.5d0 * ((c0 * m) / w)
end if
code = tmp
end function
public static double code(double c0, double w, double h, double D, double d, double M) {
double tmp;
if (M <= 1.8e+47) {
tmp = 0.0;
} else {
tmp = 0.5 * ((c0 * M) / w);
}
return tmp;
}
def code(c0, w, h, D, d, M): tmp = 0 if M <= 1.8e+47: tmp = 0.0 else: tmp = 0.5 * ((c0 * M) / w) return tmp
function code(c0, w, h, D, d, M) tmp = 0.0 if (M <= 1.8e+47) tmp = 0.0; else tmp = Float64(0.5 * Float64(Float64(c0 * M) / w)); end return tmp end
function tmp_2 = code(c0, w, h, D, d, M) tmp = 0.0; if (M <= 1.8e+47) tmp = 0.0; else tmp = 0.5 * ((c0 * M) / w); end tmp_2 = tmp; end
code[c0_, w_, h_, D_, d_, M_] := If[LessEqual[M, 1.8e+47], 0.0, N[(0.5 * N[(N[(c0 * M), $MachinePrecision] / w), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;M \leq 1.8 \cdot 10^{+47}:\\
\;\;\;\;0\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \frac{c0 \cdot M}{w}\\
\end{array}
\end{array}
if M < 1.80000000000000004e47Initial program 25.7%
Simplified26.6%
distribute-lft-in26.1%
*-commutative26.1%
times-frac26.2%
pow226.2%
*-commutative26.2%
Applied egg-rr35.9%
Taylor expanded in c0 around -inf 4.1%
mul-1-neg4.1%
Simplified4.1%
fma-define3.3%
distribute-rgt-neg-out3.3%
pow23.3%
*-commutative3.3%
*-commutative3.3%
frac-times3.8%
pow23.8%
frac-times4.5%
pow24.5%
Applied egg-rr7.8%
+-inverses42.0%
Simplified42.0%
if 1.80000000000000004e47 < M Initial program 20.2%
Simplified40.5%
*-un-lft-identity40.5%
fma-undefine40.5%
associate-*r/40.5%
*-commutative40.5%
associate-*r*40.5%
associate-*r*35.5%
associate-/l*35.5%
frac-times35.3%
fma-define35.3%
Applied egg-rr42.9%
fma-undefine42.8%
sqrt-prod42.8%
add-log-exp42.8%
fma-undefine42.8%
add-log-exp42.8%
Applied egg-rr51.4%
Taylor expanded in c0 around 0 37.2%
Final simplification41.3%
(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 24.8%
Simplified25.6%
distribute-lft-in25.2%
*-commutative25.2%
times-frac25.3%
pow225.3%
*-commutative25.3%
Applied egg-rr33.8%
Taylor expanded in c0 around -inf 3.5%
mul-1-neg3.5%
Simplified3.5%
fma-define2.8%
distribute-rgt-neg-out2.8%
pow22.8%
*-commutative2.8%
*-commutative2.8%
frac-times3.2%
pow23.2%
frac-times3.8%
pow23.8%
Applied egg-rr6.6%
+-inverses36.3%
Simplified36.3%
Final simplification36.3%
herbie shell --seed 2024115
(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))))))