
(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)
(FPCore (w0 M_m D_m h l d)
:precision binary64
(if (<= (* (pow (/ (* M_m D_m) (* 2.0 d)) 2.0) (/ h l)) (- INFINITY))
(*
w0
(exp
(*
(-
(+ (* 2.0 (log D_m)) (log (* -0.25 (/ (/ h (pow d 2.0)) l))))
(* -2.0 (log M_m)))
0.5)))
(* w0 (sqrt (- 1.0 (/ (* h (pow (* M_m (* D_m (/ 0.5 d))) 2.0)) l))))))M_m = fabs(M);
D_m = fabs(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)) <= -((double) INFINITY)) {
tmp = w0 * exp(((((2.0 * log(D_m)) + log((-0.25 * ((h / pow(d, 2.0)) / l)))) - (-2.0 * log(M_m))) * 0.5));
} else {
tmp = w0 * sqrt((1.0 - ((h * pow((M_m * (D_m * (0.5 / d))), 2.0)) / l)));
}
return tmp;
}
M_m = Math.abs(M);
D_m = Math.abs(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)) <= -Double.POSITIVE_INFINITY) {
tmp = w0 * Math.exp(((((2.0 * Math.log(D_m)) + Math.log((-0.25 * ((h / Math.pow(d, 2.0)) / l)))) - (-2.0 * Math.log(M_m))) * 0.5));
} else {
tmp = w0 * Math.sqrt((1.0 - ((h * Math.pow((M_m * (D_m * (0.5 / d))), 2.0)) / l)));
}
return tmp;
}
M_m = math.fabs(M) D_m = math.fabs(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)) <= -math.inf: tmp = w0 * math.exp(((((2.0 * math.log(D_m)) + math.log((-0.25 * ((h / math.pow(d, 2.0)) / l)))) - (-2.0 * math.log(M_m))) * 0.5)) else: tmp = w0 * math.sqrt((1.0 - ((h * math.pow((M_m * (D_m * (0.5 / d))), 2.0)) / l))) return tmp
M_m = abs(M) D_m = abs(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)) <= Float64(-Inf)) tmp = Float64(w0 * exp(Float64(Float64(Float64(Float64(2.0 * log(D_m)) + log(Float64(-0.25 * Float64(Float64(h / (d ^ 2.0)) / l)))) - Float64(-2.0 * log(M_m))) * 0.5))); else tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(h * (Float64(M_m * Float64(D_m * Float64(0.5 / d))) ^ 2.0)) / l)))); end return tmp end
M_m = abs(M); D_m = abs(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)) <= -Inf) tmp = w0 * exp(((((2.0 * log(D_m)) + log((-0.25 * ((h / (d ^ 2.0)) / l)))) - (-2.0 * log(M_m))) * 0.5)); else tmp = w0 * sqrt((1.0 - ((h * ((M_m * (D_m * (0.5 / d))) ^ 2.0)) / l))); end tmp_2 = tmp; end
M_m = N[Abs[M], $MachinePrecision] D_m = N[Abs[D], $MachinePrecision] 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], (-Infinity)], N[(w0 * N[Exp[N[(N[(N[(N[(2.0 * N[Log[D$95$m], $MachinePrecision]), $MachinePrecision] + N[Log[N[(-0.25 * N[(N[(h / N[Power[d, 2.0], $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(-2.0 * N[Log[M$95$m], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(w0 * N[Sqrt[N[(1.0 - N[(N[(h * N[Power[N[(M$95$m * N[(D$95$m * N[(0.5 / d), $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|
\\
\begin{array}{l}
\mathbf{if}\;{\left(\frac{M_m \cdot D_m}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell} \leq -\infty:\\
\;\;\;\;w0 \cdot e^{\left(\left(2 \cdot \log D_m + \log \left(-0.25 \cdot \frac{\frac{h}{{d}^{2}}}{\ell}\right)\right) - -2 \cdot \log M_m\right) \cdot 0.5}\\
\mathbf{else}:\\
\;\;\;\;w0 \cdot \sqrt{1 - \frac{h \cdot {\left(M_m \cdot \left(D_m \cdot \frac{0.5}{d}\right)\right)}^{2}}{\ell}}\\
\end{array}
\end{array}
if (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 2 d)) 2) (/.f64 h l)) < -inf.0Initial program 53.7%
Simplified53.7%
pow1/253.7%
*-commutative53.7%
frac-times53.7%
*-commutative53.7%
*-commutative53.7%
pow-to-exp53.7%
Applied egg-rr53.7%
Taylor expanded in M around inf 29.9%
associate-/r*30.5%
log-rec30.5%
Simplified30.5%
Taylor expanded in D around 0 19.6%
+-commutative19.6%
associate-/r*19.6%
Simplified19.6%
if -inf.0 < (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 2 d)) 2) (/.f64 h l)) Initial program 87.3%
Simplified87.8%
*-commutative87.8%
frac-times87.3%
*-commutative87.3%
associate-*l/97.3%
div-inv97.3%
associate-*l*97.2%
associate-/r*97.2%
metadata-eval97.2%
Applied egg-rr97.2%
Final simplification79.3%
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
(FPCore (w0 M_m D_m h l d)
:precision binary64
(if (<= (* (pow (/ (* M_m D_m) (* 2.0 d)) 2.0) (/ h l)) (- INFINITY))
(*
w0
(exp
(*
0.5
(+
(log (* -0.25 (/ h (* l (pow d 2.0)))))
(+ (* 2.0 (log D_m)) (* 2.0 (log M_m)))))))
(* w0 (sqrt (- 1.0 (/ (* h (pow (* M_m (* D_m (/ 0.5 d))) 2.0)) l))))))M_m = fabs(M);
D_m = fabs(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)) <= -((double) INFINITY)) {
tmp = w0 * exp((0.5 * (log((-0.25 * (h / (l * pow(d, 2.0))))) + ((2.0 * log(D_m)) + (2.0 * log(M_m))))));
} else {
tmp = w0 * sqrt((1.0 - ((h * pow((M_m * (D_m * (0.5 / d))), 2.0)) / l)));
}
return tmp;
}
M_m = Math.abs(M);
D_m = Math.abs(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)) <= -Double.POSITIVE_INFINITY) {
tmp = w0 * Math.exp((0.5 * (Math.log((-0.25 * (h / (l * Math.pow(d, 2.0))))) + ((2.0 * Math.log(D_m)) + (2.0 * Math.log(M_m))))));
} else {
tmp = w0 * Math.sqrt((1.0 - ((h * Math.pow((M_m * (D_m * (0.5 / d))), 2.0)) / l)));
}
return tmp;
}
M_m = math.fabs(M) D_m = math.fabs(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)) <= -math.inf: tmp = w0 * math.exp((0.5 * (math.log((-0.25 * (h / (l * math.pow(d, 2.0))))) + ((2.0 * math.log(D_m)) + (2.0 * math.log(M_m)))))) else: tmp = w0 * math.sqrt((1.0 - ((h * math.pow((M_m * (D_m * (0.5 / d))), 2.0)) / l))) return tmp
M_m = abs(M) D_m = abs(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)) <= Float64(-Inf)) tmp = Float64(w0 * exp(Float64(0.5 * Float64(log(Float64(-0.25 * Float64(h / Float64(l * (d ^ 2.0))))) + Float64(Float64(2.0 * log(D_m)) + Float64(2.0 * log(M_m))))))); else tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(h * (Float64(M_m * Float64(D_m * Float64(0.5 / d))) ^ 2.0)) / l)))); end return tmp end
M_m = abs(M); D_m = abs(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)) <= -Inf) tmp = w0 * exp((0.5 * (log((-0.25 * (h / (l * (d ^ 2.0))))) + ((2.0 * log(D_m)) + (2.0 * log(M_m)))))); else tmp = w0 * sqrt((1.0 - ((h * ((M_m * (D_m * (0.5 / d))) ^ 2.0)) / l))); end tmp_2 = tmp; end
M_m = N[Abs[M], $MachinePrecision] D_m = N[Abs[D], $MachinePrecision] 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], (-Infinity)], N[(w0 * N[Exp[N[(0.5 * N[(N[Log[N[(-0.25 * N[(h / N[(l * N[Power[d, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] + N[(N[(2.0 * N[Log[D$95$m], $MachinePrecision]), $MachinePrecision] + N[(2.0 * N[Log[M$95$m], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(w0 * N[Sqrt[N[(1.0 - N[(N[(h * N[Power[N[(M$95$m * N[(D$95$m * N[(0.5 / d), $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|
\\
\begin{array}{l}
\mathbf{if}\;{\left(\frac{M_m \cdot D_m}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell} \leq -\infty:\\
\;\;\;\;w0 \cdot e^{0.5 \cdot \left(\log \left(-0.25 \cdot \frac{h}{\ell \cdot {d}^{2}}\right) + \left(2 \cdot \log D_m + 2 \cdot \log M_m\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;w0 \cdot \sqrt{1 - \frac{h \cdot {\left(M_m \cdot \left(D_m \cdot \frac{0.5}{d}\right)\right)}^{2}}{\ell}}\\
\end{array}
\end{array}
if (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 2 d)) 2) (/.f64 h l)) < -inf.0Initial program 53.7%
Simplified53.7%
pow1/253.7%
*-commutative53.7%
frac-times53.7%
*-commutative53.7%
*-commutative53.7%
pow-to-exp53.7%
Applied egg-rr53.7%
Taylor expanded in M around inf 29.9%
associate-/r*30.5%
log-rec30.5%
Simplified30.5%
Taylor expanded in D around 0 19.6%
if -inf.0 < (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 2 d)) 2) (/.f64 h l)) Initial program 87.3%
Simplified87.8%
*-commutative87.8%
frac-times87.3%
*-commutative87.3%
associate-*l/97.3%
div-inv97.3%
associate-*l*97.2%
associate-/r*97.2%
metadata-eval97.2%
Applied egg-rr97.2%
Final simplification79.3%
M_m = (fabs.f64 M) D_m = (fabs.f64 D) (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-11) (* w0 (sqrt (- 1.0 (* (/ h l) (pow (* (/ D_m 2.0) (/ M_m d)) 2.0))))) w0))
M_m = fabs(M);
D_m = fabs(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-11) {
tmp = w0 * sqrt((1.0 - ((h / l) * pow(((D_m / 2.0) * (M_m / d)), 2.0))));
} else {
tmp = w0;
}
return tmp;
}
M_m = abs(M)
D_m = abs(D)
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-11)) then
tmp = w0 * sqrt((1.0d0 - ((h / l) * (((d_m / 2.0d0) * (m_m / d)) ** 2.0d0))))
else
tmp = w0
end if
code = tmp
end function
M_m = Math.abs(M);
D_m = Math.abs(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-11) {
tmp = w0 * Math.sqrt((1.0 - ((h / l) * Math.pow(((D_m / 2.0) * (M_m / d)), 2.0))));
} else {
tmp = w0;
}
return tmp;
}
M_m = math.fabs(M) D_m = math.fabs(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-11: tmp = w0 * math.sqrt((1.0 - ((h / l) * math.pow(((D_m / 2.0) * (M_m / d)), 2.0)))) else: tmp = w0 return tmp
M_m = abs(M) D_m = abs(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-11) tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(h / l) * (Float64(Float64(D_m / 2.0) * Float64(M_m / d)) ^ 2.0))))); else tmp = w0; end return tmp end
M_m = abs(M); D_m = abs(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-11) tmp = w0 * sqrt((1.0 - ((h / l) * (((D_m / 2.0) * (M_m / d)) ^ 2.0)))); else tmp = w0; end tmp_2 = tmp; end
M_m = N[Abs[M], $MachinePrecision] D_m = N[Abs[D], $MachinePrecision] 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-11], N[(w0 * N[Sqrt[N[(1.0 - N[(N[(h / l), $MachinePrecision] * N[Power[N[(N[(D$95$m / 2.0), $MachinePrecision] * N[(M$95$m / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], w0]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
\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^{-11}:\\
\;\;\;\;w0 \cdot \sqrt{1 - \frac{h}{\ell} \cdot {\left(\frac{D_m}{2} \cdot \frac{M_m}{d}\right)}^{2}}\\
\mathbf{else}:\\
\;\;\;\;w0\\
\end{array}
\end{array}
if (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 2 d)) 2) (/.f64 h l)) < -1.99999999999999988e-11Initial program 61.9%
Simplified61.9%
if -1.99999999999999988e-11 < (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 2 d)) 2) (/.f64 h l)) Initial program 86.4%
Simplified87.0%
Taylor expanded in D around 0 97.7%
Final simplification87.6%
M_m = (fabs.f64 M) D_m = (fabs.f64 D) (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);
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)
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);
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) 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) function code(w0, M_m, D_m, h, l, d) return Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(h * (Float64(M_m * Float64(D_m * Float64(0.5 / d))) ^ 2.0)) / l)))) end
M_m = abs(M); D_m = abs(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] code[w0_, M$95$m_, D$95$m_, h_, l_, d_] := N[(w0 * N[Sqrt[N[(1.0 - N[(N[(h * N[Power[N[(M$95$m * N[(D$95$m * N[(0.5 / d), $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|
\\
w0 \cdot \sqrt{1 - \frac{h \cdot {\left(M_m \cdot \left(D_m \cdot \frac{0.5}{d}\right)\right)}^{2}}{\ell}}
\end{array}
Initial program 79.5%
Simplified79.9%
*-commutative79.9%
frac-times79.5%
*-commutative79.5%
associate-*l/87.6%
div-inv87.6%
associate-*l*87.6%
associate-/r*87.6%
metadata-eval87.6%
Applied egg-rr87.6%
Final simplification87.6%
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
(FPCore (w0 M_m D_m h l d)
:precision binary64
(if (<= M_m 1.65e-35)
w0
(+
w0
(*
-0.125
(* (/ (* (* M_m D_m) (* M_m D_m)) (/ (pow d 2.0) h)) (/ w0 l))))))M_m = fabs(M);
D_m = fabs(D);
double code(double w0, double M_m, double D_m, double h, double l, double d) {
double tmp;
if (M_m <= 1.65e-35) {
tmp = w0;
} else {
tmp = w0 + (-0.125 * ((((M_m * D_m) * (M_m * D_m)) / (pow(d, 2.0) / h)) * (w0 / l)));
}
return tmp;
}
M_m = abs(M)
D_m = abs(D)
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 <= 1.65d-35) then
tmp = w0
else
tmp = w0 + ((-0.125d0) * ((((m_m * d_m) * (m_m * d_m)) / ((d ** 2.0d0) / h)) * (w0 / l)))
end if
code = tmp
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
public static double code(double w0, double M_m, double D_m, double h, double l, double d) {
double tmp;
if (M_m <= 1.65e-35) {
tmp = w0;
} else {
tmp = w0 + (-0.125 * ((((M_m * D_m) * (M_m * D_m)) / (Math.pow(d, 2.0) / h)) * (w0 / l)));
}
return tmp;
}
M_m = math.fabs(M) D_m = math.fabs(D) def code(w0, M_m, D_m, h, l, d): tmp = 0 if M_m <= 1.65e-35: tmp = w0 else: tmp = w0 + (-0.125 * ((((M_m * D_m) * (M_m * D_m)) / (math.pow(d, 2.0) / h)) * (w0 / l))) return tmp
M_m = abs(M) D_m = abs(D) function code(w0, M_m, D_m, h, l, d) tmp = 0.0 if (M_m <= 1.65e-35) tmp = w0; else tmp = Float64(w0 + Float64(-0.125 * Float64(Float64(Float64(Float64(M_m * D_m) * Float64(M_m * D_m)) / Float64((d ^ 2.0) / h)) * Float64(w0 / l)))); end return tmp end
M_m = abs(M); D_m = abs(D); function tmp_2 = code(w0, M_m, D_m, h, l, d) tmp = 0.0; if (M_m <= 1.65e-35) tmp = w0; else tmp = w0 + (-0.125 * ((((M_m * D_m) * (M_m * D_m)) / ((d ^ 2.0) / h)) * (w0 / l))); end tmp_2 = tmp; end
M_m = N[Abs[M], $MachinePrecision] D_m = N[Abs[D], $MachinePrecision] code[w0_, M$95$m_, D$95$m_, h_, l_, d_] := If[LessEqual[M$95$m, 1.65e-35], w0, N[(w0 + N[(-0.125 * N[(N[(N[(N[(M$95$m * D$95$m), $MachinePrecision] * N[(M$95$m * D$95$m), $MachinePrecision]), $MachinePrecision] / N[(N[Power[d, 2.0], $MachinePrecision] / h), $MachinePrecision]), $MachinePrecision] * N[(w0 / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
\begin{array}{l}
\mathbf{if}\;M_m \leq 1.65 \cdot 10^{-35}:\\
\;\;\;\;w0\\
\mathbf{else}:\\
\;\;\;\;w0 + -0.125 \cdot \left(\frac{\left(M_m \cdot D_m\right) \cdot \left(M_m \cdot D_m\right)}{\frac{{d}^{2}}{h}} \cdot \frac{w0}{\ell}\right)\\
\end{array}
\end{array}
if M < 1.65e-35Initial program 79.5%
Simplified78.9%
Taylor expanded in D around 0 76.2%
if 1.65e-35 < M Initial program 79.7%
Simplified83.0%
Taylor expanded in D around 0 48.5%
expm1-log1p-u39.8%
expm1-udef38.0%
associate-*r*39.7%
pow-prod-down44.7%
*-commutative44.7%
Applied egg-rr44.7%
expm1-def46.4%
expm1-log1p56.9%
associate-*r*60.2%
*-commutative60.2%
Simplified60.2%
times-frac56.9%
Applied egg-rr56.9%
associate-/l*58.5%
Simplified58.5%
unpow258.5%
Applied egg-rr58.5%
Final simplification72.0%
M_m = (fabs.f64 M) D_m = (fabs.f64 D) (FPCore (w0 M_m D_m h l d) :precision binary64 w0)
M_m = fabs(M);
D_m = fabs(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)
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);
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) def code(w0, M_m, D_m, h, l, d): return w0
M_m = abs(M) D_m = abs(D) function code(w0, M_m, D_m, h, l, d) return w0 end
M_m = abs(M); D_m = abs(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] 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
\end{array}
Initial program 79.5%
Simplified79.9%
Taylor expanded in D around 0 71.8%
Final simplification71.8%
herbie shell --seed 2024020
(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))))))