
(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 10 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
(if (<= (* M_m D_m) 1e-57)
(* w0 (sqrt (- 1.0 (/ (* (pow (* 0.5 (/ (* M_m D_m) d)) 2.0) h) l))))
(if (<= (* M_m D_m) 5e+150)
(*
w0
(sqrt
(+
1.0
(* -0.25 (* (pow (* M_m D_m) 2.0) (* (/ h d) (/ (/ 1.0 d) l)))))))
(*
w0
(sqrt
(- 1.0 (* 0.25 (/ (* (* h (pow M_m 2.0)) (pow (/ D_m d) 2.0)) 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 ((M_m * D_m) <= 1e-57) {
tmp = w0 * sqrt((1.0 - ((pow((0.5 * ((M_m * D_m) / d)), 2.0) * h) / l)));
} else if ((M_m * D_m) <= 5e+150) {
tmp = w0 * sqrt((1.0 + (-0.25 * (pow((M_m * D_m), 2.0) * ((h / d) * ((1.0 / d) / l))))));
} else {
tmp = w0 * sqrt((1.0 - (0.25 * (((h * pow(M_m, 2.0)) * pow((D_m / d), 2.0)) / 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 ((m_m * d_m) <= 1d-57) then
tmp = w0 * sqrt((1.0d0 - ((((0.5d0 * ((m_m * d_m) / d)) ** 2.0d0) * h) / l)))
else if ((m_m * d_m) <= 5d+150) then
tmp = w0 * sqrt((1.0d0 + ((-0.25d0) * (((m_m * d_m) ** 2.0d0) * ((h / d) * ((1.0d0 / d) / l))))))
else
tmp = w0 * sqrt((1.0d0 - (0.25d0 * (((h * (m_m ** 2.0d0)) * ((d_m / d) ** 2.0d0)) / 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 ((M_m * D_m) <= 1e-57) {
tmp = w0 * Math.sqrt((1.0 - ((Math.pow((0.5 * ((M_m * D_m) / d)), 2.0) * h) / l)));
} else if ((M_m * D_m) <= 5e+150) {
tmp = w0 * Math.sqrt((1.0 + (-0.25 * (Math.pow((M_m * D_m), 2.0) * ((h / d) * ((1.0 / d) / l))))));
} else {
tmp = w0 * Math.sqrt((1.0 - (0.25 * (((h * Math.pow(M_m, 2.0)) * Math.pow((D_m / d), 2.0)) / 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 (M_m * D_m) <= 1e-57: tmp = w0 * math.sqrt((1.0 - ((math.pow((0.5 * ((M_m * D_m) / d)), 2.0) * h) / l))) elif (M_m * D_m) <= 5e+150: tmp = w0 * math.sqrt((1.0 + (-0.25 * (math.pow((M_m * D_m), 2.0) * ((h / d) * ((1.0 / d) / l)))))) else: tmp = w0 * math.sqrt((1.0 - (0.25 * (((h * math.pow(M_m, 2.0)) * math.pow((D_m / d), 2.0)) / 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 (Float64(M_m * D_m) <= 1e-57) tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(Float64((Float64(0.5 * Float64(Float64(M_m * D_m) / d)) ^ 2.0) * h) / l)))); elseif (Float64(M_m * D_m) <= 5e+150) tmp = Float64(w0 * sqrt(Float64(1.0 + Float64(-0.25 * Float64((Float64(M_m * D_m) ^ 2.0) * Float64(Float64(h / d) * Float64(Float64(1.0 / d) / l))))))); else tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(0.25 * Float64(Float64(Float64(h * (M_m ^ 2.0)) * (Float64(D_m / d) ^ 2.0)) / 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 ((M_m * D_m) <= 1e-57)
tmp = w0 * sqrt((1.0 - ((((0.5 * ((M_m * D_m) / d)) ^ 2.0) * h) / l)));
elseif ((M_m * D_m) <= 5e+150)
tmp = w0 * sqrt((1.0 + (-0.25 * (((M_m * D_m) ^ 2.0) * ((h / d) * ((1.0 / d) / l))))));
else
tmp = w0 * sqrt((1.0 - (0.25 * (((h * (M_m ^ 2.0)) * ((D_m / d) ^ 2.0)) / 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[N[(M$95$m * D$95$m), $MachinePrecision], 1e-57], N[(w0 * N[Sqrt[N[(1.0 - N[(N[(N[Power[N[(0.5 * N[(N[(M$95$m * D$95$m), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * h), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(M$95$m * D$95$m), $MachinePrecision], 5e+150], N[(w0 * N[Sqrt[N[(1.0 + N[(-0.25 * N[(N[Power[N[(M$95$m * D$95$m), $MachinePrecision], 2.0], $MachinePrecision] * N[(N[(h / d), $MachinePrecision] * N[(N[(1.0 / d), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(w0 * N[Sqrt[N[(1.0 - N[(0.25 * N[(N[(N[(h * N[Power[M$95$m, 2.0], $MachinePrecision]), $MachinePrecision] * N[Power[N[(D$95$m / d), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / 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}\;M\_m \cdot D\_m \leq 10^{-57}:\\
\;\;\;\;w0 \cdot \sqrt{1 - \frac{{\left(0.5 \cdot \frac{M\_m \cdot D\_m}{d}\right)}^{2} \cdot h}{\ell}}\\
\mathbf{elif}\;M\_m \cdot D\_m \leq 5 \cdot 10^{+150}:\\
\;\;\;\;w0 \cdot \sqrt{1 + -0.25 \cdot \left({\left(M\_m \cdot D\_m\right)}^{2} \cdot \left(\frac{h}{d} \cdot \frac{\frac{1}{d}}{\ell}\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;w0 \cdot \sqrt{1 - 0.25 \cdot \frac{\left(h \cdot {M\_m}^{2}\right) \cdot {\left(\frac{D\_m}{d}\right)}^{2}}{\ell}}\\
\end{array}
\end{array}
if (*.f64 M D) < 9.99999999999999955e-58Initial program 79.4%
Simplified79.4%
associate-*r/88.1%
add-sqr-sqrt88.1%
pow288.1%
unpow288.1%
sqrt-prod59.2%
add-sqr-sqrt88.1%
*-un-lft-identity88.1%
times-frac88.1%
metadata-eval88.1%
Applied egg-rr88.1%
Taylor expanded in M around 0 88.6%
if 9.99999999999999955e-58 < (*.f64 M D) < 5.00000000000000009e150Initial program 71.3%
Simplified71.3%
Taylor expanded in M around 0 36.2%
*-un-lft-identity36.2%
add-sqr-sqrt14.8%
times-frac14.8%
sqrt-prod14.8%
unpow214.8%
sqrt-prod5.9%
add-sqr-sqrt8.8%
associate-*r*11.8%
pow-prod-down29.6%
sqrt-prod29.6%
unpow229.6%
sqrt-prod17.9%
add-sqr-sqrt41.7%
Applied egg-rr41.7%
associate-*l/41.7%
*-lft-identity41.7%
associate-/l*50.1%
associate-*l/47.2%
associate-/r*47.2%
Simplified47.2%
*-un-lft-identity47.2%
cancel-sign-sub-inv47.2%
metadata-eval47.2%
frac-times47.2%
Applied egg-rr47.2%
*-lft-identity47.2%
associate-/r*47.2%
associate-*l/47.2%
associate-*l/47.2%
associate-/r*47.2%
associate-/l*50.1%
associate-*l*50.1%
Simplified50.1%
add-sqr-sqrt91.5%
div-inv91.6%
times-frac91.6%
Applied egg-rr91.6%
if 5.00000000000000009e150 < (*.f64 M D) Initial program 61.3%
Simplified61.3%
Taylor expanded in M around 0 42.4%
times-frac42.3%
unpow242.3%
unpow242.3%
frac-times50.1%
pow250.1%
*-commutative50.1%
Applied egg-rr50.1%
*-commutative50.1%
associate-*l/50.1%
*-commutative50.1%
Simplified50.1%
Final simplification85.0%
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 (<= (pow (/ (* M_m D_m) (* 2.0 d)) 2.0) 2e+298)
(* w0 (sqrt (- 1.0 (/ (* (pow (* 0.5 (/ (* M_m D_m) d)) 2.0) h) l))))
(*
w0
(pow
(pow
(exp 0.25)
(-
(log (* -0.25 (* (pow M_m 2.0) (/ h (* l (pow d 2.0))))))
(* -2.0 (log D_m))))
2.0))))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 (pow(((M_m * D_m) / (2.0 * d)), 2.0) <= 2e+298) {
tmp = w0 * sqrt((1.0 - ((pow((0.5 * ((M_m * D_m) / d)), 2.0) * h) / l)));
} else {
tmp = w0 * pow(pow(exp(0.25), (log((-0.25 * (pow(M_m, 2.0) * (h / (l * pow(d, 2.0)))))) - (-2.0 * log(D_m)))), 2.0);
}
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 * d_m) / (2.0d0 * d)) ** 2.0d0) <= 2d+298) then
tmp = w0 * sqrt((1.0d0 - ((((0.5d0 * ((m_m * d_m) / d)) ** 2.0d0) * h) / l)))
else
tmp = w0 * ((exp(0.25d0) ** (log(((-0.25d0) * ((m_m ** 2.0d0) * (h / (l * (d ** 2.0d0)))))) - ((-2.0d0) * log(d_m)))) ** 2.0d0)
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 (Math.pow(((M_m * D_m) / (2.0 * d)), 2.0) <= 2e+298) {
tmp = w0 * Math.sqrt((1.0 - ((Math.pow((0.5 * ((M_m * D_m) / d)), 2.0) * h) / l)));
} else {
tmp = w0 * Math.pow(Math.pow(Math.exp(0.25), (Math.log((-0.25 * (Math.pow(M_m, 2.0) * (h / (l * Math.pow(d, 2.0)))))) - (-2.0 * Math.log(D_m)))), 2.0);
}
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 math.pow(((M_m * D_m) / (2.0 * d)), 2.0) <= 2e+298: tmp = w0 * math.sqrt((1.0 - ((math.pow((0.5 * ((M_m * D_m) / d)), 2.0) * h) / l))) else: tmp = w0 * math.pow(math.pow(math.exp(0.25), (math.log((-0.25 * (math.pow(M_m, 2.0) * (h / (l * math.pow(d, 2.0)))))) - (-2.0 * math.log(D_m)))), 2.0) 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(Float64(M_m * D_m) / Float64(2.0 * d)) ^ 2.0) <= 2e+298) tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(Float64((Float64(0.5 * Float64(Float64(M_m * D_m) / d)) ^ 2.0) * h) / l)))); else tmp = Float64(w0 * ((exp(0.25) ^ Float64(log(Float64(-0.25 * Float64((M_m ^ 2.0) * Float64(h / Float64(l * (d ^ 2.0)))))) - Float64(-2.0 * log(D_m)))) ^ 2.0)); 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 * D_m) / (2.0 * d)) ^ 2.0) <= 2e+298)
tmp = w0 * sqrt((1.0 - ((((0.5 * ((M_m * D_m) / d)) ^ 2.0) * h) / l)));
else
tmp = w0 * ((exp(0.25) ^ (log((-0.25 * ((M_m ^ 2.0) * (h / (l * (d ^ 2.0)))))) - (-2.0 * log(D_m)))) ^ 2.0);
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[Power[N[(N[(M$95$m * D$95$m), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision], 2e+298], N[(w0 * N[Sqrt[N[(1.0 - N[(N[(N[Power[N[(0.5 * N[(N[(M$95$m * D$95$m), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * h), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(w0 * N[Power[N[Power[N[Exp[0.25], $MachinePrecision], N[(N[Log[N[(-0.25 * N[(N[Power[M$95$m, 2.0], $MachinePrecision] * N[(h / N[(l * N[Power[d, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - N[(-2.0 * N[Log[D$95$m], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $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}\;{\left(\frac{M\_m \cdot D\_m}{2 \cdot d}\right)}^{2} \leq 2 \cdot 10^{+298}:\\
\;\;\;\;w0 \cdot \sqrt{1 - \frac{{\left(0.5 \cdot \frac{M\_m \cdot D\_m}{d}\right)}^{2} \cdot h}{\ell}}\\
\mathbf{else}:\\
\;\;\;\;w0 \cdot {\left({\left(e^{0.25}\right)}^{\left(\log \left(-0.25 \cdot \left({M\_m}^{2} \cdot \frac{h}{\ell \cdot {d}^{2}}\right)\right) - -2 \cdot \log D\_m\right)}\right)}^{2}\\
\end{array}
\end{array}
if (pow.f64 (/.f64 (*.f64 M D) (*.f64 2 d)) 2) < 1.9999999999999999e298Initial program 87.4%
Simplified86.9%
associate-*r/95.9%
add-sqr-sqrt95.9%
pow295.9%
unpow295.9%
sqrt-prod62.7%
add-sqr-sqrt95.9%
*-un-lft-identity95.9%
times-frac95.9%
metadata-eval95.9%
Applied egg-rr95.9%
Taylor expanded in M around 0 96.9%
if 1.9999999999999999e298 < (pow.f64 (/.f64 (*.f64 M D) (*.f64 2 d)) 2) Initial program 44.8%
Simplified46.2%
add-sqr-sqrt46.2%
pow246.2%
Applied egg-rr46.2%
Taylor expanded in D around inf 23.3%
exp-prod23.2%
distribute-lft-neg-in23.2%
metadata-eval23.2%
associate-/l*23.0%
log-rec23.0%
Simplified23.0%
Final simplification77.8%
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 (<= (- 1.0 (* (pow (/ (* M_m D_m) (* 2.0 d)) 2.0) (/ h l))) INFINITY) (* w0 (sqrt (- 1.0 (* (/ h l) (pow (/ M_m (* 2.0 (/ d D_m))) 2.0))))) 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 ((1.0 - (pow(((M_m * D_m) / (2.0 * d)), 2.0) * (h / l))) <= ((double) INFINITY)) {
tmp = w0 * sqrt((1.0 - ((h / l) * pow((M_m / (2.0 * (d / D_m))), 2.0))));
} else {
tmp = w0;
}
return tmp;
}
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 ((1.0 - (Math.pow(((M_m * D_m) / (2.0 * d)), 2.0) * (h / l))) <= Double.POSITIVE_INFINITY) {
tmp = w0 * Math.sqrt((1.0 - ((h / l) * Math.pow((M_m / (2.0 * (d / D_m))), 2.0))));
} 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 (1.0 - (math.pow(((M_m * D_m) / (2.0 * d)), 2.0) * (h / l))) <= math.inf: tmp = w0 * math.sqrt((1.0 - ((h / l) * math.pow((M_m / (2.0 * (d / D_m))), 2.0)))) 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(1.0 - Float64((Float64(Float64(M_m * D_m) / Float64(2.0 * d)) ^ 2.0) * Float64(h / l))) <= Inf) tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(h / l) * (Float64(M_m / Float64(2.0 * Float64(d / D_m))) ^ 2.0))))); 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 ((1.0 - ((((M_m * D_m) / (2.0 * d)) ^ 2.0) * (h / l))) <= Inf)
tmp = w0 * sqrt((1.0 - ((h / l) * ((M_m / (2.0 * (d / D_m))) ^ 2.0))));
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[(1.0 - N[(N[Power[N[(N[(M$95$m * D$95$m), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], Infinity], N[(w0 * N[Sqrt[N[(1.0 - N[(N[(h / l), $MachinePrecision] * N[Power[N[(M$95$m / N[(2.0 * N[(d / D$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $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}\;1 - {\left(\frac{M\_m \cdot D\_m}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell} \leq \infty:\\
\;\;\;\;w0 \cdot \sqrt{1 - \frac{h}{\ell} \cdot {\left(\frac{M\_m}{2 \cdot \frac{d}{D\_m}}\right)}^{2}}\\
\mathbf{else}:\\
\;\;\;\;w0\\
\end{array}
\end{array}
if (-.f64 1 (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 2 d)) 2) (/.f64 h l))) < +inf.0Initial program 84.0%
Simplified84.0%
clear-num84.0%
un-div-inv84.4%
associate-/l*84.4%
Applied egg-rr84.4%
if +inf.0 < (-.f64 1 (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 2 d)) 2) (/.f64 h l))) Initial program 0.0%
Simplified0.0%
Taylor expanded in M around 0 67.4%
Final simplification82.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 (<= (pow (/ (* M_m D_m) (* 2.0 d)) 2.0) 5e+230)
(* w0 (sqrt (- 1.0 (/ (* (pow (* 0.5 (/ (* M_m D_m) d)) 2.0) h) l))))
(*
w0
(sqrt (+ 1.0 (* -0.25 (* (pow (* M_m D_m) 2.0) (/ (/ h d) (* d 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 (pow(((M_m * D_m) / (2.0 * d)), 2.0) <= 5e+230) {
tmp = w0 * sqrt((1.0 - ((pow((0.5 * ((M_m * D_m) / d)), 2.0) * h) / l)));
} else {
tmp = w0 * sqrt((1.0 + (-0.25 * (pow((M_m * D_m), 2.0) * ((h / d) / (d * 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 ((((m_m * d_m) / (2.0d0 * d)) ** 2.0d0) <= 5d+230) then
tmp = w0 * sqrt((1.0d0 - ((((0.5d0 * ((m_m * d_m) / d)) ** 2.0d0) * h) / l)))
else
tmp = w0 * sqrt((1.0d0 + ((-0.25d0) * (((m_m * d_m) ** 2.0d0) * ((h / d) / (d * 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 (Math.pow(((M_m * D_m) / (2.0 * d)), 2.0) <= 5e+230) {
tmp = w0 * Math.sqrt((1.0 - ((Math.pow((0.5 * ((M_m * D_m) / d)), 2.0) * h) / l)));
} else {
tmp = w0 * Math.sqrt((1.0 + (-0.25 * (Math.pow((M_m * D_m), 2.0) * ((h / d) / (d * 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 math.pow(((M_m * D_m) / (2.0 * d)), 2.0) <= 5e+230: tmp = w0 * math.sqrt((1.0 - ((math.pow((0.5 * ((M_m * D_m) / d)), 2.0) * h) / l))) else: tmp = w0 * math.sqrt((1.0 + (-0.25 * (math.pow((M_m * D_m), 2.0) * ((h / d) / (d * 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 ((Float64(Float64(M_m * D_m) / Float64(2.0 * d)) ^ 2.0) <= 5e+230) tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(Float64((Float64(0.5 * Float64(Float64(M_m * D_m) / d)) ^ 2.0) * h) / l)))); else tmp = Float64(w0 * sqrt(Float64(1.0 + Float64(-0.25 * Float64((Float64(M_m * D_m) ^ 2.0) * Float64(Float64(h / d) / Float64(d * 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 ((((M_m * D_m) / (2.0 * d)) ^ 2.0) <= 5e+230)
tmp = w0 * sqrt((1.0 - ((((0.5 * ((M_m * D_m) / d)) ^ 2.0) * h) / l)));
else
tmp = w0 * sqrt((1.0 + (-0.25 * (((M_m * D_m) ^ 2.0) * ((h / d) / (d * 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[N[Power[N[(N[(M$95$m * D$95$m), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision], 5e+230], N[(w0 * N[Sqrt[N[(1.0 - N[(N[(N[Power[N[(0.5 * N[(N[(M$95$m * D$95$m), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * h), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(w0 * N[Sqrt[N[(1.0 + N[(-0.25 * N[(N[Power[N[(M$95$m * D$95$m), $MachinePrecision], 2.0], $MachinePrecision] * N[(N[(h / d), $MachinePrecision] / N[(d * l), $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}\;{\left(\frac{M\_m \cdot D\_m}{2 \cdot d}\right)}^{2} \leq 5 \cdot 10^{+230}:\\
\;\;\;\;w0 \cdot \sqrt{1 - \frac{{\left(0.5 \cdot \frac{M\_m \cdot D\_m}{d}\right)}^{2} \cdot h}{\ell}}\\
\mathbf{else}:\\
\;\;\;\;w0 \cdot \sqrt{1 + -0.25 \cdot \left({\left(M\_m \cdot D\_m\right)}^{2} \cdot \frac{\frac{h}{d}}{d \cdot \ell}\right)}\\
\end{array}
\end{array}
if (pow.f64 (/.f64 (*.f64 M D) (*.f64 2 d)) 2) < 5.0000000000000003e230Initial program 87.6%
Simplified87.1%
associate-*r/96.3%
add-sqr-sqrt96.3%
pow296.3%
unpow296.3%
sqrt-prod62.8%
add-sqr-sqrt96.3%
*-un-lft-identity96.3%
times-frac96.3%
metadata-eval96.3%
Applied egg-rr96.3%
Taylor expanded in M around 0 97.3%
if 5.0000000000000003e230 < (pow.f64 (/.f64 (*.f64 M D) (*.f64 2 d)) 2) Initial program 47.3%
Simplified48.6%
Taylor expanded in M around 0 44.1%
*-un-lft-identity44.1%
add-sqr-sqrt17.6%
times-frac17.6%
sqrt-prod17.6%
unpow217.6%
sqrt-prod3.3%
add-sqr-sqrt3.3%
associate-*r*3.3%
pow-prod-down3.4%
sqrt-prod3.4%
unpow23.4%
sqrt-prod3.4%
add-sqr-sqrt26.1%
Applied egg-rr26.1%
associate-*l/26.1%
*-lft-identity26.1%
associate-/l*27.4%
associate-*l/26.1%
associate-/r*26.1%
Simplified26.1%
*-un-lft-identity26.1%
cancel-sign-sub-inv26.1%
metadata-eval26.1%
frac-times24.7%
Applied egg-rr24.7%
*-lft-identity24.7%
associate-/r*24.8%
associate-*l/24.8%
associate-*l/24.8%
associate-/r*24.7%
associate-/l*27.4%
associate-*l*27.4%
Simplified27.4%
Taylor expanded in l around 0 58.0%
Final simplification86.4%
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 D_m) 1e-57)
(* w0 (sqrt (- 1.0 (/ (* (pow (* 0.5 (/ (* M_m D_m) d)) 2.0) h) l))))
(if (<= (* M_m D_m) 5e+150)
(*
w0
(sqrt
(+
1.0
(* -0.25 (* (pow (* M_m D_m) 2.0) (* (/ h d) (/ (/ 1.0 d) l)))))))
(*
w0
(sqrt
(-
1.0
(* 0.25 (/ (* (* h (pow M_m 2.0)) (/ D_m (* d (/ d D_m)))) 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 ((M_m * D_m) <= 1e-57) {
tmp = w0 * sqrt((1.0 - ((pow((0.5 * ((M_m * D_m) / d)), 2.0) * h) / l)));
} else if ((M_m * D_m) <= 5e+150) {
tmp = w0 * sqrt((1.0 + (-0.25 * (pow((M_m * D_m), 2.0) * ((h / d) * ((1.0 / d) / l))))));
} else {
tmp = w0 * sqrt((1.0 - (0.25 * (((h * pow(M_m, 2.0)) * (D_m / (d * (d / D_m)))) / 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 ((m_m * d_m) <= 1d-57) then
tmp = w0 * sqrt((1.0d0 - ((((0.5d0 * ((m_m * d_m) / d)) ** 2.0d0) * h) / l)))
else if ((m_m * d_m) <= 5d+150) then
tmp = w0 * sqrt((1.0d0 + ((-0.25d0) * (((m_m * d_m) ** 2.0d0) * ((h / d) * ((1.0d0 / d) / l))))))
else
tmp = w0 * sqrt((1.0d0 - (0.25d0 * (((h * (m_m ** 2.0d0)) * (d_m / (d * (d / d_m)))) / 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 ((M_m * D_m) <= 1e-57) {
tmp = w0 * Math.sqrt((1.0 - ((Math.pow((0.5 * ((M_m * D_m) / d)), 2.0) * h) / l)));
} else if ((M_m * D_m) <= 5e+150) {
tmp = w0 * Math.sqrt((1.0 + (-0.25 * (Math.pow((M_m * D_m), 2.0) * ((h / d) * ((1.0 / d) / l))))));
} else {
tmp = w0 * Math.sqrt((1.0 - (0.25 * (((h * Math.pow(M_m, 2.0)) * (D_m / (d * (d / D_m)))) / 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 (M_m * D_m) <= 1e-57: tmp = w0 * math.sqrt((1.0 - ((math.pow((0.5 * ((M_m * D_m) / d)), 2.0) * h) / l))) elif (M_m * D_m) <= 5e+150: tmp = w0 * math.sqrt((1.0 + (-0.25 * (math.pow((M_m * D_m), 2.0) * ((h / d) * ((1.0 / d) / l)))))) else: tmp = w0 * math.sqrt((1.0 - (0.25 * (((h * math.pow(M_m, 2.0)) * (D_m / (d * (d / D_m)))) / 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 (Float64(M_m * D_m) <= 1e-57) tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(Float64((Float64(0.5 * Float64(Float64(M_m * D_m) / d)) ^ 2.0) * h) / l)))); elseif (Float64(M_m * D_m) <= 5e+150) tmp = Float64(w0 * sqrt(Float64(1.0 + Float64(-0.25 * Float64((Float64(M_m * D_m) ^ 2.0) * Float64(Float64(h / d) * Float64(Float64(1.0 / d) / l))))))); else tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(0.25 * Float64(Float64(Float64(h * (M_m ^ 2.0)) * Float64(D_m / Float64(d * Float64(d / D_m)))) / 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 ((M_m * D_m) <= 1e-57)
tmp = w0 * sqrt((1.0 - ((((0.5 * ((M_m * D_m) / d)) ^ 2.0) * h) / l)));
elseif ((M_m * D_m) <= 5e+150)
tmp = w0 * sqrt((1.0 + (-0.25 * (((M_m * D_m) ^ 2.0) * ((h / d) * ((1.0 / d) / l))))));
else
tmp = w0 * sqrt((1.0 - (0.25 * (((h * (M_m ^ 2.0)) * (D_m / (d * (d / D_m)))) / 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[N[(M$95$m * D$95$m), $MachinePrecision], 1e-57], N[(w0 * N[Sqrt[N[(1.0 - N[(N[(N[Power[N[(0.5 * N[(N[(M$95$m * D$95$m), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * h), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(M$95$m * D$95$m), $MachinePrecision], 5e+150], N[(w0 * N[Sqrt[N[(1.0 + N[(-0.25 * N[(N[Power[N[(M$95$m * D$95$m), $MachinePrecision], 2.0], $MachinePrecision] * N[(N[(h / d), $MachinePrecision] * N[(N[(1.0 / d), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(w0 * N[Sqrt[N[(1.0 - N[(0.25 * N[(N[(N[(h * N[Power[M$95$m, 2.0], $MachinePrecision]), $MachinePrecision] * N[(D$95$m / N[(d * N[(d / D$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 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}\;M\_m \cdot D\_m \leq 10^{-57}:\\
\;\;\;\;w0 \cdot \sqrt{1 - \frac{{\left(0.5 \cdot \frac{M\_m \cdot D\_m}{d}\right)}^{2} \cdot h}{\ell}}\\
\mathbf{elif}\;M\_m \cdot D\_m \leq 5 \cdot 10^{+150}:\\
\;\;\;\;w0 \cdot \sqrt{1 + -0.25 \cdot \left({\left(M\_m \cdot D\_m\right)}^{2} \cdot \left(\frac{h}{d} \cdot \frac{\frac{1}{d}}{\ell}\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;w0 \cdot \sqrt{1 - 0.25 \cdot \frac{\left(h \cdot {M\_m}^{2}\right) \cdot \frac{D\_m}{d \cdot \frac{d}{D\_m}}}{\ell}}\\
\end{array}
\end{array}
if (*.f64 M D) < 9.99999999999999955e-58Initial program 79.4%
Simplified79.4%
associate-*r/88.1%
add-sqr-sqrt88.1%
pow288.1%
unpow288.1%
sqrt-prod59.2%
add-sqr-sqrt88.1%
*-un-lft-identity88.1%
times-frac88.1%
metadata-eval88.1%
Applied egg-rr88.1%
Taylor expanded in M around 0 88.6%
if 9.99999999999999955e-58 < (*.f64 M D) < 5.00000000000000009e150Initial program 71.3%
Simplified71.3%
Taylor expanded in M around 0 36.2%
*-un-lft-identity36.2%
add-sqr-sqrt14.8%
times-frac14.8%
sqrt-prod14.8%
unpow214.8%
sqrt-prod5.9%
add-sqr-sqrt8.8%
associate-*r*11.8%
pow-prod-down29.6%
sqrt-prod29.6%
unpow229.6%
sqrt-prod17.9%
add-sqr-sqrt41.7%
Applied egg-rr41.7%
associate-*l/41.7%
*-lft-identity41.7%
associate-/l*50.1%
associate-*l/47.2%
associate-/r*47.2%
Simplified47.2%
*-un-lft-identity47.2%
cancel-sign-sub-inv47.2%
metadata-eval47.2%
frac-times47.2%
Applied egg-rr47.2%
*-lft-identity47.2%
associate-/r*47.2%
associate-*l/47.2%
associate-*l/47.2%
associate-/r*47.2%
associate-/l*50.1%
associate-*l*50.1%
Simplified50.1%
add-sqr-sqrt91.5%
div-inv91.6%
times-frac91.6%
Applied egg-rr91.6%
if 5.00000000000000009e150 < (*.f64 M D) Initial program 61.3%
Simplified61.3%
Taylor expanded in M around 0 42.4%
times-frac42.3%
unpow242.3%
unpow242.3%
frac-times50.1%
pow250.1%
*-commutative50.1%
Applied egg-rr50.1%
*-commutative50.1%
associate-*l/50.1%
*-commutative50.1%
Simplified50.1%
unpow250.1%
clear-num50.1%
frac-times49.8%
*-un-lft-identity49.8%
Applied egg-rr49.8%
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 (<= (/ (* M_m D_m) (* 2.0 d)) 2e+115)
(* w0 (sqrt (- 1.0 (/ (* (pow (* 0.5 (/ (* M_m D_m) d)) 2.0) h) l))))
(*
w0
(sqrt (+ 1.0 (* -0.25 (/ (* (pow (* M_m D_m) 2.0) (/ h d)) (* d 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 (((M_m * D_m) / (2.0 * d)) <= 2e+115) {
tmp = w0 * sqrt((1.0 - ((pow((0.5 * ((M_m * D_m) / d)), 2.0) * h) / l)));
} else {
tmp = w0 * sqrt((1.0 + (-0.25 * ((pow((M_m * D_m), 2.0) * (h / d)) / (d * 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 (((m_m * d_m) / (2.0d0 * d)) <= 2d+115) then
tmp = w0 * sqrt((1.0d0 - ((((0.5d0 * ((m_m * d_m) / d)) ** 2.0d0) * h) / l)))
else
tmp = w0 * sqrt((1.0d0 + ((-0.25d0) * ((((m_m * d_m) ** 2.0d0) * (h / d)) / (d * 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 (((M_m * D_m) / (2.0 * d)) <= 2e+115) {
tmp = w0 * Math.sqrt((1.0 - ((Math.pow((0.5 * ((M_m * D_m) / d)), 2.0) * h) / l)));
} else {
tmp = w0 * Math.sqrt((1.0 + (-0.25 * ((Math.pow((M_m * D_m), 2.0) * (h / d)) / (d * 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 ((M_m * D_m) / (2.0 * d)) <= 2e+115: tmp = w0 * math.sqrt((1.0 - ((math.pow((0.5 * ((M_m * D_m) / d)), 2.0) * h) / l))) else: tmp = w0 * math.sqrt((1.0 + (-0.25 * ((math.pow((M_m * D_m), 2.0) * (h / d)) / (d * 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 (Float64(Float64(M_m * D_m) / Float64(2.0 * d)) <= 2e+115) tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(Float64((Float64(0.5 * Float64(Float64(M_m * D_m) / d)) ^ 2.0) * h) / l)))); else tmp = Float64(w0 * sqrt(Float64(1.0 + Float64(-0.25 * Float64(Float64((Float64(M_m * D_m) ^ 2.0) * Float64(h / d)) / Float64(d * 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 (((M_m * D_m) / (2.0 * d)) <= 2e+115)
tmp = w0 * sqrt((1.0 - ((((0.5 * ((M_m * D_m) / d)) ^ 2.0) * h) / l)));
else
tmp = w0 * sqrt((1.0 + (-0.25 * ((((M_m * D_m) ^ 2.0) * (h / d)) / (d * 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[N[(N[(M$95$m * D$95$m), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2e+115], N[(w0 * N[Sqrt[N[(1.0 - N[(N[(N[Power[N[(0.5 * N[(N[(M$95$m * D$95$m), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * h), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(w0 * N[Sqrt[N[(1.0 + N[(-0.25 * N[(N[(N[Power[N[(M$95$m * D$95$m), $MachinePrecision], 2.0], $MachinePrecision] * N[(h / d), $MachinePrecision]), $MachinePrecision] / N[(d * l), $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}\;\frac{M\_m \cdot D\_m}{2 \cdot d} \leq 2 \cdot 10^{+115}:\\
\;\;\;\;w0 \cdot \sqrt{1 - \frac{{\left(0.5 \cdot \frac{M\_m \cdot D\_m}{d}\right)}^{2} \cdot h}{\ell}}\\
\mathbf{else}:\\
\;\;\;\;w0 \cdot \sqrt{1 + -0.25 \cdot \frac{{\left(M\_m \cdot D\_m\right)}^{2} \cdot \frac{h}{d}}{d \cdot \ell}}\\
\end{array}
\end{array}
if (/.f64 (*.f64 M D) (*.f64 2 d)) < 2e115Initial program 82.4%
Simplified82.4%
associate-*r/89.9%
add-sqr-sqrt89.9%
pow289.9%
unpow289.9%
sqrt-prod53.5%
add-sqr-sqrt89.9%
*-un-lft-identity89.9%
times-frac89.9%
metadata-eval89.9%
Applied egg-rr89.9%
Taylor expanded in M around 0 90.7%
if 2e115 < (/.f64 (*.f64 M D) (*.f64 2 d)) Initial program 43.3%
Simplified43.3%
Taylor expanded in M around 0 42.9%
*-un-lft-identity42.9%
add-sqr-sqrt11.1%
times-frac11.1%
sqrt-prod11.1%
unpow211.1%
sqrt-prod0.6%
add-sqr-sqrt0.6%
associate-*r*0.6%
pow-prod-down0.7%
sqrt-prod0.7%
unpow20.7%
sqrt-prod0.7%
add-sqr-sqrt21.5%
Applied egg-rr21.5%
associate-*l/21.5%
*-lft-identity21.5%
associate-/l*21.3%
associate-*l/21.4%
associate-/r*21.4%
Simplified21.4%
*-un-lft-identity21.4%
cancel-sign-sub-inv21.4%
metadata-eval21.4%
frac-times19.0%
Applied egg-rr19.0%
*-lft-identity19.0%
associate-/r*19.0%
associate-*l/19.0%
associate-*l/19.0%
associate-/r*19.0%
associate-/l*21.4%
associate-*l*21.4%
Simplified21.4%
associate-*r/19.0%
add-sqr-sqrt55.8%
Applied egg-rr55.8%
Final simplification85.4%
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 6.8e-43) w0 (* w0 (sqrt (- 1.0 (* (/ h l) (pow (* M_m (/ D_m (* 2.0 d))) 2.0)))))))
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 <= 6.8e-43) {
tmp = w0;
} else {
tmp = w0 * sqrt((1.0 - ((h / l) * pow((M_m * (D_m / (2.0 * d))), 2.0))));
}
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 <= 6.8d-43) then
tmp = w0
else
tmp = w0 * sqrt((1.0d0 - ((h / l) * ((m_m * (d_m / (2.0d0 * d))) ** 2.0d0))))
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 <= 6.8e-43) {
tmp = w0;
} else {
tmp = w0 * Math.sqrt((1.0 - ((h / l) * Math.pow((M_m * (D_m / (2.0 * d))), 2.0))));
}
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 <= 6.8e-43: tmp = w0 else: tmp = w0 * math.sqrt((1.0 - ((h / l) * math.pow((M_m * (D_m / (2.0 * d))), 2.0)))) 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 <= 6.8e-43) tmp = w0; else tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(h / l) * (Float64(M_m * Float64(D_m / Float64(2.0 * d))) ^ 2.0))))); 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 <= 6.8e-43)
tmp = w0;
else
tmp = w0 * sqrt((1.0 - ((h / l) * ((M_m * (D_m / (2.0 * d))) ^ 2.0))));
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, 6.8e-43], w0, N[(w0 * N[Sqrt[N[(1.0 - N[(N[(h / l), $MachinePrecision] * N[Power[N[(M$95$m * N[(D$95$m / N[(2.0 * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $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 6.8 \cdot 10^{-43}:\\
\;\;\;\;w0\\
\mathbf{else}:\\
\;\;\;\;w0 \cdot \sqrt{1 - \frac{h}{\ell} \cdot {\left(M\_m \cdot \frac{D\_m}{2 \cdot d}\right)}^{2}}\\
\end{array}
\end{array}
if D < 6.8000000000000001e-43Initial program 77.1%
Simplified77.1%
Taylor expanded in M around 0 68.6%
if 6.8000000000000001e-43 < D Initial program 74.3%
Simplified74.3%
Final simplification70.0%
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 (/ (* (pow (* 0.5 (/ (* 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) {
return w0 * sqrt((1.0 - ((pow((0.5 * ((M_m * D_m) / d)), 2.0) * h) / l)));
}
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 - ((((0.5d0 * ((m_m * d_m) / d)) ** 2.0d0) * h) / l)))
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 - ((Math.pow((0.5 * ((M_m * D_m) / d)), 2.0) * h) / l)));
}
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 - ((math.pow((0.5 * ((M_m * D_m) / d)), 2.0) * h) / l)))
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(0.5 * Float64(Float64(M_m * D_m) / d)) ^ 2.0) * h) / l)))) 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 - ((((0.5 * ((M_m * D_m) / d)) ^ 2.0) * h) / l)));
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[Power[N[(0.5 * N[(N[(M$95$m * D$95$m), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * h), $MachinePrecision] / l), $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(0.5 \cdot \frac{M\_m \cdot D\_m}{d}\right)}^{2} \cdot h}{\ell}}
\end{array}
Initial program 76.4%
Simplified76.4%
associate-*r/83.2%
add-sqr-sqrt83.2%
pow283.2%
unpow283.2%
sqrt-prod52.4%
add-sqr-sqrt83.2%
*-un-lft-identity83.2%
times-frac83.2%
metadata-eval83.2%
Applied egg-rr83.2%
Taylor expanded in M around 0 84.0%
Final simplification84.0%
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 170000.0) w0 (log (exp 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 (M_m <= 170000.0) {
tmp = w0;
} else {
tmp = log(exp(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 (m_m <= 170000.0d0) then
tmp = w0
else
tmp = log(exp(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 (M_m <= 170000.0) {
tmp = w0;
} else {
tmp = Math.log(Math.exp(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 M_m <= 170000.0: tmp = w0 else: tmp = math.log(math.exp(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 (M_m <= 170000.0) tmp = w0; else tmp = log(exp(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 (M_m <= 170000.0)
tmp = w0;
else
tmp = log(exp(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[M$95$m, 170000.0], w0, N[Log[N[Exp[w0], $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 170000:\\
\;\;\;\;w0\\
\mathbf{else}:\\
\;\;\;\;\log \left(e^{w0}\right)\\
\end{array}
\end{array}
if M < 1.7e5Initial program 78.2%
Simplified77.7%
Taylor expanded in M around 0 67.7%
if 1.7e5 < M Initial program 69.9%
Simplified71.6%
add-sqr-sqrt36.4%
sqrt-unprod27.1%
*-commutative27.1%
*-commutative27.1%
swap-sqr26.9%
Applied egg-rr26.9%
Taylor expanded in M around 0 24.2%
sqrt-pow149.7%
metadata-eval49.7%
pow149.7%
add-log-exp28.3%
Applied egg-rr28.3%
Final simplification59.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 76.4%
Simplified76.4%
Taylor expanded in M around 0 63.8%
Final simplification63.8%
herbie shell --seed 2024062
(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))))))