
(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 5 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}
NOTE: M should be positive before calling this function
NOTE: D should be positive before calling this function
NOTE: d should be positive before calling this function
NOTE: M and D should be sorted in increasing order before calling this function.
(FPCore (w0 M D h l d)
:precision binary64
(if (<= (* (pow (/ (* M D) (* 2.0 d)) 2.0) (/ h l)) (- INFINITY))
(*
w0
(pow
(exp
(*
0.25
(+
(log (* (/ h l) -0.25))
(+ (* -2.0 (log d)) (+ (* -2.0 (log (/ 1.0 D))) (* 2.0 (log M)))))))
2.0))
(* w0 (sqrt (- 1.0 (/ h (/ l (pow (* D (/ M (* 2.0 d))) 2.0))))))))M = abs(M);
D = abs(D);
d = abs(d);
assert(M < D);
double code(double w0, double M, double D, double h, double l, double d) {
double tmp;
if ((pow(((M * D) / (2.0 * d)), 2.0) * (h / l)) <= -((double) INFINITY)) {
tmp = w0 * pow(exp((0.25 * (log(((h / l) * -0.25)) + ((-2.0 * log(d)) + ((-2.0 * log((1.0 / D))) + (2.0 * log(M))))))), 2.0);
} else {
tmp = w0 * sqrt((1.0 - (h / (l / pow((D * (M / (2.0 * d))), 2.0)))));
}
return tmp;
}
M = Math.abs(M);
D = Math.abs(D);
d = Math.abs(d);
assert M < D;
public static double code(double w0, double M, double D, double h, double l, double d) {
double tmp;
if ((Math.pow(((M * D) / (2.0 * d)), 2.0) * (h / l)) <= -Double.POSITIVE_INFINITY) {
tmp = w0 * Math.pow(Math.exp((0.25 * (Math.log(((h / l) * -0.25)) + ((-2.0 * Math.log(d)) + ((-2.0 * Math.log((1.0 / D))) + (2.0 * Math.log(M))))))), 2.0);
} else {
tmp = w0 * Math.sqrt((1.0 - (h / (l / Math.pow((D * (M / (2.0 * d))), 2.0)))));
}
return tmp;
}
M = abs(M) D = abs(D) d = abs(d) [M, D] = sort([M, D]) def code(w0, M, D, h, l, d): tmp = 0 if (math.pow(((M * D) / (2.0 * d)), 2.0) * (h / l)) <= -math.inf: tmp = w0 * math.pow(math.exp((0.25 * (math.log(((h / l) * -0.25)) + ((-2.0 * math.log(d)) + ((-2.0 * math.log((1.0 / D))) + (2.0 * math.log(M))))))), 2.0) else: tmp = w0 * math.sqrt((1.0 - (h / (l / math.pow((D * (M / (2.0 * d))), 2.0))))) return tmp
M = abs(M) D = abs(D) d = abs(d) M, D = sort([M, D]) function code(w0, M, D, h, l, d) tmp = 0.0 if (Float64((Float64(Float64(M * D) / Float64(2.0 * d)) ^ 2.0) * Float64(h / l)) <= Float64(-Inf)) tmp = Float64(w0 * (exp(Float64(0.25 * Float64(log(Float64(Float64(h / l) * -0.25)) + Float64(Float64(-2.0 * log(d)) + Float64(Float64(-2.0 * log(Float64(1.0 / D))) + Float64(2.0 * log(M))))))) ^ 2.0)); else tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(h / Float64(l / (Float64(D * Float64(M / Float64(2.0 * d))) ^ 2.0)))))); end return tmp end
M = abs(M)
D = abs(D)
d = abs(d)
M, D = num2cell(sort([M, D])){:}
function tmp_2 = code(w0, M, D, h, l, d)
tmp = 0.0;
if (((((M * D) / (2.0 * d)) ^ 2.0) * (h / l)) <= -Inf)
tmp = w0 * (exp((0.25 * (log(((h / l) * -0.25)) + ((-2.0 * log(d)) + ((-2.0 * log((1.0 / D))) + (2.0 * log(M))))))) ^ 2.0);
else
tmp = w0 * sqrt((1.0 - (h / (l / ((D * (M / (2.0 * d))) ^ 2.0)))));
end
tmp_2 = tmp;
end
NOTE: M should be positive before calling this function NOTE: D should be positive before calling this function NOTE: d should be positive before calling this function NOTE: M and D should be sorted in increasing order before calling this function. code[w0_, M_, D_, h_, l_, d_] := If[LessEqual[N[(N[Power[N[(N[(M * D), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision], (-Infinity)], N[(w0 * N[Power[N[Exp[N[(0.25 * N[(N[Log[N[(N[(h / l), $MachinePrecision] * -0.25), $MachinePrecision]], $MachinePrecision] + N[(N[(-2.0 * N[Log[d], $MachinePrecision]), $MachinePrecision] + N[(N[(-2.0 * N[Log[N[(1.0 / D), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + N[(2.0 * N[Log[M], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision], N[(w0 * N[Sqrt[N[(1.0 - N[(h / N[(l / N[Power[N[(D * N[(M / N[(2.0 * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
M = |M|\\
D = |D|\\
d = |d|\\
[M, D] = \mathsf{sort}([M, D])\\
\\
\begin{array}{l}
\mathbf{if}\;{\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell} \leq -\infty:\\
\;\;\;\;w0 \cdot {\left(e^{0.25 \cdot \left(\log \left(\frac{h}{\ell} \cdot -0.25\right) + \left(-2 \cdot \log d + \left(-2 \cdot \log \left(\frac{1}{D}\right) + 2 \cdot \log M\right)\right)\right)}\right)}^{2}\\
\mathbf{else}:\\
\;\;\;\;w0 \cdot \sqrt{1 - \frac{h}{\frac{\ell}{{\left(D \cdot \frac{M}{2 \cdot d}\right)}^{2}}}}\\
\end{array}
\end{array}
if (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 2 d)) 2) (/.f64 h l)) < -inf.0Initial program 56.3%
Simplified56.2%
*-commutative56.2%
frac-times56.3%
*-commutative56.3%
*-commutative56.3%
add-sqr-sqrt56.3%
pow256.3%
Applied egg-rr56.3%
Taylor expanded in D around inf 20.2%
Taylor expanded in d around 0 8.5%
+-commutative8.5%
distribute-lft-neg-in8.5%
metadata-eval8.5%
associate-*r/8.4%
Simplified8.4%
Taylor expanded in M around 0 5.7%
if -inf.0 < (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 2 d)) 2) (/.f64 h l)) Initial program 84.3%
Simplified84.9%
associate-*r/94.3%
frac-times93.7%
*-commutative93.7%
clear-num93.7%
*-commutative93.7%
*-commutative93.7%
frac-times94.3%
frac-times93.7%
*-commutative93.7%
div-inv93.7%
*-commutative93.7%
associate-/r*93.7%
metadata-eval93.7%
Applied egg-rr93.7%
associate-/r/93.7%
*-commutative93.7%
associate-*r*94.3%
associate-*r/94.3%
/-rgt-identity94.3%
associate-/l*94.3%
metadata-eval94.3%
associate-/r*94.3%
associate-*r/93.7%
associate-*l/94.3%
*-commutative94.3%
Simplified94.3%
expm1-log1p-u94.1%
expm1-udef94.1%
Applied egg-rr94.1%
expm1-def94.1%
expm1-log1p94.3%
associate-/l*94.8%
associate-/l/94.8%
*-commutative94.8%
Simplified94.8%
Final simplification70.4%
NOTE: M should be positive before calling this function
NOTE: D should be positive before calling this function
NOTE: d should be positive before calling this function
NOTE: M and D should be sorted in increasing order before calling this function.
(FPCore (w0 M D h l d)
:precision binary64
(if (<= (* (pow (/ (* M D) (* 2.0 d)) 2.0) (/ h l)) (- INFINITY))
(*
w0
(pow
(pow
(exp 0.25)
(+ (log (* (/ h l) -0.25)) (* -2.0 (- (log d) (log (* M D))))))
2.0))
(* w0 (sqrt (- 1.0 (/ h (/ l (pow (* D (/ M (* 2.0 d))) 2.0))))))))M = abs(M);
D = abs(D);
d = abs(d);
assert(M < D);
double code(double w0, double M, double D, double h, double l, double d) {
double tmp;
if ((pow(((M * D) / (2.0 * d)), 2.0) * (h / l)) <= -((double) INFINITY)) {
tmp = w0 * pow(pow(exp(0.25), (log(((h / l) * -0.25)) + (-2.0 * (log(d) - log((M * D)))))), 2.0);
} else {
tmp = w0 * sqrt((1.0 - (h / (l / pow((D * (M / (2.0 * d))), 2.0)))));
}
return tmp;
}
M = Math.abs(M);
D = Math.abs(D);
d = Math.abs(d);
assert M < D;
public static double code(double w0, double M, double D, double h, double l, double d) {
double tmp;
if ((Math.pow(((M * D) / (2.0 * d)), 2.0) * (h / l)) <= -Double.POSITIVE_INFINITY) {
tmp = w0 * Math.pow(Math.pow(Math.exp(0.25), (Math.log(((h / l) * -0.25)) + (-2.0 * (Math.log(d) - Math.log((M * D)))))), 2.0);
} else {
tmp = w0 * Math.sqrt((1.0 - (h / (l / Math.pow((D * (M / (2.0 * d))), 2.0)))));
}
return tmp;
}
M = abs(M) D = abs(D) d = abs(d) [M, D] = sort([M, D]) def code(w0, M, D, h, l, d): tmp = 0 if (math.pow(((M * D) / (2.0 * d)), 2.0) * (h / l)) <= -math.inf: tmp = w0 * math.pow(math.pow(math.exp(0.25), (math.log(((h / l) * -0.25)) + (-2.0 * (math.log(d) - math.log((M * D)))))), 2.0) else: tmp = w0 * math.sqrt((1.0 - (h / (l / math.pow((D * (M / (2.0 * d))), 2.0))))) return tmp
M = abs(M) D = abs(D) d = abs(d) M, D = sort([M, D]) function code(w0, M, D, h, l, d) tmp = 0.0 if (Float64((Float64(Float64(M * D) / Float64(2.0 * d)) ^ 2.0) * Float64(h / l)) <= Float64(-Inf)) tmp = Float64(w0 * ((exp(0.25) ^ Float64(log(Float64(Float64(h / l) * -0.25)) + Float64(-2.0 * Float64(log(d) - log(Float64(M * D)))))) ^ 2.0)); else tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(h / Float64(l / (Float64(D * Float64(M / Float64(2.0 * d))) ^ 2.0)))))); end return tmp end
M = abs(M)
D = abs(D)
d = abs(d)
M, D = num2cell(sort([M, D])){:}
function tmp_2 = code(w0, M, D, h, l, d)
tmp = 0.0;
if (((((M * D) / (2.0 * d)) ^ 2.0) * (h / l)) <= -Inf)
tmp = w0 * ((exp(0.25) ^ (log(((h / l) * -0.25)) + (-2.0 * (log(d) - log((M * D)))))) ^ 2.0);
else
tmp = w0 * sqrt((1.0 - (h / (l / ((D * (M / (2.0 * d))) ^ 2.0)))));
end
tmp_2 = tmp;
end
NOTE: M should be positive before calling this function NOTE: D should be positive before calling this function NOTE: d should be positive before calling this function NOTE: M and D should be sorted in increasing order before calling this function. code[w0_, M_, D_, h_, l_, d_] := If[LessEqual[N[(N[Power[N[(N[(M * D), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision], (-Infinity)], N[(w0 * N[Power[N[Power[N[Exp[0.25], $MachinePrecision], N[(N[Log[N[(N[(h / l), $MachinePrecision] * -0.25), $MachinePrecision]], $MachinePrecision] + N[(-2.0 * N[(N[Log[d], $MachinePrecision] - N[Log[N[(M * D), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision], N[(w0 * N[Sqrt[N[(1.0 - N[(h / N[(l / N[Power[N[(D * N[(M / N[(2.0 * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
M = |M|\\
D = |D|\\
d = |d|\\
[M, D] = \mathsf{sort}([M, D])\\
\\
\begin{array}{l}
\mathbf{if}\;{\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell} \leq -\infty:\\
\;\;\;\;w0 \cdot {\left({\left(e^{0.25}\right)}^{\left(\log \left(\frac{h}{\ell} \cdot -0.25\right) + -2 \cdot \left(\log d - \log \left(M \cdot D\right)\right)\right)}\right)}^{2}\\
\mathbf{else}:\\
\;\;\;\;w0 \cdot \sqrt{1 - \frac{h}{\frac{\ell}{{\left(D \cdot \frac{M}{2 \cdot d}\right)}^{2}}}}\\
\end{array}
\end{array}
if (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 2 d)) 2) (/.f64 h l)) < -inf.0Initial program 56.3%
Simplified56.2%
*-commutative56.2%
frac-times56.3%
*-commutative56.3%
*-commutative56.3%
add-sqr-sqrt56.3%
pow256.3%
Applied egg-rr56.3%
Taylor expanded in D around inf 20.2%
Taylor expanded in d around 0 8.5%
+-commutative8.5%
distribute-lft-neg-in8.5%
metadata-eval8.5%
associate-*r/8.4%
Simplified8.4%
Taylor expanded in M around inf 5.7%
exp-prod5.5%
distribute-lft-out5.5%
distribute-lft-out5.5%
log-rec5.5%
log-rec5.5%
distribute-neg-out5.5%
log-prod15.6%
Simplified15.6%
if -inf.0 < (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 2 d)) 2) (/.f64 h l)) Initial program 84.3%
Simplified84.9%
associate-*r/94.3%
frac-times93.7%
*-commutative93.7%
clear-num93.7%
*-commutative93.7%
*-commutative93.7%
frac-times94.3%
frac-times93.7%
*-commutative93.7%
div-inv93.7%
*-commutative93.7%
associate-/r*93.7%
metadata-eval93.7%
Applied egg-rr93.7%
associate-/r/93.7%
*-commutative93.7%
associate-*r*94.3%
associate-*r/94.3%
/-rgt-identity94.3%
associate-/l*94.3%
metadata-eval94.3%
associate-/r*94.3%
associate-*r/93.7%
associate-*l/94.3%
*-commutative94.3%
Simplified94.3%
expm1-log1p-u94.1%
expm1-udef94.1%
Applied egg-rr94.1%
expm1-def94.1%
expm1-log1p94.3%
associate-/l*94.8%
associate-/l/94.8%
*-commutative94.8%
Simplified94.8%
Final simplification73.1%
NOTE: M should be positive before calling this function NOTE: D should be positive before calling this function NOTE: d should be positive before calling this function NOTE: M and D should be sorted in increasing order before calling this function. (FPCore (w0 M D h l d) :precision binary64 (* w0 (sqrt (- 1.0 (* h (/ (pow (/ M (* d (/ 2.0 D))) 2.0) l))))))
M = abs(M);
D = abs(D);
d = abs(d);
assert(M < D);
double code(double w0, double M, double D, double h, double l, double d) {
return w0 * sqrt((1.0 - (h * (pow((M / (d * (2.0 / D))), 2.0) / l))));
}
NOTE: M should be positive before calling this function
NOTE: D should be positive before calling this function
NOTE: d should be positive before calling this function
NOTE: M and D should be sorted in increasing order before calling this function.
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 - (h * (((m / (d_1 * (2.0d0 / d))) ** 2.0d0) / l))))
end function
M = Math.abs(M);
D = Math.abs(D);
d = Math.abs(d);
assert M < D;
public static double code(double w0, double M, double D, double h, double l, double d) {
return w0 * Math.sqrt((1.0 - (h * (Math.pow((M / (d * (2.0 / D))), 2.0) / l))));
}
M = abs(M) D = abs(D) d = abs(d) [M, D] = sort([M, D]) def code(w0, M, D, h, l, d): return w0 * math.sqrt((1.0 - (h * (math.pow((M / (d * (2.0 / D))), 2.0) / l))))
M = abs(M) D = abs(D) d = abs(d) M, D = sort([M, D]) function code(w0, M, D, h, l, d) return Float64(w0 * sqrt(Float64(1.0 - Float64(h * Float64((Float64(M / Float64(d * Float64(2.0 / D))) ^ 2.0) / l))))) end
M = abs(M)
D = abs(D)
d = abs(d)
M, D = num2cell(sort([M, D])){:}
function tmp = code(w0, M, D, h, l, d)
tmp = w0 * sqrt((1.0 - (h * (((M / (d * (2.0 / D))) ^ 2.0) / l))));
end
NOTE: M should be positive before calling this function NOTE: D should be positive before calling this function NOTE: d should be positive before calling this function NOTE: M and D should be sorted in increasing order before calling this function. code[w0_, M_, D_, h_, l_, d_] := N[(w0 * N[Sqrt[N[(1.0 - N[(h * N[(N[Power[N[(M / N[(d * N[(2.0 / D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
M = |M|\\
D = |D|\\
d = |d|\\
[M, D] = \mathsf{sort}([M, D])\\
\\
w0 \cdot \sqrt{1 - h \cdot \frac{{\left(\frac{M}{d \cdot \frac{2}{D}}\right)}^{2}}{\ell}}
\end{array}
Initial program 76.7%
Simplified77.1%
frac-times76.7%
*-commutative76.7%
clear-num76.7%
un-div-inv78.6%
*-commutative78.6%
frac-times79.1%
frac-times78.6%
*-commutative78.6%
div-inv78.6%
*-commutative78.6%
associate-/r*78.6%
metadata-eval78.6%
Applied egg-rr78.6%
associate-/r/85.3%
*-commutative85.3%
*-commutative85.3%
associate-*r*85.7%
associate-*r/85.7%
associate-*r/85.3%
/-rgt-identity85.3%
associate-/l*85.3%
metadata-eval85.3%
associate-*r/85.3%
associate-/l*85.3%
associate-/l/86.1%
Simplified86.1%
Final simplification86.1%
NOTE: M should be positive before calling this function NOTE: D should be positive before calling this function NOTE: d should be positive before calling this function NOTE: M and D should be sorted in increasing order before calling this function. (FPCore (w0 M D h l d) :precision binary64 (if (<= M 4.8e-74) w0 (+ w0 (* -0.125 (/ (* (* (* M D) (* M D)) (* h w0)) (* l (pow d 2.0)))))))
M = abs(M);
D = abs(D);
d = abs(d);
assert(M < D);
double code(double w0, double M, double D, double h, double l, double d) {
double tmp;
if (M <= 4.8e-74) {
tmp = w0;
} else {
tmp = w0 + (-0.125 * ((((M * D) * (M * D)) * (h * w0)) / (l * pow(d, 2.0))));
}
return tmp;
}
NOTE: M should be positive before calling this function
NOTE: D should be positive before calling this function
NOTE: d should be positive before calling this function
NOTE: M and D should be sorted in increasing order before calling this function.
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
real(8) :: tmp
if (m <= 4.8d-74) then
tmp = w0
else
tmp = w0 + ((-0.125d0) * ((((m * d) * (m * d)) * (h * w0)) / (l * (d_1 ** 2.0d0))))
end if
code = tmp
end function
M = Math.abs(M);
D = Math.abs(D);
d = Math.abs(d);
assert M < D;
public static double code(double w0, double M, double D, double h, double l, double d) {
double tmp;
if (M <= 4.8e-74) {
tmp = w0;
} else {
tmp = w0 + (-0.125 * ((((M * D) * (M * D)) * (h * w0)) / (l * Math.pow(d, 2.0))));
}
return tmp;
}
M = abs(M) D = abs(D) d = abs(d) [M, D] = sort([M, D]) def code(w0, M, D, h, l, d): tmp = 0 if M <= 4.8e-74: tmp = w0 else: tmp = w0 + (-0.125 * ((((M * D) * (M * D)) * (h * w0)) / (l * math.pow(d, 2.0)))) return tmp
M = abs(M) D = abs(D) d = abs(d) M, D = sort([M, D]) function code(w0, M, D, h, l, d) tmp = 0.0 if (M <= 4.8e-74) tmp = w0; else tmp = Float64(w0 + Float64(-0.125 * Float64(Float64(Float64(Float64(M * D) * Float64(M * D)) * Float64(h * w0)) / Float64(l * (d ^ 2.0))))); end return tmp end
M = abs(M)
D = abs(D)
d = abs(d)
M, D = num2cell(sort([M, D])){:}
function tmp_2 = code(w0, M, D, h, l, d)
tmp = 0.0;
if (M <= 4.8e-74)
tmp = w0;
else
tmp = w0 + (-0.125 * ((((M * D) * (M * D)) * (h * w0)) / (l * (d ^ 2.0))));
end
tmp_2 = tmp;
end
NOTE: M should be positive before calling this function NOTE: D should be positive before calling this function NOTE: d should be positive before calling this function NOTE: M and D should be sorted in increasing order before calling this function. code[w0_, M_, D_, h_, l_, d_] := If[LessEqual[M, 4.8e-74], w0, N[(w0 + N[(-0.125 * N[(N[(N[(N[(M * D), $MachinePrecision] * N[(M * D), $MachinePrecision]), $MachinePrecision] * N[(h * w0), $MachinePrecision]), $MachinePrecision] / N[(l * N[Power[d, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
M = |M|\\
D = |D|\\
d = |d|\\
[M, D] = \mathsf{sort}([M, D])\\
\\
\begin{array}{l}
\mathbf{if}\;M \leq 4.8 \cdot 10^{-74}:\\
\;\;\;\;w0\\
\mathbf{else}:\\
\;\;\;\;w0 + -0.125 \cdot \frac{\left(\left(M \cdot D\right) \cdot \left(M \cdot D\right)\right) \cdot \left(h \cdot w0\right)}{\ell \cdot {d}^{2}}\\
\end{array}
\end{array}
if M < 4.7999999999999998e-74Initial program 76.4%
Simplified76.7%
Taylor expanded in D around 0 71.0%
if 4.7999999999999998e-74 < M Initial program 77.6%
Simplified78.2%
Taylor expanded in D around 0 41.5%
expm1-log1p-u32.2%
expm1-udef32.2%
associate-*r*32.2%
pow-prod-down37.0%
Applied egg-rr37.0%
expm1-def37.0%
expm1-log1p46.3%
Simplified46.3%
*-commutative46.3%
pow246.3%
Applied egg-rr46.3%
Final simplification64.6%
NOTE: M should be positive before calling this function NOTE: D should be positive before calling this function NOTE: d should be positive before calling this function NOTE: M and D should be sorted in increasing order before calling this function. (FPCore (w0 M D h l d) :precision binary64 w0)
M = abs(M);
D = abs(D);
d = abs(d);
assert(M < D);
double code(double w0, double M, double D, double h, double l, double d) {
return w0;
}
NOTE: M should be positive before calling this function
NOTE: D should be positive before calling this function
NOTE: d should be positive before calling this function
NOTE: M and D should be sorted in increasing order before calling this function.
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
end function
M = Math.abs(M);
D = Math.abs(D);
d = Math.abs(d);
assert M < D;
public static double code(double w0, double M, double D, double h, double l, double d) {
return w0;
}
M = abs(M) D = abs(D) d = abs(d) [M, D] = sort([M, D]) def code(w0, M, D, h, l, d): return w0
M = abs(M) D = abs(D) d = abs(d) M, D = sort([M, D]) function code(w0, M, D, h, l, d) return w0 end
M = abs(M)
D = abs(D)
d = abs(d)
M, D = num2cell(sort([M, D])){:}
function tmp = code(w0, M, D, h, l, d)
tmp = w0;
end
NOTE: M should be positive before calling this function NOTE: D should be positive before calling this function NOTE: d should be positive before calling this function NOTE: M and D should be sorted in increasing order before calling this function. code[w0_, M_, D_, h_, l_, d_] := w0
\begin{array}{l}
M = |M|\\
D = |D|\\
d = |d|\\
[M, D] = \mathsf{sort}([M, D])\\
\\
w0
\end{array}
Initial program 76.7%
Simplified77.1%
Taylor expanded in D around 0 65.7%
Final simplification65.7%
herbie shell --seed 2023312
(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))))))