
(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 9 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}
(FPCore (w0 M D h l d)
:precision binary64
(let* ((t_0 (- 1.0 (* (pow (/ (* D M) (* d 2.0)) 2.0) (/ h l)))))
(if (<= t_0 1e+257)
(* w0 (sqrt t_0))
(* w0 (sqrt (- 1.0 (* (/ 0.25 l) (* h (pow (* M (/ D d)) 2.0)))))))))
double code(double w0, double M, double D, double h, double l, double d) {
double t_0 = 1.0 - (pow(((D * M) / (d * 2.0)), 2.0) * (h / l));
double tmp;
if (t_0 <= 1e+257) {
tmp = w0 * sqrt(t_0);
} else {
tmp = w0 * sqrt((1.0 - ((0.25 / l) * (h * pow((M * (D / d)), 2.0)))));
}
return tmp;
}
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) :: t_0
real(8) :: tmp
t_0 = 1.0d0 - ((((d * m) / (d_1 * 2.0d0)) ** 2.0d0) * (h / l))
if (t_0 <= 1d+257) then
tmp = w0 * sqrt(t_0)
else
tmp = w0 * sqrt((1.0d0 - ((0.25d0 / l) * (h * ((m * (d / d_1)) ** 2.0d0)))))
end if
code = tmp
end function
public static double code(double w0, double M, double D, double h, double l, double d) {
double t_0 = 1.0 - (Math.pow(((D * M) / (d * 2.0)), 2.0) * (h / l));
double tmp;
if (t_0 <= 1e+257) {
tmp = w0 * Math.sqrt(t_0);
} else {
tmp = w0 * Math.sqrt((1.0 - ((0.25 / l) * (h * Math.pow((M * (D / d)), 2.0)))));
}
return tmp;
}
def code(w0, M, D, h, l, d): t_0 = 1.0 - (math.pow(((D * M) / (d * 2.0)), 2.0) * (h / l)) tmp = 0 if t_0 <= 1e+257: tmp = w0 * math.sqrt(t_0) else: tmp = w0 * math.sqrt((1.0 - ((0.25 / l) * (h * math.pow((M * (D / d)), 2.0))))) return tmp
function code(w0, M, D, h, l, d) t_0 = Float64(1.0 - Float64((Float64(Float64(D * M) / Float64(d * 2.0)) ^ 2.0) * Float64(h / l))) tmp = 0.0 if (t_0 <= 1e+257) tmp = Float64(w0 * sqrt(t_0)); else tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(0.25 / l) * Float64(h * (Float64(M * Float64(D / d)) ^ 2.0)))))); end return tmp end
function tmp_2 = code(w0, M, D, h, l, d) t_0 = 1.0 - ((((D * M) / (d * 2.0)) ^ 2.0) * (h / l)); tmp = 0.0; if (t_0 <= 1e+257) tmp = w0 * sqrt(t_0); else tmp = w0 * sqrt((1.0 - ((0.25 / l) * (h * ((M * (D / d)) ^ 2.0))))); end tmp_2 = tmp; end
code[w0_, M_, D_, h_, l_, d_] := Block[{t$95$0 = N[(1.0 - N[(N[Power[N[(N[(D * M), $MachinePrecision] / N[(d * 2.0), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, 1e+257], N[(w0 * N[Sqrt[t$95$0], $MachinePrecision]), $MachinePrecision], N[(w0 * N[Sqrt[N[(1.0 - N[(N[(0.25 / l), $MachinePrecision] * N[(h * N[Power[N[(M * N[(D / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 - {\left(\frac{D \cdot M}{d \cdot 2}\right)}^{2} \cdot \frac{h}{\ell}\\
\mathbf{if}\;t_0 \leq 10^{+257}:\\
\;\;\;\;w0 \cdot \sqrt{t_0}\\
\mathbf{else}:\\
\;\;\;\;w0 \cdot \sqrt{1 - \frac{0.25}{\ell} \cdot \left(h \cdot {\left(M \cdot \frac{D}{d}\right)}^{2}\right)}\\
\end{array}
\end{array}
(FPCore (w0 M D h l d)
:precision binary64
(let* ((t_0 (/ (/ d M) D)))
(if (<= (/ h l) -5e-56)
(* w0 (sqrt (- 1.0 (* (/ 0.25 l) (* h (pow (* M (/ D d)) 2.0))))))
(fma -0.125 (* (* w0 (/ h t_0)) (/ (/ 1.0 l) t_0)) w0))))
double code(double w0, double M, double D, double h, double l, double d) {
double t_0 = (d / M) / D;
double tmp;
if ((h / l) <= -5e-56) {
tmp = w0 * sqrt((1.0 - ((0.25 / l) * (h * pow((M * (D / d)), 2.0)))));
} else {
tmp = fma(-0.125, ((w0 * (h / t_0)) * ((1.0 / l) / t_0)), w0);
}
return tmp;
}
function code(w0, M, D, h, l, d) t_0 = Float64(Float64(d / M) / D) tmp = 0.0 if (Float64(h / l) <= -5e-56) tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(0.25 / l) * Float64(h * (Float64(M * Float64(D / d)) ^ 2.0)))))); else tmp = fma(-0.125, Float64(Float64(w0 * Float64(h / t_0)) * Float64(Float64(1.0 / l) / t_0)), w0); end return tmp end
code[w0_, M_, D_, h_, l_, d_] := Block[{t$95$0 = N[(N[(d / M), $MachinePrecision] / D), $MachinePrecision]}, If[LessEqual[N[(h / l), $MachinePrecision], -5e-56], N[(w0 * N[Sqrt[N[(1.0 - N[(N[(0.25 / l), $MachinePrecision] * N[(h * N[Power[N[(M * N[(D / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(-0.125 * N[(N[(w0 * N[(h / t$95$0), $MachinePrecision]), $MachinePrecision] * N[(N[(1.0 / l), $MachinePrecision] / t$95$0), $MachinePrecision]), $MachinePrecision] + w0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\frac{d}{M}}{D}\\
\mathbf{if}\;\frac{h}{\ell} \leq -5 \cdot 10^{-56}:\\
\;\;\;\;w0 \cdot \sqrt{1 - \frac{0.25}{\ell} \cdot \left(h \cdot {\left(M \cdot \frac{D}{d}\right)}^{2}\right)}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-0.125, \left(w0 \cdot \frac{h}{t_0}\right) \cdot \frac{\frac{1}{\ell}}{t_0}, w0\right)\\
\end{array}
\end{array}
(FPCore (w0 M D h l d) :precision binary64 (* w0 (sqrt (+ 1.0 (* (* h (pow (* D (* M (/ 0.5 d))) 2.0)) (/ -1.0 l))))))
double code(double w0, double M, double D, double h, double l, double d) {
return w0 * sqrt((1.0 + ((h * pow((D * (M * (0.5 / d))), 2.0)) * (-1.0 / 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 + ((h * ((d * (m * (0.5d0 / d_1))) ** 2.0d0)) * ((-1.0d0) / 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 + ((h * Math.pow((D * (M * (0.5 / d))), 2.0)) * (-1.0 / l))));
}
def code(w0, M, D, h, l, d): return w0 * math.sqrt((1.0 + ((h * math.pow((D * (M * (0.5 / d))), 2.0)) * (-1.0 / l))))
function code(w0, M, D, h, l, d) return Float64(w0 * sqrt(Float64(1.0 + Float64(Float64(h * (Float64(D * Float64(M * Float64(0.5 / d))) ^ 2.0)) * Float64(-1.0 / l))))) end
function tmp = code(w0, M, D, h, l, d) tmp = w0 * sqrt((1.0 + ((h * ((D * (M * (0.5 / d))) ^ 2.0)) * (-1.0 / l)))); end
code[w0_, M_, D_, h_, l_, d_] := N[(w0 * N[Sqrt[N[(1.0 + N[(N[(h * N[Power[N[(D * N[(M * N[(0.5 / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(-1.0 / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
w0 \cdot \sqrt{1 + \left(h \cdot {\left(D \cdot \left(M \cdot \frac{0.5}{d}\right)\right)}^{2}\right) \cdot \frac{-1}{\ell}}
\end{array}
(FPCore (w0 M D h l d) :precision binary64 (* w0 (fma (/ h (/ l (pow (/ D (/ d M)) 2.0))) -0.125 1.0)))
double code(double w0, double M, double D, double h, double l, double d) {
return w0 * fma((h / (l / pow((D / (d / M)), 2.0))), -0.125, 1.0);
}
function code(w0, M, D, h, l, d) return Float64(w0 * fma(Float64(h / Float64(l / (Float64(D / Float64(d / M)) ^ 2.0))), -0.125, 1.0)) end
code[w0_, M_, D_, h_, l_, d_] := N[(w0 * N[(N[(h / N[(l / N[Power[N[(D / N[(d / M), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * -0.125 + 1.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
w0 \cdot \mathsf{fma}\left(\frac{h}{\frac{\ell}{{\left(\frac{D}{\frac{d}{M}}\right)}^{2}}}, -0.125, 1\right)
\end{array}
(FPCore (w0 M D h l d) :precision binary64 (let* ((t_0 (* M (/ D d)))) (if (<= M 1.95e-143) w0 (fma -0.125 (* (* t_0 t_0) (/ (* w0 h) l)) w0))))
double code(double w0, double M, double D, double h, double l, double d) {
double t_0 = M * (D / d);
double tmp;
if (M <= 1.95e-143) {
tmp = w0;
} else {
tmp = fma(-0.125, ((t_0 * t_0) * ((w0 * h) / l)), w0);
}
return tmp;
}
function code(w0, M, D, h, l, d) t_0 = Float64(M * Float64(D / d)) tmp = 0.0 if (M <= 1.95e-143) tmp = w0; else tmp = fma(-0.125, Float64(Float64(t_0 * t_0) * Float64(Float64(w0 * h) / l)), w0); end return tmp end
code[w0_, M_, D_, h_, l_, d_] := Block[{t$95$0 = N[(M * N[(D / d), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[M, 1.95e-143], w0, N[(-0.125 * N[(N[(t$95$0 * t$95$0), $MachinePrecision] * N[(N[(w0 * h), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision] + w0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := M \cdot \frac{D}{d}\\
\mathbf{if}\;M \leq 1.95 \cdot 10^{-143}:\\
\;\;\;\;w0\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-0.125, \left(t_0 \cdot t_0\right) \cdot \frac{w0 \cdot h}{\ell}, w0\right)\\
\end{array}
\end{array}
(FPCore (w0 M D h l d) :precision binary64 (let* ((t_0 (/ d (* D M)))) (if (<= M 4.1e-169) w0 (fma -0.125 (* (/ (/ h l) t_0) (/ w0 t_0)) w0))))
double code(double w0, double M, double D, double h, double l, double d) {
double t_0 = d / (D * M);
double tmp;
if (M <= 4.1e-169) {
tmp = w0;
} else {
tmp = fma(-0.125, (((h / l) / t_0) * (w0 / t_0)), w0);
}
return tmp;
}
function code(w0, M, D, h, l, d) t_0 = Float64(d / Float64(D * M)) tmp = 0.0 if (M <= 4.1e-169) tmp = w0; else tmp = fma(-0.125, Float64(Float64(Float64(h / l) / t_0) * Float64(w0 / t_0)), w0); end return tmp end
code[w0_, M_, D_, h_, l_, d_] := Block[{t$95$0 = N[(d / N[(D * M), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[M, 4.1e-169], w0, N[(-0.125 * N[(N[(N[(h / l), $MachinePrecision] / t$95$0), $MachinePrecision] * N[(w0 / t$95$0), $MachinePrecision]), $MachinePrecision] + w0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{d}{D \cdot M}\\
\mathbf{if}\;M \leq 4.1 \cdot 10^{-169}:\\
\;\;\;\;w0\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-0.125, \frac{\frac{h}{\ell}}{t_0} \cdot \frac{w0}{t_0}, w0\right)\\
\end{array}
\end{array}
(FPCore (w0 M D h l d) :precision binary64 (let* ((t_0 (/ D (/ d M)))) (if (<= M 2.45e-143) w0 (fma -0.125 (/ (* (* t_0 t_0) (* w0 h)) l) w0))))
double code(double w0, double M, double D, double h, double l, double d) {
double t_0 = D / (d / M);
double tmp;
if (M <= 2.45e-143) {
tmp = w0;
} else {
tmp = fma(-0.125, (((t_0 * t_0) * (w0 * h)) / l), w0);
}
return tmp;
}
function code(w0, M, D, h, l, d) t_0 = Float64(D / Float64(d / M)) tmp = 0.0 if (M <= 2.45e-143) tmp = w0; else tmp = fma(-0.125, Float64(Float64(Float64(t_0 * t_0) * Float64(w0 * h)) / l), w0); end return tmp end
code[w0_, M_, D_, h_, l_, d_] := Block[{t$95$0 = N[(D / N[(d / M), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[M, 2.45e-143], w0, N[(-0.125 * N[(N[(N[(t$95$0 * t$95$0), $MachinePrecision] * N[(w0 * h), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision] + w0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{D}{\frac{d}{M}}\\
\mathbf{if}\;M \leq 2.45 \cdot 10^{-143}:\\
\;\;\;\;w0\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-0.125, \frac{\left(t_0 \cdot t_0\right) \cdot \left(w0 \cdot h\right)}{\ell}, w0\right)\\
\end{array}
\end{array}
(FPCore (w0 M D h l d) :precision binary64 (let* ((t_0 (/ (/ d M) D))) (fma -0.125 (* (* w0 (/ h t_0)) (/ (/ 1.0 l) t_0)) w0)))
double code(double w0, double M, double D, double h, double l, double d) {
double t_0 = (d / M) / D;
return fma(-0.125, ((w0 * (h / t_0)) * ((1.0 / l) / t_0)), w0);
}
function code(w0, M, D, h, l, d) t_0 = Float64(Float64(d / M) / D) return fma(-0.125, Float64(Float64(w0 * Float64(h / t_0)) * Float64(Float64(1.0 / l) / t_0)), w0) end
code[w0_, M_, D_, h_, l_, d_] := Block[{t$95$0 = N[(N[(d / M), $MachinePrecision] / D), $MachinePrecision]}, N[(-0.125 * N[(N[(w0 * N[(h / t$95$0), $MachinePrecision]), $MachinePrecision] * N[(N[(1.0 / l), $MachinePrecision] / t$95$0), $MachinePrecision]), $MachinePrecision] + w0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\frac{d}{M}}{D}\\
\mathsf{fma}\left(-0.125, \left(w0 \cdot \frac{h}{t_0}\right) \cdot \frac{\frac{1}{\ell}}{t_0}, w0\right)
\end{array}
\end{array}
(FPCore (w0 M D h l d) :precision binary64 w0)
double code(double w0, double M, double D, double h, double l, double d) {
return w0;
}
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
public static double code(double w0, double M, double D, double h, double l, double d) {
return w0;
}
def code(w0, M, D, h, l, d): return w0
function code(w0, M, D, h, l, d) return w0 end
function tmp = code(w0, M, D, h, l, d) tmp = w0; end
code[w0_, M_, D_, h_, l_, d_] := w0
\begin{array}{l}
\\
w0
\end{array}
herbie shell --seed 2023348
(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))))))