
(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 6 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 (/ (* M (* D 0.5)) 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(((M * (D * 0.5)) / 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 * (((m * (d * 0.5d0)) / 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(((M * (D * 0.5)) / d), 2.0)) / l)));
}
def code(w0, M, D, h, l, d): return w0 * math.sqrt((1.0 - ((h * math.pow(((M * (D * 0.5)) / d), 2.0)) / l)))
function code(w0, M, D, h, l, d) return Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(h * (Float64(Float64(M * Float64(D * 0.5)) / d) ^ 2.0)) / l)))) end
function tmp = code(w0, M, D, h, l, d) tmp = w0 * sqrt((1.0 - ((h * (((M * (D * 0.5)) / d) ^ 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[(M * N[(D * 0.5), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
w0 \cdot \sqrt{1 - \frac{h \cdot {\left(\frac{M \cdot \left(D \cdot 0.5\right)}{d}\right)}^{2}}{\ell}}
\end{array}
Initial program 81.1%
Simplified80.3%
unpow280.3%
unpow280.3%
*-commutative80.3%
associate-*l/81.1%
associate-*r/81.5%
times-frac81.1%
associate-*r/86.3%
*-commutative86.3%
pow186.3%
associate-/l*87.0%
pow187.0%
div-inv87.0%
associate-/r*87.0%
metadata-eval87.0%
Applied egg-rr87.0%
associate-*r/87.0%
associate-*r/86.3%
Applied egg-rr86.3%
(FPCore (w0 M D h l d) :precision binary64 (if (<= D 2.8e+17) w0 (* w0 (sqrt (- 1.0 (* (* D (* (/ M d) (* 0.25 (* D (/ M d))))) (/ h l)))))))
double code(double w0, double M, double D, double h, double l, double d) {
double tmp;
if (D <= 2.8e+17) {
tmp = w0;
} else {
tmp = w0 * sqrt((1.0 - ((D * ((M / d) * (0.25 * (D * (M / d))))) * (h / 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 <= 2.8d+17) then
tmp = w0
else
tmp = w0 * sqrt((1.0d0 - ((d * ((m / d_1) * (0.25d0 * (d * (m / d_1))))) * (h / 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 <= 2.8e+17) {
tmp = w0;
} else {
tmp = w0 * Math.sqrt((1.0 - ((D * ((M / d) * (0.25 * (D * (M / d))))) * (h / l))));
}
return tmp;
}
def code(w0, M, D, h, l, d): tmp = 0 if D <= 2.8e+17: tmp = w0 else: tmp = w0 * math.sqrt((1.0 - ((D * ((M / d) * (0.25 * (D * (M / d))))) * (h / l)))) return tmp
function code(w0, M, D, h, l, d) tmp = 0.0 if (D <= 2.8e+17) tmp = w0; else tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(D * Float64(Float64(M / d) * Float64(0.25 * Float64(D * Float64(M / d))))) * Float64(h / l))))); end return tmp end
function tmp_2 = code(w0, M, D, h, l, d) tmp = 0.0; if (D <= 2.8e+17) tmp = w0; else tmp = w0 * sqrt((1.0 - ((D * ((M / d) * (0.25 * (D * (M / d))))) * (h / l)))); end tmp_2 = tmp; end
code[w0_, M_, D_, h_, l_, d_] := If[LessEqual[D, 2.8e+17], w0, N[(w0 * N[Sqrt[N[(1.0 - N[(N[(D * N[(N[(M / d), $MachinePrecision] * N[(0.25 * N[(D * N[(M / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;D \leq 2.8 \cdot 10^{+17}:\\
\;\;\;\;w0\\
\mathbf{else}:\\
\;\;\;\;w0 \cdot \sqrt{1 - \left(D \cdot \left(\frac{M}{d} \cdot \left(0.25 \cdot \left(D \cdot \frac{M}{d}\right)\right)\right)\right) \cdot \frac{h}{\ell}}\\
\end{array}
\end{array}
if D < 2.8e17Initial program 82.3%
Simplified81.4%
Taylor expanded in D around 0 72.4%
if 2.8e17 < D Initial program 75.6%
Simplified75.6%
unpow275.6%
*-commutative75.6%
associate-*l/75.6%
associate-*r/75.6%
times-frac75.6%
clear-num75.6%
un-div-inv75.6%
*-commutative75.6%
associate-*l/75.6%
associate-*r/75.6%
times-frac75.6%
associate-/l*75.6%
div-inv75.6%
associate-/r*75.6%
metadata-eval75.6%
times-frac75.6%
Applied egg-rr75.6%
associate-*r*75.5%
*-commutative75.5%
associate-*r/75.6%
associate-*r*75.6%
associate-/r*73.6%
*-commutative73.6%
associate-/l*73.7%
*-commutative73.7%
Simplified73.7%
times-frac75.6%
Applied egg-rr75.6%
associate-*l/75.6%
associate-/l*75.6%
associate-/r*75.6%
Simplified75.6%
Taylor expanded in d around 0 75.6%
associate-*r/75.6%
Simplified75.6%
(FPCore (w0 M D h l d) :precision binary64 (if (<= D 1e+17) w0 (* w0 (sqrt (- 1.0 (* D (* (/ h l) (* (/ M d) (* (* M D) (/ 0.25 d))))))))))
double code(double w0, double M, double D, double h, double l, double d) {
double tmp;
if (D <= 1e+17) {
tmp = w0;
} else {
tmp = w0 * sqrt((1.0 - (D * ((h / l) * ((M / d) * ((M * D) * (0.25 / 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 <= 1d+17) then
tmp = w0
else
tmp = w0 * sqrt((1.0d0 - (d * ((h / l) * ((m / d_1) * ((m * d) * (0.25d0 / 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 <= 1e+17) {
tmp = w0;
} else {
tmp = w0 * Math.sqrt((1.0 - (D * ((h / l) * ((M / d) * ((M * D) * (0.25 / d)))))));
}
return tmp;
}
def code(w0, M, D, h, l, d): tmp = 0 if D <= 1e+17: tmp = w0 else: tmp = w0 * math.sqrt((1.0 - (D * ((h / l) * ((M / d) * ((M * D) * (0.25 / d))))))) return tmp
function code(w0, M, D, h, l, d) tmp = 0.0 if (D <= 1e+17) tmp = w0; else tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(D * Float64(Float64(h / l) * Float64(Float64(M / d) * Float64(Float64(M * D) * Float64(0.25 / d)))))))); end return tmp end
function tmp_2 = code(w0, M, D, h, l, d) tmp = 0.0; if (D <= 1e+17) tmp = w0; else tmp = w0 * sqrt((1.0 - (D * ((h / l) * ((M / d) * ((M * D) * (0.25 / d))))))); end tmp_2 = tmp; end
code[w0_, M_, D_, h_, l_, d_] := If[LessEqual[D, 1e+17], w0, N[(w0 * N[Sqrt[N[(1.0 - N[(D * N[(N[(h / l), $MachinePrecision] * N[(N[(M / d), $MachinePrecision] * N[(N[(M * D), $MachinePrecision] * N[(0.25 / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;D \leq 10^{+17}:\\
\;\;\;\;w0\\
\mathbf{else}:\\
\;\;\;\;w0 \cdot \sqrt{1 - D \cdot \left(\frac{h}{\ell} \cdot \left(\frac{M}{d} \cdot \left(\left(M \cdot D\right) \cdot \frac{0.25}{d}\right)\right)\right)}\\
\end{array}
\end{array}
if D < 1e17Initial program 82.3%
Simplified81.4%
Taylor expanded in D around 0 72.4%
if 1e17 < D Initial program 75.6%
Simplified75.6%
unpow275.6%
*-commutative75.6%
associate-*l/75.6%
associate-*r/75.6%
times-frac75.6%
clear-num75.6%
un-div-inv75.6%
*-commutative75.6%
associate-*l/75.6%
associate-*r/75.6%
times-frac75.6%
associate-/l*75.6%
div-inv75.6%
associate-/r*75.6%
metadata-eval75.6%
times-frac75.6%
Applied egg-rr75.6%
associate-*r*75.5%
*-commutative75.5%
associate-*r/75.6%
associate-*r*75.6%
associate-/r*73.6%
*-commutative73.6%
associate-/l*73.7%
*-commutative73.7%
Simplified73.7%
times-frac75.6%
Applied egg-rr75.6%
associate-*l/75.6%
associate-/l*75.6%
associate-/r*75.6%
Simplified75.6%
associate-*r/75.9%
associate-/r*75.9%
metadata-eval75.9%
*-commutative75.9%
Applied egg-rr75.9%
associate-*r/75.6%
associate-*l*77.6%
associate-/r/77.6%
*-commutative77.6%
Simplified77.6%
Final simplification73.3%
(FPCore (w0 M D h l d) :precision binary64 (if (<= D 1.18e+145) w0 (+ w0 (* -0.125 (/ 1.0 (* (pow (/ (/ d M) D) 2.0) (/ l (* w0 h))))))))
double code(double w0, double M, double D, double h, double l, double d) {
double tmp;
if (D <= 1.18e+145) {
tmp = w0;
} else {
tmp = w0 + (-0.125 * (1.0 / (pow(((d / M) / D), 2.0) * (l / (w0 * h)))));
}
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.18d+145) then
tmp = w0
else
tmp = w0 + ((-0.125d0) * (1.0d0 / ((((d_1 / m) / d) ** 2.0d0) * (l / (w0 * h)))))
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.18e+145) {
tmp = w0;
} else {
tmp = w0 + (-0.125 * (1.0 / (Math.pow(((d / M) / D), 2.0) * (l / (w0 * h)))));
}
return tmp;
}
def code(w0, M, D, h, l, d): tmp = 0 if D <= 1.18e+145: tmp = w0 else: tmp = w0 + (-0.125 * (1.0 / (math.pow(((d / M) / D), 2.0) * (l / (w0 * h))))) return tmp
function code(w0, M, D, h, l, d) tmp = 0.0 if (D <= 1.18e+145) tmp = w0; else tmp = Float64(w0 + Float64(-0.125 * Float64(1.0 / Float64((Float64(Float64(d / M) / D) ^ 2.0) * Float64(l / Float64(w0 * h)))))); end return tmp end
function tmp_2 = code(w0, M, D, h, l, d) tmp = 0.0; if (D <= 1.18e+145) tmp = w0; else tmp = w0 + (-0.125 * (1.0 / ((((d / M) / D) ^ 2.0) * (l / (w0 * h))))); end tmp_2 = tmp; end
code[w0_, M_, D_, h_, l_, d_] := If[LessEqual[D, 1.18e+145], w0, N[(w0 + N[(-0.125 * N[(1.0 / N[(N[Power[N[(N[(d / M), $MachinePrecision] / D), $MachinePrecision], 2.0], $MachinePrecision] * N[(l / N[(w0 * h), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;D \leq 1.18 \cdot 10^{+145}:\\
\;\;\;\;w0\\
\mathbf{else}:\\
\;\;\;\;w0 + -0.125 \cdot \frac{1}{{\left(\frac{\frac{d}{M}}{D}\right)}^{2} \cdot \frac{\ell}{w0 \cdot h}}\\
\end{array}
\end{array}
if D < 1.17999999999999998e145Initial program 82.9%
Simplified82.1%
Taylor expanded in D around 0 71.2%
if 1.17999999999999998e145 < D Initial program 62.5%
Simplified62.5%
Taylor expanded in D around 0 26.5%
unpow226.5%
Applied egg-rr26.5%
expm1-log1p-u13.5%
associate-*r*13.8%
pow213.8%
pow-prod-down22.9%
*-commutative22.9%
Applied egg-rr22.9%
clear-num22.9%
inv-pow22.9%
expm1-log1p-u40.5%
Applied egg-rr40.5%
unpow-140.5%
times-frac40.2%
unpow240.2%
unpow240.2%
times-frac57.6%
unpow257.6%
associate-/r*57.6%
Simplified57.6%
Final simplification70.0%
(FPCore (w0 M D h l d) :precision binary64 (* w0 (sqrt (- 1.0 (/ (* h (* D (* (/ M d) (/ 0.25 (/ d (* M D)))))) l)))))
double code(double w0, double M, double D, double h, double l, double d) {
return w0 * sqrt((1.0 - ((h * (D * ((M / d) * (0.25 / (d / (M * D)))))) / 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) * (0.25d0 / (d_1 / (m * d)))))) / 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 * (D * ((M / d) * (0.25 / (d / (M * D)))))) / l)));
}
def code(w0, M, D, h, l, d): return w0 * math.sqrt((1.0 - ((h * (D * ((M / d) * (0.25 / (d / (M * D)))))) / l)))
function code(w0, M, D, h, l, d) return Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(h * Float64(D * Float64(Float64(M / d) * Float64(0.25 / Float64(d / Float64(M * D)))))) / l)))) end
function tmp = code(w0, M, D, h, l, d) tmp = w0 * sqrt((1.0 - ((h * (D * ((M / d) * (0.25 / (d / (M * D)))))) / l))); end
code[w0_, M_, D_, h_, l_, d_] := N[(w0 * N[Sqrt[N[(1.0 - N[(N[(h * N[(D * N[(N[(M / d), $MachinePrecision] * N[(0.25 / N[(d / N[(M * D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
w0 \cdot \sqrt{1 - \frac{h \cdot \left(D \cdot \left(\frac{M}{d} \cdot \frac{0.25}{\frac{d}{M \cdot D}}\right)\right)}{\ell}}
\end{array}
Initial program 81.1%
Simplified80.3%
unpow280.3%
*-commutative80.3%
associate-*l/79.9%
associate-*r/80.4%
times-frac79.9%
clear-num79.9%
un-div-inv79.9%
*-commutative79.9%
associate-*l/81.0%
associate-*r/81.1%
times-frac81.0%
associate-/l*81.1%
div-inv81.1%
associate-/r*81.1%
metadata-eval81.1%
times-frac81.5%
Applied egg-rr81.5%
associate-*r*81.0%
*-commutative81.0%
associate-*r/81.0%
associate-*r*81.0%
associate-/r*79.2%
*-commutative79.2%
associate-/l*78.5%
*-commutative78.5%
Simplified78.5%
times-frac79.6%
Applied egg-rr79.6%
associate-*l/79.6%
associate-/l*79.6%
associate-/r*79.1%
Simplified79.1%
associate-*r/84.4%
associate-/r*84.4%
metadata-eval84.4%
*-commutative84.4%
Applied egg-rr84.4%
Final simplification84.4%
(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.1%
Simplified80.3%
Taylor expanded in D around 0 67.7%
herbie shell --seed 2024146
(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))))))