
(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}
d_m = (fabs.f64 d)
w0_m = (fabs.f64 w0)
w0_s = (copysign.f64 1 w0)
(FPCore (w0_s w0_m M D h l d_m)
:precision binary64
(let* ((t_0 (* (pow (/ (* M D) (* 2.0 d_m)) 2.0) (/ h l))))
(*
w0_s
(if (<= t_0 (- INFINITY))
(pow
(*
(sqrt w0_m)
(exp
(*
0.25
(+
(log (* 0.25 (/ (* (pow (* M D) 2.0) (- h)) l)))
(* -2.0 (log d_m))))))
2.0)
(if (<= t_0 1e-6) (* w0_m (sqrt (- 1.0 t_0))) w0_m)))))d_m = fabs(d);
w0_m = fabs(w0);
w0_s = copysign(1.0, w0);
double code(double w0_s, double w0_m, double M, double D, double h, double l, double d_m) {
double t_0 = pow(((M * D) / (2.0 * d_m)), 2.0) * (h / l);
double tmp;
if (t_0 <= -((double) INFINITY)) {
tmp = pow((sqrt(w0_m) * exp((0.25 * (log((0.25 * ((pow((M * D), 2.0) * -h) / l))) + (-2.0 * log(d_m)))))), 2.0);
} else if (t_0 <= 1e-6) {
tmp = w0_m * sqrt((1.0 - t_0));
} else {
tmp = w0_m;
}
return w0_s * tmp;
}
d_m = Math.abs(d);
w0_m = Math.abs(w0);
w0_s = Math.copySign(1.0, w0);
public static double code(double w0_s, double w0_m, double M, double D, double h, double l, double d_m) {
double t_0 = Math.pow(((M * D) / (2.0 * d_m)), 2.0) * (h / l);
double tmp;
if (t_0 <= -Double.POSITIVE_INFINITY) {
tmp = Math.pow((Math.sqrt(w0_m) * Math.exp((0.25 * (Math.log((0.25 * ((Math.pow((M * D), 2.0) * -h) / l))) + (-2.0 * Math.log(d_m)))))), 2.0);
} else if (t_0 <= 1e-6) {
tmp = w0_m * Math.sqrt((1.0 - t_0));
} else {
tmp = w0_m;
}
return w0_s * tmp;
}
d_m = math.fabs(d) w0_m = math.fabs(w0) w0_s = math.copysign(1.0, w0) def code(w0_s, w0_m, M, D, h, l, d_m): t_0 = math.pow(((M * D) / (2.0 * d_m)), 2.0) * (h / l) tmp = 0 if t_0 <= -math.inf: tmp = math.pow((math.sqrt(w0_m) * math.exp((0.25 * (math.log((0.25 * ((math.pow((M * D), 2.0) * -h) / l))) + (-2.0 * math.log(d_m)))))), 2.0) elif t_0 <= 1e-6: tmp = w0_m * math.sqrt((1.0 - t_0)) else: tmp = w0_m return w0_s * tmp
d_m = abs(d) w0_m = abs(w0) w0_s = copysign(1.0, w0) function code(w0_s, w0_m, M, D, h, l, d_m) t_0 = Float64((Float64(Float64(M * D) / Float64(2.0 * d_m)) ^ 2.0) * Float64(h / l)) tmp = 0.0 if (t_0 <= Float64(-Inf)) tmp = Float64(sqrt(w0_m) * exp(Float64(0.25 * Float64(log(Float64(0.25 * Float64(Float64((Float64(M * D) ^ 2.0) * Float64(-h)) / l))) + Float64(-2.0 * log(d_m)))))) ^ 2.0; elseif (t_0 <= 1e-6) tmp = Float64(w0_m * sqrt(Float64(1.0 - t_0))); else tmp = w0_m; end return Float64(w0_s * tmp) end
d_m = abs(d); w0_m = abs(w0); w0_s = sign(w0) * abs(1.0); function tmp_2 = code(w0_s, w0_m, M, D, h, l, d_m) t_0 = (((M * D) / (2.0 * d_m)) ^ 2.0) * (h / l); tmp = 0.0; if (t_0 <= -Inf) tmp = (sqrt(w0_m) * exp((0.25 * (log((0.25 * ((((M * D) ^ 2.0) * -h) / l))) + (-2.0 * log(d_m)))))) ^ 2.0; elseif (t_0 <= 1e-6) tmp = w0_m * sqrt((1.0 - t_0)); else tmp = w0_m; end tmp_2 = w0_s * tmp; end
d_m = N[Abs[d], $MachinePrecision]
w0_m = N[Abs[w0], $MachinePrecision]
w0_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[w0]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[w0$95$s_, w0$95$m_, M_, D_, h_, l_, d$95$m_] := Block[{t$95$0 = N[(N[Power[N[(N[(M * D), $MachinePrecision] / N[(2.0 * d$95$m), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]}, N[(w0$95$s * If[LessEqual[t$95$0, (-Infinity)], N[Power[N[(N[Sqrt[w0$95$m], $MachinePrecision] * N[Exp[N[(0.25 * N[(N[Log[N[(0.25 * N[(N[(N[Power[N[(M * D), $MachinePrecision], 2.0], $MachinePrecision] * (-h)), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] + N[(-2.0 * N[Log[d$95$m], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision], If[LessEqual[t$95$0, 1e-6], N[(w0$95$m * N[Sqrt[N[(1.0 - t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], w0$95$m]]), $MachinePrecision]]
\begin{array}{l}
d_m = \left|d\right|
\\
w0_m = \left|w0\right|
\\
w0_s = \mathsf{copysign}\left(1, w0\right)
\\
\begin{array}{l}
t_0 := {\left(\frac{M \cdot D}{2 \cdot d_m}\right)}^{2} \cdot \frac{h}{\ell}\\
w0_s \cdot \begin{array}{l}
\mathbf{if}\;t_0 \leq -\infty:\\
\;\;\;\;{\left(\sqrt{w0_m} \cdot e^{0.25 \cdot \left(\log \left(0.25 \cdot \frac{{\left(M \cdot D\right)}^{2} \cdot \left(-h\right)}{\ell}\right) + -2 \cdot \log d_m\right)}\right)}^{2}\\
\mathbf{elif}\;t_0 \leq 10^{-6}:\\
\;\;\;\;w0_m \cdot \sqrt{1 - t_0}\\
\mathbf{else}:\\
\;\;\;\;w0_m\\
\end{array}
\end{array}
\end{array}
if (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 2 d)) 2) (/.f64 h l)) < -inf.0Initial program 60.7%
Simplified65.0%
Applied egg-rr36.2%
Taylor expanded in d around 0 16.4%
expm1-log1p-u10.4%
expm1-udef10.4%
associate-*r*10.4%
pow-prod-down10.4%
Applied egg-rr10.4%
expm1-def11.8%
expm1-log1p19.0%
*-commutative19.0%
Simplified19.0%
if -inf.0 < (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 2 d)) 2) (/.f64 h l)) < 9.99999999999999955e-7Initial program 99.9%
if 9.99999999999999955e-7 < (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 2 d)) 2) (/.f64 h l)) Initial program 0.0%
Simplified28.6%
Taylor expanded in M around 0 67.2%
Final simplification76.6%
d_m = (fabs.f64 d)
w0_m = (fabs.f64 w0)
w0_s = (copysign.f64 1 w0)
(FPCore (w0_s w0_m M D h l d_m)
:precision binary64
(let* ((t_0 (* (pow (/ (* M D) (* 2.0 d_m)) 2.0) (/ h l))))
(*
w0_s
(if (<= t_0 (- INFINITY))
(pow
(*
(sqrt w0_m)
(exp
(*
0.25
(+
(* -2.0 (log d_m))
(log (* -0.25 (* (/ h l) (pow (* M D) 2.0))))))))
2.0)
(if (<= t_0 1e-6) (* w0_m (sqrt (- 1.0 t_0))) w0_m)))))d_m = fabs(d);
w0_m = fabs(w0);
w0_s = copysign(1.0, w0);
double code(double w0_s, double w0_m, double M, double D, double h, double l, double d_m) {
double t_0 = pow(((M * D) / (2.0 * d_m)), 2.0) * (h / l);
double tmp;
if (t_0 <= -((double) INFINITY)) {
tmp = pow((sqrt(w0_m) * exp((0.25 * ((-2.0 * log(d_m)) + log((-0.25 * ((h / l) * pow((M * D), 2.0)))))))), 2.0);
} else if (t_0 <= 1e-6) {
tmp = w0_m * sqrt((1.0 - t_0));
} else {
tmp = w0_m;
}
return w0_s * tmp;
}
d_m = Math.abs(d);
w0_m = Math.abs(w0);
w0_s = Math.copySign(1.0, w0);
public static double code(double w0_s, double w0_m, double M, double D, double h, double l, double d_m) {
double t_0 = Math.pow(((M * D) / (2.0 * d_m)), 2.0) * (h / l);
double tmp;
if (t_0 <= -Double.POSITIVE_INFINITY) {
tmp = Math.pow((Math.sqrt(w0_m) * Math.exp((0.25 * ((-2.0 * Math.log(d_m)) + Math.log((-0.25 * ((h / l) * Math.pow((M * D), 2.0)))))))), 2.0);
} else if (t_0 <= 1e-6) {
tmp = w0_m * Math.sqrt((1.0 - t_0));
} else {
tmp = w0_m;
}
return w0_s * tmp;
}
d_m = math.fabs(d) w0_m = math.fabs(w0) w0_s = math.copysign(1.0, w0) def code(w0_s, w0_m, M, D, h, l, d_m): t_0 = math.pow(((M * D) / (2.0 * d_m)), 2.0) * (h / l) tmp = 0 if t_0 <= -math.inf: tmp = math.pow((math.sqrt(w0_m) * math.exp((0.25 * ((-2.0 * math.log(d_m)) + math.log((-0.25 * ((h / l) * math.pow((M * D), 2.0)))))))), 2.0) elif t_0 <= 1e-6: tmp = w0_m * math.sqrt((1.0 - t_0)) else: tmp = w0_m return w0_s * tmp
d_m = abs(d) w0_m = abs(w0) w0_s = copysign(1.0, w0) function code(w0_s, w0_m, M, D, h, l, d_m) t_0 = Float64((Float64(Float64(M * D) / Float64(2.0 * d_m)) ^ 2.0) * Float64(h / l)) tmp = 0.0 if (t_0 <= Float64(-Inf)) tmp = Float64(sqrt(w0_m) * exp(Float64(0.25 * Float64(Float64(-2.0 * log(d_m)) + log(Float64(-0.25 * Float64(Float64(h / l) * (Float64(M * D) ^ 2.0)))))))) ^ 2.0; elseif (t_0 <= 1e-6) tmp = Float64(w0_m * sqrt(Float64(1.0 - t_0))); else tmp = w0_m; end return Float64(w0_s * tmp) end
d_m = abs(d); w0_m = abs(w0); w0_s = sign(w0) * abs(1.0); function tmp_2 = code(w0_s, w0_m, M, D, h, l, d_m) t_0 = (((M * D) / (2.0 * d_m)) ^ 2.0) * (h / l); tmp = 0.0; if (t_0 <= -Inf) tmp = (sqrt(w0_m) * exp((0.25 * ((-2.0 * log(d_m)) + log((-0.25 * ((h / l) * ((M * D) ^ 2.0)))))))) ^ 2.0; elseif (t_0 <= 1e-6) tmp = w0_m * sqrt((1.0 - t_0)); else tmp = w0_m; end tmp_2 = w0_s * tmp; end
d_m = N[Abs[d], $MachinePrecision]
w0_m = N[Abs[w0], $MachinePrecision]
w0_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[w0]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[w0$95$s_, w0$95$m_, M_, D_, h_, l_, d$95$m_] := Block[{t$95$0 = N[(N[Power[N[(N[(M * D), $MachinePrecision] / N[(2.0 * d$95$m), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]}, N[(w0$95$s * If[LessEqual[t$95$0, (-Infinity)], N[Power[N[(N[Sqrt[w0$95$m], $MachinePrecision] * N[Exp[N[(0.25 * N[(N[(-2.0 * N[Log[d$95$m], $MachinePrecision]), $MachinePrecision] + N[Log[N[(-0.25 * N[(N[(h / l), $MachinePrecision] * N[Power[N[(M * D), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision], If[LessEqual[t$95$0, 1e-6], N[(w0$95$m * N[Sqrt[N[(1.0 - t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], w0$95$m]]), $MachinePrecision]]
\begin{array}{l}
d_m = \left|d\right|
\\
w0_m = \left|w0\right|
\\
w0_s = \mathsf{copysign}\left(1, w0\right)
\\
\begin{array}{l}
t_0 := {\left(\frac{M \cdot D}{2 \cdot d_m}\right)}^{2} \cdot \frac{h}{\ell}\\
w0_s \cdot \begin{array}{l}
\mathbf{if}\;t_0 \leq -\infty:\\
\;\;\;\;{\left(\sqrt{w0_m} \cdot e^{0.25 \cdot \left(-2 \cdot \log d_m + \log \left(-0.25 \cdot \left(\frac{h}{\ell} \cdot {\left(M \cdot D\right)}^{2}\right)\right)\right)}\right)}^{2}\\
\mathbf{elif}\;t_0 \leq 10^{-6}:\\
\;\;\;\;w0_m \cdot \sqrt{1 - t_0}\\
\mathbf{else}:\\
\;\;\;\;w0_m\\
\end{array}
\end{array}
\end{array}
if (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 2 d)) 2) (/.f64 h l)) < -inf.0Initial program 60.7%
Simplified65.0%
Applied egg-rr36.2%
Taylor expanded in d around 0 16.4%
Taylor expanded in l around 0 6.1%
Simplified19.0%
if -inf.0 < (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 2 d)) 2) (/.f64 h l)) < 9.99999999999999955e-7Initial program 99.9%
if 9.99999999999999955e-7 < (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 2 d)) 2) (/.f64 h l)) Initial program 0.0%
Simplified28.6%
Taylor expanded in M around 0 67.2%
Final simplification76.6%
d_m = (fabs.f64 d)
w0_m = (fabs.f64 w0)
w0_s = (copysign.f64 1 w0)
(FPCore (w0_s w0_m M D h l d_m)
:precision binary64
(*
w0_s
(if (<= (* (pow (/ (* M D) (* 2.0 d_m)) 2.0) (/ h l)) 1e-6)
(* w0_m (sqrt (- 1.0 (* (/ h l) (pow (* D (/ M (* 2.0 d_m))) 2.0)))))
w0_m)))d_m = fabs(d);
w0_m = fabs(w0);
w0_s = copysign(1.0, w0);
double code(double w0_s, double w0_m, double M, double D, double h, double l, double d_m) {
double tmp;
if ((pow(((M * D) / (2.0 * d_m)), 2.0) * (h / l)) <= 1e-6) {
tmp = w0_m * sqrt((1.0 - ((h / l) * pow((D * (M / (2.0 * d_m))), 2.0))));
} else {
tmp = w0_m;
}
return w0_s * tmp;
}
d_m = abs(d)
w0_m = abs(w0)
w0_s = copysign(1.0d0, w0)
real(8) function code(w0_s, w0_m, m, d, h, l, d_m)
real(8), intent (in) :: w0_s
real(8), intent (in) :: w0_m
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_m
real(8) :: tmp
if (((((m * d) / (2.0d0 * d_m)) ** 2.0d0) * (h / l)) <= 1d-6) then
tmp = w0_m * sqrt((1.0d0 - ((h / l) * ((d * (m / (2.0d0 * d_m))) ** 2.0d0))))
else
tmp = w0_m
end if
code = w0_s * tmp
end function
d_m = Math.abs(d);
w0_m = Math.abs(w0);
w0_s = Math.copySign(1.0, w0);
public static double code(double w0_s, double w0_m, double M, double D, double h, double l, double d_m) {
double tmp;
if ((Math.pow(((M * D) / (2.0 * d_m)), 2.0) * (h / l)) <= 1e-6) {
tmp = w0_m * Math.sqrt((1.0 - ((h / l) * Math.pow((D * (M / (2.0 * d_m))), 2.0))));
} else {
tmp = w0_m;
}
return w0_s * tmp;
}
d_m = math.fabs(d) w0_m = math.fabs(w0) w0_s = math.copysign(1.0, w0) def code(w0_s, w0_m, M, D, h, l, d_m): tmp = 0 if (math.pow(((M * D) / (2.0 * d_m)), 2.0) * (h / l)) <= 1e-6: tmp = w0_m * math.sqrt((1.0 - ((h / l) * math.pow((D * (M / (2.0 * d_m))), 2.0)))) else: tmp = w0_m return w0_s * tmp
d_m = abs(d) w0_m = abs(w0) w0_s = copysign(1.0, w0) function code(w0_s, w0_m, M, D, h, l, d_m) tmp = 0.0 if (Float64((Float64(Float64(M * D) / Float64(2.0 * d_m)) ^ 2.0) * Float64(h / l)) <= 1e-6) tmp = Float64(w0_m * sqrt(Float64(1.0 - Float64(Float64(h / l) * (Float64(D * Float64(M / Float64(2.0 * d_m))) ^ 2.0))))); else tmp = w0_m; end return Float64(w0_s * tmp) end
d_m = abs(d); w0_m = abs(w0); w0_s = sign(w0) * abs(1.0); function tmp_2 = code(w0_s, w0_m, M, D, h, l, d_m) tmp = 0.0; if (((((M * D) / (2.0 * d_m)) ^ 2.0) * (h / l)) <= 1e-6) tmp = w0_m * sqrt((1.0 - ((h / l) * ((D * (M / (2.0 * d_m))) ^ 2.0)))); else tmp = w0_m; end tmp_2 = w0_s * tmp; end
d_m = N[Abs[d], $MachinePrecision]
w0_m = N[Abs[w0], $MachinePrecision]
w0_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[w0]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[w0$95$s_, w0$95$m_, M_, D_, h_, l_, d$95$m_] := N[(w0$95$s * If[LessEqual[N[(N[Power[N[(N[(M * D), $MachinePrecision] / N[(2.0 * d$95$m), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision], 1e-6], N[(w0$95$m * N[Sqrt[N[(1.0 - N[(N[(h / l), $MachinePrecision] * N[Power[N[(D * N[(M / N[(2.0 * d$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], w0$95$m]), $MachinePrecision]
\begin{array}{l}
d_m = \left|d\right|
\\
w0_m = \left|w0\right|
\\
w0_s = \mathsf{copysign}\left(1, w0\right)
\\
w0_s \cdot \begin{array}{l}
\mathbf{if}\;{\left(\frac{M \cdot D}{2 \cdot d_m}\right)}^{2} \cdot \frac{h}{\ell} \leq 10^{-6}:\\
\;\;\;\;w0_m \cdot \sqrt{1 - \frac{h}{\ell} \cdot {\left(D \cdot \frac{M}{2 \cdot d_m}\right)}^{2}}\\
\mathbf{else}:\\
\;\;\;\;w0_m\\
\end{array}
\end{array}
if (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 2 d)) 2) (/.f64 h l)) < 9.99999999999999955e-7Initial program 88.9%
Simplified88.5%
if 9.99999999999999955e-7 < (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 2 d)) 2) (/.f64 h l)) Initial program 0.0%
Simplified28.6%
Taylor expanded in M around 0 67.2%
Final simplification87.4%
d_m = (fabs.f64 d)
w0_m = (fabs.f64 w0)
w0_s = (copysign.f64 1 w0)
(FPCore (w0_s w0_m M D h l d_m)
:precision binary64
(*
w0_s
(if (<= h -5e-310)
(* w0_m (sqrt (- 1.0 (/ (* h (pow (* M (* D (/ 0.5 d_m))) 2.0)) l))))
(*
w0_m
(sqrt (- 1.0 (/ (pow (* (/ (* D 0.5) (/ d_m M)) (sqrt h)) 2.0) l)))))))d_m = fabs(d);
w0_m = fabs(w0);
w0_s = copysign(1.0, w0);
double code(double w0_s, double w0_m, double M, double D, double h, double l, double d_m) {
double tmp;
if (h <= -5e-310) {
tmp = w0_m * sqrt((1.0 - ((h * pow((M * (D * (0.5 / d_m))), 2.0)) / l)));
} else {
tmp = w0_m * sqrt((1.0 - (pow((((D * 0.5) / (d_m / M)) * sqrt(h)), 2.0) / l)));
}
return w0_s * tmp;
}
d_m = abs(d)
w0_m = abs(w0)
w0_s = copysign(1.0d0, w0)
real(8) function code(w0_s, w0_m, m, d, h, l, d_m)
real(8), intent (in) :: w0_s
real(8), intent (in) :: w0_m
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_m
real(8) :: tmp
if (h <= (-5d-310)) then
tmp = w0_m * sqrt((1.0d0 - ((h * ((m * (d * (0.5d0 / d_m))) ** 2.0d0)) / l)))
else
tmp = w0_m * sqrt((1.0d0 - (((((d * 0.5d0) / (d_m / m)) * sqrt(h)) ** 2.0d0) / l)))
end if
code = w0_s * tmp
end function
d_m = Math.abs(d);
w0_m = Math.abs(w0);
w0_s = Math.copySign(1.0, w0);
public static double code(double w0_s, double w0_m, double M, double D, double h, double l, double d_m) {
double tmp;
if (h <= -5e-310) {
tmp = w0_m * Math.sqrt((1.0 - ((h * Math.pow((M * (D * (0.5 / d_m))), 2.0)) / l)));
} else {
tmp = w0_m * Math.sqrt((1.0 - (Math.pow((((D * 0.5) / (d_m / M)) * Math.sqrt(h)), 2.0) / l)));
}
return w0_s * tmp;
}
d_m = math.fabs(d) w0_m = math.fabs(w0) w0_s = math.copysign(1.0, w0) def code(w0_s, w0_m, M, D, h, l, d_m): tmp = 0 if h <= -5e-310: tmp = w0_m * math.sqrt((1.0 - ((h * math.pow((M * (D * (0.5 / d_m))), 2.0)) / l))) else: tmp = w0_m * math.sqrt((1.0 - (math.pow((((D * 0.5) / (d_m / M)) * math.sqrt(h)), 2.0) / l))) return w0_s * tmp
d_m = abs(d) w0_m = abs(w0) w0_s = copysign(1.0, w0) function code(w0_s, w0_m, M, D, h, l, d_m) tmp = 0.0 if (h <= -5e-310) tmp = Float64(w0_m * sqrt(Float64(1.0 - Float64(Float64(h * (Float64(M * Float64(D * Float64(0.5 / d_m))) ^ 2.0)) / l)))); else tmp = Float64(w0_m * sqrt(Float64(1.0 - Float64((Float64(Float64(Float64(D * 0.5) / Float64(d_m / M)) * sqrt(h)) ^ 2.0) / l)))); end return Float64(w0_s * tmp) end
d_m = abs(d); w0_m = abs(w0); w0_s = sign(w0) * abs(1.0); function tmp_2 = code(w0_s, w0_m, M, D, h, l, d_m) tmp = 0.0; if (h <= -5e-310) tmp = w0_m * sqrt((1.0 - ((h * ((M * (D * (0.5 / d_m))) ^ 2.0)) / l))); else tmp = w0_m * sqrt((1.0 - (((((D * 0.5) / (d_m / M)) * sqrt(h)) ^ 2.0) / l))); end tmp_2 = w0_s * tmp; end
d_m = N[Abs[d], $MachinePrecision]
w0_m = N[Abs[w0], $MachinePrecision]
w0_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[w0]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[w0$95$s_, w0$95$m_, M_, D_, h_, l_, d$95$m_] := N[(w0$95$s * If[LessEqual[h, -5e-310], N[(w0$95$m * N[Sqrt[N[(1.0 - N[(N[(h * N[Power[N[(M * N[(D * N[(0.5 / d$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(w0$95$m * N[Sqrt[N[(1.0 - N[(N[Power[N[(N[(N[(D * 0.5), $MachinePrecision] / N[(d$95$m / M), $MachinePrecision]), $MachinePrecision] * N[Sqrt[h], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
d_m = \left|d\right|
\\
w0_m = \left|w0\right|
\\
w0_s = \mathsf{copysign}\left(1, w0\right)
\\
w0_s \cdot \begin{array}{l}
\mathbf{if}\;h \leq -5 \cdot 10^{-310}:\\
\;\;\;\;w0_m \cdot \sqrt{1 - \frac{h \cdot {\left(M \cdot \left(D \cdot \frac{0.5}{d_m}\right)\right)}^{2}}{\ell}}\\
\mathbf{else}:\\
\;\;\;\;w0_m \cdot \sqrt{1 - \frac{{\left(\frac{D \cdot 0.5}{\frac{d_m}{M}} \cdot \sqrt{h}\right)}^{2}}{\ell}}\\
\end{array}
\end{array}
if h < -4.999999999999985e-310Initial program 84.9%
Simplified85.7%
associate-*r/87.3%
frac-times86.5%
associate-*l/85.9%
div-inv85.9%
associate-*l*87.3%
associate-/r*87.3%
metadata-eval87.3%
Applied egg-rr87.3%
if -4.999999999999985e-310 < h Initial program 83.2%
Simplified87.8%
associate-*r/87.9%
frac-times84.3%
associate-*l/86.4%
div-inv86.4%
associate-*l*87.9%
associate-/r*87.9%
metadata-eval87.9%
Applied egg-rr87.9%
associate-*r*86.4%
*-commutative86.4%
expm1-log1p-u69.9%
expm1-udef69.2%
*-commutative69.2%
associate-*r*69.2%
associate-*l/69.2%
Applied egg-rr69.2%
expm1-def70.6%
expm1-log1p87.9%
*-commutative87.9%
Simplified87.9%
add-sqr-sqrt87.9%
pow287.9%
Applied egg-rr91.0%
associate-*l*90.2%
associate-*r/90.2%
Simplified90.2%
Taylor expanded in M around 0 88.1%
associate-*r*88.1%
associate-/l*91.7%
associate-*r/91.7%
*-commutative91.7%
Simplified91.7%
Final simplification89.5%
d_m = (fabs.f64 d) w0_m = (fabs.f64 w0) w0_s = (copysign.f64 1 w0) (FPCore (w0_s w0_m M D h l d_m) :precision binary64 (* w0_s (* w0_m (sqrt (- 1.0 (* (/ h l) (pow (* (/ M 2.0) (/ D d_m)) 2.0)))))))
d_m = fabs(d);
w0_m = fabs(w0);
w0_s = copysign(1.0, w0);
double code(double w0_s, double w0_m, double M, double D, double h, double l, double d_m) {
return w0_s * (w0_m * sqrt((1.0 - ((h / l) * pow(((M / 2.0) * (D / d_m)), 2.0)))));
}
d_m = abs(d)
w0_m = abs(w0)
w0_s = copysign(1.0d0, w0)
real(8) function code(w0_s, w0_m, m, d, h, l, d_m)
real(8), intent (in) :: w0_s
real(8), intent (in) :: w0_m
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_m
code = w0_s * (w0_m * sqrt((1.0d0 - ((h / l) * (((m / 2.0d0) * (d / d_m)) ** 2.0d0)))))
end function
d_m = Math.abs(d);
w0_m = Math.abs(w0);
w0_s = Math.copySign(1.0, w0);
public static double code(double w0_s, double w0_m, double M, double D, double h, double l, double d_m) {
return w0_s * (w0_m * Math.sqrt((1.0 - ((h / l) * Math.pow(((M / 2.0) * (D / d_m)), 2.0)))));
}
d_m = math.fabs(d) w0_m = math.fabs(w0) w0_s = math.copysign(1.0, w0) def code(w0_s, w0_m, M, D, h, l, d_m): return w0_s * (w0_m * math.sqrt((1.0 - ((h / l) * math.pow(((M / 2.0) * (D / d_m)), 2.0)))))
d_m = abs(d) w0_m = abs(w0) w0_s = copysign(1.0, w0) function code(w0_s, w0_m, M, D, h, l, d_m) return Float64(w0_s * Float64(w0_m * sqrt(Float64(1.0 - Float64(Float64(h / l) * (Float64(Float64(M / 2.0) * Float64(D / d_m)) ^ 2.0)))))) end
d_m = abs(d); w0_m = abs(w0); w0_s = sign(w0) * abs(1.0); function tmp = code(w0_s, w0_m, M, D, h, l, d_m) tmp = w0_s * (w0_m * sqrt((1.0 - ((h / l) * (((M / 2.0) * (D / d_m)) ^ 2.0))))); end
d_m = N[Abs[d], $MachinePrecision]
w0_m = N[Abs[w0], $MachinePrecision]
w0_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[w0]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[w0$95$s_, w0$95$m_, M_, D_, h_, l_, d$95$m_] := N[(w0$95$s * N[(w0$95$m * N[Sqrt[N[(1.0 - N[(N[(h / l), $MachinePrecision] * N[Power[N[(N[(M / 2.0), $MachinePrecision] * N[(D / d$95$m), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
d_m = \left|d\right|
\\
w0_m = \left|w0\right|
\\
w0_s = \mathsf{copysign}\left(1, w0\right)
\\
w0_s \cdot \left(w0_m \cdot \sqrt{1 - \frac{h}{\ell} \cdot {\left(\frac{M}{2} \cdot \frac{D}{d_m}\right)}^{2}}\right)
\end{array}
Initial program 84.1%
Simplified86.7%
Final simplification86.7%
d_m = (fabs.f64 d) w0_m = (fabs.f64 w0) w0_s = (copysign.f64 1 w0) (FPCore (w0_s w0_m M D h l d_m) :precision binary64 (* w0_s (if (<= M 5.8e+108) w0_m (log (exp w0_m)))))
d_m = fabs(d);
w0_m = fabs(w0);
w0_s = copysign(1.0, w0);
double code(double w0_s, double w0_m, double M, double D, double h, double l, double d_m) {
double tmp;
if (M <= 5.8e+108) {
tmp = w0_m;
} else {
tmp = log(exp(w0_m));
}
return w0_s * tmp;
}
d_m = abs(d)
w0_m = abs(w0)
w0_s = copysign(1.0d0, w0)
real(8) function code(w0_s, w0_m, m, d, h, l, d_m)
real(8), intent (in) :: w0_s
real(8), intent (in) :: w0_m
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_m
real(8) :: tmp
if (m <= 5.8d+108) then
tmp = w0_m
else
tmp = log(exp(w0_m))
end if
code = w0_s * tmp
end function
d_m = Math.abs(d);
w0_m = Math.abs(w0);
w0_s = Math.copySign(1.0, w0);
public static double code(double w0_s, double w0_m, double M, double D, double h, double l, double d_m) {
double tmp;
if (M <= 5.8e+108) {
tmp = w0_m;
} else {
tmp = Math.log(Math.exp(w0_m));
}
return w0_s * tmp;
}
d_m = math.fabs(d) w0_m = math.fabs(w0) w0_s = math.copysign(1.0, w0) def code(w0_s, w0_m, M, D, h, l, d_m): tmp = 0 if M <= 5.8e+108: tmp = w0_m else: tmp = math.log(math.exp(w0_m)) return w0_s * tmp
d_m = abs(d) w0_m = abs(w0) w0_s = copysign(1.0, w0) function code(w0_s, w0_m, M, D, h, l, d_m) tmp = 0.0 if (M <= 5.8e+108) tmp = w0_m; else tmp = log(exp(w0_m)); end return Float64(w0_s * tmp) end
d_m = abs(d); w0_m = abs(w0); w0_s = sign(w0) * abs(1.0); function tmp_2 = code(w0_s, w0_m, M, D, h, l, d_m) tmp = 0.0; if (M <= 5.8e+108) tmp = w0_m; else tmp = log(exp(w0_m)); end tmp_2 = w0_s * tmp; end
d_m = N[Abs[d], $MachinePrecision]
w0_m = N[Abs[w0], $MachinePrecision]
w0_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[w0]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[w0$95$s_, w0$95$m_, M_, D_, h_, l_, d$95$m_] := N[(w0$95$s * If[LessEqual[M, 5.8e+108], w0$95$m, N[Log[N[Exp[w0$95$m], $MachinePrecision]], $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
d_m = \left|d\right|
\\
w0_m = \left|w0\right|
\\
w0_s = \mathsf{copysign}\left(1, w0\right)
\\
w0_s \cdot \begin{array}{l}
\mathbf{if}\;M \leq 5.8 \cdot 10^{+108}:\\
\;\;\;\;w0_m\\
\mathbf{else}:\\
\;\;\;\;\log \left(e^{w0_m}\right)\\
\end{array}
\end{array}
if M < 5.80000000000000015e108Initial program 83.9%
Simplified86.1%
Taylor expanded in M around 0 72.0%
if 5.80000000000000015e108 < M Initial program 85.2%
Simplified91.1%
add-sqr-sqrt51.2%
sqrt-unprod43.5%
*-commutative43.5%
*-commutative43.5%
swap-sqr34.6%
Applied egg-rr34.6%
associate-*r/37.7%
associate-*l/37.7%
*-commutative37.7%
associate-*r*34.7%
*-commutative34.7%
Simplified34.7%
Taylor expanded in h around 0 17.8%
sqrt-pow136.9%
metadata-eval36.9%
pow136.9%
add-log-exp32.8%
Applied egg-rr32.8%
Final simplification67.0%
d_m = (fabs.f64 d) w0_m = (fabs.f64 w0) w0_s = (copysign.f64 1 w0) (FPCore (w0_s w0_m M D h l d_m) :precision binary64 (* w0_s w0_m))
d_m = fabs(d);
w0_m = fabs(w0);
w0_s = copysign(1.0, w0);
double code(double w0_s, double w0_m, double M, double D, double h, double l, double d_m) {
return w0_s * w0_m;
}
d_m = abs(d)
w0_m = abs(w0)
w0_s = copysign(1.0d0, w0)
real(8) function code(w0_s, w0_m, m, d, h, l, d_m)
real(8), intent (in) :: w0_s
real(8), intent (in) :: w0_m
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_m
code = w0_s * w0_m
end function
d_m = Math.abs(d);
w0_m = Math.abs(w0);
w0_s = Math.copySign(1.0, w0);
public static double code(double w0_s, double w0_m, double M, double D, double h, double l, double d_m) {
return w0_s * w0_m;
}
d_m = math.fabs(d) w0_m = math.fabs(w0) w0_s = math.copysign(1.0, w0) def code(w0_s, w0_m, M, D, h, l, d_m): return w0_s * w0_m
d_m = abs(d) w0_m = abs(w0) w0_s = copysign(1.0, w0) function code(w0_s, w0_m, M, D, h, l, d_m) return Float64(w0_s * w0_m) end
d_m = abs(d); w0_m = abs(w0); w0_s = sign(w0) * abs(1.0); function tmp = code(w0_s, w0_m, M, D, h, l, d_m) tmp = w0_s * w0_m; end
d_m = N[Abs[d], $MachinePrecision]
w0_m = N[Abs[w0], $MachinePrecision]
w0_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[w0]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[w0$95$s_, w0$95$m_, M_, D_, h_, l_, d$95$m_] := N[(w0$95$s * w0$95$m), $MachinePrecision]
\begin{array}{l}
d_m = \left|d\right|
\\
w0_m = \left|w0\right|
\\
w0_s = \mathsf{copysign}\left(1, w0\right)
\\
w0_s \cdot w0_m
\end{array}
Initial program 84.1%
Simplified86.7%
Taylor expanded in M around 0 67.5%
Final simplification67.5%
herbie shell --seed 2024011
(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))))))