
(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 3 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 (* (* 0.5 (/ D d)) (* h (/ (/ M (/ (/ d D) 0.5)) l))))))))
double code(double w0, double M, double D, double h, double l, double d) {
return w0 * sqrt((1.0 - (M * ((0.5 * (D / d)) * (h * ((M / ((d / D) / 0.5)) / 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 * ((0.5d0 * (d / d_1)) * (h * ((m / ((d_1 / d) / 0.5d0)) / 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 - (M * ((0.5 * (D / d)) * (h * ((M / ((d / D) / 0.5)) / l))))));
}
def code(w0, M, D, h, l, d): return w0 * math.sqrt((1.0 - (M * ((0.5 * (D / d)) * (h * ((M / ((d / D) / 0.5)) / l))))))
function code(w0, M, D, h, l, d) return Float64(w0 * sqrt(Float64(1.0 - Float64(M * Float64(Float64(0.5 * Float64(D / d)) * Float64(h * Float64(Float64(M / Float64(Float64(d / D) / 0.5)) / l))))))) end
function tmp = code(w0, M, D, h, l, d) tmp = w0 * sqrt((1.0 - (M * ((0.5 * (D / d)) * (h * ((M / ((d / D) / 0.5)) / l)))))); end
code[w0_, M_, D_, h_, l_, d_] := N[(w0 * N[Sqrt[N[(1.0 - N[(M * N[(N[(0.5 * N[(D / d), $MachinePrecision]), $MachinePrecision] * N[(h * N[(N[(M / N[(N[(d / D), $MachinePrecision] / 0.5), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
w0 \cdot \sqrt{1 - M \cdot \left(\left(0.5 \cdot \frac{D}{d}\right) \cdot \left(h \cdot \frac{\frac{M}{\frac{\frac{d}{D}}{0.5}}}{\ell}\right)\right)}
\end{array}
Initial program 81.2%
associate-*r/86.4%
pow186.4%
pow186.4%
times-frac86.0%
div-inv86.0%
metadata-eval86.0%
Applied egg-rr86.0%
associate-/l*82.3%
unpow282.3%
*-un-lft-identity82.3%
times-frac84.7%
associate-*l*84.7%
associate-*l*84.7%
Applied egg-rr84.7%
associate-*r*84.7%
associate-*r/84.3%
Applied egg-rr84.3%
expm1-log1p-u59.2%
expm1-udef27.8%
/-rgt-identity27.8%
associate-/l*28.1%
Applied egg-rr28.1%
expm1-def59.5%
expm1-log1p84.7%
associate-*l*84.7%
associate-/r/89.7%
*-commutative89.7%
associate-/l*89.7%
Simplified89.7%
Final simplification89.7%
(FPCore (w0 M D h l d) :precision binary64 (if (<= (* M D) 3.7e+209) 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 * D) <= 3.7e+209) {
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 * d) <= 3.7d+209) 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 * D) <= 3.7e+209) {
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 * D) <= 3.7e+209: 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 (Float64(M * D) <= 3.7e+209) 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 * D) <= 3.7e+209) 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[N[(M * D), $MachinePrecision], 3.7e+209], 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 \cdot D \leq 3.7 \cdot 10^{+209}:\\
\;\;\;\;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 (*.f64 M D) < 3.7e209Initial program 82.9%
Taylor expanded in M around 0 73.7%
if 3.7e209 < (*.f64 M D) Initial program 62.8%
Taylor expanded in M around 0 44.7%
+-commutative44.7%
*-commutative44.7%
fma-def44.7%
times-frac44.7%
associate-/l*39.9%
Simplified39.9%
Taylor expanded in D around inf 43.9%
associate-*r*43.9%
unpow243.9%
unpow243.9%
swap-sqr43.9%
unpow243.9%
Simplified43.9%
unpow243.9%
*-commutative43.9%
*-commutative43.9%
Applied egg-rr43.9%
Final simplification71.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 81.2%
Taylor expanded in M around 0 67.7%
Final simplification67.7%
herbie shell --seed 2023335
(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))))))