
(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 7 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 (<= (* (pow (/ (* M_m D_m) (* 2.0 d)) 2.0) (/ h l)) -2e+26)
(*
w0
(pow
(exp
(*
0.25
(+
(log (* -0.25 (* (/ h l) (pow (/ M_m d) 2.0))))
(* -2.0 (log (/ 1.0 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 ((pow(((M_m * D_m) / (2.0 * d)), 2.0) * (h / l)) <= -2e+26) {
tmp = w0 * pow(exp((0.25 * (log((-0.25 * ((h / l) * pow((M_m / d), 2.0)))) + (-2.0 * log((1.0 / D_m)))))), 2.0);
} else {
tmp = 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 * d_m) / (2.0d0 * d)) ** 2.0d0) * (h / l)) <= (-2d+26)) then
tmp = w0 * (exp((0.25d0 * (log(((-0.25d0) * ((h / l) * ((m_m / d) ** 2.0d0)))) + ((-2.0d0) * log((1.0d0 / d_m)))))) ** 2.0d0)
else
tmp = 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 ((Math.pow(((M_m * D_m) / (2.0 * d)), 2.0) * (h / l)) <= -2e+26) {
tmp = w0 * Math.pow(Math.exp((0.25 * (Math.log((-0.25 * ((h / l) * Math.pow((M_m / d), 2.0)))) + (-2.0 * Math.log((1.0 / 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 (math.pow(((M_m * D_m) / (2.0 * d)), 2.0) * (h / l)) <= -2e+26: tmp = w0 * math.pow(math.exp((0.25 * (math.log((-0.25 * ((h / l) * math.pow((M_m / d), 2.0)))) + (-2.0 * math.log((1.0 / 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((Float64(Float64(M_m * D_m) / Float64(2.0 * d)) ^ 2.0) * Float64(h / l)) <= -2e+26) tmp = Float64(w0 * (exp(Float64(0.25 * Float64(log(Float64(-0.25 * Float64(Float64(h / l) * (Float64(M_m / d) ^ 2.0)))) + Float64(-2.0 * log(Float64(1.0 / 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 (((((M_m * D_m) / (2.0 * d)) ^ 2.0) * (h / l)) <= -2e+26)
tmp = w0 * (exp((0.25 * (log((-0.25 * ((h / l) * ((M_m / d) ^ 2.0)))) + (-2.0 * log((1.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] 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[Power[N[(N[(M$95$m * D$95$m), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision], -2e+26], N[(w0 * N[Power[N[Exp[N[(0.25 * N[(N[Log[N[(-0.25 * N[(N[(h / l), $MachinePrecision] * N[Power[N[(M$95$m / d), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] + N[(-2.0 * N[Log[N[(1.0 / D$95$m), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $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}\;{\left(\frac{M\_m \cdot D\_m}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell} \leq -2 \cdot 10^{+26}:\\
\;\;\;\;w0 \cdot {\left(e^{0.25 \cdot \left(\log \left(-0.25 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{M\_m}{d}\right)}^{2}\right)\right) + -2 \cdot \log \left(\frac{1}{D\_m}\right)\right)}\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)) < -2.0000000000000001e26Initial program 62.8%
Simplified66.0%
Applied egg-rr66.0%
Taylor expanded in D around inf 24.2%
*-un-lft-identity24.2%
log-prod24.2%
metadata-eval24.2%
*-commutative24.2%
times-frac26.6%
unpow226.6%
unpow226.6%
frac-times36.0%
pow236.0%
Applied egg-rr36.0%
+-lft-identity36.0%
*-commutative36.0%
*-commutative36.0%
Simplified36.0%
if -2.0000000000000001e26 < (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64)) (/.f64 h l)) Initial program 90.5%
Simplified92.3%
Taylor expanded in D around 0 97.1%
Final simplification76.3%
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 (<=
(sqrt (- 1.0 (* (pow (/ (* M_m D_m) (* 2.0 d)) 2.0) (/ h l))))
INFINITY)
(* w0 (sqrt (- 1.0 (* (/ h l) (pow (* D_m (/ (/ M_m 2.0) d)) 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 (sqrt((1.0 - (pow(((M_m * D_m) / (2.0 * d)), 2.0) * (h / l)))) <= ((double) INFINITY)) {
tmp = w0 * sqrt((1.0 - ((h / l) * pow((D_m * ((M_m / 2.0) / d)), 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 (Math.sqrt((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((D_m * ((M_m / 2.0) / d)), 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 math.sqrt((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((D_m * ((M_m / 2.0) / d)), 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 (sqrt(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(D_m * Float64(Float64(M_m / 2.0) / d)) ^ 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 (sqrt((1.0 - ((((M_m * D_m) / (2.0 * d)) ^ 2.0) * (h / l)))) <= Inf)
tmp = w0 * sqrt((1.0 - ((h / l) * ((D_m * ((M_m / 2.0) / d)) ^ 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[Sqrt[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]], $MachinePrecision], Infinity], 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), $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}\;\sqrt{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(D\_m \cdot \frac{\frac{M\_m}{2}}{d}\right)}^{2}}\\
\mathbf{else}:\\
\;\;\;\;w0\\
\end{array}
\end{array}
if (sqrt.f64 (-.f64 #s(literal 1 binary64) (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64)) (/.f64 h l)))) < +inf.0Initial program 86.5%
Simplified87.7%
if +inf.0 < (sqrt.f64 (-.f64 #s(literal 1 binary64) (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64)) (/.f64 h l)))) Initial program 0.0%
Simplified18.8%
Taylor expanded in D around 0 74.5%
Final simplification86.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 (<= (/ h l) -5e-290) (* w0 (fma -0.125 (* (/ h l) (pow (* D_m (/ M_m d)) 2.0)) 1.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 ((h / l) <= -5e-290) {
tmp = w0 * fma(-0.125, ((h / l) * pow((D_m * (M_m / d)), 2.0)), 1.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(h / l) <= -5e-290) tmp = Float64(w0 * fma(-0.125, Float64(Float64(h / l) * (Float64(D_m * Float64(M_m / d)) ^ 2.0)), 1.0)); else tmp = w0; end return 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[(h / l), $MachinePrecision], -5e-290], N[(w0 * N[(-0.125 * N[(N[(h / l), $MachinePrecision] * N[Power[N[(D$95$m * N[(M$95$m / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] + 1.0), $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}\;\frac{h}{\ell} \leq -5 \cdot 10^{-290}:\\
\;\;\;\;w0 \cdot \mathsf{fma}\left(-0.125, \frac{h}{\ell} \cdot {\left(D\_m \cdot \frac{M\_m}{d}\right)}^{2}, 1\right)\\
\mathbf{else}:\\
\;\;\;\;w0\\
\end{array}
\end{array}
if (/.f64 h l) < -5.0000000000000001e-290Initial program 77.5%
Simplified79.3%
Taylor expanded in D around 0 46.9%
*-commutative46.9%
associate-/l*46.3%
times-frac48.8%
Simplified48.8%
associate-*r/49.5%
add-sqr-sqrt49.5%
pow249.5%
sqrt-div49.5%
sqrt-pow159.9%
metadata-eval59.9%
pow159.9%
sqrt-pow165.9%
metadata-eval65.9%
pow165.9%
Applied egg-rr65.9%
Taylor expanded in D around 0 45.2%
+-commutative45.2%
fma-define45.2%
associate-*r*47.0%
times-frac46.0%
associate-/l*46.6%
unpow246.6%
unpow246.6%
unpow246.6%
times-frac60.7%
swap-sqr69.6%
unpow269.6%
Simplified69.6%
if -5.0000000000000001e-290 < (/.f64 h l) Initial program 87.3%
Simplified90.5%
Taylor expanded in D around 0 95.6%
Final simplification79.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 (sqrt (- 1.0 (* h (/ (pow (* M_m (/ (* D_m 0.5) 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) {
return w0 * sqrt((1.0 - (h * (pow((M_m * ((D_m * 0.5) / d)), 2.0) / 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 - (h * (((m_m * ((d_m * 0.5d0) / d)) ** 2.0d0) / 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 - (h * (Math.pow((M_m * ((D_m * 0.5) / d)), 2.0) / 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 - (h * (math.pow((M_m * ((D_m * 0.5) / d)), 2.0) / 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(h * Float64((Float64(M_m * Float64(Float64(D_m * 0.5) / d)) ^ 2.0) / 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 - (h * (((M_m * ((D_m * 0.5) / d)) ^ 2.0) / 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[(h * N[(N[Power[N[(M$95$m * N[(N[(D$95$m * 0.5), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision], 2.0], $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])\\
\\
w0 \cdot \sqrt{1 - h \cdot \frac{{\left(M\_m \cdot \frac{D\_m \cdot 0.5}{d}\right)}^{2}}{\ell}}
\end{array}
Initial program 81.1%
Simplified83.4%
Applied egg-rr83.4%
*-lft-identity83.4%
associate-*l/84.7%
associate-/l*85.4%
associate-*r/85.4%
associate-/l*83.2%
*-commutative83.2%
associate-*l*83.2%
*-commutative83.2%
associate-/l*84.0%
Simplified84.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 (<= d 1.65e+115) (+ w0 (* -0.125 (* (pow (/ (* M_m D_m) d) 2.0) (/ (* h w0) l)))) 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 (d <= 1.65e+115) {
tmp = w0 + (-0.125 * (pow(((M_m * D_m) / d), 2.0) * ((h * w0) / l)));
} else {
tmp = 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 (d <= 1.65d+115) then
tmp = w0 + ((-0.125d0) * ((((m_m * d_m) / d) ** 2.0d0) * ((h * w0) / l)))
else
tmp = 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 (d <= 1.65e+115) {
tmp = w0 + (-0.125 * (Math.pow(((M_m * D_m) / d), 2.0) * ((h * w0) / l)));
} 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 d <= 1.65e+115: tmp = w0 + (-0.125 * (math.pow(((M_m * D_m) / d), 2.0) * ((h * w0) / l))) 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 (d <= 1.65e+115) tmp = Float64(w0 + Float64(-0.125 * Float64((Float64(Float64(M_m * D_m) / d) ^ 2.0) * Float64(Float64(h * w0) / l)))); 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 (d <= 1.65e+115)
tmp = w0 + (-0.125 * ((((M_m * D_m) / d) ^ 2.0) * ((h * w0) / l)));
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[d, 1.65e+115], N[(w0 + N[(-0.125 * N[(N[Power[N[(N[(M$95$m * D$95$m), $MachinePrecision] / d), $MachinePrecision], 2.0], $MachinePrecision] * N[(N[(h * w0), $MachinePrecision] / l), $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}\;d \leq 1.65 \cdot 10^{+115}:\\
\;\;\;\;w0 + -0.125 \cdot \left({\left(\frac{M\_m \cdot D\_m}{d}\right)}^{2} \cdot \frac{h \cdot w0}{\ell}\right)\\
\mathbf{else}:\\
\;\;\;\;w0\\
\end{array}
\end{array}
if d < 1.65000000000000003e115Initial program 80.1%
Simplified82.0%
Taylor expanded in D around 0 48.2%
associate-/l*47.7%
times-frac47.7%
Simplified47.7%
add-sqr-sqrt47.7%
sqrt-div47.7%
sqrt-pow138.0%
metadata-eval38.0%
pow138.0%
sqrt-pow138.7%
metadata-eval38.7%
pow138.7%
sqrt-div38.7%
sqrt-pow144.3%
metadata-eval44.3%
pow144.3%
sqrt-pow161.8%
metadata-eval61.8%
pow161.8%
Applied egg-rr61.8%
frac-times47.7%
unpow247.7%
unpow247.7%
rem-cube-cbrt47.7%
pow147.7%
rem-cube-cbrt47.7%
unpow247.7%
unpow247.7%
frac-times61.8%
associate-*r*61.8%
pow261.8%
pow-prod-down71.7%
associate-/l*69.2%
Applied egg-rr69.2%
unpow169.2%
associate-*r/67.7%
Simplified67.7%
Taylor expanded in h around 0 70.3%
if 1.65000000000000003e115 < d Initial program 85.1%
Simplified88.9%
Taylor expanded in D around 0 87.4%
Final simplification73.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 (let* ((t_0 (* D_m (/ M_m d)))) (if (<= d 3.6e+100) (+ w0 (* -0.125 (* (* t_0 t_0) (* h (/ w0 l))))) 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 t_0 = D_m * (M_m / d);
double tmp;
if (d <= 3.6e+100) {
tmp = w0 + (-0.125 * ((t_0 * t_0) * (h * (w0 / l))));
} else {
tmp = 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) :: t_0
real(8) :: tmp
t_0 = d_m * (m_m / d)
if (d <= 3.6d+100) 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);
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 t_0 = D_m * (M_m / d);
double tmp;
if (d <= 3.6e+100) {
tmp = w0 + (-0.125 * ((t_0 * t_0) * (h * (w0 / l))));
} 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): t_0 = D_m * (M_m / d) tmp = 0 if d <= 3.6e+100: tmp = w0 + (-0.125 * ((t_0 * t_0) * (h * (w0 / l)))) 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) t_0 = Float64(D_m * Float64(M_m / d)) tmp = 0.0 if (d <= 3.6e+100) 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);
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)
t_0 = D_m * (M_m / d);
tmp = 0.0;
if (d <= 3.6e+100)
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]
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_] := Block[{t$95$0 = N[(D$95$m * N[(M$95$m / d), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, 3.6e+100], 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|
\\
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}
t_0 := D\_m \cdot \frac{M\_m}{d}\\
\mathbf{if}\;d \leq 3.6 \cdot 10^{+100}:\\
\;\;\;\;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 < 3.6e100Initial program 80.0%
Simplified82.0%
Taylor expanded in D around 0 47.9%
associate-/l*47.4%
times-frac47.4%
Simplified47.4%
add-sqr-sqrt47.4%
sqrt-div47.4%
sqrt-pow137.5%
metadata-eval37.5%
pow137.5%
sqrt-pow138.1%
metadata-eval38.1%
pow138.1%
sqrt-div38.1%
sqrt-pow143.9%
metadata-eval43.9%
pow143.9%
sqrt-pow161.8%
metadata-eval61.8%
pow161.8%
Applied egg-rr61.8%
frac-times47.4%
unpow247.4%
unpow247.4%
rem-cube-cbrt47.4%
pow147.4%
rem-cube-cbrt47.4%
unpow247.4%
unpow247.4%
frac-times61.8%
associate-*r*61.8%
pow261.8%
pow-prod-down72.0%
associate-/l*69.8%
Applied egg-rr69.8%
unpow169.8%
associate-*r/68.3%
Simplified68.3%
unpow268.3%
associate-/l*68.3%
associate-/l*69.8%
Applied egg-rr69.8%
if 3.6e100 < d Initial program 84.8%
Simplified88.2%
Taylor expanded in D around 0 85.2%
Final simplification73.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 81.1%
Simplified83.4%
Taylor expanded in D around 0 66.1%
Final simplification66.1%
herbie shell --seed 2024131
(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))))))