
(FPCore (w0 M D h l d) :precision binary64 (* w0 (sqrt (- 1.0 (* (pow (/ (* M D) (* 2.0 d)) 2.0) (/ h l))))))
double code(double w0, double M, double D, double h, double l, double d) {
return w0 * sqrt((1.0 - (pow(((M * D) / (2.0 * d)), 2.0) * (h / l))));
}
real(8) function code(w0, m, d, h, l, d_1)
real(8), intent (in) :: w0
real(8), intent (in) :: m
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: d_1
code = w0 * sqrt((1.0d0 - ((((m * d) / (2.0d0 * d_1)) ** 2.0d0) * (h / l))))
end function
public static double code(double w0, double M, double D, double h, double l, double d) {
return w0 * Math.sqrt((1.0 - (Math.pow(((M * D) / (2.0 * d)), 2.0) * (h / l))));
}
def code(w0, M, D, h, l, d): return w0 * math.sqrt((1.0 - (math.pow(((M * D) / (2.0 * d)), 2.0) * (h / l))))
function code(w0, M, D, h, l, d) return Float64(w0 * sqrt(Float64(1.0 - Float64((Float64(Float64(M * D) / Float64(2.0 * d)) ^ 2.0) * Float64(h / l))))) end
function tmp = code(w0, M, D, h, l, d) tmp = w0 * sqrt((1.0 - ((((M * D) / (2.0 * d)) ^ 2.0) * (h / l)))); end
code[w0_, M_, D_, h_, l_, d_] := N[(w0 * N[Sqrt[N[(1.0 - N[(N[Power[N[(N[(M * D), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 5 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (w0 M D h l d) :precision binary64 (* w0 (sqrt (- 1.0 (* (pow (/ (* M D) (* 2.0 d)) 2.0) (/ h l))))))
double code(double w0, double M, double D, double h, double l, double d) {
return w0 * sqrt((1.0 - (pow(((M * D) / (2.0 * d)), 2.0) * (h / l))));
}
real(8) function code(w0, m, d, h, l, d_1)
real(8), intent (in) :: w0
real(8), intent (in) :: m
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: d_1
code = w0 * sqrt((1.0d0 - ((((m * d) / (2.0d0 * d_1)) ** 2.0d0) * (h / l))))
end function
public static double code(double w0, double M, double D, double h, double l, double d) {
return w0 * Math.sqrt((1.0 - (Math.pow(((M * D) / (2.0 * d)), 2.0) * (h / l))));
}
def code(w0, M, D, h, l, d): return w0 * math.sqrt((1.0 - (math.pow(((M * D) / (2.0 * d)), 2.0) * (h / l))))
function code(w0, M, D, h, l, d) return Float64(w0 * sqrt(Float64(1.0 - Float64((Float64(Float64(M * D) / Float64(2.0 * d)) ^ 2.0) * Float64(h / l))))) end
function tmp = code(w0, M, D, h, l, d) tmp = w0 * sqrt((1.0 - ((((M * D) / (2.0 * d)) ^ 2.0) * (h / l)))); end
code[w0_, M_, D_, h_, l_, d_] := N[(w0 * N[Sqrt[N[(1.0 - N[(N[Power[N[(N[(M * D), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}}
\end{array}
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
(FPCore (w0 M_m D_m h l d)
:precision binary64
(*
w0
(sqrt
(-
1.0
(/ (* (* (/ M_m d) (/ D_m 2.0)) h) (* l (* (/ d M_m) (/ 2.0 D_m))))))))M_m = fabs(M);
D_m = fabs(D);
assert(w0 < M_m && M_m < D_m && D_m < h && h < l && l < d);
double code(double w0, double M_m, double D_m, double h, double l, double d) {
return w0 * sqrt((1.0 - ((((M_m / d) * (D_m / 2.0)) * h) / (l * ((d / M_m) * (2.0 / D_m))))));
}
M_m = abs(m)
D_m = abs(d)
NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
real(8) function code(w0, m_m, d_m, h, l, d)
real(8), intent (in) :: w0
real(8), intent (in) :: m_m
real(8), intent (in) :: d_m
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: d
code = w0 * sqrt((1.0d0 - ((((m_m / d) * (d_m / 2.0d0)) * h) / (l * ((d / m_m) * (2.0d0 / d_m))))))
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
assert w0 < M_m && M_m < D_m && D_m < h && h < l && l < d;
public static double code(double w0, double M_m, double D_m, double h, double l, double d) {
return w0 * Math.sqrt((1.0 - ((((M_m / d) * (D_m / 2.0)) * h) / (l * ((d / M_m) * (2.0 / D_m))))));
}
M_m = math.fabs(M) D_m = math.fabs(D) [w0, M_m, D_m, h, l, d] = sort([w0, M_m, D_m, h, l, d]) def code(w0, M_m, D_m, h, l, d): return w0 * math.sqrt((1.0 - ((((M_m / d) * (D_m / 2.0)) * h) / (l * ((d / M_m) * (2.0 / D_m))))))
M_m = abs(M) D_m = abs(D) w0, M_m, D_m, h, l, d = sort([w0, M_m, D_m, h, l, d]) function code(w0, M_m, D_m, h, l, d) return Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(Float64(Float64(M_m / d) * Float64(D_m / 2.0)) * h) / Float64(l * Float64(Float64(d / M_m) * Float64(2.0 / D_m))))))) end
M_m = abs(M);
D_m = abs(D);
w0, M_m, D_m, h, l, d = num2cell(sort([w0, M_m, D_m, h, l, d])){:}
function tmp = code(w0, M_m, D_m, h, l, d)
tmp = w0 * sqrt((1.0 - ((((M_m / d) * (D_m / 2.0)) * h) / (l * ((d / M_m) * (2.0 / D_m))))));
end
M_m = N[Abs[M], $MachinePrecision] D_m = N[Abs[D], $MachinePrecision] NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function. code[w0_, M$95$m_, D$95$m_, h_, l_, d_] := N[(w0 * N[Sqrt[N[(1.0 - N[(N[(N[(N[(M$95$m / d), $MachinePrecision] * N[(D$95$m / 2.0), $MachinePrecision]), $MachinePrecision] * h), $MachinePrecision] / N[(l * N[(N[(d / M$95$m), $MachinePrecision] * N[(2.0 / D$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[w0, M_m, D_m, h, l, d] = \mathsf{sort}([w0, M_m, D_m, h, l, d])\\
\\
w0 \cdot \sqrt{1 - \frac{\left(\frac{M\_m}{d} \cdot \frac{D\_m}{2}\right) \cdot h}{\ell \cdot \left(\frac{d}{M\_m} \cdot \frac{2}{D\_m}\right)}}
\end{array}
Initial program 81.7%
Simplified81.7%
unpow281.7%
associate-*r/80.6%
clear-num80.6%
un-div-inv80.6%
*-un-lft-identity80.6%
times-frac80.6%
metadata-eval80.6%
times-frac81.7%
Applied egg-rr81.7%
frac-times87.6%
associate-*r/87.6%
frac-times86.2%
*-commutative86.2%
Applied egg-rr86.2%
*-un-lft-identity86.2%
associate-*r/88.1%
associate-/l*88.9%
associate-*r/87.0%
associate-/l*87.0%
*-commutative87.0%
associate-/l*87.0%
Applied egg-rr87.0%
*-lft-identity87.0%
associate-*r/86.3%
*-commutative86.3%
associate-*l*86.3%
associate-*l/88.1%
*-commutative88.1%
*-commutative88.1%
metadata-eval88.1%
times-frac88.1%
*-rgt-identity88.1%
associate-*r/86.3%
associate-*r/88.1%
times-frac86.7%
associate-*r/86.7%
times-frac88.1%
Simplified88.1%
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
(FPCore (w0 M_m D_m h l d)
:precision binary64
(if (<= (/ h l) -1e-309)
(*
w0
(sqrt
(-
1.0
(* (* (/ (* M_m (* D_m 0.5)) d) (/ (* M_m D_m) (* d 2.0))) (/ h l)))))
w0))M_m = fabs(M);
D_m = fabs(D);
assert(w0 < M_m && M_m < D_m && D_m < h && h < l && l < d);
double code(double w0, double M_m, double D_m, double h, double l, double d) {
double tmp;
if ((h / l) <= -1e-309) {
tmp = w0 * sqrt((1.0 - ((((M_m * (D_m * 0.5)) / d) * ((M_m * D_m) / (d * 2.0))) * (h / l))));
} else {
tmp = w0;
}
return tmp;
}
M_m = abs(m)
D_m = abs(d)
NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
real(8) function code(w0, m_m, d_m, h, l, d)
real(8), intent (in) :: w0
real(8), intent (in) :: m_m
real(8), intent (in) :: d_m
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: d
real(8) :: tmp
if ((h / l) <= (-1d-309)) then
tmp = w0 * sqrt((1.0d0 - ((((m_m * (d_m * 0.5d0)) / d) * ((m_m * d_m) / (d * 2.0d0))) * (h / l))))
else
tmp = w0
end if
code = tmp
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
assert w0 < M_m && M_m < D_m && D_m < h && h < l && l < d;
public static double code(double w0, double M_m, double D_m, double h, double l, double d) {
double tmp;
if ((h / l) <= -1e-309) {
tmp = w0 * Math.sqrt((1.0 - ((((M_m * (D_m * 0.5)) / d) * ((M_m * D_m) / (d * 2.0))) * (h / l))));
} else {
tmp = w0;
}
return tmp;
}
M_m = math.fabs(M) D_m = math.fabs(D) [w0, M_m, D_m, h, l, d] = sort([w0, M_m, D_m, h, l, d]) def code(w0, M_m, D_m, h, l, d): tmp = 0 if (h / l) <= -1e-309: tmp = w0 * math.sqrt((1.0 - ((((M_m * (D_m * 0.5)) / d) * ((M_m * D_m) / (d * 2.0))) * (h / l)))) else: tmp = w0 return tmp
M_m = abs(M) D_m = abs(D) w0, M_m, D_m, h, l, d = sort([w0, M_m, D_m, h, l, d]) function code(w0, M_m, D_m, h, l, d) tmp = 0.0 if (Float64(h / l) <= -1e-309) tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(Float64(Float64(M_m * Float64(D_m * 0.5)) / d) * Float64(Float64(M_m * D_m) / Float64(d * 2.0))) * Float64(h / l))))); else tmp = w0; end return tmp end
M_m = abs(M);
D_m = abs(D);
w0, M_m, D_m, h, l, d = num2cell(sort([w0, M_m, D_m, h, l, d])){:}
function tmp_2 = code(w0, M_m, D_m, h, l, d)
tmp = 0.0;
if ((h / l) <= -1e-309)
tmp = w0 * sqrt((1.0 - ((((M_m * (D_m * 0.5)) / d) * ((M_m * D_m) / (d * 2.0))) * (h / l))));
else
tmp = w0;
end
tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision] D_m = N[Abs[D], $MachinePrecision] NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function. code[w0_, M$95$m_, D$95$m_, h_, l_, d_] := If[LessEqual[N[(h / l), $MachinePrecision], -1e-309], N[(w0 * N[Sqrt[N[(1.0 - N[(N[(N[(N[(M$95$m * N[(D$95$m * 0.5), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision] * N[(N[(M$95$m * D$95$m), $MachinePrecision] / N[(d * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], w0]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[w0, M_m, D_m, h, l, d] = \mathsf{sort}([w0, M_m, D_m, h, l, d])\\
\\
\begin{array}{l}
\mathbf{if}\;\frac{h}{\ell} \leq -1 \cdot 10^{-309}:\\
\;\;\;\;w0 \cdot \sqrt{1 - \left(\frac{M\_m \cdot \left(D\_m \cdot 0.5\right)}{d} \cdot \frac{M\_m \cdot D\_m}{d \cdot 2}\right) \cdot \frac{h}{\ell}}\\
\mathbf{else}:\\
\;\;\;\;w0\\
\end{array}
\end{array}
if (/.f64 h l) < -1.000000000000002e-309Initial program 74.8%
Simplified75.6%
associate-*r/74.8%
unpow274.8%
associate-/r*74.8%
frac-times59.6%
associate-/l*59.6%
div-inv59.6%
metadata-eval59.6%
Applied egg-rr59.6%
times-frac74.8%
*-commutative74.8%
*-commutative74.8%
Applied egg-rr74.8%
if -1.000000000000002e-309 < (/.f64 h l) Initial program 88.9%
Simplified88.1%
Taylor expanded in M around 0 95.3%
Final simplification84.9%
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
(FPCore (w0 M_m D_m h l d)
:precision binary64
(if (<= D_m 1e+111)
(*
w0
(sqrt
(-
1.0
(/ (* h (* M_m (/ (* D_m 0.5) d))) (* l (/ (* d 2.0) (* M_m D_m)))))))
(*
w0
(sqrt
(-
1.0
(* (* (/ (* M_m (* D_m 0.5)) d) (/ (* M_m D_m) (* d 2.0))) (/ h l)))))))M_m = fabs(M);
D_m = fabs(D);
assert(w0 < M_m && M_m < D_m && D_m < h && h < l && l < d);
double code(double w0, double M_m, double D_m, double h, double l, double d) {
double tmp;
if (D_m <= 1e+111) {
tmp = w0 * sqrt((1.0 - ((h * (M_m * ((D_m * 0.5) / d))) / (l * ((d * 2.0) / (M_m * D_m))))));
} else {
tmp = w0 * sqrt((1.0 - ((((M_m * (D_m * 0.5)) / d) * ((M_m * D_m) / (d * 2.0))) * (h / l))));
}
return tmp;
}
M_m = abs(m)
D_m = abs(d)
NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
real(8) function code(w0, m_m, d_m, h, l, d)
real(8), intent (in) :: w0
real(8), intent (in) :: m_m
real(8), intent (in) :: d_m
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: d
real(8) :: tmp
if (d_m <= 1d+111) then
tmp = w0 * sqrt((1.0d0 - ((h * (m_m * ((d_m * 0.5d0) / d))) / (l * ((d * 2.0d0) / (m_m * d_m))))))
else
tmp = w0 * sqrt((1.0d0 - ((((m_m * (d_m * 0.5d0)) / d) * ((m_m * d_m) / (d * 2.0d0))) * (h / l))))
end if
code = tmp
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
assert w0 < M_m && M_m < D_m && D_m < h && h < l && l < d;
public static double code(double w0, double M_m, double D_m, double h, double l, double d) {
double tmp;
if (D_m <= 1e+111) {
tmp = w0 * Math.sqrt((1.0 - ((h * (M_m * ((D_m * 0.5) / d))) / (l * ((d * 2.0) / (M_m * D_m))))));
} else {
tmp = w0 * Math.sqrt((1.0 - ((((M_m * (D_m * 0.5)) / d) * ((M_m * D_m) / (d * 2.0))) * (h / l))));
}
return tmp;
}
M_m = math.fabs(M) D_m = math.fabs(D) [w0, M_m, D_m, h, l, d] = sort([w0, M_m, D_m, h, l, d]) def code(w0, M_m, D_m, h, l, d): tmp = 0 if D_m <= 1e+111: tmp = w0 * math.sqrt((1.0 - ((h * (M_m * ((D_m * 0.5) / d))) / (l * ((d * 2.0) / (M_m * D_m)))))) else: tmp = w0 * math.sqrt((1.0 - ((((M_m * (D_m * 0.5)) / d) * ((M_m * D_m) / (d * 2.0))) * (h / l)))) return tmp
M_m = abs(M) D_m = abs(D) w0, M_m, D_m, h, l, d = sort([w0, M_m, D_m, h, l, d]) function code(w0, M_m, D_m, h, l, d) tmp = 0.0 if (D_m <= 1e+111) tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(h * Float64(M_m * Float64(Float64(D_m * 0.5) / d))) / Float64(l * Float64(Float64(d * 2.0) / Float64(M_m * D_m))))))); else tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(Float64(Float64(M_m * Float64(D_m * 0.5)) / d) * Float64(Float64(M_m * D_m) / Float64(d * 2.0))) * Float64(h / l))))); end return tmp end
M_m = abs(M);
D_m = abs(D);
w0, M_m, D_m, h, l, d = num2cell(sort([w0, M_m, D_m, h, l, d])){:}
function tmp_2 = code(w0, M_m, D_m, h, l, d)
tmp = 0.0;
if (D_m <= 1e+111)
tmp = w0 * sqrt((1.0 - ((h * (M_m * ((D_m * 0.5) / d))) / (l * ((d * 2.0) / (M_m * D_m))))));
else
tmp = w0 * sqrt((1.0 - ((((M_m * (D_m * 0.5)) / d) * ((M_m * D_m) / (d * 2.0))) * (h / l))));
end
tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision] D_m = N[Abs[D], $MachinePrecision] NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function. code[w0_, M$95$m_, D$95$m_, h_, l_, d_] := If[LessEqual[D$95$m, 1e+111], N[(w0 * N[Sqrt[N[(1.0 - N[(N[(h * N[(M$95$m * N[(N[(D$95$m * 0.5), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(l * N[(N[(d * 2.0), $MachinePrecision] / N[(M$95$m * D$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(w0 * N[Sqrt[N[(1.0 - N[(N[(N[(N[(M$95$m * N[(D$95$m * 0.5), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision] * N[(N[(M$95$m * D$95$m), $MachinePrecision] / N[(d * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[w0, M_m, D_m, h, l, d] = \mathsf{sort}([w0, M_m, D_m, h, l, d])\\
\\
\begin{array}{l}
\mathbf{if}\;D\_m \leq 10^{+111}:\\
\;\;\;\;w0 \cdot \sqrt{1 - \frac{h \cdot \left(M\_m \cdot \frac{D\_m \cdot 0.5}{d}\right)}{\ell \cdot \frac{d \cdot 2}{M\_m \cdot D\_m}}}\\
\mathbf{else}:\\
\;\;\;\;w0 \cdot \sqrt{1 - \left(\frac{M\_m \cdot \left(D\_m \cdot 0.5\right)}{d} \cdot \frac{M\_m \cdot D\_m}{d \cdot 2}\right) \cdot \frac{h}{\ell}}\\
\end{array}
\end{array}
if D < 9.99999999999999957e110Initial program 82.4%
Simplified82.4%
unpow282.4%
associate-*r/82.0%
clear-num82.0%
un-div-inv82.0%
*-un-lft-identity82.0%
times-frac82.0%
metadata-eval82.0%
times-frac82.4%
Applied egg-rr82.4%
frac-times88.7%
associate-*r/88.7%
frac-times88.0%
*-commutative88.0%
Applied egg-rr88.0%
if 9.99999999999999957e110 < D Initial program 77.3%
Simplified77.2%
associate-*r/77.3%
unpow277.3%
associate-/r*77.3%
frac-times50.7%
associate-/l*50.7%
div-inv50.7%
metadata-eval50.7%
Applied egg-rr50.7%
times-frac77.3%
*-commutative77.3%
*-commutative77.3%
Applied egg-rr77.3%
Final simplification86.6%
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
(FPCore (w0 M_m D_m h l d)
:precision binary64
(if (<= M_m 4.35e-212)
w0
(*
w0
(sqrt
(-
1.0
(* (/ h l) (* (/ D_m d) (* (* M_m (* 0.5 (/ D_m d))) (* M_m 0.5)))))))))M_m = fabs(M);
D_m = fabs(D);
assert(w0 < M_m && M_m < D_m && D_m < h && h < l && l < d);
double code(double w0, double M_m, double D_m, double h, double l, double d) {
double tmp;
if (M_m <= 4.35e-212) {
tmp = w0;
} else {
tmp = w0 * sqrt((1.0 - ((h / l) * ((D_m / d) * ((M_m * (0.5 * (D_m / d))) * (M_m * 0.5))))));
}
return tmp;
}
M_m = abs(m)
D_m = abs(d)
NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
real(8) function code(w0, m_m, d_m, h, l, d)
real(8), intent (in) :: w0
real(8), intent (in) :: m_m
real(8), intent (in) :: d_m
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: d
real(8) :: tmp
if (m_m <= 4.35d-212) then
tmp = w0
else
tmp = w0 * sqrt((1.0d0 - ((h / l) * ((d_m / d) * ((m_m * (0.5d0 * (d_m / d))) * (m_m * 0.5d0))))))
end if
code = tmp
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
assert w0 < M_m && M_m < D_m && D_m < h && h < l && l < d;
public static double code(double w0, double M_m, double D_m, double h, double l, double d) {
double tmp;
if (M_m <= 4.35e-212) {
tmp = w0;
} else {
tmp = w0 * Math.sqrt((1.0 - ((h / l) * ((D_m / d) * ((M_m * (0.5 * (D_m / d))) * (M_m * 0.5))))));
}
return tmp;
}
M_m = math.fabs(M) D_m = math.fabs(D) [w0, M_m, D_m, h, l, d] = sort([w0, M_m, D_m, h, l, d]) def code(w0, M_m, D_m, h, l, d): tmp = 0 if M_m <= 4.35e-212: tmp = w0 else: tmp = w0 * math.sqrt((1.0 - ((h / l) * ((D_m / d) * ((M_m * (0.5 * (D_m / d))) * (M_m * 0.5)))))) return tmp
M_m = abs(M) D_m = abs(D) w0, M_m, D_m, h, l, d = sort([w0, M_m, D_m, h, l, d]) function code(w0, M_m, D_m, h, l, d) tmp = 0.0 if (M_m <= 4.35e-212) tmp = w0; else tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(h / l) * Float64(Float64(D_m / d) * Float64(Float64(M_m * Float64(0.5 * Float64(D_m / d))) * Float64(M_m * 0.5))))))); end return tmp end
M_m = abs(M);
D_m = abs(D);
w0, M_m, D_m, h, l, d = num2cell(sort([w0, M_m, D_m, h, l, d])){:}
function tmp_2 = code(w0, M_m, D_m, h, l, d)
tmp = 0.0;
if (M_m <= 4.35e-212)
tmp = w0;
else
tmp = w0 * sqrt((1.0 - ((h / l) * ((D_m / d) * ((M_m * (0.5 * (D_m / d))) * (M_m * 0.5))))));
end
tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision] D_m = N[Abs[D], $MachinePrecision] NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function. code[w0_, M$95$m_, D$95$m_, h_, l_, d_] := If[LessEqual[M$95$m, 4.35e-212], w0, N[(w0 * N[Sqrt[N[(1.0 - N[(N[(h / l), $MachinePrecision] * N[(N[(D$95$m / d), $MachinePrecision] * N[(N[(M$95$m * N[(0.5 * N[(D$95$m / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(M$95$m * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[w0, M_m, D_m, h, l, d] = \mathsf{sort}([w0, M_m, D_m, h, l, d])\\
\\
\begin{array}{l}
\mathbf{if}\;M\_m \leq 4.35 \cdot 10^{-212}:\\
\;\;\;\;w0\\
\mathbf{else}:\\
\;\;\;\;w0 \cdot \sqrt{1 - \frac{h}{\ell} \cdot \left(\frac{D\_m}{d} \cdot \left(\left(M\_m \cdot \left(0.5 \cdot \frac{D\_m}{d}\right)\right) \cdot \left(M\_m \cdot 0.5\right)\right)\right)}\\
\end{array}
\end{array}
if M < 4.3499999999999999e-212Initial program 79.4%
Simplified79.3%
Taylor expanded in M around 0 69.9%
if 4.3499999999999999e-212 < M Initial program 84.6%
Simplified84.7%
unpow284.7%
associate-*r/83.8%
times-frac84.7%
associate-*r*83.9%
*-un-lft-identity83.9%
times-frac83.9%
metadata-eval83.9%
div-inv83.9%
metadata-eval83.9%
Applied egg-rr83.9%
Final simplification76.2%
M_m = (fabs.f64 M) D_m = (fabs.f64 D) NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function. (FPCore (w0 M_m D_m h l d) :precision binary64 w0)
M_m = fabs(M);
D_m = fabs(D);
assert(w0 < M_m && M_m < D_m && D_m < h && h < l && l < d);
double code(double w0, double M_m, double D_m, double h, double l, double d) {
return w0;
}
M_m = abs(m)
D_m = abs(d)
NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
real(8) function code(w0, m_m, d_m, h, l, d)
real(8), intent (in) :: w0
real(8), intent (in) :: m_m
real(8), intent (in) :: d_m
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: d
code = w0
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
assert w0 < M_m && M_m < D_m && D_m < h && h < l && l < d;
public static double code(double w0, double M_m, double D_m, double h, double l, double d) {
return w0;
}
M_m = math.fabs(M) D_m = math.fabs(D) [w0, M_m, D_m, h, l, d] = sort([w0, M_m, D_m, h, l, d]) def code(w0, M_m, D_m, h, l, d): return w0
M_m = abs(M) D_m = abs(D) w0, M_m, D_m, h, l, d = sort([w0, M_m, D_m, h, l, d]) function code(w0, M_m, D_m, h, l, d) return w0 end
M_m = abs(M);
D_m = abs(D);
w0, M_m, D_m, h, l, d = num2cell(sort([w0, M_m, D_m, h, l, d])){:}
function tmp = code(w0, M_m, D_m, h, l, d)
tmp = w0;
end
M_m = N[Abs[M], $MachinePrecision] D_m = N[Abs[D], $MachinePrecision] NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function. code[w0_, M$95$m_, D$95$m_, h_, l_, d_] := w0
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[w0, M_m, D_m, h, l, d] = \mathsf{sort}([w0, M_m, D_m, h, l, d])\\
\\
w0
\end{array}
Initial program 81.7%
Simplified81.7%
Taylor expanded in M around 0 68.1%
herbie shell --seed 2024179
(FPCore (w0 M D h l d)
:name "Henrywood and Agarwal, Equation (9a)"
:precision binary64
(* w0 (sqrt (- 1.0 (* (pow (/ (* M D) (* 2.0 d)) 2.0) (/ h l))))))