
(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 8 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) NOTE: w0, M_m, D, h, l, and d should be sorted in increasing order before calling this function. (FPCore (w0 M_m D h l d) :precision binary64 (if (<= h -2e-308) (* w0 (sqrt (- 1.0 (/ (* h (pow (* D (/ M_m (* 2.0 d))) 2.0)) l)))) (* w0 (sqrt (- 1.0 (/ (pow (* (* (/ M_m d) (/ D 2.0)) (sqrt h)) 2.0) l))))))
M_m = fabs(M);
assert(w0 < M_m && M_m < D && D < h && h < l && l < d);
double code(double w0, double M_m, double D, double h, double l, double d) {
double tmp;
if (h <= -2e-308) {
tmp = w0 * sqrt((1.0 - ((h * pow((D * (M_m / (2.0 * d))), 2.0)) / l)));
} else {
tmp = w0 * sqrt((1.0 - (pow((((M_m / d) * (D / 2.0)) * sqrt(h)), 2.0) / l)));
}
return tmp;
}
M_m = abs(m)
NOTE: w0, M_m, D, h, l, and d should be sorted in increasing order before calling this function.
real(8) function code(w0, m_m, d, h, l, d_1)
real(8), intent (in) :: w0
real(8), intent (in) :: m_m
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: d_1
real(8) :: tmp
if (h <= (-2d-308)) then
tmp = w0 * sqrt((1.0d0 - ((h * ((d * (m_m / (2.0d0 * d_1))) ** 2.0d0)) / l)))
else
tmp = w0 * sqrt((1.0d0 - (((((m_m / d_1) * (d / 2.0d0)) * sqrt(h)) ** 2.0d0) / l)))
end if
code = tmp
end function
M_m = Math.abs(M);
assert w0 < M_m && M_m < D && D < h && h < l && l < d;
public static double code(double w0, double M_m, double D, double h, double l, double d) {
double tmp;
if (h <= -2e-308) {
tmp = w0 * Math.sqrt((1.0 - ((h * Math.pow((D * (M_m / (2.0 * d))), 2.0)) / l)));
} else {
tmp = w0 * Math.sqrt((1.0 - (Math.pow((((M_m / d) * (D / 2.0)) * Math.sqrt(h)), 2.0) / l)));
}
return tmp;
}
M_m = math.fabs(M) [w0, M_m, D, h, l, d] = sort([w0, M_m, D, h, l, d]) def code(w0, M_m, D, h, l, d): tmp = 0 if h <= -2e-308: tmp = w0 * math.sqrt((1.0 - ((h * math.pow((D * (M_m / (2.0 * d))), 2.0)) / l))) else: tmp = w0 * math.sqrt((1.0 - (math.pow((((M_m / d) * (D / 2.0)) * math.sqrt(h)), 2.0) / l))) return tmp
M_m = abs(M) w0, M_m, D, h, l, d = sort([w0, M_m, D, h, l, d]) function code(w0, M_m, D, h, l, d) tmp = 0.0 if (h <= -2e-308) tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(h * (Float64(D * Float64(M_m / Float64(2.0 * d))) ^ 2.0)) / l)))); else tmp = Float64(w0 * sqrt(Float64(1.0 - Float64((Float64(Float64(Float64(M_m / d) * Float64(D / 2.0)) * sqrt(h)) ^ 2.0) / l)))); end return tmp end
M_m = abs(M);
w0, M_m, D, h, l, d = num2cell(sort([w0, M_m, D, h, l, d])){:}
function tmp_2 = code(w0, M_m, D, h, l, d)
tmp = 0.0;
if (h <= -2e-308)
tmp = w0 * sqrt((1.0 - ((h * ((D * (M_m / (2.0 * d))) ^ 2.0)) / l)));
else
tmp = w0 * sqrt((1.0 - (((((M_m / d) * (D / 2.0)) * sqrt(h)) ^ 2.0) / l)));
end
tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision] NOTE: w0, M_m, D, h, l, and d should be sorted in increasing order before calling this function. code[w0_, M$95$m_, D_, h_, l_, d_] := If[LessEqual[h, -2e-308], N[(w0 * N[Sqrt[N[(1.0 - N[(N[(h * N[Power[N[(D * N[(M$95$m / N[(2.0 * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(w0 * N[Sqrt[N[(1.0 - N[(N[Power[N[(N[(N[(M$95$m / d), $MachinePrecision] * N[(D / 2.0), $MachinePrecision]), $MachinePrecision] * N[Sqrt[h], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
M_m = \left|M\right|
\\
[w0, M_m, D, h, l, d] = \mathsf{sort}([w0, M_m, D, h, l, d])\\
\\
\begin{array}{l}
\mathbf{if}\;h \leq -2 \cdot 10^{-308}:\\
\;\;\;\;w0 \cdot \sqrt{1 - \frac{h \cdot {\left(D \cdot \frac{M\_m}{2 \cdot d}\right)}^{2}}{\ell}}\\
\mathbf{else}:\\
\;\;\;\;w0 \cdot \sqrt{1 - \frac{{\left(\left(\frac{M\_m}{d} \cdot \frac{D}{2}\right) \cdot \sqrt{h}\right)}^{2}}{\ell}}\\
\end{array}
\end{array}
if h < -1.9999999999999998e-308Initial program 80.4%
Simplified81.2%
associate-*r/85.2%
add-sqr-sqrt85.2%
pow285.2%
unpow285.2%
sqrt-prod57.1%
add-sqr-sqrt85.2%
div-inv85.2%
frac-times85.2%
*-commutative85.2%
*-un-lft-identity85.2%
Applied egg-rr85.2%
if -1.9999999999999998e-308 < h Initial program 76.8%
Simplified76.8%
associate-*r/83.3%
add-sqr-sqrt83.3%
pow283.3%
unpow283.3%
sqrt-prod51.1%
add-sqr-sqrt83.3%
div-inv83.3%
frac-times83.3%
*-commutative83.3%
*-un-lft-identity83.3%
Applied egg-rr83.3%
add-sqr-sqrt83.3%
pow283.3%
sqrt-prod83.3%
sqrt-pow187.9%
metadata-eval87.9%
pow187.9%
Applied egg-rr87.9%
associate-*r/87.1%
*-commutative87.1%
*-commutative87.1%
times-frac87.9%
Simplified87.9%
Final simplification86.5%
M_m = (fabs.f64 M) NOTE: w0, M_m, D, h, l, and d should be sorted in increasing order before calling this function. (FPCore (w0 M_m D h l d) :precision binary64 (if (<= (* (pow (/ (* D M_m) (* 2.0 d)) 2.0) (/ h l)) 5e-8) (* w0 (sqrt (- 1.0 (* (/ h l) (pow (/ D (/ (* 2.0 d) M_m)) 2.0))))) w0))
M_m = fabs(M);
assert(w0 < M_m && M_m < D && D < h && h < l && l < d);
double code(double w0, double M_m, double D, double h, double l, double d) {
double tmp;
if ((pow(((D * M_m) / (2.0 * d)), 2.0) * (h / l)) <= 5e-8) {
tmp = w0 * sqrt((1.0 - ((h / l) * pow((D / ((2.0 * d) / M_m)), 2.0))));
} else {
tmp = w0;
}
return tmp;
}
M_m = abs(m)
NOTE: w0, M_m, D, h, l, and d should be sorted in increasing order before calling this function.
real(8) function code(w0, m_m, d, h, l, d_1)
real(8), intent (in) :: w0
real(8), intent (in) :: m_m
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: d_1
real(8) :: tmp
if (((((d * m_m) / (2.0d0 * d_1)) ** 2.0d0) * (h / l)) <= 5d-8) then
tmp = w0 * sqrt((1.0d0 - ((h / l) * ((d / ((2.0d0 * d_1) / m_m)) ** 2.0d0))))
else
tmp = w0
end if
code = tmp
end function
M_m = Math.abs(M);
assert w0 < M_m && M_m < D && D < h && h < l && l < d;
public static double code(double w0, double M_m, double D, double h, double l, double d) {
double tmp;
if ((Math.pow(((D * M_m) / (2.0 * d)), 2.0) * (h / l)) <= 5e-8) {
tmp = w0 * Math.sqrt((1.0 - ((h / l) * Math.pow((D / ((2.0 * d) / M_m)), 2.0))));
} else {
tmp = w0;
}
return tmp;
}
M_m = math.fabs(M) [w0, M_m, D, h, l, d] = sort([w0, M_m, D, h, l, d]) def code(w0, M_m, D, h, l, d): tmp = 0 if (math.pow(((D * M_m) / (2.0 * d)), 2.0) * (h / l)) <= 5e-8: tmp = w0 * math.sqrt((1.0 - ((h / l) * math.pow((D / ((2.0 * d) / M_m)), 2.0)))) else: tmp = w0 return tmp
M_m = abs(M) w0, M_m, D, h, l, d = sort([w0, M_m, D, h, l, d]) function code(w0, M_m, D, h, l, d) tmp = 0.0 if (Float64((Float64(Float64(D * M_m) / Float64(2.0 * d)) ^ 2.0) * Float64(h / l)) <= 5e-8) tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(h / l) * (Float64(D / Float64(Float64(2.0 * d) / M_m)) ^ 2.0))))); else tmp = w0; end return tmp end
M_m = abs(M);
w0, M_m, D, h, l, d = num2cell(sort([w0, M_m, D, h, l, d])){:}
function tmp_2 = code(w0, M_m, D, h, l, d)
tmp = 0.0;
if (((((D * M_m) / (2.0 * d)) ^ 2.0) * (h / l)) <= 5e-8)
tmp = w0 * sqrt((1.0 - ((h / l) * ((D / ((2.0 * d) / M_m)) ^ 2.0))));
else
tmp = w0;
end
tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision] NOTE: w0, M_m, D, h, l, and d should be sorted in increasing order before calling this function. code[w0_, M$95$m_, D_, h_, l_, d_] := If[LessEqual[N[(N[Power[N[(N[(D * M$95$m), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision], 5e-8], N[(w0 * N[Sqrt[N[(1.0 - N[(N[(h / l), $MachinePrecision] * N[Power[N[(D / N[(N[(2.0 * d), $MachinePrecision] / M$95$m), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], w0]
\begin{array}{l}
M_m = \left|M\right|
\\
[w0, M_m, D, h, l, d] = \mathsf{sort}([w0, M_m, D, h, l, d])\\
\\
\begin{array}{l}
\mathbf{if}\;{\left(\frac{D \cdot M\_m}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell} \leq 5 \cdot 10^{-8}:\\
\;\;\;\;w0 \cdot \sqrt{1 - \frac{h}{\ell} \cdot {\left(\frac{D}{\frac{2 \cdot d}{M\_m}}\right)}^{2}}\\
\mathbf{else}:\\
\;\;\;\;w0\\
\end{array}
\end{array}
if (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64)) (/.f64 h l)) < 4.9999999999999998e-8Initial program 87.5%
Simplified87.5%
clear-num87.5%
un-div-inv87.5%
div-inv87.5%
clear-num87.5%
Applied egg-rr87.5%
*-un-lft-identity87.5%
Applied egg-rr87.5%
*-lft-identity87.5%
associate-*r/87.5%
*-commutative87.5%
Simplified87.5%
if 4.9999999999999998e-8 < (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64)) (/.f64 h l)) Initial program 0.0%
Simplified3.8%
Taylor expanded in D around 0 63.5%
Final simplification85.1%
M_m = (fabs.f64 M) NOTE: w0, M_m, D, h, l, and d should be sorted in increasing order before calling this function. (FPCore (w0 M_m D h l d) :precision binary64 (if (<= (/ h l) -4e-311) (* w0 (sqrt (- 1.0 (* (/ h l) (pow (* D (/ (/ M_m 2.0) d)) 2.0))))) w0))
M_m = fabs(M);
assert(w0 < M_m && M_m < D && D < h && h < l && l < d);
double code(double w0, double M_m, double D, double h, double l, double d) {
double tmp;
if ((h / l) <= -4e-311) {
tmp = w0 * sqrt((1.0 - ((h / l) * pow((D * ((M_m / 2.0) / d)), 2.0))));
} else {
tmp = w0;
}
return tmp;
}
M_m = abs(m)
NOTE: w0, M_m, D, h, l, and d should be sorted in increasing order before calling this function.
real(8) function code(w0, m_m, d, h, l, d_1)
real(8), intent (in) :: w0
real(8), intent (in) :: m_m
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: d_1
real(8) :: tmp
if ((h / l) <= (-4d-311)) then
tmp = w0 * sqrt((1.0d0 - ((h / l) * ((d * ((m_m / 2.0d0) / d_1)) ** 2.0d0))))
else
tmp = w0
end if
code = tmp
end function
M_m = Math.abs(M);
assert w0 < M_m && M_m < D && D < h && h < l && l < d;
public static double code(double w0, double M_m, double D, double h, double l, double d) {
double tmp;
if ((h / l) <= -4e-311) {
tmp = w0 * Math.sqrt((1.0 - ((h / l) * Math.pow((D * ((M_m / 2.0) / d)), 2.0))));
} else {
tmp = w0;
}
return tmp;
}
M_m = math.fabs(M) [w0, M_m, D, h, l, d] = sort([w0, M_m, D, h, l, d]) def code(w0, M_m, D, h, l, d): tmp = 0 if (h / l) <= -4e-311: tmp = w0 * math.sqrt((1.0 - ((h / l) * math.pow((D * ((M_m / 2.0) / d)), 2.0)))) else: tmp = w0 return tmp
M_m = abs(M) w0, M_m, D, h, l, d = sort([w0, M_m, D, h, l, d]) function code(w0, M_m, D, h, l, d) tmp = 0.0 if (Float64(h / l) <= -4e-311) tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(h / l) * (Float64(D * Float64(Float64(M_m / 2.0) / d)) ^ 2.0))))); else tmp = w0; end return tmp end
M_m = abs(M);
w0, M_m, D, h, l, d = num2cell(sort([w0, M_m, D, h, l, d])){:}
function tmp_2 = code(w0, M_m, D, h, l, d)
tmp = 0.0;
if ((h / l) <= -4e-311)
tmp = w0 * sqrt((1.0 - ((h / l) * ((D * ((M_m / 2.0) / d)) ^ 2.0))));
else
tmp = w0;
end
tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision] NOTE: w0, M_m, D, h, l, and d should be sorted in increasing order before calling this function. code[w0_, M$95$m_, D_, h_, l_, d_] := If[LessEqual[N[(h / l), $MachinePrecision], -4e-311], N[(w0 * N[Sqrt[N[(1.0 - N[(N[(h / l), $MachinePrecision] * N[Power[N[(D * N[(N[(M$95$m / 2.0), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], w0]
\begin{array}{l}
M_m = \left|M\right|
\\
[w0, M_m, D, h, l, d] = \mathsf{sort}([w0, M_m, D, h, l, d])\\
\\
\begin{array}{l}
\mathbf{if}\;\frac{h}{\ell} \leq -4 \cdot 10^{-311}:\\
\;\;\;\;w0 \cdot \sqrt{1 - \frac{h}{\ell} \cdot {\left(D \cdot \frac{\frac{M\_m}{2}}{d}\right)}^{2}}\\
\mathbf{else}:\\
\;\;\;\;w0\\
\end{array}
\end{array}
if (/.f64 h l) < -3.99999999999979e-311Initial program 75.7%
Simplified75.7%
if -3.99999999999979e-311 < (/.f64 h l) Initial program 82.7%
Simplified83.6%
Taylor expanded in D around 0 91.7%
Final simplification82.5%
M_m = (fabs.f64 M) NOTE: w0, M_m, D, h, l, and d should be sorted in increasing order before calling this function. (FPCore (w0 M_m D h l d) :precision binary64 (if (<= (/ h l) -4e-311) (* w0 (sqrt (- 1.0 (* (/ h l) (pow (/ D (* d (/ 2.0 M_m))) 2.0))))) w0))
M_m = fabs(M);
assert(w0 < M_m && M_m < D && D < h && h < l && l < d);
double code(double w0, double M_m, double D, double h, double l, double d) {
double tmp;
if ((h / l) <= -4e-311) {
tmp = w0 * sqrt((1.0 - ((h / l) * pow((D / (d * (2.0 / M_m))), 2.0))));
} else {
tmp = w0;
}
return tmp;
}
M_m = abs(m)
NOTE: w0, M_m, D, h, l, and d should be sorted in increasing order before calling this function.
real(8) function code(w0, m_m, d, h, l, d_1)
real(8), intent (in) :: w0
real(8), intent (in) :: m_m
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: d_1
real(8) :: tmp
if ((h / l) <= (-4d-311)) then
tmp = w0 * sqrt((1.0d0 - ((h / l) * ((d / (d_1 * (2.0d0 / m_m))) ** 2.0d0))))
else
tmp = w0
end if
code = tmp
end function
M_m = Math.abs(M);
assert w0 < M_m && M_m < D && D < h && h < l && l < d;
public static double code(double w0, double M_m, double D, double h, double l, double d) {
double tmp;
if ((h / l) <= -4e-311) {
tmp = w0 * Math.sqrt((1.0 - ((h / l) * Math.pow((D / (d * (2.0 / M_m))), 2.0))));
} else {
tmp = w0;
}
return tmp;
}
M_m = math.fabs(M) [w0, M_m, D, h, l, d] = sort([w0, M_m, D, h, l, d]) def code(w0, M_m, D, h, l, d): tmp = 0 if (h / l) <= -4e-311: tmp = w0 * math.sqrt((1.0 - ((h / l) * math.pow((D / (d * (2.0 / M_m))), 2.0)))) else: tmp = w0 return tmp
M_m = abs(M) w0, M_m, D, h, l, d = sort([w0, M_m, D, h, l, d]) function code(w0, M_m, D, h, l, d) tmp = 0.0 if (Float64(h / l) <= -4e-311) tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(h / l) * (Float64(D / Float64(d * Float64(2.0 / M_m))) ^ 2.0))))); else tmp = w0; end return tmp end
M_m = abs(M);
w0, M_m, D, h, l, d = num2cell(sort([w0, M_m, D, h, l, d])){:}
function tmp_2 = code(w0, M_m, D, h, l, d)
tmp = 0.0;
if ((h / l) <= -4e-311)
tmp = w0 * sqrt((1.0 - ((h / l) * ((D / (d * (2.0 / M_m))) ^ 2.0))));
else
tmp = w0;
end
tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision] NOTE: w0, M_m, D, h, l, and d should be sorted in increasing order before calling this function. code[w0_, M$95$m_, D_, h_, l_, d_] := If[LessEqual[N[(h / l), $MachinePrecision], -4e-311], N[(w0 * N[Sqrt[N[(1.0 - N[(N[(h / l), $MachinePrecision] * N[Power[N[(D / N[(d * N[(2.0 / M$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], w0]
\begin{array}{l}
M_m = \left|M\right|
\\
[w0, M_m, D, h, l, d] = \mathsf{sort}([w0, M_m, D, h, l, d])\\
\\
\begin{array}{l}
\mathbf{if}\;\frac{h}{\ell} \leq -4 \cdot 10^{-311}:\\
\;\;\;\;w0 \cdot \sqrt{1 - \frac{h}{\ell} \cdot {\left(\frac{D}{d \cdot \frac{2}{M\_m}}\right)}^{2}}\\
\mathbf{else}:\\
\;\;\;\;w0\\
\end{array}
\end{array}
if (/.f64 h l) < -3.99999999999979e-311Initial program 75.7%
Simplified75.7%
clear-num75.7%
un-div-inv75.7%
div-inv75.6%
clear-num75.6%
Applied egg-rr75.6%
if -3.99999999999979e-311 < (/.f64 h l) Initial program 82.7%
Simplified83.6%
Taylor expanded in D around 0 91.7%
Final simplification82.5%
M_m = (fabs.f64 M) NOTE: w0, M_m, D, h, l, and d should be sorted in increasing order before calling this function. (FPCore (w0 M_m D h l d) :precision binary64 (* w0 (sqrt (- 1.0 (/ (* h (pow (* D (/ M_m (* 2.0 d))) 2.0)) l)))))
M_m = fabs(M);
assert(w0 < M_m && M_m < D && D < h && h < l && l < d);
double code(double w0, double M_m, double D, double h, double l, double d) {
return w0 * sqrt((1.0 - ((h * pow((D * (M_m / (2.0 * d))), 2.0)) / l)));
}
M_m = abs(m)
NOTE: w0, M_m, D, h, l, and d should be sorted in increasing order before calling this function.
real(8) function code(w0, m_m, d, h, l, d_1)
real(8), intent (in) :: w0
real(8), intent (in) :: m_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 - ((h * ((d * (m_m / (2.0d0 * d_1))) ** 2.0d0)) / l)))
end function
M_m = Math.abs(M);
assert w0 < M_m && M_m < D && D < h && h < l && l < d;
public static double code(double w0, double M_m, double D, double h, double l, double d) {
return w0 * Math.sqrt((1.0 - ((h * Math.pow((D * (M_m / (2.0 * d))), 2.0)) / l)));
}
M_m = math.fabs(M) [w0, M_m, D, h, l, d] = sort([w0, M_m, D, h, l, d]) def code(w0, M_m, D, h, l, d): return w0 * math.sqrt((1.0 - ((h * math.pow((D * (M_m / (2.0 * d))), 2.0)) / l)))
M_m = abs(M) w0, M_m, D, h, l, d = sort([w0, M_m, D, h, l, d]) function code(w0, M_m, D, h, l, d) return Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(h * (Float64(D * Float64(M_m / Float64(2.0 * d))) ^ 2.0)) / l)))) end
M_m = abs(M);
w0, M_m, D, h, l, d = num2cell(sort([w0, M_m, D, h, l, d])){:}
function tmp = code(w0, M_m, D, h, l, d)
tmp = w0 * sqrt((1.0 - ((h * ((D * (M_m / (2.0 * d))) ^ 2.0)) / l)));
end
M_m = N[Abs[M], $MachinePrecision] NOTE: w0, M_m, D, h, l, and d should be sorted in increasing order before calling this function. code[w0_, M$95$m_, D_, h_, l_, d_] := N[(w0 * N[Sqrt[N[(1.0 - N[(N[(h * N[Power[N[(D * N[(M$95$m / N[(2.0 * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
M_m = \left|M\right|
\\
[w0, M_m, D, h, l, d] = \mathsf{sort}([w0, M_m, D, h, l, d])\\
\\
w0 \cdot \sqrt{1 - \frac{h \cdot {\left(D \cdot \frac{M\_m}{2 \cdot d}\right)}^{2}}{\ell}}
\end{array}
Initial program 78.6%
Simplified79.0%
associate-*r/84.3%
add-sqr-sqrt84.3%
pow284.3%
unpow284.3%
sqrt-prod54.2%
add-sqr-sqrt84.3%
div-inv84.3%
frac-times84.3%
*-commutative84.3%
*-un-lft-identity84.3%
Applied egg-rr84.3%
Final simplification84.3%
M_m = (fabs.f64 M) NOTE: w0, M_m, D, h, l, and d should be sorted in increasing order before calling this function. (FPCore (w0 M_m D h l d) :precision binary64 (if (<= (* D M_m) 5e-8) w0 (+ w0 (* -0.125 (* (pow (* D (/ M_m d)) 2.0) (/ (* h w0) l))))))
M_m = fabs(M);
assert(w0 < M_m && M_m < D && D < h && h < l && l < d);
double code(double w0, double M_m, double D, double h, double l, double d) {
double tmp;
if ((D * M_m) <= 5e-8) {
tmp = w0;
} else {
tmp = w0 + (-0.125 * (pow((D * (M_m / d)), 2.0) * ((h * w0) / l)));
}
return tmp;
}
M_m = abs(m)
NOTE: w0, M_m, D, h, l, and d should be sorted in increasing order before calling this function.
real(8) function code(w0, m_m, d, h, l, d_1)
real(8), intent (in) :: w0
real(8), intent (in) :: m_m
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: d_1
real(8) :: tmp
if ((d * m_m) <= 5d-8) then
tmp = w0
else
tmp = w0 + ((-0.125d0) * (((d * (m_m / d_1)) ** 2.0d0) * ((h * w0) / l)))
end if
code = tmp
end function
M_m = Math.abs(M);
assert w0 < M_m && M_m < D && D < h && h < l && l < d;
public static double code(double w0, double M_m, double D, double h, double l, double d) {
double tmp;
if ((D * M_m) <= 5e-8) {
tmp = w0;
} else {
tmp = w0 + (-0.125 * (Math.pow((D * (M_m / d)), 2.0) * ((h * w0) / l)));
}
return tmp;
}
M_m = math.fabs(M) [w0, M_m, D, h, l, d] = sort([w0, M_m, D, h, l, d]) def code(w0, M_m, D, h, l, d): tmp = 0 if (D * M_m) <= 5e-8: tmp = w0 else: tmp = w0 + (-0.125 * (math.pow((D * (M_m / d)), 2.0) * ((h * w0) / l))) return tmp
M_m = abs(M) w0, M_m, D, h, l, d = sort([w0, M_m, D, h, l, d]) function code(w0, M_m, D, h, l, d) tmp = 0.0 if (Float64(D * M_m) <= 5e-8) tmp = w0; else tmp = Float64(w0 + Float64(-0.125 * Float64((Float64(D * Float64(M_m / d)) ^ 2.0) * Float64(Float64(h * w0) / l)))); end return tmp end
M_m = abs(M);
w0, M_m, D, h, l, d = num2cell(sort([w0, M_m, D, h, l, d])){:}
function tmp_2 = code(w0, M_m, D, h, l, d)
tmp = 0.0;
if ((D * M_m) <= 5e-8)
tmp = w0;
else
tmp = w0 + (-0.125 * (((D * (M_m / d)) ^ 2.0) * ((h * w0) / l)));
end
tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision] NOTE: w0, M_m, D, h, l, and d should be sorted in increasing order before calling this function. code[w0_, M$95$m_, D_, h_, l_, d_] := If[LessEqual[N[(D * M$95$m), $MachinePrecision], 5e-8], w0, N[(w0 + N[(-0.125 * N[(N[Power[N[(D * N[(M$95$m / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(N[(h * w0), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
M_m = \left|M\right|
\\
[w0, M_m, D, h, l, d] = \mathsf{sort}([w0, M_m, D, h, l, d])\\
\\
\begin{array}{l}
\mathbf{if}\;D \cdot M\_m \leq 5 \cdot 10^{-8}:\\
\;\;\;\;w0\\
\mathbf{else}:\\
\;\;\;\;w0 + -0.125 \cdot \left({\left(D \cdot \frac{M\_m}{d}\right)}^{2} \cdot \frac{h \cdot w0}{\ell}\right)\\
\end{array}
\end{array}
if (*.f64 M D) < 4.9999999999999998e-8Initial program 80.7%
Simplified81.2%
Taylor expanded in D around 0 74.2%
if 4.9999999999999998e-8 < (*.f64 M D) Initial program 72.2%
Simplified72.2%
Taylor expanded in D around 0 39.9%
associate-/l*39.9%
times-frac40.0%
Simplified40.0%
add-sqr-sqrt40.0%
sqrt-div40.0%
sqrt-pow124.1%
metadata-eval24.1%
pow124.1%
sqrt-pow126.7%
metadata-eval26.7%
pow126.7%
sqrt-div26.7%
sqrt-pow140.6%
metadata-eval40.6%
pow140.6%
sqrt-pow151.5%
metadata-eval51.5%
pow151.5%
Applied egg-rr51.5%
pow151.5%
associate-*r*51.5%
pow251.5%
pow-prod-down62.9%
associate-/l*61.5%
Applied egg-rr61.5%
unpow161.5%
Simplified61.5%
Taylor expanded in h around 0 62.9%
Final simplification71.5%
M_m = (fabs.f64 M) NOTE: w0, M_m, D, h, l, and d should be sorted in increasing order before calling this function. (FPCore (w0 M_m D h l d) :precision binary64 (let* ((t_0 (* D (/ M_m d)))) (if (<= d 1.15e+41) (+ w0 (* -0.125 (* (* t_0 t_0) (* h (/ w0 l))))) w0)))
M_m = fabs(M);
assert(w0 < M_m && M_m < D && D < h && h < l && l < d);
double code(double w0, double M_m, double D, double h, double l, double d) {
double t_0 = D * (M_m / d);
double tmp;
if (d <= 1.15e+41) {
tmp = w0 + (-0.125 * ((t_0 * t_0) * (h * (w0 / l))));
} else {
tmp = w0;
}
return tmp;
}
M_m = abs(m)
NOTE: w0, M_m, D, h, l, and d should be sorted in increasing order before calling this function.
real(8) function code(w0, m_m, d, h, l, d_1)
real(8), intent (in) :: w0
real(8), intent (in) :: m_m
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: d_1
real(8) :: t_0
real(8) :: tmp
t_0 = d * (m_m / d_1)
if (d_1 <= 1.15d+41) then
tmp = w0 + ((-0.125d0) * ((t_0 * t_0) * (h * (w0 / l))))
else
tmp = w0
end if
code = tmp
end function
M_m = Math.abs(M);
assert w0 < M_m && M_m < D && D < h && h < l && l < d;
public static double code(double w0, double M_m, double D, double h, double l, double d) {
double t_0 = D * (M_m / d);
double tmp;
if (d <= 1.15e+41) {
tmp = w0 + (-0.125 * ((t_0 * t_0) * (h * (w0 / l))));
} else {
tmp = w0;
}
return tmp;
}
M_m = math.fabs(M) [w0, M_m, D, h, l, d] = sort([w0, M_m, D, h, l, d]) def code(w0, M_m, D, h, l, d): t_0 = D * (M_m / d) tmp = 0 if d <= 1.15e+41: tmp = w0 + (-0.125 * ((t_0 * t_0) * (h * (w0 / l)))) else: tmp = w0 return tmp
M_m = abs(M) w0, M_m, D, h, l, d = sort([w0, M_m, D, h, l, d]) function code(w0, M_m, D, h, l, d) t_0 = Float64(D * Float64(M_m / d)) tmp = 0.0 if (d <= 1.15e+41) tmp = Float64(w0 + Float64(-0.125 * Float64(Float64(t_0 * t_0) * Float64(h * Float64(w0 / l))))); else tmp = w0; end return tmp end
M_m = abs(M);
w0, M_m, D, h, l, d = num2cell(sort([w0, M_m, D, h, l, d])){:}
function tmp_2 = code(w0, M_m, D, h, l, d)
t_0 = D * (M_m / d);
tmp = 0.0;
if (d <= 1.15e+41)
tmp = w0 + (-0.125 * ((t_0 * t_0) * (h * (w0 / l))));
else
tmp = w0;
end
tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision]
NOTE: w0, M_m, D, h, l, and d should be sorted in increasing order before calling this function.
code[w0_, M$95$m_, D_, h_, l_, d_] := Block[{t$95$0 = N[(D * N[(M$95$m / d), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, 1.15e+41], N[(w0 + N[(-0.125 * N[(N[(t$95$0 * t$95$0), $MachinePrecision] * N[(h * N[(w0 / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], w0]]
\begin{array}{l}
M_m = \left|M\right|
\\
[w0, M_m, D, h, l, d] = \mathsf{sort}([w0, M_m, D, h, l, d])\\
\\
\begin{array}{l}
t_0 := D \cdot \frac{M\_m}{d}\\
\mathbf{if}\;d \leq 1.15 \cdot 10^{+41}:\\
\;\;\;\;w0 + -0.125 \cdot \left(\left(t\_0 \cdot t\_0\right) \cdot \left(h \cdot \frac{w0}{\ell}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;w0\\
\end{array}
\end{array}
if d < 1.1499999999999999e41Initial program 78.8%
Simplified78.8%
Taylor expanded in D around 0 45.2%
associate-/l*45.2%
times-frac44.3%
Simplified44.3%
add-sqr-sqrt44.3%
sqrt-div44.3%
sqrt-pow134.6%
metadata-eval34.6%
pow134.6%
sqrt-pow136.6%
metadata-eval36.6%
pow136.6%
sqrt-div36.6%
sqrt-pow139.5%
metadata-eval39.5%
pow139.5%
sqrt-pow153.3%
metadata-eval53.3%
pow153.3%
Applied egg-rr53.3%
pow153.3%
associate-*r*53.8%
pow253.8%
pow-prod-down66.8%
associate-/l*67.4%
Applied egg-rr67.4%
unpow167.4%
Simplified67.4%
unpow267.4%
Applied egg-rr67.4%
if 1.1499999999999999e41 < d Initial program 78.2%
Simplified79.6%
Taylor expanded in D around 0 84.3%
Final simplification72.2%
M_m = (fabs.f64 M) NOTE: w0, M_m, D, h, l, and d should be sorted in increasing order before calling this function. (FPCore (w0 M_m D h l d) :precision binary64 w0)
M_m = fabs(M);
assert(w0 < M_m && M_m < D && D < h && h < l && l < d);
double code(double w0, double M_m, double D, double h, double l, double d) {
return w0;
}
M_m = abs(m)
NOTE: w0, M_m, D, h, l, and d should be sorted in increasing order before calling this function.
real(8) function code(w0, m_m, d, h, l, d_1)
real(8), intent (in) :: w0
real(8), intent (in) :: m_m
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: d_1
code = w0
end function
M_m = Math.abs(M);
assert w0 < M_m && M_m < D && D < h && h < l && l < d;
public static double code(double w0, double M_m, double D, double h, double l, double d) {
return w0;
}
M_m = math.fabs(M) [w0, M_m, D, h, l, d] = sort([w0, M_m, D, h, l, d]) def code(w0, M_m, D, h, l, d): return w0
M_m = abs(M) w0, M_m, D, h, l, d = sort([w0, M_m, D, h, l, d]) function code(w0, M_m, D, h, l, d) return w0 end
M_m = abs(M);
w0, M_m, D, h, l, d = num2cell(sort([w0, M_m, D, h, l, d])){:}
function tmp = code(w0, M_m, D, h, l, d)
tmp = w0;
end
M_m = N[Abs[M], $MachinePrecision] NOTE: w0, M_m, D, h, l, and d should be sorted in increasing order before calling this function. code[w0_, M$95$m_, D_, h_, l_, d_] := w0
\begin{array}{l}
M_m = \left|M\right|
\\
[w0, M_m, D, h, l, d] = \mathsf{sort}([w0, M_m, D, h, l, d])\\
\\
w0
\end{array}
Initial program 78.6%
Simplified79.0%
Taylor expanded in D around 0 65.8%
Final simplification65.8%
herbie shell --seed 2024115
(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))))))