
(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
(let* ((t_0 (sqrt (- 1.0 (* (pow (/ (* M D) (* 2.0 d)) 2.0) (/ h l))))))
(if (<= t_0 5e+145)
(* t_0 w0)
(*
w0
(exp
(*
(log1p (* h (* (/ (* D (/ M (* 2.0 d))) l) (* D (/ M (* d (- 2.0)))))))
0.5))))))
double code(double w0, double M, double D, double h, double l, double d) {
double t_0 = sqrt((1.0 - (pow(((M * D) / (2.0 * d)), 2.0) * (h / l))));
double tmp;
if (t_0 <= 5e+145) {
tmp = t_0 * w0;
} else {
tmp = w0 * exp((log1p((h * (((D * (M / (2.0 * d))) / l) * (D * (M / (d * -2.0)))))) * 0.5));
}
return tmp;
}
public static double code(double w0, double M, double D, double h, double l, double d) {
double t_0 = Math.sqrt((1.0 - (Math.pow(((M * D) / (2.0 * d)), 2.0) * (h / l))));
double tmp;
if (t_0 <= 5e+145) {
tmp = t_0 * w0;
} else {
tmp = w0 * Math.exp((Math.log1p((h * (((D * (M / (2.0 * d))) / l) * (D * (M / (d * -2.0)))))) * 0.5));
}
return tmp;
}
def code(w0, M, D, h, l, d): t_0 = math.sqrt((1.0 - (math.pow(((M * D) / (2.0 * d)), 2.0) * (h / l)))) tmp = 0 if t_0 <= 5e+145: tmp = t_0 * w0 else: tmp = w0 * math.exp((math.log1p((h * (((D * (M / (2.0 * d))) / l) * (D * (M / (d * -2.0)))))) * 0.5)) return tmp
function code(w0, M, D, h, l, d) t_0 = sqrt(Float64(1.0 - Float64((Float64(Float64(M * D) / Float64(2.0 * d)) ^ 2.0) * Float64(h / l)))) tmp = 0.0 if (t_0 <= 5e+145) tmp = Float64(t_0 * w0); else tmp = Float64(w0 * exp(Float64(log1p(Float64(h * Float64(Float64(Float64(D * Float64(M / Float64(2.0 * d))) / l) * Float64(D * Float64(M / Float64(d * Float64(-2.0))))))) * 0.5))); end return tmp end
code[w0_, M_, D_, h_, l_, d_] := Block[{t$95$0 = 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]}, If[LessEqual[t$95$0, 5e+145], N[(t$95$0 * w0), $MachinePrecision], N[(w0 * N[Exp[N[(N[Log[1 + N[(h * N[(N[(N[(D * N[(M / N[(2.0 * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision] * N[(D * N[(M / N[(d * (-2.0)), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}}\\
\mathbf{if}\;t\_0 \leq 5 \cdot 10^{+145}:\\
\;\;\;\;t\_0 \cdot w0\\
\mathbf{else}:\\
\;\;\;\;w0 \cdot e^{\mathsf{log1p}\left(h \cdot \left(\frac{D \cdot \frac{M}{2 \cdot d}}{\ell} \cdot \left(D \cdot \frac{M}{d \cdot \left(-2\right)}\right)\right)\right) \cdot 0.5}\\
\end{array}
\end{array}
if (sqrt.f64 (-.f64 1 (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 2 d)) 2) (/.f64 h l)))) < 4.99999999999999967e145Initial program 99.9%
if 4.99999999999999967e145 < (sqrt.f64 (-.f64 1 (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 2 d)) 2) (/.f64 h l)))) Initial program 38.5%
Simplified43.1%
clear-num43.1%
un-div-inv43.1%
associate-/l*43.1%
Applied egg-rr43.1%
associate-*r/63.7%
*-un-lft-identity63.7%
*-commutative63.7%
times-frac63.7%
clear-num63.7%
times-frac60.2%
Applied egg-rr60.2%
*-commutative60.2%
associate-/l*60.2%
associate-/l*64.8%
*-commutative64.8%
Simplified64.8%
pow1/264.9%
pow-to-exp64.4%
cancel-sign-sub-inv64.4%
log1p-define64.4%
associate-*r/59.9%
Applied egg-rr59.9%
associate-/l*64.4%
*-commutative64.4%
associate-/l*59.9%
unpow259.9%
*-un-lft-identity59.9%
times-frac63.4%
associate-/l*63.4%
associate-/l*70.2%
Applied egg-rr70.2%
Final simplification90.4%
(FPCore (w0 M D h l d) :precision binary64 (* w0 (sqrt (- 1.0 (* h (/ (pow (* D (/ M (* 2.0 d))) 2.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 / (2.0 * d))), 2.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 / (2.0d0 * d_1))) ** 2.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 / (2.0 * d))), 2.0) / l))));
}
def code(w0, M, D, h, l, d): return w0 * math.sqrt((1.0 - (h * (math.pow((D * (M / (2.0 * d))), 2.0) / l))))
function code(w0, M, D, h, l, d) return Float64(w0 * sqrt(Float64(1.0 - Float64(h * Float64((Float64(D * Float64(M / Float64(2.0 * d))) ^ 2.0) / l))))) end
function tmp = code(w0, M, D, h, l, d) tmp = w0 * sqrt((1.0 - (h * (((D * (M / (2.0 * d))) ^ 2.0) / l)))); end
code[w0_, M_, D_, h_, l_, d_] := N[(w0 * N[Sqrt[N[(1.0 - N[(h * N[(N[Power[N[(D * N[(M / N[(2.0 * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
w0 \cdot \sqrt{1 - h \cdot \frac{{\left(D \cdot \frac{M}{2 \cdot d}\right)}^{2}}{\ell}}
\end{array}
Initial program 80.2%
Simplified80.9%
clear-num80.9%
un-div-inv81.7%
associate-/l*81.7%
Applied egg-rr81.7%
associate-*r/88.0%
*-un-lft-identity88.0%
*-commutative88.0%
times-frac87.2%
clear-num87.2%
times-frac86.9%
Applied egg-rr86.9%
*-commutative86.9%
associate-/l*86.5%
associate-/l*86.1%
*-commutative86.1%
Simplified86.1%
Final simplification86.1%
(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 80.2%
Simplified80.9%
Taylor expanded in M around 0 64.2%
Final simplification64.2%
herbie shell --seed 2024061
(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))))))