
(FPCore (w0 M D h l d) :precision binary64 (* w0 (sqrt (- 1.0 (* (pow (/ (* M D) (* 2.0 d)) 2.0) (/ h l))))))
double code(double w0, double M, double D, double h, double l, double d) {
return w0 * sqrt((1.0 - (pow(((M * D) / (2.0 * d)), 2.0) * (h / l))));
}
real(8) function code(w0, m, d, h, l, d_1)
real(8), intent (in) :: w0
real(8), intent (in) :: m
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: d_1
code = w0 * sqrt((1.0d0 - ((((m * d) / (2.0d0 * d_1)) ** 2.0d0) * (h / l))))
end function
public static double code(double w0, double M, double D, double h, double l, double d) {
return w0 * Math.sqrt((1.0 - (Math.pow(((M * D) / (2.0 * d)), 2.0) * (h / l))));
}
def code(w0, M, D, h, l, d): return w0 * math.sqrt((1.0 - (math.pow(((M * D) / (2.0 * d)), 2.0) * (h / l))))
function code(w0, M, D, h, l, d) return Float64(w0 * sqrt(Float64(1.0 - Float64((Float64(Float64(M * D) / Float64(2.0 * d)) ^ 2.0) * Float64(h / l))))) end
function tmp = code(w0, M, D, h, l, d) tmp = w0 * sqrt((1.0 - ((((M * D) / (2.0 * d)) ^ 2.0) * (h / l)))); end
code[w0_, M_, D_, h_, l_, d_] := N[(w0 * N[Sqrt[N[(1.0 - N[(N[Power[N[(N[(M * D), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 5 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (w0 M D h l d) :precision binary64 (* w0 (sqrt (- 1.0 (* (pow (/ (* M D) (* 2.0 d)) 2.0) (/ h l))))))
double code(double w0, double M, double D, double h, double l, double d) {
return w0 * sqrt((1.0 - (pow(((M * D) / (2.0 * d)), 2.0) * (h / l))));
}
real(8) function code(w0, m, d, h, l, d_1)
real(8), intent (in) :: w0
real(8), intent (in) :: m
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: d_1
code = w0 * sqrt((1.0d0 - ((((m * d) / (2.0d0 * d_1)) ** 2.0d0) * (h / l))))
end function
public static double code(double w0, double M, double D, double h, double l, double d) {
return w0 * Math.sqrt((1.0 - (Math.pow(((M * D) / (2.0 * d)), 2.0) * (h / l))));
}
def code(w0, M, D, h, l, d): return w0 * math.sqrt((1.0 - (math.pow(((M * D) / (2.0 * d)), 2.0) * (h / l))))
function code(w0, M, D, h, l, d) return Float64(w0 * sqrt(Float64(1.0 - Float64((Float64(Float64(M * D) / Float64(2.0 * d)) ^ 2.0) * Float64(h / l))))) end
function tmp = code(w0, M, D, h, l, d) tmp = w0 * sqrt((1.0 - ((((M * D) / (2.0 * d)) ^ 2.0) * (h / l)))); end
code[w0_, M_, D_, h_, l_, d_] := N[(w0 * N[Sqrt[N[(1.0 - N[(N[Power[N[(N[(M * D), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}}
\end{array}
(FPCore (w0 M D h l d) :precision binary64 (* w0 (sqrt (- 1.0 (/ (* (* (* D (/ M (* 2.0 d))) (* D (* M (/ 0.5 d)))) h) l)))))
double code(double w0, double M, double D, double h, double l, double d) {
return w0 * sqrt((1.0 - ((((D * (M / (2.0 * d))) * (D * (M * (0.5 / d)))) * 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 - ((((d * (m / (2.0d0 * d_1))) * (d * (m * (0.5d0 / d_1)))) * 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 - ((((D * (M / (2.0 * d))) * (D * (M * (0.5 / d)))) * h) / l)));
}
def code(w0, M, D, h, l, d): return w0 * math.sqrt((1.0 - ((((D * (M / (2.0 * d))) * (D * (M * (0.5 / d)))) * h) / l)))
function code(w0, M, D, h, l, d) return Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(Float64(Float64(D * Float64(M / Float64(2.0 * d))) * Float64(D * Float64(M * Float64(0.5 / d)))) * h) / l)))) end
function tmp = code(w0, M, D, h, l, d) tmp = w0 * sqrt((1.0 - ((((D * (M / (2.0 * d))) * (D * (M * (0.5 / d)))) * h) / l))); end
code[w0_, M_, D_, h_, l_, d_] := N[(w0 * N[Sqrt[N[(1.0 - N[(N[(N[(N[(D * N[(M / N[(2.0 * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(D * N[(M * N[(0.5 / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * h), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
w0 \cdot \sqrt{1 - \frac{\left(\left(D \cdot \frac{M}{2 \cdot d}\right) \cdot \left(D \cdot \left(M \cdot \frac{0.5}{d}\right)\right)\right) \cdot h}{\ell}}
\end{array}
Initial program 83.9%
Simplified85.1%
associate-*r/89.1%
associate-/r*89.1%
Applied egg-rr89.1%
unpow289.1%
Applied egg-rr89.1%
Taylor expanded in M around 0 89.1%
associate-*r/89.1%
*-commutative89.1%
associate-*r/89.1%
Simplified89.1%
(FPCore (w0 M D h l d)
:precision binary64
(if (<= D 6.5e-78)
w0
(*
w0
(sqrt
(- 1.0 (* (/ h l) (* (/ (* D M) (* 2.0 d)) (/ (* D (* M 0.5)) d))))))))
double code(double w0, double M, double D, double h, double l, double d) {
double tmp;
if (D <= 6.5e-78) {
tmp = w0;
} else {
tmp = w0 * sqrt((1.0 - ((h / l) * (((D * M) / (2.0 * d)) * ((D * (M * 0.5)) / d)))));
}
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) :: tmp
if (d <= 6.5d-78) then
tmp = w0
else
tmp = w0 * sqrt((1.0d0 - ((h / l) * (((d * m) / (2.0d0 * d_1)) * ((d * (m * 0.5d0)) / d_1)))))
end if
code = tmp
end function
public static double code(double w0, double M, double D, double h, double l, double d) {
double tmp;
if (D <= 6.5e-78) {
tmp = w0;
} else {
tmp = w0 * Math.sqrt((1.0 - ((h / l) * (((D * M) / (2.0 * d)) * ((D * (M * 0.5)) / d)))));
}
return tmp;
}
def code(w0, M, D, h, l, d): tmp = 0 if D <= 6.5e-78: tmp = w0 else: tmp = w0 * math.sqrt((1.0 - ((h / l) * (((D * M) / (2.0 * d)) * ((D * (M * 0.5)) / d))))) return tmp
function code(w0, M, D, h, l, d) tmp = 0.0 if (D <= 6.5e-78) tmp = w0; else tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(h / l) * Float64(Float64(Float64(D * M) / Float64(2.0 * d)) * Float64(Float64(D * Float64(M * 0.5)) / d)))))); end return tmp end
function tmp_2 = code(w0, M, D, h, l, d) tmp = 0.0; if (D <= 6.5e-78) tmp = w0; else tmp = w0 * sqrt((1.0 - ((h / l) * (((D * M) / (2.0 * d)) * ((D * (M * 0.5)) / d))))); end tmp_2 = tmp; end
code[w0_, M_, D_, h_, l_, d_] := If[LessEqual[D, 6.5e-78], w0, N[(w0 * N[Sqrt[N[(1.0 - N[(N[(h / l), $MachinePrecision] * N[(N[(N[(D * M), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision] * N[(N[(D * N[(M * 0.5), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;D \leq 6.5 \cdot 10^{-78}:\\
\;\;\;\;w0\\
\mathbf{else}:\\
\;\;\;\;w0 \cdot \sqrt{1 - \frac{h}{\ell} \cdot \left(\frac{D \cdot M}{2 \cdot d} \cdot \frac{D \cdot \left(M \cdot 0.5\right)}{d}\right)}\\
\end{array}
\end{array}
if D < 6.5000000000000003e-78Initial program 84.5%
Simplified85.6%
Taylor expanded in D around 0 74.2%
if 6.5000000000000003e-78 < D Initial program 82.2%
Simplified83.7%
associate-*r/87.7%
associate-/r*87.7%
Applied egg-rr87.7%
unpow287.7%
Applied egg-rr87.7%
Taylor expanded in M around 0 87.7%
associate-*r/87.7%
*-commutative87.7%
associate-*r/87.8%
Simplified87.8%
*-un-lft-identity87.8%
associate-/l*83.7%
associate-*l*83.7%
*-commutative83.7%
Applied egg-rr83.7%
*-lft-identity83.7%
*-commutative83.7%
associate-*r*83.7%
associate-*r/82.2%
associate-*r/82.3%
associate-*r/82.2%
Simplified82.2%
Final simplification76.3%
(FPCore (w0 M D h l d) :precision binary64 (if (<= D 4.9e+164) w0 (fma -0.125 (/ (* (* (* D M) (* D M)) (* w0 h)) (* l (* d d))) w0)))
double code(double w0, double M, double D, double h, double l, double d) {
double tmp;
if (D <= 4.9e+164) {
tmp = w0;
} else {
tmp = fma(-0.125, ((((D * M) * (D * M)) * (w0 * h)) / (l * (d * d))), w0);
}
return tmp;
}
function code(w0, M, D, h, l, d) tmp = 0.0 if (D <= 4.9e+164) tmp = w0; else tmp = fma(-0.125, Float64(Float64(Float64(Float64(D * M) * Float64(D * M)) * Float64(w0 * h)) / Float64(l * Float64(d * d))), w0); end return tmp end
code[w0_, M_, D_, h_, l_, d_] := If[LessEqual[D, 4.9e+164], w0, N[(-0.125 * N[(N[(N[(N[(D * M), $MachinePrecision] * N[(D * M), $MachinePrecision]), $MachinePrecision] * N[(w0 * h), $MachinePrecision]), $MachinePrecision] / N[(l * N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + w0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;D \leq 4.9 \cdot 10^{+164}:\\
\;\;\;\;w0\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-0.125, \frac{\left(\left(D \cdot M\right) \cdot \left(D \cdot M\right)\right) \cdot \left(w0 \cdot h\right)}{\ell \cdot \left(d \cdot d\right)}, w0\right)\\
\end{array}
\end{array}
if D < 4.8999999999999999e164Initial program 85.7%
Simplified86.5%
Taylor expanded in D around 0 74.5%
if 4.8999999999999999e164 < D Initial program 66.1%
Simplified70.3%
Taylor expanded in D around 0 30.7%
+-commutative30.7%
fma-define30.7%
associate-*r*35.2%
unpow235.2%
unpow235.2%
swap-sqr59.5%
unpow259.5%
*-commutative59.5%
Simplified59.5%
unpow259.5%
Applied egg-rr59.5%
unpow259.5%
Applied egg-rr59.5%
Final simplification73.1%
(FPCore (w0 M D h l d) :precision binary64 (if (<= M 7e+24) w0 (* -0.125 (* (* (* D M) (* D M)) (* (/ h l) (/ w0 (* d d)))))))
double code(double w0, double M, double D, double h, double l, double d) {
double tmp;
if (M <= 7e+24) {
tmp = w0;
} else {
tmp = -0.125 * (((D * M) * (D * M)) * ((h / l) * (w0 / (d * d))));
}
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) :: tmp
if (m <= 7d+24) then
tmp = w0
else
tmp = (-0.125d0) * (((d * m) * (d * m)) * ((h / l) * (w0 / (d_1 * d_1))))
end if
code = tmp
end function
public static double code(double w0, double M, double D, double h, double l, double d) {
double tmp;
if (M <= 7e+24) {
tmp = w0;
} else {
tmp = -0.125 * (((D * M) * (D * M)) * ((h / l) * (w0 / (d * d))));
}
return tmp;
}
def code(w0, M, D, h, l, d): tmp = 0 if M <= 7e+24: tmp = w0 else: tmp = -0.125 * (((D * M) * (D * M)) * ((h / l) * (w0 / (d * d)))) return tmp
function code(w0, M, D, h, l, d) tmp = 0.0 if (M <= 7e+24) tmp = w0; else tmp = Float64(-0.125 * Float64(Float64(Float64(D * M) * Float64(D * M)) * Float64(Float64(h / l) * Float64(w0 / Float64(d * d))))); end return tmp end
function tmp_2 = code(w0, M, D, h, l, d) tmp = 0.0; if (M <= 7e+24) tmp = w0; else tmp = -0.125 * (((D * M) * (D * M)) * ((h / l) * (w0 / (d * d)))); end tmp_2 = tmp; end
code[w0_, M_, D_, h_, l_, d_] := If[LessEqual[M, 7e+24], w0, N[(-0.125 * N[(N[(N[(D * M), $MachinePrecision] * N[(D * M), $MachinePrecision]), $MachinePrecision] * N[(N[(h / l), $MachinePrecision] * N[(w0 / N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;M \leq 7 \cdot 10^{+24}:\\
\;\;\;\;w0\\
\mathbf{else}:\\
\;\;\;\;-0.125 \cdot \left(\left(\left(D \cdot M\right) \cdot \left(D \cdot M\right)\right) \cdot \left(\frac{h}{\ell} \cdot \frac{w0}{d \cdot d}\right)\right)\\
\end{array}
\end{array}
if M < 7.0000000000000004e24Initial program 87.7%
Simplified88.7%
Taylor expanded in D around 0 73.2%
if 7.0000000000000004e24 < M Initial program 63.4%
Simplified65.8%
Taylor expanded in D around 0 37.8%
+-commutative37.8%
fma-define37.8%
associate-*r*40.3%
unpow240.3%
unpow240.3%
swap-sqr55.3%
unpow255.3%
*-commutative55.3%
Simplified55.3%
Taylor expanded in D around inf 16.0%
associate-*r*16.1%
unpow216.1%
unpow216.1%
swap-sqr16.6%
unpow216.6%
associate-*r/16.7%
*-commutative16.7%
times-frac19.2%
Simplified19.2%
unpow255.3%
Applied egg-rr19.2%
unpow255.3%
Applied egg-rr19.2%
(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}
Initial program 83.9%
Simplified85.1%
Taylor expanded in D around 0 70.0%
herbie shell --seed 2024154
(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))))))