
(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)
d_m = (fabs.f64 d)
NOTE: w0, M_m, D_m, h, l, and d_m should be sorted in increasing order before calling this function.
(FPCore (w0 M_m D_m h l d_m)
:precision binary64
(if (<= (/ (* M_m D_m) (* 2.0 d_m)) 1e+132)
(* w0 (sqrt (- 1.0 (* h (/ (pow (* M_m (/ D_m (* 2.0 d_m))) 2.0) l)))))
(pow
(*
(cbrt w0)
(pow
(exp 0.16666666666666666)
(+
(log (* -0.25 (/ (* h (pow (* M_m D_m) 2.0)) l)))
(* -2.0 (log d_m)))))
3.0)))M_m = fabs(M);
D_m = fabs(D);
d_m = fabs(d);
assert(w0 < M_m && M_m < D_m && D_m < h && h < l && l < d_m);
double code(double w0, double M_m, double D_m, double h, double l, double d_m) {
double tmp;
if (((M_m * D_m) / (2.0 * d_m)) <= 1e+132) {
tmp = w0 * sqrt((1.0 - (h * (pow((M_m * (D_m / (2.0 * d_m))), 2.0) / l))));
} else {
tmp = pow((cbrt(w0) * pow(exp(0.16666666666666666), (log((-0.25 * ((h * pow((M_m * D_m), 2.0)) / l))) + (-2.0 * log(d_m))))), 3.0);
}
return tmp;
}
M_m = Math.abs(M);
D_m = Math.abs(D);
d_m = Math.abs(d);
assert w0 < M_m && M_m < D_m && D_m < h && h < l && l < d_m;
public static double code(double w0, double M_m, double D_m, double h, double l, double d_m) {
double tmp;
if (((M_m * D_m) / (2.0 * d_m)) <= 1e+132) {
tmp = w0 * Math.sqrt((1.0 - (h * (Math.pow((M_m * (D_m / (2.0 * d_m))), 2.0) / l))));
} else {
tmp = Math.pow((Math.cbrt(w0) * Math.pow(Math.exp(0.16666666666666666), (Math.log((-0.25 * ((h * Math.pow((M_m * D_m), 2.0)) / l))) + (-2.0 * Math.log(d_m))))), 3.0);
}
return tmp;
}
M_m = abs(M) D_m = abs(D) d_m = abs(d) w0, M_m, D_m, h, l, d_m = sort([w0, M_m, D_m, h, l, d_m]) function code(w0, M_m, D_m, h, l, d_m) tmp = 0.0 if (Float64(Float64(M_m * D_m) / Float64(2.0 * d_m)) <= 1e+132) tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(h * Float64((Float64(M_m * Float64(D_m / Float64(2.0 * d_m))) ^ 2.0) / l))))); else tmp = Float64(cbrt(w0) * (exp(0.16666666666666666) ^ Float64(log(Float64(-0.25 * Float64(Float64(h * (Float64(M_m * D_m) ^ 2.0)) / l))) + Float64(-2.0 * log(d_m))))) ^ 3.0; end return tmp end
M_m = N[Abs[M], $MachinePrecision] D_m = N[Abs[D], $MachinePrecision] d_m = N[Abs[d], $MachinePrecision] NOTE: w0, M_m, D_m, h, l, and d_m should be sorted in increasing order before calling this function. code[w0_, M$95$m_, D$95$m_, h_, l_, d$95$m_] := If[LessEqual[N[(N[(M$95$m * D$95$m), $MachinePrecision] / N[(2.0 * d$95$m), $MachinePrecision]), $MachinePrecision], 1e+132], N[(w0 * N[Sqrt[N[(1.0 - N[(h * N[(N[Power[N[(M$95$m * N[(D$95$m / N[(2.0 * d$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[Power[N[(N[Power[w0, 1/3], $MachinePrecision] * N[Power[N[Exp[0.16666666666666666], $MachinePrecision], N[(N[Log[N[(-0.25 * N[(N[(h * N[Power[N[(M$95$m * D$95$m), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] + N[(-2.0 * N[Log[d$95$m], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 3.0], $MachinePrecision]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
d_m = \left|d\right|
\\
[w0, M_m, D_m, h, l, d_m] = \mathsf{sort}([w0, M_m, D_m, h, l, d_m])\\
\\
\begin{array}{l}
\mathbf{if}\;\frac{M\_m \cdot D\_m}{2 \cdot d\_m} \leq 10^{+132}:\\
\;\;\;\;w0 \cdot \sqrt{1 - h \cdot \frac{{\left(M\_m \cdot \frac{D\_m}{2 \cdot d\_m}\right)}^{2}}{\ell}}\\
\mathbf{else}:\\
\;\;\;\;{\left(\sqrt[3]{w0} \cdot {\left(e^{0.16666666666666666}\right)}^{\left(\log \left(-0.25 \cdot \frac{h \cdot {\left(M\_m \cdot D\_m\right)}^{2}}{\ell}\right) + -2 \cdot \log d\_m\right)}\right)}^{3}\\
\end{array}
\end{array}
if (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) < 9.99999999999999991e131Initial program 82.2%
Simplified81.8%
Applied egg-rr81.8%
unpow181.8%
associate-*l/87.6%
associate-/l*87.2%
associate-*r/87.5%
*-rgt-identity87.5%
times-frac86.7%
/-rgt-identity86.7%
Simplified86.7%
if 9.99999999999999991e131 < (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) Initial program 52.4%
Simplified52.4%
Applied egg-rr52.4%
unpow152.4%
associate-*l/52.5%
associate-/l*52.5%
associate-*r/52.5%
*-rgt-identity52.5%
times-frac52.5%
/-rgt-identity52.5%
Simplified52.5%
add-cube-cbrt52.5%
pow352.5%
associate-*l/52.5%
Applied egg-rr52.5%
add-sqr-sqrt24.3%
pow224.3%
Applied egg-rr24.3%
Taylor expanded in d around 0 16.2%
exp-prod16.2%
distribute-lft-neg-in16.2%
metadata-eval16.2%
associate-*r*16.3%
unpow216.3%
unpow216.3%
swap-sqr20.2%
unpow220.2%
Simplified20.2%
Final simplification80.0%
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
d_m = (fabs.f64 d)
NOTE: w0, M_m, D_m, h, l, and d_m should be sorted in increasing order before calling this function.
(FPCore (w0 M_m D_m h l d_m)
:precision binary64
(if (<= (/ (* M_m D_m) (* 2.0 d_m)) 1e+132)
(* w0 (sqrt (- 1.0 (* h (/ (pow (* M_m (/ D_m (* 2.0 d_m))) 2.0) l)))))
(pow
(*
(cbrt w0)
(pow
(exp 0.16666666666666666)
(+
(* -2.0 (log d_m))
(log (* -0.25 (* (pow (* M_m D_m) 2.0) (/ h l)))))))
3.0)))M_m = fabs(M);
D_m = fabs(D);
d_m = fabs(d);
assert(w0 < M_m && M_m < D_m && D_m < h && h < l && l < d_m);
double code(double w0, double M_m, double D_m, double h, double l, double d_m) {
double tmp;
if (((M_m * D_m) / (2.0 * d_m)) <= 1e+132) {
tmp = w0 * sqrt((1.0 - (h * (pow((M_m * (D_m / (2.0 * d_m))), 2.0) / l))));
} else {
tmp = pow((cbrt(w0) * pow(exp(0.16666666666666666), ((-2.0 * log(d_m)) + log((-0.25 * (pow((M_m * D_m), 2.0) * (h / l))))))), 3.0);
}
return tmp;
}
M_m = Math.abs(M);
D_m = Math.abs(D);
d_m = Math.abs(d);
assert w0 < M_m && M_m < D_m && D_m < h && h < l && l < d_m;
public static double code(double w0, double M_m, double D_m, double h, double l, double d_m) {
double tmp;
if (((M_m * D_m) / (2.0 * d_m)) <= 1e+132) {
tmp = w0 * Math.sqrt((1.0 - (h * (Math.pow((M_m * (D_m / (2.0 * d_m))), 2.0) / l))));
} else {
tmp = Math.pow((Math.cbrt(w0) * Math.pow(Math.exp(0.16666666666666666), ((-2.0 * Math.log(d_m)) + Math.log((-0.25 * (Math.pow((M_m * D_m), 2.0) * (h / l))))))), 3.0);
}
return tmp;
}
M_m = abs(M) D_m = abs(D) d_m = abs(d) w0, M_m, D_m, h, l, d_m = sort([w0, M_m, D_m, h, l, d_m]) function code(w0, M_m, D_m, h, l, d_m) tmp = 0.0 if (Float64(Float64(M_m * D_m) / Float64(2.0 * d_m)) <= 1e+132) tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(h * Float64((Float64(M_m * Float64(D_m / Float64(2.0 * d_m))) ^ 2.0) / l))))); else tmp = Float64(cbrt(w0) * (exp(0.16666666666666666) ^ Float64(Float64(-2.0 * log(d_m)) + log(Float64(-0.25 * Float64((Float64(M_m * D_m) ^ 2.0) * Float64(h / l))))))) ^ 3.0; end return tmp end
M_m = N[Abs[M], $MachinePrecision] D_m = N[Abs[D], $MachinePrecision] d_m = N[Abs[d], $MachinePrecision] NOTE: w0, M_m, D_m, h, l, and d_m should be sorted in increasing order before calling this function. code[w0_, M$95$m_, D$95$m_, h_, l_, d$95$m_] := If[LessEqual[N[(N[(M$95$m * D$95$m), $MachinePrecision] / N[(2.0 * d$95$m), $MachinePrecision]), $MachinePrecision], 1e+132], N[(w0 * N[Sqrt[N[(1.0 - N[(h * N[(N[Power[N[(M$95$m * N[(D$95$m / N[(2.0 * d$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[Power[N[(N[Power[w0, 1/3], $MachinePrecision] * N[Power[N[Exp[0.16666666666666666], $MachinePrecision], N[(N[(-2.0 * N[Log[d$95$m], $MachinePrecision]), $MachinePrecision] + N[Log[N[(-0.25 * N[(N[Power[N[(M$95$m * D$95$m), $MachinePrecision], 2.0], $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 3.0], $MachinePrecision]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
d_m = \left|d\right|
\\
[w0, M_m, D_m, h, l, d_m] = \mathsf{sort}([w0, M_m, D_m, h, l, d_m])\\
\\
\begin{array}{l}
\mathbf{if}\;\frac{M\_m \cdot D\_m}{2 \cdot d\_m} \leq 10^{+132}:\\
\;\;\;\;w0 \cdot \sqrt{1 - h \cdot \frac{{\left(M\_m \cdot \frac{D\_m}{2 \cdot d\_m}\right)}^{2}}{\ell}}\\
\mathbf{else}:\\
\;\;\;\;{\left(\sqrt[3]{w0} \cdot {\left(e^{0.16666666666666666}\right)}^{\left(-2 \cdot \log d\_m + \log \left(-0.25 \cdot \left({\left(M\_m \cdot D\_m\right)}^{2} \cdot \frac{h}{\ell}\right)\right)\right)}\right)}^{3}\\
\end{array}
\end{array}
if (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) < 9.99999999999999991e131Initial program 82.2%
Simplified81.8%
Applied egg-rr81.8%
unpow181.8%
associate-*l/87.6%
associate-/l*87.2%
associate-*r/87.5%
*-rgt-identity87.5%
times-frac86.7%
/-rgt-identity86.7%
Simplified86.7%
if 9.99999999999999991e131 < (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) Initial program 52.4%
Simplified52.4%
Applied egg-rr52.4%
unpow152.4%
associate-*l/52.5%
associate-/l*52.5%
associate-*r/52.5%
*-rgt-identity52.5%
times-frac52.5%
/-rgt-identity52.5%
Simplified52.5%
add-cube-cbrt52.5%
pow352.5%
associate-*l/52.5%
Applied egg-rr52.5%
Taylor expanded in d around 0 16.2%
exp-prod16.2%
distribute-lft-neg-in16.2%
metadata-eval16.2%
associate-*r*16.3%
unpow216.3%
unpow216.3%
swap-sqr20.2%
unpow220.2%
associate-*r/20.2%
*-commutative20.2%
Simplified20.2%
Final simplification80.0%
M_m = (fabs.f64 M) D_m = (fabs.f64 D) d_m = (fabs.f64 d) NOTE: w0, M_m, D_m, h, l, and d_m should be sorted in increasing order before calling this function. (FPCore (w0 M_m D_m h l d_m) :precision binary64 (* w0 (sqrt (- 1.0 (* h (/ (pow (* M_m (/ D_m (* 2.0 d_m))) 2.0) l))))))
M_m = fabs(M);
D_m = fabs(D);
d_m = fabs(d);
assert(w0 < M_m && M_m < D_m && D_m < h && h < l && l < d_m);
double code(double w0, double M_m, double D_m, double h, double l, double d_m) {
return w0 * sqrt((1.0 - (h * (pow((M_m * (D_m / (2.0 * d_m))), 2.0) / l))));
}
M_m = abs(m)
D_m = abs(d)
d_m = abs(d)
NOTE: w0, M_m, D_m, h, l, and d_m should be sorted in increasing order before calling this function.
real(8) function code(w0, m_m, d_m, h, l, d_m_1)
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_m_1
code = w0 * sqrt((1.0d0 - (h * (((m_m * (d_m / (2.0d0 * d_m_1))) ** 2.0d0) / l))))
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
d_m = Math.abs(d);
assert w0 < M_m && M_m < D_m && D_m < h && h < l && l < d_m;
public static double code(double w0, double M_m, double D_m, double h, double l, double d_m) {
return w0 * Math.sqrt((1.0 - (h * (Math.pow((M_m * (D_m / (2.0 * d_m))), 2.0) / l))));
}
M_m = math.fabs(M) D_m = math.fabs(D) d_m = math.fabs(d) [w0, M_m, D_m, h, l, d_m] = sort([w0, M_m, D_m, h, l, d_m]) def code(w0, M_m, D_m, h, l, d_m): return w0 * math.sqrt((1.0 - (h * (math.pow((M_m * (D_m / (2.0 * d_m))), 2.0) / l))))
M_m = abs(M) D_m = abs(D) d_m = abs(d) w0, M_m, D_m, h, l, d_m = sort([w0, M_m, D_m, h, l, d_m]) function code(w0, M_m, D_m, h, l, d_m) return Float64(w0 * sqrt(Float64(1.0 - Float64(h * Float64((Float64(M_m * Float64(D_m / Float64(2.0 * d_m))) ^ 2.0) / l))))) end
M_m = abs(M);
D_m = abs(D);
d_m = abs(d);
w0, M_m, D_m, h, l, d_m = num2cell(sort([w0, M_m, D_m, h, l, d_m])){:}
function tmp = code(w0, M_m, D_m, h, l, d_m)
tmp = w0 * sqrt((1.0 - (h * (((M_m * (D_m / (2.0 * d_m))) ^ 2.0) / l))));
end
M_m = N[Abs[M], $MachinePrecision] D_m = N[Abs[D], $MachinePrecision] d_m = N[Abs[d], $MachinePrecision] NOTE: w0, M_m, D_m, h, l, and d_m should be sorted in increasing order before calling this function. code[w0_, M$95$m_, D$95$m_, h_, l_, d$95$m_] := N[(w0 * N[Sqrt[N[(1.0 - N[(h * N[(N[Power[N[(M$95$m * N[(D$95$m / N[(2.0 * d$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
d_m = \left|d\right|
\\
[w0, M_m, D_m, h, l, d_m] = \mathsf{sort}([w0, M_m, D_m, h, l, d_m])\\
\\
w0 \cdot \sqrt{1 - h \cdot \frac{{\left(M\_m \cdot \frac{D\_m}{2 \cdot d\_m}\right)}^{2}}{\ell}}
\end{array}
Initial program 79.1%
Simplified78.8%
Applied egg-rr78.8%
unpow178.8%
associate-*l/84.0%
associate-/l*83.6%
associate-*r/84.0%
*-rgt-identity84.0%
times-frac83.2%
/-rgt-identity83.2%
Simplified83.2%
Final simplification83.2%
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
d_m = (fabs.f64 d)
NOTE: w0, M_m, D_m, h, l, and d_m should be sorted in increasing order before calling this function.
(FPCore (w0 M_m D_m h l d_m)
:precision binary64
(if (<= M_m 4.2e-55)
w0
(+
w0
(*
-0.125
(* (* (/ D_m d_m) (/ D_m d_m)) (/ (* (pow M_m 2.0) (* w0 h)) l))))))M_m = fabs(M);
D_m = fabs(D);
d_m = fabs(d);
assert(w0 < M_m && M_m < D_m && D_m < h && h < l && l < d_m);
double code(double w0, double M_m, double D_m, double h, double l, double d_m) {
double tmp;
if (M_m <= 4.2e-55) {
tmp = w0;
} else {
tmp = w0 + (-0.125 * (((D_m / d_m) * (D_m / d_m)) * ((pow(M_m, 2.0) * (w0 * h)) / l)));
}
return tmp;
}
M_m = abs(m)
D_m = abs(d)
d_m = abs(d)
NOTE: w0, M_m, D_m, h, l, and d_m should be sorted in increasing order before calling this function.
real(8) function code(w0, m_m, d_m, h, l, d_m_1)
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_m_1
real(8) :: tmp
if (m_m <= 4.2d-55) then
tmp = w0
else
tmp = w0 + ((-0.125d0) * (((d_m / d_m_1) * (d_m / d_m_1)) * (((m_m ** 2.0d0) * (w0 * h)) / l)))
end if
code = tmp
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
d_m = Math.abs(d);
assert w0 < M_m && M_m < D_m && D_m < h && h < l && l < d_m;
public static double code(double w0, double M_m, double D_m, double h, double l, double d_m) {
double tmp;
if (M_m <= 4.2e-55) {
tmp = w0;
} else {
tmp = w0 + (-0.125 * (((D_m / d_m) * (D_m / d_m)) * ((Math.pow(M_m, 2.0) * (w0 * h)) / l)));
}
return tmp;
}
M_m = math.fabs(M) D_m = math.fabs(D) d_m = math.fabs(d) [w0, M_m, D_m, h, l, d_m] = sort([w0, M_m, D_m, h, l, d_m]) def code(w0, M_m, D_m, h, l, d_m): tmp = 0 if M_m <= 4.2e-55: tmp = w0 else: tmp = w0 + (-0.125 * (((D_m / d_m) * (D_m / d_m)) * ((math.pow(M_m, 2.0) * (w0 * h)) / l))) return tmp
M_m = abs(M) D_m = abs(D) d_m = abs(d) w0, M_m, D_m, h, l, d_m = sort([w0, M_m, D_m, h, l, d_m]) function code(w0, M_m, D_m, h, l, d_m) tmp = 0.0 if (M_m <= 4.2e-55) tmp = w0; else tmp = Float64(w0 + Float64(-0.125 * Float64(Float64(Float64(D_m / d_m) * Float64(D_m / d_m)) * Float64(Float64((M_m ^ 2.0) * Float64(w0 * h)) / l)))); end return tmp end
M_m = abs(M);
D_m = abs(D);
d_m = abs(d);
w0, M_m, D_m, h, l, d_m = num2cell(sort([w0, M_m, D_m, h, l, d_m])){:}
function tmp_2 = code(w0, M_m, D_m, h, l, d_m)
tmp = 0.0;
if (M_m <= 4.2e-55)
tmp = w0;
else
tmp = w0 + (-0.125 * (((D_m / d_m) * (D_m / d_m)) * (((M_m ^ 2.0) * (w0 * h)) / l)));
end
tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision] D_m = N[Abs[D], $MachinePrecision] d_m = N[Abs[d], $MachinePrecision] NOTE: w0, M_m, D_m, h, l, and d_m should be sorted in increasing order before calling this function. code[w0_, M$95$m_, D$95$m_, h_, l_, d$95$m_] := If[LessEqual[M$95$m, 4.2e-55], w0, N[(w0 + N[(-0.125 * N[(N[(N[(D$95$m / d$95$m), $MachinePrecision] * N[(D$95$m / d$95$m), $MachinePrecision]), $MachinePrecision] * N[(N[(N[Power[M$95$m, 2.0], $MachinePrecision] * N[(w0 * h), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
d_m = \left|d\right|
\\
[w0, M_m, D_m, h, l, d_m] = \mathsf{sort}([w0, M_m, D_m, h, l, d_m])\\
\\
\begin{array}{l}
\mathbf{if}\;M\_m \leq 4.2 \cdot 10^{-55}:\\
\;\;\;\;w0\\
\mathbf{else}:\\
\;\;\;\;w0 + -0.125 \cdot \left(\left(\frac{D\_m}{d\_m} \cdot \frac{D\_m}{d\_m}\right) \cdot \frac{{M\_m}^{2} \cdot \left(w0 \cdot h\right)}{\ell}\right)\\
\end{array}
\end{array}
if M < 4.2000000000000003e-55Initial program 83.0%
Simplified82.5%
Taylor expanded in D around 0 74.5%
if 4.2000000000000003e-55 < M Initial program 68.2%
Simplified68.2%
Taylor expanded in D around 0 40.9%
times-frac44.4%
add-sqr-sqrt44.4%
pow244.4%
sqrt-div44.4%
sqrt-pow150.5%
metadata-eval50.5%
pow150.5%
sqrt-pow150.6%
metadata-eval50.6%
pow150.6%
*-commutative50.6%
Applied egg-rr50.6%
unpow250.6%
Applied egg-rr50.6%
M_m = (fabs.f64 M) D_m = (fabs.f64 D) d_m = (fabs.f64 d) NOTE: w0, M_m, D_m, h, l, and d_m should be sorted in increasing order before calling this function. (FPCore (w0 M_m D_m h l d_m) :precision binary64 w0)
M_m = fabs(M);
D_m = fabs(D);
d_m = fabs(d);
assert(w0 < M_m && M_m < D_m && D_m < h && h < l && l < d_m);
double code(double w0, double M_m, double D_m, double h, double l, double d_m) {
return w0;
}
M_m = abs(m)
D_m = abs(d)
d_m = abs(d)
NOTE: w0, M_m, D_m, h, l, and d_m should be sorted in increasing order before calling this function.
real(8) function code(w0, m_m, d_m, h, l, d_m_1)
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_m_1
code = w0
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
d_m = Math.abs(d);
assert w0 < M_m && M_m < D_m && D_m < h && h < l && l < d_m;
public static double code(double w0, double M_m, double D_m, double h, double l, double d_m) {
return w0;
}
M_m = math.fabs(M) D_m = math.fabs(D) d_m = math.fabs(d) [w0, M_m, D_m, h, l, d_m] = sort([w0, M_m, D_m, h, l, d_m]) def code(w0, M_m, D_m, h, l, d_m): return w0
M_m = abs(M) D_m = abs(D) d_m = abs(d) w0, M_m, D_m, h, l, d_m = sort([w0, M_m, D_m, h, l, d_m]) function code(w0, M_m, D_m, h, l, d_m) return w0 end
M_m = abs(M);
D_m = abs(D);
d_m = abs(d);
w0, M_m, D_m, h, l, d_m = num2cell(sort([w0, M_m, D_m, h, l, d_m])){:}
function tmp = code(w0, M_m, D_m, h, l, d_m)
tmp = w0;
end
M_m = N[Abs[M], $MachinePrecision] D_m = N[Abs[D], $MachinePrecision] d_m = N[Abs[d], $MachinePrecision] NOTE: w0, M_m, D_m, h, l, and d_m should be sorted in increasing order before calling this function. code[w0_, M$95$m_, D$95$m_, h_, l_, d$95$m_] := w0
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
d_m = \left|d\right|
\\
[w0, M_m, D_m, h, l, d_m] = \mathsf{sort}([w0, M_m, D_m, h, l, d_m])\\
\\
w0
\end{array}
Initial program 79.1%
Simplified78.8%
Taylor expanded in D around 0 68.1%
herbie shell --seed 2024137
(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))))))