
(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 6 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
(let* ((t_0 (* (* (/ D 2.0) (/ M_m d)) (sqrt h))))
(if (<= h 2e-213)
(* w0 (sqrt (- 1.0 (/ (* h (pow (/ (* D M_m) (* 2.0 d)) 2.0)) l))))
(* w0 (sqrt (- 1.0 (* t_0 (/ t_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 t_0 = ((D / 2.0) * (M_m / d)) * sqrt(h);
double tmp;
if (h <= 2e-213) {
tmp = w0 * sqrt((1.0 - ((h * pow(((D * M_m) / (2.0 * d)), 2.0)) / l)));
} else {
tmp = w0 * sqrt((1.0 - (t_0 * (t_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) :: t_0
real(8) :: tmp
t_0 = ((d / 2.0d0) * (m_m / d_1)) * sqrt(h)
if (h <= 2d-213) then
tmp = w0 * sqrt((1.0d0 - ((h * (((d * m_m) / (2.0d0 * d_1)) ** 2.0d0)) / l)))
else
tmp = w0 * sqrt((1.0d0 - (t_0 * (t_0 / 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 t_0 = ((D / 2.0) * (M_m / d)) * Math.sqrt(h);
double tmp;
if (h <= 2e-213) {
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 - (t_0 * (t_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): t_0 = ((D / 2.0) * (M_m / d)) * math.sqrt(h) tmp = 0 if h <= 2e-213: 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 - (t_0 * (t_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) t_0 = Float64(Float64(Float64(D / 2.0) * Float64(M_m / d)) * sqrt(h)) tmp = 0.0 if (h <= 2e-213) tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(h * (Float64(Float64(D * M_m) / Float64(2.0 * d)) ^ 2.0)) / l)))); else tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(t_0 * Float64(t_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)
t_0 = ((D / 2.0) * (M_m / d)) * sqrt(h);
tmp = 0.0;
if (h <= 2e-213)
tmp = w0 * sqrt((1.0 - ((h * (((D * M_m) / (2.0 * d)) ^ 2.0)) / l)));
else
tmp = w0 * sqrt((1.0 - (t_0 * (t_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_] := Block[{t$95$0 = N[(N[(N[(D / 2.0), $MachinePrecision] * N[(M$95$m / d), $MachinePrecision]), $MachinePrecision] * N[Sqrt[h], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[h, 2e-213], N[(w0 * N[Sqrt[N[(1.0 - N[(N[(h * N[Power[N[(N[(D * M$95$m), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(w0 * N[Sqrt[N[(1.0 - N[(t$95$0 * N[(t$95$0 / l), $MachinePrecision]), $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}
t_0 := \left(\frac{D}{2} \cdot \frac{M\_m}{d}\right) \cdot \sqrt{h}\\
\mathbf{if}\;h \leq 2 \cdot 10^{-213}:\\
\;\;\;\;w0 \cdot \sqrt{1 - \frac{h \cdot {\left(\frac{D \cdot M\_m}{2 \cdot d}\right)}^{2}}{\ell}}\\
\mathbf{else}:\\
\;\;\;\;w0 \cdot \sqrt{1 - t\_0 \cdot \frac{t\_0}{\ell}}\\
\end{array}
\end{array}
if h < 1.9999999999999999e-213Initial program 80.6%
Simplified80.6%
associate-*r/86.4%
unpow286.4%
associate-*l*86.4%
associate-/r*86.4%
associate-*r/85.8%
associate-*l/85.8%
*-commutative85.8%
associate-/r*85.8%
associate-*r/87.1%
associate-*l/87.7%
*-commutative87.7%
associate-*l*86.4%
unpow286.4%
Applied egg-rr86.5%
if 1.9999999999999999e-213 < h Initial program 85.4%
Simplified84.4%
associate-*r/88.8%
unpow288.8%
associate-*l*90.4%
associate-/r*90.4%
associate-*r/90.4%
associate-*l/90.4%
*-commutative90.4%
associate-/r*90.4%
associate-*r/91.4%
associate-*l/91.4%
*-commutative91.4%
associate-*l*89.8%
unpow289.8%
Applied egg-rr89.8%
add-sqr-sqrt89.8%
*-un-lft-identity89.8%
times-frac89.8%
*-commutative89.8%
sqrt-prod89.8%
sqrt-pow174.8%
metadata-eval74.8%
pow174.8%
times-frac73.8%
Applied egg-rr94.1%
Final simplification89.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)) 1e-15) (* 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 ((pow(((D * M_m) / (2.0 * d)), 2.0) * (h / l)) <= 1e-15) {
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 (((((d * m_m) / (2.0d0 * d_1)) ** 2.0d0) * (h / l)) <= 1d-15) 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 ((Math.pow(((D * M_m) / (2.0 * d)), 2.0) * (h / l)) <= 1e-15) {
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 (math.pow(((D * M_m) / (2.0 * d)), 2.0) * (h / l)) <= 1e-15: 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((Float64(Float64(D * M_m) / Float64(2.0 * d)) ^ 2.0) * Float64(h / l)) <= 1e-15) 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 (((((D * M_m) / (2.0 * d)) ^ 2.0) * (h / l)) <= 1e-15)
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[(N[Power[N[(N[(D * M$95$m), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision], 1e-15], 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}\;{\left(\frac{D \cdot M\_m}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell} \leq 10^{-15}:\\
\;\;\;\;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 (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64)) (/.f64 h l)) < 1.0000000000000001e-15Initial program 89.1%
Simplified88.7%
if 1.0000000000000001e-15 < (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64)) (/.f64 h l)) Initial program 0.0%
Simplified0.0%
Taylor expanded in D around 0 66.5%
Final simplification87.0%
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(Float64(D * 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[(N[(D * M$95$m), $MachinePrecision] / N[(2.0 * d), $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(\frac{D \cdot M\_m}{2 \cdot d}\right)}^{2}}{\ell}}
\end{array}
Initial program 82.5%
Simplified82.1%
associate-*r/87.4%
unpow287.4%
associate-*l*88.0%
associate-/r*88.0%
associate-*r/87.6%
associate-*l/87.6%
*-commutative87.6%
associate-/r*87.6%
associate-*r/88.8%
associate-*l/89.2%
*-commutative89.2%
associate-*l*87.8%
unpow287.8%
Applied egg-rr87.8%
Final simplification87.8%
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 4e+100) w0 (+ w0 (* -0.125 (* (pow (* D M_m) 2.0) (/ (* h (/ w0 d)) (* d 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 <= 4e+100) {
tmp = w0;
} else {
tmp = w0 + (-0.125 * (pow((D * M_m), 2.0) * ((h * (w0 / d)) / (d * 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 <= 4d+100) then
tmp = w0
else
tmp = w0 + ((-0.125d0) * (((d * m_m) ** 2.0d0) * ((h * (w0 / d_1)) / (d_1 * 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 <= 4e+100) {
tmp = w0;
} else {
tmp = w0 + (-0.125 * (Math.pow((D * M_m), 2.0) * ((h * (w0 / d)) / (d * 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 <= 4e+100: tmp = w0 else: tmp = w0 + (-0.125 * (math.pow((D * M_m), 2.0) * ((h * (w0 / d)) / (d * 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 (D <= 4e+100) tmp = w0; else tmp = Float64(w0 + Float64(-0.125 * Float64((Float64(D * M_m) ^ 2.0) * Float64(Float64(h * Float64(w0 / d)) / Float64(d * 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 <= 4e+100)
tmp = w0;
else
tmp = w0 + (-0.125 * (((D * M_m) ^ 2.0) * ((h * (w0 / d)) / (d * 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[D, 4e+100], w0, N[(w0 + N[(-0.125 * N[(N[Power[N[(D * M$95$m), $MachinePrecision], 2.0], $MachinePrecision] * N[(N[(h * N[(w0 / d), $MachinePrecision]), $MachinePrecision] / N[(d * l), $MachinePrecision]), $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 \leq 4 \cdot 10^{+100}:\\
\;\;\;\;w0\\
\mathbf{else}:\\
\;\;\;\;w0 + -0.125 \cdot \left({\left(D \cdot M\_m\right)}^{2} \cdot \frac{h \cdot \frac{w0}{d}}{d \cdot \ell}\right)\\
\end{array}
\end{array}
if D < 4.00000000000000006e100Initial program 86.1%
Simplified85.6%
Taylor expanded in D around 0 73.5%
if 4.00000000000000006e100 < D Initial program 62.0%
Simplified62.0%
Taylor expanded in D around 0 32.5%
associate-/l*32.5%
associate-/l*32.1%
Simplified32.1%
Taylor expanded in D around 0 32.5%
associate-*r*32.6%
unpow232.6%
unpow232.6%
swap-sqr54.0%
unpow254.0%
*-commutative54.0%
associate-*r/53.7%
associate-*r/51.2%
associate-/r*51.0%
Simplified51.0%
div-inv51.0%
unpow251.0%
times-frac51.4%
Applied egg-rr51.4%
associate-*r*51.4%
associate-/l/51.3%
un-div-inv51.3%
Applied egg-rr51.3%
Final simplification70.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
(if (<= D 4.4e+100)
w0
(+
w0
(*
-0.125
(* (* (* D M_m) (* D M_m)) (* h (* (/ w0 d) (/ (/ 1.0 l) d))))))))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 <= 4.4e+100) {
tmp = w0;
} else {
tmp = w0 + (-0.125 * (((D * M_m) * (D * M_m)) * (h * ((w0 / d) * ((1.0 / l) / d)))));
}
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 <= 4.4d+100) then
tmp = w0
else
tmp = w0 + ((-0.125d0) * (((d * m_m) * (d * m_m)) * (h * ((w0 / d_1) * ((1.0d0 / l) / d_1)))))
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 <= 4.4e+100) {
tmp = w0;
} else {
tmp = w0 + (-0.125 * (((D * M_m) * (D * M_m)) * (h * ((w0 / d) * ((1.0 / l) / d)))));
}
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 <= 4.4e+100: tmp = w0 else: tmp = w0 + (-0.125 * (((D * M_m) * (D * M_m)) * (h * ((w0 / d) * ((1.0 / l) / d))))) 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 (D <= 4.4e+100) tmp = w0; else tmp = Float64(w0 + Float64(-0.125 * Float64(Float64(Float64(D * M_m) * Float64(D * M_m)) * Float64(h * Float64(Float64(w0 / d) * Float64(Float64(1.0 / l) / d)))))); 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 <= 4.4e+100)
tmp = w0;
else
tmp = w0 + (-0.125 * (((D * M_m) * (D * M_m)) * (h * ((w0 / d) * ((1.0 / l) / d)))));
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[D, 4.4e+100], w0, N[(w0 + N[(-0.125 * N[(N[(N[(D * M$95$m), $MachinePrecision] * N[(D * M$95$m), $MachinePrecision]), $MachinePrecision] * N[(h * N[(N[(w0 / d), $MachinePrecision] * N[(N[(1.0 / l), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision]), $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 \leq 4.4 \cdot 10^{+100}:\\
\;\;\;\;w0\\
\mathbf{else}:\\
\;\;\;\;w0 + -0.125 \cdot \left(\left(\left(D \cdot M\_m\right) \cdot \left(D \cdot M\_m\right)\right) \cdot \left(h \cdot \left(\frac{w0}{d} \cdot \frac{\frac{1}{\ell}}{d}\right)\right)\right)\\
\end{array}
\end{array}
if D < 4.4000000000000001e100Initial program 86.1%
Simplified85.6%
Taylor expanded in D around 0 73.5%
if 4.4000000000000001e100 < D Initial program 62.0%
Simplified62.0%
Taylor expanded in D around 0 32.5%
associate-/l*32.5%
associate-/l*32.1%
Simplified32.1%
Taylor expanded in D around 0 32.5%
associate-*r*32.6%
unpow232.6%
unpow232.6%
swap-sqr54.0%
unpow254.0%
*-commutative54.0%
associate-*r/53.7%
associate-*r/51.2%
associate-/r*51.0%
Simplified51.0%
div-inv51.0%
unpow251.0%
times-frac51.4%
Applied egg-rr51.4%
unpow251.4%
Applied egg-rr51.4%
Final simplification70.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 82.5%
Simplified82.1%
Taylor expanded in D around 0 65.9%
Final simplification65.9%
herbie shell --seed 2024069
(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))))))