
(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 (* (/ (* M (* D 0.5)) d) (/ h (* l (* 2.0 (/ d (* M D))))))))))
double code(double w0, double M, double D, double h, double l, double d) {
return w0 * sqrt((1.0 - (((M * (D * 0.5)) / d) * (h / (l * (2.0 * (d / (M * D))))))));
}
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 * 0.5d0)) / d_1) * (h / (l * (2.0d0 * (d_1 / (m * d))))))))
end function
public static double code(double w0, double M, double D, double h, double l, double d) {
return w0 * Math.sqrt((1.0 - (((M * (D * 0.5)) / d) * (h / (l * (2.0 * (d / (M * D))))))));
}
def code(w0, M, D, h, l, d): return w0 * math.sqrt((1.0 - (((M * (D * 0.5)) / d) * (h / (l * (2.0 * (d / (M * D))))))))
function code(w0, M, D, h, l, d) return Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(Float64(M * Float64(D * 0.5)) / d) * Float64(h / Float64(l * Float64(2.0 * Float64(d / Float64(M * D))))))))) end
function tmp = code(w0, M, D, h, l, d) tmp = w0 * sqrt((1.0 - (((M * (D * 0.5)) / d) * (h / (l * (2.0 * (d / (M * D)))))))); end
code[w0_, M_, D_, h_, l_, d_] := N[(w0 * N[Sqrt[N[(1.0 - N[(N[(N[(M * N[(D * 0.5), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision] * N[(h / N[(l * N[(2.0 * N[(d / N[(M * D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
w0 \cdot \sqrt{1 - \frac{M \cdot \left(D \cdot 0.5\right)}{d} \cdot \frac{h}{\ell \cdot \left(2 \cdot \frac{d}{M \cdot D}\right)}}
\end{array}
Initial program 82.6%
Simplified82.6%
unpow282.6%
associate-*r/82.2%
clear-num82.2%
un-div-inv82.2%
*-un-lft-identity82.2%
times-frac82.2%
metadata-eval82.2%
times-frac82.2%
Applied egg-rr82.2%
frac-times90.3%
associate-*r/90.3%
Applied egg-rr90.3%
associate-/l*90.7%
associate-*r/90.4%
*-commutative90.4%
*-commutative90.4%
associate-*l/90.4%
associate-*r/90.4%
Simplified90.4%
Taylor expanded in d around 0 92.1%
Final simplification92.1%
(FPCore (w0 M D h l d)
:precision binary64
(if (<= D 1.6e-74)
w0
(*
w0
(sqrt
(- 1.0 (* (* M (/ (* D 0.5) d)) (* 0.5 (/ (* D (* M h)) (* d l)))))))))
double code(double w0, double M, double D, double h, double l, double d) {
double tmp;
if (D <= 1.6e-74) {
tmp = w0;
} else {
tmp = w0 * sqrt((1.0 - ((M * ((D * 0.5) / d)) * (0.5 * ((D * (M * h)) / (d * l))))));
}
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 <= 1.6d-74) then
tmp = w0
else
tmp = w0 * sqrt((1.0d0 - ((m * ((d * 0.5d0) / d_1)) * (0.5d0 * ((d * (m * h)) / (d_1 * l))))))
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 <= 1.6e-74) {
tmp = w0;
} else {
tmp = w0 * Math.sqrt((1.0 - ((M * ((D * 0.5) / d)) * (0.5 * ((D * (M * h)) / (d * l))))));
}
return tmp;
}
def code(w0, M, D, h, l, d): tmp = 0 if D <= 1.6e-74: tmp = w0 else: tmp = w0 * math.sqrt((1.0 - ((M * ((D * 0.5) / d)) * (0.5 * ((D * (M * h)) / (d * l)))))) return tmp
function code(w0, M, D, h, l, d) tmp = 0.0 if (D <= 1.6e-74) tmp = w0; else tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(M * Float64(Float64(D * 0.5) / d)) * Float64(0.5 * Float64(Float64(D * Float64(M * h)) / Float64(d * l))))))); end return tmp end
function tmp_2 = code(w0, M, D, h, l, d) tmp = 0.0; if (D <= 1.6e-74) tmp = w0; else tmp = w0 * sqrt((1.0 - ((M * ((D * 0.5) / d)) * (0.5 * ((D * (M * h)) / (d * l)))))); end tmp_2 = tmp; end
code[w0_, M_, D_, h_, l_, d_] := If[LessEqual[D, 1.6e-74], w0, N[(w0 * N[Sqrt[N[(1.0 - N[(N[(M * N[(N[(D * 0.5), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision] * N[(0.5 * N[(N[(D * N[(M * h), $MachinePrecision]), $MachinePrecision] / N[(d * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;D \leq 1.6 \cdot 10^{-74}:\\
\;\;\;\;w0\\
\mathbf{else}:\\
\;\;\;\;w0 \cdot \sqrt{1 - \left(M \cdot \frac{D \cdot 0.5}{d}\right) \cdot \left(0.5 \cdot \frac{D \cdot \left(M \cdot h\right)}{d \cdot \ell}\right)}\\
\end{array}
\end{array}
if D < 1.5999999999999999e-74Initial program 82.9%
Simplified83.5%
Taylor expanded in M around 0 73.2%
if 1.5999999999999999e-74 < D Initial program 81.7%
Simplified80.4%
unpow280.4%
associate-*r/80.4%
clear-num80.4%
un-div-inv80.4%
*-un-lft-identity80.4%
times-frac80.4%
metadata-eval80.4%
times-frac80.4%
Applied egg-rr80.4%
frac-times91.0%
associate-*r/91.0%
Applied egg-rr91.0%
associate-/l*91.0%
associate-*r/91.0%
*-commutative91.0%
*-commutative91.0%
associate-*l/91.0%
associate-*r/91.0%
Simplified91.0%
associate-/l*91.0%
Applied egg-rr91.0%
Taylor expanded in h around 0 88.3%
(FPCore (w0 M D h l d) :precision binary64 (if (<= M 3.8e+36) w0 (* -0.125 (/ (* (* (* M D) (* M D)) (* w0 h)) (* l (pow d 2.0))))))
double code(double w0, double M, double D, double h, double l, double d) {
double tmp;
if (M <= 3.8e+36) {
tmp = w0;
} else {
tmp = -0.125 * ((((M * D) * (M * D)) * (w0 * h)) / (l * pow(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) :: tmp
if (m <= 3.8d+36) then
tmp = w0
else
tmp = (-0.125d0) * ((((m * d) * (m * d)) * (w0 * h)) / (l * (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 tmp;
if (M <= 3.8e+36) {
tmp = w0;
} else {
tmp = -0.125 * ((((M * D) * (M * D)) * (w0 * h)) / (l * Math.pow(d, 2.0)));
}
return tmp;
}
def code(w0, M, D, h, l, d): tmp = 0 if M <= 3.8e+36: tmp = w0 else: tmp = -0.125 * ((((M * D) * (M * D)) * (w0 * h)) / (l * math.pow(d, 2.0))) return tmp
function code(w0, M, D, h, l, d) tmp = 0.0 if (M <= 3.8e+36) tmp = w0; else tmp = Float64(-0.125 * Float64(Float64(Float64(Float64(M * D) * Float64(M * D)) * Float64(w0 * h)) / Float64(l * (d ^ 2.0)))); end return tmp end
function tmp_2 = code(w0, M, D, h, l, d) tmp = 0.0; if (M <= 3.8e+36) tmp = w0; else tmp = -0.125 * ((((M * D) * (M * D)) * (w0 * h)) / (l * (d ^ 2.0))); end tmp_2 = tmp; end
code[w0_, M_, D_, h_, l_, d_] := If[LessEqual[M, 3.8e+36], w0, N[(-0.125 * N[(N[(N[(N[(M * D), $MachinePrecision] * N[(M * D), $MachinePrecision]), $MachinePrecision] * N[(w0 * h), $MachinePrecision]), $MachinePrecision] / N[(l * N[Power[d, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;M \leq 3.8 \cdot 10^{+36}:\\
\;\;\;\;w0\\
\mathbf{else}:\\
\;\;\;\;-0.125 \cdot \frac{\left(\left(M \cdot D\right) \cdot \left(M \cdot D\right)\right) \cdot \left(w0 \cdot h\right)}{\ell \cdot {d}^{2}}\\
\end{array}
\end{array}
if M < 3.80000000000000025e36Initial program 82.0%
Simplified82.0%
Taylor expanded in M around 0 71.1%
if 3.80000000000000025e36 < M Initial program 84.6%
Simplified84.6%
Taylor expanded in M around 0 39.5%
+-commutative39.5%
*-commutative39.5%
fma-define39.5%
associate-*r*50.0%
*-commutative50.0%
unpow250.0%
unpow250.0%
swap-sqr71.4%
unpow271.4%
*-commutative71.4%
Simplified71.4%
Taylor expanded in D around inf 19.6%
associate-*r*19.7%
unpow219.7%
unpow219.7%
swap-sqr24.2%
unpow224.2%
*-commutative24.2%
Simplified24.2%
*-commutative24.2%
pow224.2%
Applied egg-rr24.2%
Final simplification60.7%
(FPCore (w0 M D h l d) :precision binary64 (* w0 (sqrt (- 1.0 (* (* M (/ (* D 0.5) d)) (/ h (* l (/ (/ (* d 2.0) D) M))))))))
double code(double w0, double M, double D, double h, double l, double d) {
return w0 * sqrt((1.0 - ((M * ((D * 0.5) / d)) * (h / (l * (((d * 2.0) / D) / M))))));
}
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 * 0.5d0) / d_1)) * (h / (l * (((d_1 * 2.0d0) / d) / m))))))
end function
public static double code(double w0, double M, double D, double h, double l, double d) {
return w0 * Math.sqrt((1.0 - ((M * ((D * 0.5) / d)) * (h / (l * (((d * 2.0) / D) / M))))));
}
def code(w0, M, D, h, l, d): return w0 * math.sqrt((1.0 - ((M * ((D * 0.5) / d)) * (h / (l * (((d * 2.0) / D) / M))))))
function code(w0, M, D, h, l, d) return Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(M * Float64(Float64(D * 0.5) / d)) * Float64(h / Float64(l * Float64(Float64(Float64(d * 2.0) / D) / M))))))) end
function tmp = code(w0, M, D, h, l, d) tmp = w0 * sqrt((1.0 - ((M * ((D * 0.5) / d)) * (h / (l * (((d * 2.0) / D) / M)))))); end
code[w0_, M_, D_, h_, l_, d_] := N[(w0 * N[Sqrt[N[(1.0 - N[(N[(M * N[(N[(D * 0.5), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision] * N[(h / N[(l * N[(N[(N[(d * 2.0), $MachinePrecision] / D), $MachinePrecision] / M), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
w0 \cdot \sqrt{1 - \left(M \cdot \frac{D \cdot 0.5}{d}\right) \cdot \frac{h}{\ell \cdot \frac{\frac{d \cdot 2}{D}}{M}}}
\end{array}
Initial program 82.6%
Simplified82.6%
unpow282.6%
associate-*r/82.2%
clear-num82.2%
un-div-inv82.2%
*-un-lft-identity82.2%
times-frac82.2%
metadata-eval82.2%
times-frac82.2%
Applied egg-rr82.2%
frac-times90.3%
associate-*r/90.3%
Applied egg-rr90.3%
associate-/l*90.7%
associate-*r/90.4%
*-commutative90.4%
*-commutative90.4%
associate-*l/90.4%
associate-*r/90.4%
Simplified90.4%
associate-/l*90.7%
Applied egg-rr90.7%
Final simplification90.7%
(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 82.6%
Simplified82.6%
Taylor expanded in M around 0 68.4%
herbie shell --seed 2024145
(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))))))