
(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 (/ (* h (pow (* (/ D d) (* M 0.5)) 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 / d) * (M * 0.5)), 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 / d_1) * (m * 0.5d0)) ** 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 / d) * (M * 0.5)), 2.0)) / l)));
}
def code(w0, M, D, h, l, d): return w0 * math.sqrt((1.0 - ((h * math.pow(((D / d) * (M * 0.5)), 2.0)) / l)))
function code(w0, M, D, h, l, d) return Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(h * (Float64(Float64(D / d) * Float64(M * 0.5)) ^ 2.0)) / l)))) end
function tmp = code(w0, M, D, h, l, d) tmp = w0 * sqrt((1.0 - ((h * (((D / d) * (M * 0.5)) ^ 2.0)) / l))); end
code[w0_, M_, D_, h_, l_, d_] := N[(w0 * N[Sqrt[N[(1.0 - N[(N[(h * N[Power[N[(N[(D / d), $MachinePrecision] * N[(M * 0.5), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
w0 \cdot \sqrt{1 - \frac{h \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}}{\ell}}
\end{array}
Initial program 81.8%
Simplified82.9%
unpow282.9%
associate-*l*84.4%
associate-/r*84.4%
associate-*r/83.3%
associate-*l/84.1%
*-commutative84.1%
associate-/r*84.1%
associate-*r/83.0%
associate-*l/84.1%
*-commutative84.1%
associate-*l*82.9%
unpow282.9%
*-commutative82.9%
associate-*l/88.6%
*-commutative88.6%
associate-*l/87.3%
Applied egg-rr87.3%
*-commutative87.3%
times-frac88.6%
div-inv88.6%
metadata-eval88.6%
Applied egg-rr88.6%
Final simplification88.6%
(FPCore (w0 M D h l d) :precision binary64 (* w0 (sqrt (- 1.0 (* h (/ (pow (* D (/ M (* d 2.0))) 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 / (d * 2.0))), 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 / (d_1 * 2.0d0))) ** 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 / (d * 2.0))), 2.0) / l))));
}
def code(w0, M, D, h, l, d): return w0 * math.sqrt((1.0 - (h * (math.pow((D * (M / (d * 2.0))), 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(d * 2.0))) ^ 2.0) / l))))) end
function tmp = code(w0, M, D, h, l, d) tmp = w0 * sqrt((1.0 - (h * (((D * (M / (d * 2.0))) ^ 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[(d * 2.0), $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}{d \cdot 2}\right)}^{2}}{\ell}}
\end{array}
Initial program 81.8%
Simplified82.9%
unpow282.9%
associate-*l*84.4%
associate-/r*84.4%
associate-*r/83.3%
associate-*l/84.1%
*-commutative84.1%
associate-/r*84.1%
associate-*r/83.0%
associate-*l/84.1%
*-commutative84.1%
associate-*l*82.9%
unpow282.9%
expm1-log1p-u59.8%
expm1-undefine59.8%
Applied egg-rr81.8%
associate--l+81.8%
metadata-eval81.8%
+-rgt-identity81.8%
associate-*l/87.3%
associate-/l*86.5%
associate-/l*87.4%
Simplified87.4%
Final simplification87.4%
(FPCore (w0 M D h l d) :precision binary64 (if (<= (/ h l) -1e-283) (* w0 (+ 1.0 (* (/ 1.0 (* (/ l h) (pow (/ (/ d D) M) 2.0))) -0.125))) w0))
double code(double w0, double M, double D, double h, double l, double d) {
double tmp;
if ((h / l) <= -1e-283) {
tmp = w0 * (1.0 + ((1.0 / ((l / h) * pow(((d / D) / M), 2.0))) * -0.125));
} else {
tmp = w0;
}
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 ((h / l) <= (-1d-283)) then
tmp = w0 * (1.0d0 + ((1.0d0 / ((l / h) * (((d_1 / d) / m) ** 2.0d0))) * (-0.125d0)))
else
tmp = w0
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 ((h / l) <= -1e-283) {
tmp = w0 * (1.0 + ((1.0 / ((l / h) * Math.pow(((d / D) / M), 2.0))) * -0.125));
} else {
tmp = w0;
}
return tmp;
}
def code(w0, M, D, h, l, d): tmp = 0 if (h / l) <= -1e-283: tmp = w0 * (1.0 + ((1.0 / ((l / h) * math.pow(((d / D) / M), 2.0))) * -0.125)) else: tmp = w0 return tmp
function code(w0, M, D, h, l, d) tmp = 0.0 if (Float64(h / l) <= -1e-283) tmp = Float64(w0 * Float64(1.0 + Float64(Float64(1.0 / Float64(Float64(l / h) * (Float64(Float64(d / D) / M) ^ 2.0))) * -0.125))); else tmp = w0; end return tmp end
function tmp_2 = code(w0, M, D, h, l, d) tmp = 0.0; if ((h / l) <= -1e-283) tmp = w0 * (1.0 + ((1.0 / ((l / h) * (((d / D) / M) ^ 2.0))) * -0.125)); else tmp = w0; end tmp_2 = tmp; end
code[w0_, M_, D_, h_, l_, d_] := If[LessEqual[N[(h / l), $MachinePrecision], -1e-283], N[(w0 * N[(1.0 + N[(N[(1.0 / N[(N[(l / h), $MachinePrecision] * N[Power[N[(N[(d / D), $MachinePrecision] / M), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * -0.125), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], w0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{h}{\ell} \leq -1 \cdot 10^{-283}:\\
\;\;\;\;w0 \cdot \left(1 + \frac{1}{\frac{\ell}{h} \cdot {\left(\frac{\frac{d}{D}}{M}\right)}^{2}} \cdot -0.125\right)\\
\mathbf{else}:\\
\;\;\;\;w0\\
\end{array}
\end{array}
if (/.f64 h l) < -9.99999999999999947e-284Initial program 79.6%
Simplified80.3%
Taylor expanded in D around 0 54.9%
*-commutative54.9%
Simplified54.9%
add-sqr-sqrt37.8%
times-frac38.8%
sqrt-prod37.4%
sqrt-pow130.9%
metadata-eval30.9%
pow130.9%
sqrt-prod24.0%
sqrt-pow122.8%
metadata-eval22.8%
pow122.8%
Applied egg-rr38.3%
Taylor expanded in D around 0 54.9%
associate-*r*57.0%
unpow257.0%
unpow257.0%
swap-sqr69.5%
unpow269.5%
Simplified69.5%
clear-num69.5%
inv-pow69.5%
times-frac69.3%
unpow269.3%
unpow269.3%
frac-times72.3%
pow272.3%
Applied egg-rr72.3%
unpow-172.3%
*-commutative72.3%
associate-/r*72.3%
Simplified72.3%
if -9.99999999999999947e-284 < (/.f64 h l) Initial program 84.6%
Simplified86.4%
Taylor expanded in D around 0 95.6%
Final simplification82.3%
(FPCore (w0 M D h l d) :precision binary64 (if (<= D 2000000000000.0) w0 (+ w0 (* w0 (/ -0.125 (* (/ l h) (pow (/ d (* D M)) 2.0)))))))
double code(double w0, double M, double D, double h, double l, double d) {
double tmp;
if (D <= 2000000000000.0) {
tmp = w0;
} else {
tmp = w0 + (w0 * (-0.125 / ((l / h) * pow((d / (D * M)), 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 (d <= 2000000000000.0d0) then
tmp = w0
else
tmp = w0 + (w0 * ((-0.125d0) / ((l / h) * ((d_1 / (d * m)) ** 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 (D <= 2000000000000.0) {
tmp = w0;
} else {
tmp = w0 + (w0 * (-0.125 / ((l / h) * Math.pow((d / (D * M)), 2.0))));
}
return tmp;
}
def code(w0, M, D, h, l, d): tmp = 0 if D <= 2000000000000.0: tmp = w0 else: tmp = w0 + (w0 * (-0.125 / ((l / h) * math.pow((d / (D * M)), 2.0)))) return tmp
function code(w0, M, D, h, l, d) tmp = 0.0 if (D <= 2000000000000.0) tmp = w0; else tmp = Float64(w0 + Float64(w0 * Float64(-0.125 / Float64(Float64(l / h) * (Float64(d / Float64(D * M)) ^ 2.0))))); end return tmp end
function tmp_2 = code(w0, M, D, h, l, d) tmp = 0.0; if (D <= 2000000000000.0) tmp = w0; else tmp = w0 + (w0 * (-0.125 / ((l / h) * ((d / (D * M)) ^ 2.0)))); end tmp_2 = tmp; end
code[w0_, M_, D_, h_, l_, d_] := If[LessEqual[D, 2000000000000.0], w0, N[(w0 + N[(w0 * N[(-0.125 / N[(N[(l / h), $MachinePrecision] * N[Power[N[(d / N[(D * M), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;D \leq 2000000000000:\\
\;\;\;\;w0\\
\mathbf{else}:\\
\;\;\;\;w0 + w0 \cdot \frac{-0.125}{\frac{\ell}{h} \cdot {\left(\frac{d}{D \cdot M}\right)}^{2}}\\
\end{array}
\end{array}
if D < 2e12Initial program 82.0%
Simplified82.5%
Taylor expanded in D around 0 70.6%
if 2e12 < D Initial program 81.0%
Simplified84.2%
Taylor expanded in D around 0 34.5%
*-commutative34.5%
Simplified34.5%
add-sqr-sqrt25.3%
times-frac27.4%
sqrt-prod27.4%
sqrt-pow127.4%
metadata-eval27.4%
pow127.4%
sqrt-prod24.1%
sqrt-pow115.7%
metadata-eval15.7%
pow115.7%
Applied egg-rr52.1%
Taylor expanded in D around 0 34.5%
associate-*r*34.5%
unpow234.5%
unpow234.5%
swap-sqr62.5%
unpow262.5%
Simplified62.5%
+-commutative62.5%
distribute-rgt-in62.5%
*-commutative62.5%
clear-num62.5%
un-div-inv62.5%
times-frac63.6%
unpow263.6%
unpow263.6%
frac-times72.1%
pow272.1%
*-un-lft-identity72.1%
Applied egg-rr72.1%
Final simplification71.0%
(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.8%
Simplified82.9%
Taylor expanded in D around 0 66.4%
Final simplification66.4%
herbie shell --seed 2024071
(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))))))