
(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 8 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)
(FPCore (w0 M D h l d_m)
:precision binary64
(let* ((t_0 (pow (* M D) 2.0))
(t_1 (* (pow (/ (* M D) (* 2.0 d_m)) 2.0) (/ h l))))
(if (<= t_1 (- INFINITY))
(*
w0
(pow
(pow (exp 0.25) (+ (log (* -0.25 (/ (* h t_0) l))) (* -2.0 (log d_m))))
2.0))
(if (<= t_1 5e-39)
(* w0 (sqrt (- 1.0 t_1)))
(* w0 (sqrt (- 1.0 (* 0.25 (* (/ t_0 l) (/ h (pow d_m 2.0)))))))))))d_m = fabs(d);
double code(double w0, double M, double D, double h, double l, double d_m) {
double t_0 = pow((M * D), 2.0);
double t_1 = pow(((M * D) / (2.0 * d_m)), 2.0) * (h / l);
double tmp;
if (t_1 <= -((double) INFINITY)) {
tmp = w0 * pow(pow(exp(0.25), (log((-0.25 * ((h * t_0) / l))) + (-2.0 * log(d_m)))), 2.0);
} else if (t_1 <= 5e-39) {
tmp = w0 * sqrt((1.0 - t_1));
} else {
tmp = w0 * sqrt((1.0 - (0.25 * ((t_0 / l) * (h / pow(d_m, 2.0))))));
}
return tmp;
}
d_m = Math.abs(d);
public static double code(double w0, double M, double D, double h, double l, double d_m) {
double t_0 = Math.pow((M * D), 2.0);
double t_1 = Math.pow(((M * D) / (2.0 * d_m)), 2.0) * (h / l);
double tmp;
if (t_1 <= -Double.POSITIVE_INFINITY) {
tmp = w0 * Math.pow(Math.pow(Math.exp(0.25), (Math.log((-0.25 * ((h * t_0) / l))) + (-2.0 * Math.log(d_m)))), 2.0);
} else if (t_1 <= 5e-39) {
tmp = w0 * Math.sqrt((1.0 - t_1));
} else {
tmp = w0 * Math.sqrt((1.0 - (0.25 * ((t_0 / l) * (h / Math.pow(d_m, 2.0))))));
}
return tmp;
}
d_m = math.fabs(d) def code(w0, M, D, h, l, d_m): t_0 = math.pow((M * D), 2.0) t_1 = math.pow(((M * D) / (2.0 * d_m)), 2.0) * (h / l) tmp = 0 if t_1 <= -math.inf: tmp = w0 * math.pow(math.pow(math.exp(0.25), (math.log((-0.25 * ((h * t_0) / l))) + (-2.0 * math.log(d_m)))), 2.0) elif t_1 <= 5e-39: tmp = w0 * math.sqrt((1.0 - t_1)) else: tmp = w0 * math.sqrt((1.0 - (0.25 * ((t_0 / l) * (h / math.pow(d_m, 2.0)))))) return tmp
d_m = abs(d) function code(w0, M, D, h, l, d_m) t_0 = Float64(M * D) ^ 2.0 t_1 = Float64((Float64(Float64(M * D) / Float64(2.0 * d_m)) ^ 2.0) * Float64(h / l)) tmp = 0.0 if (t_1 <= Float64(-Inf)) tmp = Float64(w0 * ((exp(0.25) ^ Float64(log(Float64(-0.25 * Float64(Float64(h * t_0) / l))) + Float64(-2.0 * log(d_m)))) ^ 2.0)); elseif (t_1 <= 5e-39) tmp = Float64(w0 * sqrt(Float64(1.0 - t_1))); else tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(0.25 * Float64(Float64(t_0 / l) * Float64(h / (d_m ^ 2.0))))))); end return tmp end
d_m = abs(d); function tmp_2 = code(w0, M, D, h, l, d_m) t_0 = (M * D) ^ 2.0; t_1 = (((M * D) / (2.0 * d_m)) ^ 2.0) * (h / l); tmp = 0.0; if (t_1 <= -Inf) tmp = w0 * ((exp(0.25) ^ (log((-0.25 * ((h * t_0) / l))) + (-2.0 * log(d_m)))) ^ 2.0); elseif (t_1 <= 5e-39) tmp = w0 * sqrt((1.0 - t_1)); else tmp = w0 * sqrt((1.0 - (0.25 * ((t_0 / l) * (h / (d_m ^ 2.0)))))); end tmp_2 = tmp; end
d_m = N[Abs[d], $MachinePrecision]
code[w0_, M_, D_, h_, l_, d$95$m_] := Block[{t$95$0 = N[Power[N[(M * D), $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$1 = N[(N[Power[N[(N[(M * D), $MachinePrecision] / N[(2.0 * d$95$m), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, (-Infinity)], N[(w0 * N[Power[N[Power[N[Exp[0.25], $MachinePrecision], N[(N[Log[N[(-0.25 * N[(N[(h * t$95$0), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] + N[(-2.0 * N[Log[d$95$m], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 5e-39], N[(w0 * N[Sqrt[N[(1.0 - t$95$1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(w0 * N[Sqrt[N[(1.0 - N[(0.25 * N[(N[(t$95$0 / l), $MachinePrecision] * N[(h / N[Power[d$95$m, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
d_m = \left|d\right|
\\
\begin{array}{l}
t_0 := {\left(M \cdot D\right)}^{2}\\
t_1 := {\left(\frac{M \cdot D}{2 \cdot d\_m}\right)}^{2} \cdot \frac{h}{\ell}\\
\mathbf{if}\;t\_1 \leq -\infty:\\
\;\;\;\;w0 \cdot {\left({\left(e^{0.25}\right)}^{\left(\log \left(-0.25 \cdot \frac{h \cdot t\_0}{\ell}\right) + -2 \cdot \log d\_m\right)}\right)}^{2}\\
\mathbf{elif}\;t\_1 \leq 5 \cdot 10^{-39}:\\
\;\;\;\;w0 \cdot \sqrt{1 - t\_1}\\
\mathbf{else}:\\
\;\;\;\;w0 \cdot \sqrt{1 - 0.25 \cdot \left(\frac{t\_0}{\ell} \cdot \frac{h}{{d\_m}^{2}}\right)}\\
\end{array}
\end{array}
if (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 2 d)) 2) (/.f64 h l)) < -inf.0Initial program 54.3%
Simplified55.9%
Taylor expanded in D around 0 49.6%
*-un-lft-identity49.6%
add-sqr-sqrt23.8%
times-frac23.8%
sqrt-prod23.8%
unpow223.8%
sqrt-prod16.8%
add-sqr-sqrt16.8%
associate-*r*16.8%
*-commutative16.8%
pow-prod-down18.5%
sqrt-prod18.5%
unpow218.5%
sqrt-prod18.7%
add-sqr-sqrt30.9%
Applied egg-rr30.9%
Applied egg-rr24.1%
Taylor expanded in d around 0 35.0%
exp-prod34.7%
associate-*r*34.7%
unpow234.7%
unpow234.7%
swap-sqr36.4%
unpow236.4%
*-commutative36.4%
Simplified36.4%
if -inf.0 < (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 2 d)) 2) (/.f64 h l)) < 4.9999999999999998e-39Initial program 99.9%
if 4.9999999999999998e-39 < (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 2 d)) 2) (/.f64 h l)) Initial program 3.8%
Simplified7.7%
Taylor expanded in D around 0 51.5%
associate-*r*59.2%
*-commutative59.2%
times-frac59.2%
pow-prod-down73.8%
Applied egg-rr73.8%
Final simplification82.4%
d_m = (fabs.f64 d)
(FPCore (w0 M D h l d_m)
:precision binary64
(if (<=
(* w0 (sqrt (- 1.0 (* (pow (/ (* M D) (* 2.0 d_m)) 2.0) (/ h l)))))
INFINITY)
(* w0 (sqrt (- 1.0 (* (/ h l) (pow (* (/ D 2.0) (/ M d_m)) 2.0)))))
w0))d_m = fabs(d);
double code(double w0, double M, double D, double h, double l, double d_m) {
double tmp;
if ((w0 * sqrt((1.0 - (pow(((M * D) / (2.0 * d_m)), 2.0) * (h / l))))) <= ((double) INFINITY)) {
tmp = w0 * sqrt((1.0 - ((h / l) * pow(((D / 2.0) * (M / d_m)), 2.0))));
} else {
tmp = w0;
}
return tmp;
}
d_m = Math.abs(d);
public static double code(double w0, double M, double D, double h, double l, double d_m) {
double tmp;
if ((w0 * Math.sqrt((1.0 - (Math.pow(((M * D) / (2.0 * d_m)), 2.0) * (h / l))))) <= Double.POSITIVE_INFINITY) {
tmp = w0 * Math.sqrt((1.0 - ((h / l) * Math.pow(((D / 2.0) * (M / d_m)), 2.0))));
} else {
tmp = w0;
}
return tmp;
}
d_m = math.fabs(d) def code(w0, M, D, h, l, d_m): tmp = 0 if (w0 * math.sqrt((1.0 - (math.pow(((M * D) / (2.0 * d_m)), 2.0) * (h / l))))) <= math.inf: tmp = w0 * math.sqrt((1.0 - ((h / l) * math.pow(((D / 2.0) * (M / d_m)), 2.0)))) else: tmp = w0 return tmp
d_m = abs(d) function code(w0, M, D, h, l, d_m) tmp = 0.0 if (Float64(w0 * sqrt(Float64(1.0 - Float64((Float64(Float64(M * D) / Float64(2.0 * d_m)) ^ 2.0) * Float64(h / l))))) <= Inf) tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(h / l) * (Float64(Float64(D / 2.0) * Float64(M / d_m)) ^ 2.0))))); else tmp = w0; end return tmp end
d_m = abs(d); function tmp_2 = code(w0, M, D, h, l, d_m) tmp = 0.0; if ((w0 * sqrt((1.0 - ((((M * D) / (2.0 * d_m)) ^ 2.0) * (h / l))))) <= Inf) tmp = w0 * sqrt((1.0 - ((h / l) * (((D / 2.0) * (M / d_m)) ^ 2.0)))); else tmp = w0; end tmp_2 = tmp; end
d_m = N[Abs[d], $MachinePrecision] code[w0_, M_, D_, h_, l_, d$95$m_] := If[LessEqual[N[(w0 * N[Sqrt[N[(1.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]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], Infinity], N[(w0 * N[Sqrt[N[(1.0 - N[(N[(h / l), $MachinePrecision] * N[Power[N[(N[(D / 2.0), $MachinePrecision] * N[(M / d$95$m), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], w0]
\begin{array}{l}
d_m = \left|d\right|
\\
\begin{array}{l}
\mathbf{if}\;w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d\_m}\right)}^{2} \cdot \frac{h}{\ell}} \leq \infty:\\
\;\;\;\;w0 \cdot \sqrt{1 - \frac{h}{\ell} \cdot {\left(\frac{D}{2} \cdot \frac{M}{d\_m}\right)}^{2}}\\
\mathbf{else}:\\
\;\;\;\;w0\\
\end{array}
\end{array}
if (*.f64 w0 (sqrt.f64 (-.f64 1 (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 2 d)) 2) (/.f64 h l))))) < +inf.0Initial program 88.1%
Simplified87.2%
if +inf.0 < (*.f64 w0 (sqrt.f64 (-.f64 1 (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 2 d)) 2) (/.f64 h l))))) Initial program 0.0%
Simplified4.0%
Taylor expanded in D around 0 68.9%
Final simplification85.4%
d_m = (fabs.f64 d)
(FPCore (w0 M D h l d_m)
:precision binary64
(let* ((t_0 (- 1.0 (* (pow (/ (* M D) (* 2.0 d_m)) 2.0) (/ h l)))))
(if (<= t_0 5e+257)
(* w0 (sqrt t_0))
(*
w0
(sqrt
(- 1.0 (* 0.25 (* (/ (pow (* M D) 2.0) l) (/ h (pow d_m 2.0))))))))))d_m = fabs(d);
double code(double w0, double M, double D, double h, double l, double d_m) {
double t_0 = 1.0 - (pow(((M * D) / (2.0 * d_m)), 2.0) * (h / l));
double tmp;
if (t_0 <= 5e+257) {
tmp = w0 * sqrt(t_0);
} else {
tmp = w0 * sqrt((1.0 - (0.25 * ((pow((M * D), 2.0) / l) * (h / pow(d_m, 2.0))))));
}
return tmp;
}
d_m = abs(d)
real(8) function code(w0, m, d, h, l, d_m)
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_m
real(8) :: t_0
real(8) :: tmp
t_0 = 1.0d0 - ((((m * d) / (2.0d0 * d_m)) ** 2.0d0) * (h / l))
if (t_0 <= 5d+257) then
tmp = w0 * sqrt(t_0)
else
tmp = w0 * sqrt((1.0d0 - (0.25d0 * ((((m * d) ** 2.0d0) / l) * (h / (d_m ** 2.0d0))))))
end if
code = tmp
end function
d_m = Math.abs(d);
public static double code(double w0, double M, double D, double h, double l, double d_m) {
double t_0 = 1.0 - (Math.pow(((M * D) / (2.0 * d_m)), 2.0) * (h / l));
double tmp;
if (t_0 <= 5e+257) {
tmp = w0 * Math.sqrt(t_0);
} else {
tmp = w0 * Math.sqrt((1.0 - (0.25 * ((Math.pow((M * D), 2.0) / l) * (h / Math.pow(d_m, 2.0))))));
}
return tmp;
}
d_m = math.fabs(d) def code(w0, M, D, h, l, d_m): t_0 = 1.0 - (math.pow(((M * D) / (2.0 * d_m)), 2.0) * (h / l)) tmp = 0 if t_0 <= 5e+257: tmp = w0 * math.sqrt(t_0) else: tmp = w0 * math.sqrt((1.0 - (0.25 * ((math.pow((M * D), 2.0) / l) * (h / math.pow(d_m, 2.0)))))) return tmp
d_m = abs(d) function code(w0, M, D, h, l, d_m) t_0 = Float64(1.0 - Float64((Float64(Float64(M * D) / Float64(2.0 * d_m)) ^ 2.0) * Float64(h / l))) tmp = 0.0 if (t_0 <= 5e+257) tmp = Float64(w0 * sqrt(t_0)); else tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(0.25 * Float64(Float64((Float64(M * D) ^ 2.0) / l) * Float64(h / (d_m ^ 2.0))))))); end return tmp end
d_m = abs(d); function tmp_2 = code(w0, M, D, h, l, d_m) t_0 = 1.0 - ((((M * D) / (2.0 * d_m)) ^ 2.0) * (h / l)); tmp = 0.0; if (t_0 <= 5e+257) tmp = w0 * sqrt(t_0); else tmp = w0 * sqrt((1.0 - (0.25 * ((((M * D) ^ 2.0) / l) * (h / (d_m ^ 2.0)))))); end tmp_2 = tmp; end
d_m = N[Abs[d], $MachinePrecision]
code[w0_, M_, D_, h_, l_, d$95$m_] := Block[{t$95$0 = N[(1.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]), $MachinePrecision]}, If[LessEqual[t$95$0, 5e+257], N[(w0 * N[Sqrt[t$95$0], $MachinePrecision]), $MachinePrecision], N[(w0 * N[Sqrt[N[(1.0 - N[(0.25 * N[(N[(N[Power[N[(M * D), $MachinePrecision], 2.0], $MachinePrecision] / l), $MachinePrecision] * N[(h / N[Power[d$95$m, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
d_m = \left|d\right|
\\
\begin{array}{l}
t_0 := 1 - {\left(\frac{M \cdot D}{2 \cdot d\_m}\right)}^{2} \cdot \frac{h}{\ell}\\
\mathbf{if}\;t\_0 \leq 5 \cdot 10^{+257}:\\
\;\;\;\;w0 \cdot \sqrt{t\_0}\\
\mathbf{else}:\\
\;\;\;\;w0 \cdot \sqrt{1 - 0.25 \cdot \left(\frac{{\left(M \cdot D\right)}^{2}}{\ell} \cdot \frac{h}{{d\_m}^{2}}\right)}\\
\end{array}
\end{array}
if (-.f64 1 (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 2 d)) 2) (/.f64 h l))) < 5.00000000000000028e257Initial program 99.9%
if 5.00000000000000028e257 < (-.f64 1 (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 2 d)) 2) (/.f64 h l))) Initial program 39.7%
Simplified42.0%
Taylor expanded in D around 0 48.5%
associate-*r*50.9%
*-commutative50.9%
times-frac52.1%
pow-prod-down62.5%
Applied egg-rr62.5%
Final simplification87.2%
d_m = (fabs.f64 d) (FPCore (w0 M D h l d_m) :precision binary64 (if (<= h -2e-309) (* w0 (sqrt (- 1.0 (/ (* h (pow (* M (* D (/ 0.5 d_m))) 2.0)) l)))) (* w0 (sqrt (- 1.0 (/ (pow (* D (* M (* (/ 0.5 d_m) (sqrt h)))) 2.0) l))))))
d_m = fabs(d);
double code(double w0, double M, double D, double h, double l, double d_m) {
double tmp;
if (h <= -2e-309) {
tmp = w0 * sqrt((1.0 - ((h * pow((M * (D * (0.5 / d_m))), 2.0)) / l)));
} else {
tmp = w0 * sqrt((1.0 - (pow((D * (M * ((0.5 / d_m) * sqrt(h)))), 2.0) / l)));
}
return tmp;
}
d_m = abs(d)
real(8) function code(w0, m, d, h, l, d_m)
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_m
real(8) :: tmp
if (h <= (-2d-309)) then
tmp = w0 * sqrt((1.0d0 - ((h * ((m * (d * (0.5d0 / d_m))) ** 2.0d0)) / l)))
else
tmp = w0 * sqrt((1.0d0 - (((d * (m * ((0.5d0 / d_m) * sqrt(h)))) ** 2.0d0) / l)))
end if
code = tmp
end function
d_m = Math.abs(d);
public static double code(double w0, double M, double D, double h, double l, double d_m) {
double tmp;
if (h <= -2e-309) {
tmp = w0 * Math.sqrt((1.0 - ((h * Math.pow((M * (D * (0.5 / d_m))), 2.0)) / l)));
} else {
tmp = w0 * Math.sqrt((1.0 - (Math.pow((D * (M * ((0.5 / d_m) * Math.sqrt(h)))), 2.0) / l)));
}
return tmp;
}
d_m = math.fabs(d) def code(w0, M, D, h, l, d_m): tmp = 0 if h <= -2e-309: tmp = w0 * math.sqrt((1.0 - ((h * math.pow((M * (D * (0.5 / d_m))), 2.0)) / l))) else: tmp = w0 * math.sqrt((1.0 - (math.pow((D * (M * ((0.5 / d_m) * math.sqrt(h)))), 2.0) / l))) return tmp
d_m = abs(d) function code(w0, M, D, h, l, d_m) tmp = 0.0 if (h <= -2e-309) tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(h * (Float64(M * Float64(D * Float64(0.5 / d_m))) ^ 2.0)) / l)))); else tmp = Float64(w0 * sqrt(Float64(1.0 - Float64((Float64(D * Float64(M * Float64(Float64(0.5 / d_m) * sqrt(h)))) ^ 2.0) / l)))); end return tmp end
d_m = abs(d); function tmp_2 = code(w0, M, D, h, l, d_m) tmp = 0.0; if (h <= -2e-309) tmp = w0 * sqrt((1.0 - ((h * ((M * (D * (0.5 / d_m))) ^ 2.0)) / l))); else tmp = w0 * sqrt((1.0 - (((D * (M * ((0.5 / d_m) * sqrt(h)))) ^ 2.0) / l))); end tmp_2 = tmp; end
d_m = N[Abs[d], $MachinePrecision] code[w0_, M_, D_, h_, l_, d$95$m_] := If[LessEqual[h, -2e-309], N[(w0 * 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 * N[Sqrt[N[(1.0 - N[(N[Power[N[(D * N[(M * N[(N[(0.5 / d$95$m), $MachinePrecision] * N[Sqrt[h], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
d_m = \left|d\right|
\\
\begin{array}{l}
\mathbf{if}\;h \leq -2 \cdot 10^{-309}:\\
\;\;\;\;w0 \cdot \sqrt{1 - \frac{h \cdot {\left(M \cdot \left(D \cdot \frac{0.5}{d\_m}\right)\right)}^{2}}{\ell}}\\
\mathbf{else}:\\
\;\;\;\;w0 \cdot \sqrt{1 - \frac{{\left(D \cdot \left(M \cdot \left(\frac{0.5}{d\_m} \cdot \sqrt{h}\right)\right)\right)}^{2}}{\ell}}\\
\end{array}
\end{array}
if h < -1.9999999999999988e-309Initial program 79.5%
Simplified80.4%
*-commutative80.4%
frac-times79.5%
*-commutative79.5%
associate-*l/82.9%
div-inv82.9%
associate-*l*84.5%
associate-/r*84.5%
metadata-eval84.5%
Applied egg-rr84.5%
if -1.9999999999999988e-309 < h Initial program 79.4%
Simplified77.9%
*-commutative77.9%
frac-times79.4%
*-commutative79.4%
associate-*l/86.5%
div-inv86.5%
associate-*l*85.3%
associate-/r*85.3%
metadata-eval85.3%
Applied egg-rr85.3%
add-sqr-sqrt85.2%
pow285.2%
*-commutative85.2%
sqrt-prod85.2%
unpow285.2%
sqrt-prod55.8%
add-sqr-sqrt88.7%
*-commutative88.7%
*-commutative88.7%
associate-*l*90.7%
Applied egg-rr90.7%
*-commutative90.7%
associate-*l*90.0%
Simplified90.0%
expm1-log1p-u76.5%
expm1-udef73.1%
associate-*l*73.8%
Applied egg-rr73.8%
expm1-def77.1%
expm1-log1p89.9%
*-commutative89.9%
Simplified89.9%
Final simplification87.3%
d_m = (fabs.f64 d) (FPCore (w0 M D h l d_m) :precision binary64 (if (<= h -2e-309) (* w0 (sqrt (- 1.0 (/ (* h (pow (* M (* D (/ 0.5 d_m))) 2.0)) l)))) (* w0 (sqrt (- 1.0 (/ (pow (* (* M D) (* (/ 0.5 d_m) (sqrt h))) 2.0) l))))))
d_m = fabs(d);
double code(double w0, double M, double D, double h, double l, double d_m) {
double tmp;
if (h <= -2e-309) {
tmp = w0 * sqrt((1.0 - ((h * pow((M * (D * (0.5 / d_m))), 2.0)) / l)));
} else {
tmp = w0 * sqrt((1.0 - (pow(((M * D) * ((0.5 / d_m) * sqrt(h))), 2.0) / l)));
}
return tmp;
}
d_m = abs(d)
real(8) function code(w0, m, d, h, l, d_m)
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_m
real(8) :: tmp
if (h <= (-2d-309)) then
tmp = w0 * sqrt((1.0d0 - ((h * ((m * (d * (0.5d0 / d_m))) ** 2.0d0)) / l)))
else
tmp = w0 * sqrt((1.0d0 - ((((m * d) * ((0.5d0 / d_m) * sqrt(h))) ** 2.0d0) / l)))
end if
code = tmp
end function
d_m = Math.abs(d);
public static double code(double w0, double M, double D, double h, double l, double d_m) {
double tmp;
if (h <= -2e-309) {
tmp = w0 * Math.sqrt((1.0 - ((h * Math.pow((M * (D * (0.5 / d_m))), 2.0)) / l)));
} else {
tmp = w0 * Math.sqrt((1.0 - (Math.pow(((M * D) * ((0.5 / d_m) * Math.sqrt(h))), 2.0) / l)));
}
return tmp;
}
d_m = math.fabs(d) def code(w0, M, D, h, l, d_m): tmp = 0 if h <= -2e-309: tmp = w0 * math.sqrt((1.0 - ((h * math.pow((M * (D * (0.5 / d_m))), 2.0)) / l))) else: tmp = w0 * math.sqrt((1.0 - (math.pow(((M * D) * ((0.5 / d_m) * math.sqrt(h))), 2.0) / l))) return tmp
d_m = abs(d) function code(w0, M, D, h, l, d_m) tmp = 0.0 if (h <= -2e-309) tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(h * (Float64(M * Float64(D * Float64(0.5 / d_m))) ^ 2.0)) / l)))); else tmp = Float64(w0 * sqrt(Float64(1.0 - Float64((Float64(Float64(M * D) * Float64(Float64(0.5 / d_m) * sqrt(h))) ^ 2.0) / l)))); end return tmp end
d_m = abs(d); function tmp_2 = code(w0, M, D, h, l, d_m) tmp = 0.0; if (h <= -2e-309) tmp = w0 * sqrt((1.0 - ((h * ((M * (D * (0.5 / d_m))) ^ 2.0)) / l))); else tmp = w0 * sqrt((1.0 - ((((M * D) * ((0.5 / d_m) * sqrt(h))) ^ 2.0) / l))); end tmp_2 = tmp; end
d_m = N[Abs[d], $MachinePrecision] code[w0_, M_, D_, h_, l_, d$95$m_] := If[LessEqual[h, -2e-309], N[(w0 * 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 * N[Sqrt[N[(1.0 - N[(N[Power[N[(N[(M * D), $MachinePrecision] * N[(N[(0.5 / d$95$m), $MachinePrecision] * N[Sqrt[h], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
d_m = \left|d\right|
\\
\begin{array}{l}
\mathbf{if}\;h \leq -2 \cdot 10^{-309}:\\
\;\;\;\;w0 \cdot \sqrt{1 - \frac{h \cdot {\left(M \cdot \left(D \cdot \frac{0.5}{d\_m}\right)\right)}^{2}}{\ell}}\\
\mathbf{else}:\\
\;\;\;\;w0 \cdot \sqrt{1 - \frac{{\left(\left(M \cdot D\right) \cdot \left(\frac{0.5}{d\_m} \cdot \sqrt{h}\right)\right)}^{2}}{\ell}}\\
\end{array}
\end{array}
if h < -1.9999999999999988e-309Initial program 79.5%
Simplified80.4%
*-commutative80.4%
frac-times79.5%
*-commutative79.5%
associate-*l/82.9%
div-inv82.9%
associate-*l*84.5%
associate-/r*84.5%
metadata-eval84.5%
Applied egg-rr84.5%
if -1.9999999999999988e-309 < h Initial program 79.4%
Simplified77.9%
*-commutative77.9%
frac-times79.4%
*-commutative79.4%
associate-*l/86.5%
div-inv86.5%
associate-*l*85.3%
associate-/r*85.3%
metadata-eval85.3%
Applied egg-rr85.3%
add-sqr-sqrt85.2%
pow285.2%
*-commutative85.2%
sqrt-prod85.2%
unpow285.2%
sqrt-prod55.8%
add-sqr-sqrt88.7%
*-commutative88.7%
*-commutative88.7%
associate-*l*90.7%
Applied egg-rr90.7%
*-commutative90.7%
associate-*l*90.0%
Simplified90.0%
Final simplification87.3%
d_m = (fabs.f64 d)
(FPCore (w0 M D h l d_m)
:precision binary64
(if (or (<= D 8e+16) (and (not (<= D 8e+114)) (<= D 2.4e+203)))
w0
(+
w0
(* w0 (* -0.125 (* (/ (* (* M D) (* M D)) l) (* h (pow d_m -2.0))))))))d_m = fabs(d);
double code(double w0, double M, double D, double h, double l, double d_m) {
double tmp;
if ((D <= 8e+16) || (!(D <= 8e+114) && (D <= 2.4e+203))) {
tmp = w0;
} else {
tmp = w0 + (w0 * (-0.125 * ((((M * D) * (M * D)) / l) * (h * pow(d_m, -2.0)))));
}
return tmp;
}
d_m = abs(d)
real(8) function code(w0, m, d, h, l, d_m)
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_m
real(8) :: tmp
if ((d <= 8d+16) .or. (.not. (d <= 8d+114)) .and. (d <= 2.4d+203)) then
tmp = w0
else
tmp = w0 + (w0 * ((-0.125d0) * ((((m * d) * (m * d)) / l) * (h * (d_m ** (-2.0d0))))))
end if
code = tmp
end function
d_m = Math.abs(d);
public static double code(double w0, double M, double D, double h, double l, double d_m) {
double tmp;
if ((D <= 8e+16) || (!(D <= 8e+114) && (D <= 2.4e+203))) {
tmp = w0;
} else {
tmp = w0 + (w0 * (-0.125 * ((((M * D) * (M * D)) / l) * (h * Math.pow(d_m, -2.0)))));
}
return tmp;
}
d_m = math.fabs(d) def code(w0, M, D, h, l, d_m): tmp = 0 if (D <= 8e+16) or (not (D <= 8e+114) and (D <= 2.4e+203)): tmp = w0 else: tmp = w0 + (w0 * (-0.125 * ((((M * D) * (M * D)) / l) * (h * math.pow(d_m, -2.0))))) return tmp
d_m = abs(d) function code(w0, M, D, h, l, d_m) tmp = 0.0 if ((D <= 8e+16) || (!(D <= 8e+114) && (D <= 2.4e+203))) tmp = w0; else tmp = Float64(w0 + Float64(w0 * Float64(-0.125 * Float64(Float64(Float64(Float64(M * D) * Float64(M * D)) / l) * Float64(h * (d_m ^ -2.0)))))); end return tmp end
d_m = abs(d); function tmp_2 = code(w0, M, D, h, l, d_m) tmp = 0.0; if ((D <= 8e+16) || (~((D <= 8e+114)) && (D <= 2.4e+203))) tmp = w0; else tmp = w0 + (w0 * (-0.125 * ((((M * D) * (M * D)) / l) * (h * (d_m ^ -2.0))))); end tmp_2 = tmp; end
d_m = N[Abs[d], $MachinePrecision] code[w0_, M_, D_, h_, l_, d$95$m_] := If[Or[LessEqual[D, 8e+16], And[N[Not[LessEqual[D, 8e+114]], $MachinePrecision], LessEqual[D, 2.4e+203]]], w0, N[(w0 + N[(w0 * N[(-0.125 * N[(N[(N[(N[(M * D), $MachinePrecision] * N[(M * D), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision] * N[(h * N[Power[d$95$m, -2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
d_m = \left|d\right|
\\
\begin{array}{l}
\mathbf{if}\;D \leq 8 \cdot 10^{+16} \lor \neg \left(D \leq 8 \cdot 10^{+114}\right) \land D \leq 2.4 \cdot 10^{+203}:\\
\;\;\;\;w0\\
\mathbf{else}:\\
\;\;\;\;w0 + w0 \cdot \left(-0.125 \cdot \left(\frac{\left(M \cdot D\right) \cdot \left(M \cdot D\right)}{\ell} \cdot \left(h \cdot {d\_m}^{-2}\right)\right)\right)\\
\end{array}
\end{array}
if D < 8e16 or 8e114 < D < 2.4000000000000001e203Initial program 79.6%
Simplified78.7%
Taylor expanded in D around 0 72.0%
if 8e16 < D < 8e114 or 2.4000000000000001e203 < D Initial program 78.6%
Simplified81.1%
Taylor expanded in D around 0 55.7%
*-commutative55.7%
associate-*r*55.7%
Simplified55.7%
expm1-log1p-u55.7%
expm1-udef53.2%
pow-prod-down63.3%
Applied egg-rr63.3%
expm1-def65.9%
expm1-log1p65.9%
Simplified65.9%
distribute-rgt-in65.9%
*-un-lft-identity65.9%
*-commutative65.9%
*-commutative65.9%
frac-times68.7%
div-inv68.7%
pow-flip68.7%
metadata-eval68.7%
Applied egg-rr68.7%
unpow231.9%
Applied egg-rr68.7%
Final simplification71.5%
d_m = (fabs.f64 d) (FPCore (w0 M D h l d_m) :precision binary64 (if (<= M 1.05e+75) w0 (* -0.125 (/ (* (* M D) (* M D)) (/ (* l (pow d_m 2.0)) (* h w0))))))
d_m = fabs(d);
double code(double w0, double M, double D, double h, double l, double d_m) {
double tmp;
if (M <= 1.05e+75) {
tmp = w0;
} else {
tmp = -0.125 * (((M * D) * (M * D)) / ((l * pow(d_m, 2.0)) / (h * w0)));
}
return tmp;
}
d_m = abs(d)
real(8) function code(w0, m, d, h, l, d_m)
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_m
real(8) :: tmp
if (m <= 1.05d+75) then
tmp = w0
else
tmp = (-0.125d0) * (((m * d) * (m * d)) / ((l * (d_m ** 2.0d0)) / (h * w0)))
end if
code = tmp
end function
d_m = Math.abs(d);
public static double code(double w0, double M, double D, double h, double l, double d_m) {
double tmp;
if (M <= 1.05e+75) {
tmp = w0;
} else {
tmp = -0.125 * (((M * D) * (M * D)) / ((l * Math.pow(d_m, 2.0)) / (h * w0)));
}
return tmp;
}
d_m = math.fabs(d) def code(w0, M, D, h, l, d_m): tmp = 0 if M <= 1.05e+75: tmp = w0 else: tmp = -0.125 * (((M * D) * (M * D)) / ((l * math.pow(d_m, 2.0)) / (h * w0))) return tmp
d_m = abs(d) function code(w0, M, D, h, l, d_m) tmp = 0.0 if (M <= 1.05e+75) tmp = w0; else tmp = Float64(-0.125 * Float64(Float64(Float64(M * D) * Float64(M * D)) / Float64(Float64(l * (d_m ^ 2.0)) / Float64(h * w0)))); end return tmp end
d_m = abs(d); function tmp_2 = code(w0, M, D, h, l, d_m) tmp = 0.0; if (M <= 1.05e+75) tmp = w0; else tmp = -0.125 * (((M * D) * (M * D)) / ((l * (d_m ^ 2.0)) / (h * w0))); end tmp_2 = tmp; end
d_m = N[Abs[d], $MachinePrecision] code[w0_, M_, D_, h_, l_, d$95$m_] := If[LessEqual[M, 1.05e+75], w0, N[(-0.125 * N[(N[(N[(M * D), $MachinePrecision] * N[(M * D), $MachinePrecision]), $MachinePrecision] / N[(N[(l * N[Power[d$95$m, 2.0], $MachinePrecision]), $MachinePrecision] / N[(h * w0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
d_m = \left|d\right|
\\
\begin{array}{l}
\mathbf{if}\;M \leq 1.05 \cdot 10^{+75}:\\
\;\;\;\;w0\\
\mathbf{else}:\\
\;\;\;\;-0.125 \cdot \frac{\left(M \cdot D\right) \cdot \left(M \cdot D\right)}{\frac{\ell \cdot {d\_m}^{2}}{h \cdot w0}}\\
\end{array}
\end{array}
if M < 1.04999999999999999e75Initial program 79.5%
Simplified79.0%
Taylor expanded in D around 0 70.5%
if 1.04999999999999999e75 < M Initial program 79.7%
Simplified79.7%
Taylor expanded in D around 0 32.7%
*-commutative32.7%
associate-*r*36.3%
Simplified36.3%
expm1-log1p-u36.3%
expm1-udef32.7%
pow-prod-down61.4%
Applied egg-rr61.4%
expm1-def65.0%
expm1-log1p65.0%
Simplified65.0%
Taylor expanded in D around inf 22.6%
associate-*r*22.4%
unpow222.4%
unpow222.4%
swap-sqr27.1%
unpow227.1%
*-commutative27.1%
associate-/l*27.1%
*-commutative27.1%
Simplified27.1%
unpow227.1%
Applied egg-rr27.1%
Final simplification65.7%
d_m = (fabs.f64 d) (FPCore (w0 M D h l d_m) :precision binary64 w0)
d_m = fabs(d);
double code(double w0, double M, double D, double h, double l, double d_m) {
return w0;
}
d_m = abs(d)
real(8) function code(w0, m, d, h, l, d_m)
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_m
code = w0
end function
d_m = Math.abs(d);
public static double code(double w0, double M, double D, double h, double l, double d_m) {
return w0;
}
d_m = math.fabs(d) def code(w0, M, D, h, l, d_m): return w0
d_m = abs(d) function code(w0, M, D, h, l, d_m) return w0 end
d_m = abs(d); function tmp = code(w0, M, D, h, l, d_m) tmp = w0; end
d_m = N[Abs[d], $MachinePrecision] code[w0_, M_, D_, h_, l_, d$95$m_] := w0
\begin{array}{l}
d_m = \left|d\right|
\\
w0
\end{array}
Initial program 79.5%
Simplified79.1%
Taylor expanded in D around 0 67.8%
Final simplification67.8%
herbie shell --seed 2024041
(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))))))