
(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)
D_m = (fabs.f64 D)
d_m = (fabs.f64 d)
NOTE: w0, M_m, D_m, h, l, and d_m should be sorted in increasing order before calling this function.
(FPCore (w0 M_m D_m h l d_m)
:precision binary64
(if (<= (/ (* M_m D_m) (* 2.0 d_m)) 5e+116)
(* w0 (sqrt (- 1.0 (/ (* h (pow (/ D_m (* 2.0 (/ d_m M_m))) 2.0)) l))))
(*
w0
(pow
(pow
(exp 0.16666666666666666)
(+ (log (/ (* -0.25 (* h (pow (* M_m D_m) 2.0))) l)) (* -2.0 (log d_m))))
3.0))))M_m = fabs(M);
D_m = fabs(D);
d_m = fabs(d);
assert(w0 < M_m && M_m < D_m && D_m < h && h < l && l < d_m);
double code(double w0, double M_m, double D_m, double h, double l, double d_m) {
double tmp;
if (((M_m * D_m) / (2.0 * d_m)) <= 5e+116) {
tmp = w0 * sqrt((1.0 - ((h * pow((D_m / (2.0 * (d_m / M_m))), 2.0)) / l)));
} else {
tmp = w0 * pow(pow(exp(0.16666666666666666), (log(((-0.25 * (h * pow((M_m * D_m), 2.0))) / l)) + (-2.0 * log(d_m)))), 3.0);
}
return tmp;
}
M_m = abs(m)
D_m = abs(d)
d_m = abs(d)
NOTE: w0, M_m, D_m, h, l, and d_m should be sorted in increasing order before calling this function.
real(8) function code(w0, m_m, d_m, h, l, d_m_1)
real(8), intent (in) :: w0
real(8), intent (in) :: m_m
real(8), intent (in) :: d_m
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: d_m_1
real(8) :: tmp
if (((m_m * d_m) / (2.0d0 * d_m_1)) <= 5d+116) then
tmp = w0 * sqrt((1.0d0 - ((h * ((d_m / (2.0d0 * (d_m_1 / m_m))) ** 2.0d0)) / l)))
else
tmp = w0 * ((exp(0.16666666666666666d0) ** (log((((-0.25d0) * (h * ((m_m * d_m) ** 2.0d0))) / l)) + ((-2.0d0) * log(d_m_1)))) ** 3.0d0)
end if
code = tmp
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
d_m = Math.abs(d);
assert w0 < M_m && M_m < D_m && D_m < h && h < l && l < d_m;
public static double code(double w0, double M_m, double D_m, double h, double l, double d_m) {
double tmp;
if (((M_m * D_m) / (2.0 * d_m)) <= 5e+116) {
tmp = w0 * Math.sqrt((1.0 - ((h * Math.pow((D_m / (2.0 * (d_m / M_m))), 2.0)) / l)));
} else {
tmp = w0 * Math.pow(Math.pow(Math.exp(0.16666666666666666), (Math.log(((-0.25 * (h * Math.pow((M_m * D_m), 2.0))) / l)) + (-2.0 * Math.log(d_m)))), 3.0);
}
return tmp;
}
M_m = math.fabs(M) D_m = math.fabs(D) d_m = math.fabs(d) [w0, M_m, D_m, h, l, d_m] = sort([w0, M_m, D_m, h, l, d_m]) def code(w0, M_m, D_m, h, l, d_m): tmp = 0 if ((M_m * D_m) / (2.0 * d_m)) <= 5e+116: tmp = w0 * math.sqrt((1.0 - ((h * math.pow((D_m / (2.0 * (d_m / M_m))), 2.0)) / l))) else: tmp = w0 * math.pow(math.pow(math.exp(0.16666666666666666), (math.log(((-0.25 * (h * math.pow((M_m * D_m), 2.0))) / l)) + (-2.0 * math.log(d_m)))), 3.0) return tmp
M_m = abs(M) D_m = abs(D) d_m = abs(d) w0, M_m, D_m, h, l, d_m = sort([w0, M_m, D_m, h, l, d_m]) function code(w0, M_m, D_m, h, l, d_m) tmp = 0.0 if (Float64(Float64(M_m * D_m) / Float64(2.0 * d_m)) <= 5e+116) tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(h * (Float64(D_m / Float64(2.0 * Float64(d_m / M_m))) ^ 2.0)) / l)))); else tmp = Float64(w0 * ((exp(0.16666666666666666) ^ Float64(log(Float64(Float64(-0.25 * Float64(h * (Float64(M_m * D_m) ^ 2.0))) / l)) + Float64(-2.0 * log(d_m)))) ^ 3.0)); end return tmp end
M_m = abs(M);
D_m = abs(D);
d_m = abs(d);
w0, M_m, D_m, h, l, d_m = num2cell(sort([w0, M_m, D_m, h, l, d_m])){:}
function tmp_2 = code(w0, M_m, D_m, h, l, d_m)
tmp = 0.0;
if (((M_m * D_m) / (2.0 * d_m)) <= 5e+116)
tmp = w0 * sqrt((1.0 - ((h * ((D_m / (2.0 * (d_m / M_m))) ^ 2.0)) / l)));
else
tmp = w0 * ((exp(0.16666666666666666) ^ (log(((-0.25 * (h * ((M_m * D_m) ^ 2.0))) / l)) + (-2.0 * log(d_m)))) ^ 3.0);
end
tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision] D_m = N[Abs[D], $MachinePrecision] d_m = N[Abs[d], $MachinePrecision] NOTE: w0, M_m, D_m, h, l, and d_m should be sorted in increasing order before calling this function. code[w0_, M$95$m_, D$95$m_, h_, l_, d$95$m_] := If[LessEqual[N[(N[(M$95$m * D$95$m), $MachinePrecision] / N[(2.0 * d$95$m), $MachinePrecision]), $MachinePrecision], 5e+116], N[(w0 * N[Sqrt[N[(1.0 - N[(N[(h * N[Power[N[(D$95$m / N[(2.0 * N[(d$95$m / M$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(w0 * N[Power[N[Power[N[Exp[0.16666666666666666], $MachinePrecision], N[(N[Log[N[(N[(-0.25 * N[(h * N[Power[N[(M$95$m * D$95$m), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]], $MachinePrecision] + N[(-2.0 * N[Log[d$95$m], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 3.0], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
d_m = \left|d\right|
\\
[w0, M_m, D_m, h, l, d_m] = \mathsf{sort}([w0, M_m, D_m, h, l, d_m])\\
\\
\begin{array}{l}
\mathbf{if}\;\frac{M\_m \cdot D\_m}{2 \cdot d\_m} \leq 5 \cdot 10^{+116}:\\
\;\;\;\;w0 \cdot \sqrt{1 - \frac{h \cdot {\left(\frac{D\_m}{2 \cdot \frac{d\_m}{M\_m}}\right)}^{2}}{\ell}}\\
\mathbf{else}:\\
\;\;\;\;w0 \cdot {\left({\left(e^{0.16666666666666666}\right)}^{\left(\log \left(\frac{-0.25 \cdot \left(h \cdot {\left(M\_m \cdot D\_m\right)}^{2}\right)}{\ell}\right) + -2 \cdot \log d\_m\right)}\right)}^{3}\\
\end{array}
\end{array}
if (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) < 5.00000000000000025e116Initial program 84.5%
Simplified84.1%
unpow284.1%
unpow284.1%
associate-/r*84.1%
associate-*r/84.5%
*-commutative84.5%
associate-*r/89.5%
*-commutative89.5%
associate-*l/89.1%
associate-/r*89.1%
clear-num89.1%
associate-*l/89.5%
*-un-lft-identity89.5%
associate-/r/89.5%
Applied egg-rr89.5%
if 5.00000000000000025e116 < (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) Initial program 48.1%
Simplified50.6%
Taylor expanded in D around 0 47.9%
associate-/l*47.9%
associate-/l*50.5%
Simplified50.5%
add-cube-cbrt50.5%
pow350.5%
Applied egg-rr47.7%
Taylor expanded in d around 0 30.4%
exp-prod30.2%
associate-*r*30.2%
unpow230.2%
unpow230.2%
swap-sqr30.2%
unpow230.2%
associate-*r/30.2%
*-commutative30.2%
Simplified30.2%
Final simplification80.9%
M_m = (fabs.f64 M) D_m = (fabs.f64 D) d_m = (fabs.f64 d) NOTE: w0, M_m, D_m, h, l, and d_m should be sorted in increasing order before calling this function. (FPCore (w0 M_m D_m h l d_m) :precision binary64 (if (<= (* (pow (/ (* M_m D_m) (* 2.0 d_m)) 2.0) (/ h l)) 0.0) (* w0 (sqrt (- 1.0 (* (/ h l) (pow (* D_m (/ (/ M_m 2.0) d_m)) 2.0))))) w0))
M_m = fabs(M);
D_m = fabs(D);
d_m = fabs(d);
assert(w0 < M_m && M_m < D_m && D_m < h && h < l && l < d_m);
double code(double w0, double M_m, double D_m, double h, double l, double d_m) {
double tmp;
if ((pow(((M_m * D_m) / (2.0 * d_m)), 2.0) * (h / l)) <= 0.0) {
tmp = w0 * sqrt((1.0 - ((h / l) * pow((D_m * ((M_m / 2.0) / d_m)), 2.0))));
} else {
tmp = w0;
}
return tmp;
}
M_m = abs(m)
D_m = abs(d)
d_m = abs(d)
NOTE: w0, M_m, D_m, h, l, and d_m should be sorted in increasing order before calling this function.
real(8) function code(w0, m_m, d_m, h, l, d_m_1)
real(8), intent (in) :: w0
real(8), intent (in) :: m_m
real(8), intent (in) :: d_m
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: d_m_1
real(8) :: tmp
if (((((m_m * d_m) / (2.0d0 * d_m_1)) ** 2.0d0) * (h / l)) <= 0.0d0) then
tmp = w0 * sqrt((1.0d0 - ((h / l) * ((d_m * ((m_m / 2.0d0) / d_m_1)) ** 2.0d0))))
else
tmp = w0
end if
code = tmp
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
d_m = Math.abs(d);
assert w0 < M_m && M_m < D_m && D_m < h && h < l && l < d_m;
public static double code(double w0, double M_m, double D_m, double h, double l, double d_m) {
double tmp;
if ((Math.pow(((M_m * D_m) / (2.0 * d_m)), 2.0) * (h / l)) <= 0.0) {
tmp = w0 * Math.sqrt((1.0 - ((h / l) * Math.pow((D_m * ((M_m / 2.0) / d_m)), 2.0))));
} else {
tmp = w0;
}
return tmp;
}
M_m = math.fabs(M) D_m = math.fabs(D) d_m = math.fabs(d) [w0, M_m, D_m, h, l, d_m] = sort([w0, M_m, D_m, h, l, d_m]) def code(w0, M_m, D_m, h, l, d_m): tmp = 0 if (math.pow(((M_m * D_m) / (2.0 * d_m)), 2.0) * (h / l)) <= 0.0: tmp = w0 * math.sqrt((1.0 - ((h / l) * math.pow((D_m * ((M_m / 2.0) / d_m)), 2.0)))) else: tmp = w0 return tmp
M_m = abs(M) D_m = abs(D) d_m = abs(d) w0, M_m, D_m, h, l, d_m = sort([w0, M_m, D_m, h, l, d_m]) function code(w0, M_m, D_m, h, l, d_m) tmp = 0.0 if (Float64((Float64(Float64(M_m * D_m) / Float64(2.0 * d_m)) ^ 2.0) * Float64(h / l)) <= 0.0) tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(h / l) * (Float64(D_m * Float64(Float64(M_m / 2.0) / d_m)) ^ 2.0))))); else tmp = w0; end return tmp end
M_m = abs(M);
D_m = abs(D);
d_m = abs(d);
w0, M_m, D_m, h, l, d_m = num2cell(sort([w0, M_m, D_m, h, l, d_m])){:}
function tmp_2 = code(w0, M_m, D_m, h, l, d_m)
tmp = 0.0;
if (((((M_m * D_m) / (2.0 * d_m)) ^ 2.0) * (h / l)) <= 0.0)
tmp = w0 * sqrt((1.0 - ((h / l) * ((D_m * ((M_m / 2.0) / d_m)) ^ 2.0))));
else
tmp = w0;
end
tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision] D_m = N[Abs[D], $MachinePrecision] d_m = N[Abs[d], $MachinePrecision] NOTE: w0, M_m, D_m, h, l, and d_m should be sorted in increasing order before calling this function. code[w0_, M$95$m_, D$95$m_, h_, l_, d$95$m_] := If[LessEqual[N[(N[Power[N[(N[(M$95$m * D$95$m), $MachinePrecision] / N[(2.0 * d$95$m), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision], 0.0], N[(w0 * N[Sqrt[N[(1.0 - N[(N[(h / l), $MachinePrecision] * N[Power[N[(D$95$m * N[(N[(M$95$m / 2.0), $MachinePrecision] / d$95$m), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], w0]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
d_m = \left|d\right|
\\
[w0, M_m, D_m, h, l, d_m] = \mathsf{sort}([w0, M_m, D_m, h, l, d_m])\\
\\
\begin{array}{l}
\mathbf{if}\;{\left(\frac{M\_m \cdot D\_m}{2 \cdot d\_m}\right)}^{2} \cdot \frac{h}{\ell} \leq 0:\\
\;\;\;\;w0 \cdot \sqrt{1 - \frac{h}{\ell} \cdot {\left(D\_m \cdot \frac{\frac{M\_m}{2}}{d\_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)) < -0.0Initial program 84.0%
Simplified84.4%
if -0.0 < (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64)) (/.f64 h l)) Initial program 43.3%
Simplified40.0%
Taylor expanded in D around 0 74.7%
Final simplification83.3%
M_m = (fabs.f64 M) D_m = (fabs.f64 D) d_m = (fabs.f64 d) NOTE: w0, M_m, D_m, h, l, and d_m should be sorted in increasing order before calling this function. (FPCore (w0 M_m D_m h l d_m) :precision binary64 (* w0 (sqrt (- 1.0 (/ (* h (pow (/ D_m (* 2.0 (/ d_m M_m))) 2.0)) l)))))
M_m = fabs(M);
D_m = fabs(D);
d_m = fabs(d);
assert(w0 < M_m && M_m < D_m && D_m < h && h < l && l < d_m);
double code(double w0, double M_m, double D_m, double h, double l, double d_m) {
return w0 * sqrt((1.0 - ((h * pow((D_m / (2.0 * (d_m / M_m))), 2.0)) / l)));
}
M_m = abs(m)
D_m = abs(d)
d_m = abs(d)
NOTE: w0, M_m, D_m, h, l, and d_m should be sorted in increasing order before calling this function.
real(8) function code(w0, m_m, d_m, h, l, d_m_1)
real(8), intent (in) :: w0
real(8), intent (in) :: m_m
real(8), intent (in) :: d_m
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: d_m_1
code = w0 * sqrt((1.0d0 - ((h * ((d_m / (2.0d0 * (d_m_1 / m_m))) ** 2.0d0)) / l)))
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
d_m = Math.abs(d);
assert w0 < M_m && M_m < D_m && D_m < h && h < l && l < d_m;
public static double code(double w0, double M_m, double D_m, double h, double l, double d_m) {
return w0 * Math.sqrt((1.0 - ((h * Math.pow((D_m / (2.0 * (d_m / M_m))), 2.0)) / l)));
}
M_m = math.fabs(M) D_m = math.fabs(D) d_m = math.fabs(d) [w0, M_m, D_m, h, l, d_m] = sort([w0, M_m, D_m, h, l, d_m]) def code(w0, M_m, D_m, h, l, d_m): return w0 * math.sqrt((1.0 - ((h * math.pow((D_m / (2.0 * (d_m / M_m))), 2.0)) / l)))
M_m = abs(M) D_m = abs(D) d_m = abs(d) w0, M_m, D_m, h, l, d_m = sort([w0, M_m, D_m, h, l, d_m]) function code(w0, M_m, D_m, h, l, d_m) return Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(h * (Float64(D_m / Float64(2.0 * Float64(d_m / M_m))) ^ 2.0)) / l)))) end
M_m = abs(M);
D_m = abs(D);
d_m = abs(d);
w0, M_m, D_m, h, l, d_m = num2cell(sort([w0, M_m, D_m, h, l, d_m])){:}
function tmp = code(w0, M_m, D_m, h, l, d_m)
tmp = w0 * sqrt((1.0 - ((h * ((D_m / (2.0 * (d_m / M_m))) ^ 2.0)) / l)));
end
M_m = N[Abs[M], $MachinePrecision] D_m = N[Abs[D], $MachinePrecision] d_m = N[Abs[d], $MachinePrecision] NOTE: w0, M_m, D_m, h, l, and d_m should be sorted in increasing order before calling this function. code[w0_, M$95$m_, D$95$m_, h_, l_, d$95$m_] := N[(w0 * N[Sqrt[N[(1.0 - N[(N[(h * N[Power[N[(D$95$m / N[(2.0 * N[(d$95$m / M$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
d_m = \left|d\right|
\\
[w0, M_m, D_m, h, l, d_m] = \mathsf{sort}([w0, M_m, D_m, h, l, d_m])\\
\\
w0 \cdot \sqrt{1 - \frac{h \cdot {\left(\frac{D\_m}{2 \cdot \frac{d\_m}{M\_m}}\right)}^{2}}{\ell}}
\end{array}
Initial program 79.3%
Simplified79.2%
unpow279.2%
unpow279.2%
associate-/r*79.2%
associate-*r/79.3%
*-commutative79.3%
associate-*r/84.0%
*-commutative84.0%
associate-*l/84.0%
associate-/r*84.0%
clear-num84.0%
associate-*l/84.3%
*-un-lft-identity84.3%
associate-/r/84.3%
Applied egg-rr84.3%
Final simplification84.3%
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
d_m = (fabs.f64 d)
NOTE: w0, M_m, D_m, h, l, and d_m should be sorted in increasing order before calling this function.
(FPCore (w0 M_m D_m h l d_m)
:precision binary64
(if (<= D_m 3.7e+143)
w0
(+
w0
(*
-0.125
(* (* h (* (* M_m D_m) (* M_m D_m))) (/ (/ w0 (pow d_m 2.0)) l))))))M_m = fabs(M);
D_m = fabs(D);
d_m = fabs(d);
assert(w0 < M_m && M_m < D_m && D_m < h && h < l && l < d_m);
double code(double w0, double M_m, double D_m, double h, double l, double d_m) {
double tmp;
if (D_m <= 3.7e+143) {
tmp = w0;
} else {
tmp = w0 + (-0.125 * ((h * ((M_m * D_m) * (M_m * D_m))) * ((w0 / pow(d_m, 2.0)) / l)));
}
return tmp;
}
M_m = abs(m)
D_m = abs(d)
d_m = abs(d)
NOTE: w0, M_m, D_m, h, l, and d_m should be sorted in increasing order before calling this function.
real(8) function code(w0, m_m, d_m, h, l, d_m_1)
real(8), intent (in) :: w0
real(8), intent (in) :: m_m
real(8), intent (in) :: d_m
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: d_m_1
real(8) :: tmp
if (d_m <= 3.7d+143) then
tmp = w0
else
tmp = w0 + ((-0.125d0) * ((h * ((m_m * d_m) * (m_m * d_m))) * ((w0 / (d_m_1 ** 2.0d0)) / l)))
end if
code = tmp
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
d_m = Math.abs(d);
assert w0 < M_m && M_m < D_m && D_m < h && h < l && l < d_m;
public static double code(double w0, double M_m, double D_m, double h, double l, double d_m) {
double tmp;
if (D_m <= 3.7e+143) {
tmp = w0;
} else {
tmp = w0 + (-0.125 * ((h * ((M_m * D_m) * (M_m * D_m))) * ((w0 / Math.pow(d_m, 2.0)) / l)));
}
return tmp;
}
M_m = math.fabs(M) D_m = math.fabs(D) d_m = math.fabs(d) [w0, M_m, D_m, h, l, d_m] = sort([w0, M_m, D_m, h, l, d_m]) def code(w0, M_m, D_m, h, l, d_m): tmp = 0 if D_m <= 3.7e+143: tmp = w0 else: tmp = w0 + (-0.125 * ((h * ((M_m * D_m) * (M_m * D_m))) * ((w0 / math.pow(d_m, 2.0)) / l))) return tmp
M_m = abs(M) D_m = abs(D) d_m = abs(d) w0, M_m, D_m, h, l, d_m = sort([w0, M_m, D_m, h, l, d_m]) function code(w0, M_m, D_m, h, l, d_m) tmp = 0.0 if (D_m <= 3.7e+143) tmp = w0; else tmp = Float64(w0 + Float64(-0.125 * Float64(Float64(h * Float64(Float64(M_m * D_m) * Float64(M_m * D_m))) * Float64(Float64(w0 / (d_m ^ 2.0)) / l)))); end return tmp end
M_m = abs(M);
D_m = abs(D);
d_m = abs(d);
w0, M_m, D_m, h, l, d_m = num2cell(sort([w0, M_m, D_m, h, l, d_m])){:}
function tmp_2 = code(w0, M_m, D_m, h, l, d_m)
tmp = 0.0;
if (D_m <= 3.7e+143)
tmp = w0;
else
tmp = w0 + (-0.125 * ((h * ((M_m * D_m) * (M_m * D_m))) * ((w0 / (d_m ^ 2.0)) / l)));
end
tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision] D_m = N[Abs[D], $MachinePrecision] d_m = N[Abs[d], $MachinePrecision] NOTE: w0, M_m, D_m, h, l, and d_m should be sorted in increasing order before calling this function. code[w0_, M$95$m_, D$95$m_, h_, l_, d$95$m_] := If[LessEqual[D$95$m, 3.7e+143], w0, N[(w0 + N[(-0.125 * N[(N[(h * N[(N[(M$95$m * D$95$m), $MachinePrecision] * N[(M$95$m * D$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[(w0 / N[Power[d$95$m, 2.0], $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
d_m = \left|d\right|
\\
[w0, M_m, D_m, h, l, d_m] = \mathsf{sort}([w0, M_m, D_m, h, l, d_m])\\
\\
\begin{array}{l}
\mathbf{if}\;D\_m \leq 3.7 \cdot 10^{+143}:\\
\;\;\;\;w0\\
\mathbf{else}:\\
\;\;\;\;w0 + -0.125 \cdot \left(\left(h \cdot \left(\left(M\_m \cdot D\_m\right) \cdot \left(M\_m \cdot D\_m\right)\right)\right) \cdot \frac{\frac{w0}{{d\_m}^{2}}}{\ell}\right)\\
\end{array}
\end{array}
if D < 3.7000000000000002e143Initial program 80.4%
Simplified80.4%
Taylor expanded in D around 0 70.1%
if 3.7000000000000002e143 < D Initial program 70.8%
Simplified70.8%
Taylor expanded in D around 0 24.1%
associate-/l*24.1%
associate-/l*24.2%
Simplified24.2%
pow124.2%
associate-*r*24.2%
pow-prod-down60.9%
associate-/l*60.9%
*-un-lft-identity60.9%
times-frac57.5%
pow-flip57.5%
metadata-eval57.5%
Applied egg-rr57.5%
unpow157.5%
associate-*r*57.6%
Simplified57.6%
unpow257.6%
Applied egg-rr57.6%
Taylor expanded in d around 0 61.1%
associate-/r*60.9%
Simplified60.9%
Final simplification69.0%
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
d_m = (fabs.f64 d)
NOTE: w0, M_m, D_m, h, l, and d_m should be sorted in increasing order before calling this function.
(FPCore (w0 M_m D_m h l d_m)
:precision binary64
(if (<= D_m 7.5e+144)
w0
(+
w0
(*
-0.125
(* (* h (* (* M_m D_m) (* M_m D_m))) (* (pow d_m -2.0) (/ w0 l)))))))M_m = fabs(M);
D_m = fabs(D);
d_m = fabs(d);
assert(w0 < M_m && M_m < D_m && D_m < h && h < l && l < d_m);
double code(double w0, double M_m, double D_m, double h, double l, double d_m) {
double tmp;
if (D_m <= 7.5e+144) {
tmp = w0;
} else {
tmp = w0 + (-0.125 * ((h * ((M_m * D_m) * (M_m * D_m))) * (pow(d_m, -2.0) * (w0 / l))));
}
return tmp;
}
M_m = abs(m)
D_m = abs(d)
d_m = abs(d)
NOTE: w0, M_m, D_m, h, l, and d_m should be sorted in increasing order before calling this function.
real(8) function code(w0, m_m, d_m, h, l, d_m_1)
real(8), intent (in) :: w0
real(8), intent (in) :: m_m
real(8), intent (in) :: d_m
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: d_m_1
real(8) :: tmp
if (d_m <= 7.5d+144) then
tmp = w0
else
tmp = w0 + ((-0.125d0) * ((h * ((m_m * d_m) * (m_m * d_m))) * ((d_m_1 ** (-2.0d0)) * (w0 / l))))
end if
code = tmp
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
d_m = Math.abs(d);
assert w0 < M_m && M_m < D_m && D_m < h && h < l && l < d_m;
public static double code(double w0, double M_m, double D_m, double h, double l, double d_m) {
double tmp;
if (D_m <= 7.5e+144) {
tmp = w0;
} else {
tmp = w0 + (-0.125 * ((h * ((M_m * D_m) * (M_m * D_m))) * (Math.pow(d_m, -2.0) * (w0 / l))));
}
return tmp;
}
M_m = math.fabs(M) D_m = math.fabs(D) d_m = math.fabs(d) [w0, M_m, D_m, h, l, d_m] = sort([w0, M_m, D_m, h, l, d_m]) def code(w0, M_m, D_m, h, l, d_m): tmp = 0 if D_m <= 7.5e+144: tmp = w0 else: tmp = w0 + (-0.125 * ((h * ((M_m * D_m) * (M_m * D_m))) * (math.pow(d_m, -2.0) * (w0 / l)))) return tmp
M_m = abs(M) D_m = abs(D) d_m = abs(d) w0, M_m, D_m, h, l, d_m = sort([w0, M_m, D_m, h, l, d_m]) function code(w0, M_m, D_m, h, l, d_m) tmp = 0.0 if (D_m <= 7.5e+144) tmp = w0; else tmp = Float64(w0 + Float64(-0.125 * Float64(Float64(h * Float64(Float64(M_m * D_m) * Float64(M_m * D_m))) * Float64((d_m ^ -2.0) * Float64(w0 / l))))); end return tmp end
M_m = abs(M);
D_m = abs(D);
d_m = abs(d);
w0, M_m, D_m, h, l, d_m = num2cell(sort([w0, M_m, D_m, h, l, d_m])){:}
function tmp_2 = code(w0, M_m, D_m, h, l, d_m)
tmp = 0.0;
if (D_m <= 7.5e+144)
tmp = w0;
else
tmp = w0 + (-0.125 * ((h * ((M_m * D_m) * (M_m * D_m))) * ((d_m ^ -2.0) * (w0 / l))));
end
tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision] D_m = N[Abs[D], $MachinePrecision] d_m = N[Abs[d], $MachinePrecision] NOTE: w0, M_m, D_m, h, l, and d_m should be sorted in increasing order before calling this function. code[w0_, M$95$m_, D$95$m_, h_, l_, d$95$m_] := If[LessEqual[D$95$m, 7.5e+144], w0, N[(w0 + N[(-0.125 * N[(N[(h * N[(N[(M$95$m * D$95$m), $MachinePrecision] * N[(M$95$m * D$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[Power[d$95$m, -2.0], $MachinePrecision] * N[(w0 / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
d_m = \left|d\right|
\\
[w0, M_m, D_m, h, l, d_m] = \mathsf{sort}([w0, M_m, D_m, h, l, d_m])\\
\\
\begin{array}{l}
\mathbf{if}\;D\_m \leq 7.5 \cdot 10^{+144}:\\
\;\;\;\;w0\\
\mathbf{else}:\\
\;\;\;\;w0 + -0.125 \cdot \left(\left(h \cdot \left(\left(M\_m \cdot D\_m\right) \cdot \left(M\_m \cdot D\_m\right)\right)\right) \cdot \left({d\_m}^{-2} \cdot \frac{w0}{\ell}\right)\right)\\
\end{array}
\end{array}
if D < 7.5000000000000006e144Initial program 80.4%
Simplified80.4%
Taylor expanded in D around 0 70.1%
if 7.5000000000000006e144 < D Initial program 70.8%
Simplified70.8%
Taylor expanded in D around 0 24.1%
associate-/l*24.1%
associate-/l*24.2%
Simplified24.2%
pow124.2%
associate-*r*24.2%
pow-prod-down60.9%
associate-/l*60.9%
*-un-lft-identity60.9%
times-frac57.5%
pow-flip57.5%
metadata-eval57.5%
Applied egg-rr57.5%
unpow157.5%
associate-*r*57.6%
Simplified57.6%
unpow257.6%
Applied egg-rr57.6%
Final simplification68.7%
M_m = (fabs.f64 M) D_m = (fabs.f64 D) d_m = (fabs.f64 d) NOTE: w0, M_m, D_m, h, l, and d_m should be sorted in increasing order before calling this function. (FPCore (w0 M_m D_m h l d_m) :precision binary64 w0)
M_m = fabs(M);
D_m = fabs(D);
d_m = fabs(d);
assert(w0 < M_m && M_m < D_m && D_m < h && h < l && l < d_m);
double code(double w0, double M_m, double D_m, double h, double l, double d_m) {
return w0;
}
M_m = abs(m)
D_m = abs(d)
d_m = abs(d)
NOTE: w0, M_m, D_m, h, l, and d_m should be sorted in increasing order before calling this function.
real(8) function code(w0, m_m, d_m, h, l, d_m_1)
real(8), intent (in) :: w0
real(8), intent (in) :: m_m
real(8), intent (in) :: d_m
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: d_m_1
code = w0
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
d_m = Math.abs(d);
assert w0 < M_m && M_m < D_m && D_m < h && h < l && l < d_m;
public static double code(double w0, double M_m, double D_m, double h, double l, double d_m) {
return w0;
}
M_m = math.fabs(M) D_m = math.fabs(D) d_m = math.fabs(d) [w0, M_m, D_m, h, l, d_m] = sort([w0, M_m, D_m, h, l, d_m]) def code(w0, M_m, D_m, h, l, d_m): return w0
M_m = abs(M) D_m = abs(D) d_m = abs(d) w0, M_m, D_m, h, l, d_m = sort([w0, M_m, D_m, h, l, d_m]) function code(w0, M_m, D_m, h, l, d_m) return w0 end
M_m = abs(M);
D_m = abs(D);
d_m = abs(d);
w0, M_m, D_m, h, l, d_m = num2cell(sort([w0, M_m, D_m, h, l, d_m])){:}
function tmp = code(w0, M_m, D_m, h, l, d_m)
tmp = w0;
end
M_m = N[Abs[M], $MachinePrecision] D_m = N[Abs[D], $MachinePrecision] d_m = N[Abs[d], $MachinePrecision] NOTE: w0, M_m, D_m, h, l, and d_m should be sorted in increasing order before calling this function. code[w0_, M$95$m_, D$95$m_, h_, l_, d$95$m_] := w0
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
d_m = \left|d\right|
\\
[w0, M_m, D_m, h, l, d_m] = \mathsf{sort}([w0, M_m, D_m, h, l, d_m])\\
\\
w0
\end{array}
Initial program 79.3%
Simplified79.2%
Taylor expanded in D around 0 66.5%
herbie shell --seed 2024101
(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))))))