
(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 (let* ((t_0 (* (/ 0.5 d) (* D M)))) (* w0 (sqrt (- 1.0 (/ (* h t_0) (/ l t_0)))))))
double code(double w0, double M, double D, double h, double l, double d) {
double t_0 = (0.5 / d) * (D * M);
return w0 * sqrt((1.0 - ((h * t_0) / (l / t_0))));
}
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) :: t_0
t_0 = (0.5d0 / d_1) * (d * m)
code = w0 * sqrt((1.0d0 - ((h * t_0) / (l / t_0))))
end function
public static double code(double w0, double M, double D, double h, double l, double d) {
double t_0 = (0.5 / d) * (D * M);
return w0 * Math.sqrt((1.0 - ((h * t_0) / (l / t_0))));
}
def code(w0, M, D, h, l, d): t_0 = (0.5 / d) * (D * M) return w0 * math.sqrt((1.0 - ((h * t_0) / (l / t_0))))
function code(w0, M, D, h, l, d) t_0 = Float64(Float64(0.5 / d) * Float64(D * M)) return Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(h * t_0) / Float64(l / t_0))))) end
function tmp = code(w0, M, D, h, l, d) t_0 = (0.5 / d) * (D * M); tmp = w0 * sqrt((1.0 - ((h * t_0) / (l / t_0)))); end
code[w0_, M_, D_, h_, l_, d_] := Block[{t$95$0 = N[(N[(0.5 / d), $MachinePrecision] * N[(D * M), $MachinePrecision]), $MachinePrecision]}, N[(w0 * N[Sqrt[N[(1.0 - N[(N[(h * t$95$0), $MachinePrecision] / N[(l / t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{0.5}{d} \cdot \left(D \cdot M\right)\\
w0 \cdot \sqrt{1 - \frac{h \cdot t\_0}{\frac{\ell}{t\_0}}}
\end{array}
\end{array}
Initial program 77.2%
Simplified76.5%
clear-num76.5%
un-div-inv76.5%
*-commutative76.5%
associate-*l/77.3%
associate-*r/76.5%
div-inv76.5%
metadata-eval76.5%
Applied egg-rr76.5%
associate-/r/84.7%
associate-*l/84.4%
*-commutative84.4%
associate-/l*84.7%
associate-*r/84.8%
*-commutative84.8%
associate-/l*84.4%
associate-*r/84.4%
Simplified84.4%
unpow284.4%
add-sqr-sqrt41.8%
times-frac42.5%
Applied egg-rr42.5%
unpow242.5%
Simplified42.5%
unpow242.5%
frac-times41.8%
add-sqr-sqrt84.4%
*-un-lft-identity84.4%
frac-times86.2%
clear-num86.2%
frac-times86.2%
metadata-eval86.2%
div-inv86.2%
/-rgt-identity86.2%
metadata-eval86.2%
times-frac86.2%
*-un-lft-identity86.2%
*-un-lft-identity86.2%
Applied egg-rr86.2%
div-inv86.2%
associate-*r*85.1%
clear-num85.1%
associate-*r*86.2%
clear-num86.2%
div-inv86.2%
associate-*r*85.1%
associate-*r/86.4%
*-commutative86.4%
associate-*r*87.5%
*-commutative87.5%
Applied egg-rr87.5%
Final simplification87.5%
(FPCore (w0 M D h l d) :precision binary64 (let* ((t_0 (/ (* D M) d))) (if (<= D 1.12e+132) w0 (fma -0.125 (* (* t_0 t_0) (/ (* w0 h) l)) w0))))
double code(double w0, double M, double D, double h, double l, double d) {
double t_0 = (D * M) / d;
double tmp;
if (D <= 1.12e+132) {
tmp = w0;
} else {
tmp = fma(-0.125, ((t_0 * t_0) * ((w0 * h) / l)), w0);
}
return tmp;
}
function code(w0, M, D, h, l, d) t_0 = Float64(Float64(D * M) / d) tmp = 0.0 if (D <= 1.12e+132) tmp = w0; else tmp = fma(-0.125, Float64(Float64(t_0 * t_0) * Float64(Float64(w0 * h) / l)), w0); end return tmp end
code[w0_, M_, D_, h_, l_, d_] := Block[{t$95$0 = N[(N[(D * M), $MachinePrecision] / d), $MachinePrecision]}, If[LessEqual[D, 1.12e+132], w0, N[(-0.125 * N[(N[(t$95$0 * t$95$0), $MachinePrecision] * N[(N[(w0 * h), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision] + w0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{D \cdot M}{d}\\
\mathbf{if}\;D \leq 1.12 \cdot 10^{+132}:\\
\;\;\;\;w0\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-0.125, \left(t\_0 \cdot t\_0\right) \cdot \frac{w0 \cdot h}{\ell}, w0\right)\\
\end{array}
\end{array}
if D < 1.12e132Initial program 78.5%
Simplified77.6%
Taylor expanded in D around 0 72.1%
if 1.12e132 < D Initial program 65.9%
Simplified65.9%
Taylor expanded in D around 0 37.1%
+-commutative37.1%
fma-define37.1%
associate-*r*33.3%
unpow233.3%
unpow233.3%
swap-sqr53.8%
unpow253.8%
Simplified53.8%
times-frac57.0%
Applied egg-rr57.0%
add-sqr-sqrt57.0%
sqrt-div57.0%
sqrt-pow136.9%
metadata-eval36.9%
pow136.9%
sqrt-pow144.9%
metadata-eval44.9%
pow144.9%
sqrt-div44.9%
sqrt-pow149.1%
metadata-eval49.1%
pow149.1%
sqrt-pow165.1%
metadata-eval65.1%
pow165.1%
Applied egg-rr65.1%
Final simplification71.4%
(FPCore (w0 M D h l d) :precision binary64 (* w0 (sqrt (- 1.0 (* h (/ (* D (* (/ 0.5 d) M)) (/ l (* 0.5 (/ (* D M) d)))))))))
double code(double w0, double M, double D, double h, double l, double d) {
return w0 * sqrt((1.0 - (h * ((D * ((0.5 / d) * M)) / (l / (0.5 * ((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 - (h * ((d * ((0.5d0 / d_1) * m)) / (l / (0.5d0 * ((d * m) / d_1)))))))
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 * ((0.5 / d) * M)) / (l / (0.5 * ((D * M) / d)))))));
}
def code(w0, M, D, h, l, d): return w0 * math.sqrt((1.0 - (h * ((D * ((0.5 / d) * M)) / (l / (0.5 * ((D * M) / d)))))))
function code(w0, M, D, h, l, d) return Float64(w0 * sqrt(Float64(1.0 - Float64(h * Float64(Float64(D * Float64(Float64(0.5 / d) * M)) / Float64(l / Float64(0.5 * Float64(Float64(D * M) / d)))))))) end
function tmp = code(w0, M, D, h, l, d) tmp = w0 * sqrt((1.0 - (h * ((D * ((0.5 / d) * M)) / (l / (0.5 * ((D * M) / d))))))); end
code[w0_, M_, D_, h_, l_, d_] := N[(w0 * N[Sqrt[N[(1.0 - N[(h * N[(N[(D * N[(N[(0.5 / d), $MachinePrecision] * M), $MachinePrecision]), $MachinePrecision] / N[(l / N[(0.5 * N[(N[(D * M), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
w0 \cdot \sqrt{1 - h \cdot \frac{D \cdot \left(\frac{0.5}{d} \cdot M\right)}{\frac{\ell}{0.5 \cdot \frac{D \cdot M}{d}}}}
\end{array}
Initial program 77.2%
Simplified76.5%
clear-num76.5%
un-div-inv76.5%
*-commutative76.5%
associate-*l/77.3%
associate-*r/76.5%
div-inv76.5%
metadata-eval76.5%
Applied egg-rr76.5%
associate-/r/84.7%
associate-*l/84.4%
*-commutative84.4%
associate-/l*84.7%
associate-*r/84.8%
*-commutative84.8%
associate-/l*84.4%
associate-*r/84.4%
Simplified84.4%
unpow284.4%
add-sqr-sqrt41.8%
times-frac42.5%
Applied egg-rr42.5%
unpow242.5%
Simplified42.5%
unpow242.5%
frac-times41.8%
add-sqr-sqrt84.4%
*-un-lft-identity84.4%
frac-times86.2%
clear-num86.2%
frac-times86.2%
metadata-eval86.2%
div-inv86.2%
/-rgt-identity86.2%
metadata-eval86.2%
times-frac86.2%
*-un-lft-identity86.2%
*-un-lft-identity86.2%
Applied egg-rr86.2%
Taylor expanded in D around 0 85.1%
Final simplification85.1%
(FPCore (w0 M D h l d) :precision binary64 (let* ((t_0 (* D (* (/ 0.5 d) M)))) (* w0 (sqrt (- 1.0 (* h (/ t_0 (/ l t_0))))))))
double code(double w0, double M, double D, double h, double l, double d) {
double t_0 = D * ((0.5 / d) * M);
return w0 * sqrt((1.0 - (h * (t_0 / (l / t_0)))));
}
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) :: t_0
t_0 = d * ((0.5d0 / d_1) * m)
code = w0 * sqrt((1.0d0 - (h * (t_0 / (l / t_0)))))
end function
public static double code(double w0, double M, double D, double h, double l, double d) {
double t_0 = D * ((0.5 / d) * M);
return w0 * Math.sqrt((1.0 - (h * (t_0 / (l / t_0)))));
}
def code(w0, M, D, h, l, d): t_0 = D * ((0.5 / d) * M) return w0 * math.sqrt((1.0 - (h * (t_0 / (l / t_0)))))
function code(w0, M, D, h, l, d) t_0 = Float64(D * Float64(Float64(0.5 / d) * M)) return Float64(w0 * sqrt(Float64(1.0 - Float64(h * Float64(t_0 / Float64(l / t_0)))))) end
function tmp = code(w0, M, D, h, l, d) t_0 = D * ((0.5 / d) * M); tmp = w0 * sqrt((1.0 - (h * (t_0 / (l / t_0))))); end
code[w0_, M_, D_, h_, l_, d_] := Block[{t$95$0 = N[(D * N[(N[(0.5 / d), $MachinePrecision] * M), $MachinePrecision]), $MachinePrecision]}, N[(w0 * N[Sqrt[N[(1.0 - N[(h * N[(t$95$0 / N[(l / t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := D \cdot \left(\frac{0.5}{d} \cdot M\right)\\
w0 \cdot \sqrt{1 - h \cdot \frac{t\_0}{\frac{\ell}{t\_0}}}
\end{array}
\end{array}
Initial program 77.2%
Simplified76.5%
clear-num76.5%
un-div-inv76.5%
*-commutative76.5%
associate-*l/77.3%
associate-*r/76.5%
div-inv76.5%
metadata-eval76.5%
Applied egg-rr76.5%
associate-/r/84.7%
associate-*l/84.4%
*-commutative84.4%
associate-/l*84.7%
associate-*r/84.8%
*-commutative84.8%
associate-/l*84.4%
associate-*r/84.4%
Simplified84.4%
unpow284.4%
add-sqr-sqrt41.8%
times-frac42.5%
Applied egg-rr42.5%
unpow242.5%
Simplified42.5%
unpow242.5%
frac-times41.8%
add-sqr-sqrt84.4%
*-un-lft-identity84.4%
frac-times86.2%
clear-num86.2%
frac-times86.2%
metadata-eval86.2%
div-inv86.2%
/-rgt-identity86.2%
metadata-eval86.2%
times-frac86.2%
*-un-lft-identity86.2%
*-un-lft-identity86.2%
Applied egg-rr86.2%
Final simplification86.2%
(FPCore (w0 M D h l d) :precision binary64 (let* ((t_0 (* M (* (/ 0.5 d) D)))) (* w0 (sqrt (- 1.0 (/ (* h t_0) (/ l t_0)))))))
double code(double w0, double M, double D, double h, double l, double d) {
double t_0 = M * ((0.5 / d) * D);
return w0 * sqrt((1.0 - ((h * t_0) / (l / t_0))));
}
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) :: t_0
t_0 = m * ((0.5d0 / d_1) * d)
code = w0 * sqrt((1.0d0 - ((h * t_0) / (l / t_0))))
end function
public static double code(double w0, double M, double D, double h, double l, double d) {
double t_0 = M * ((0.5 / d) * D);
return w0 * Math.sqrt((1.0 - ((h * t_0) / (l / t_0))));
}
def code(w0, M, D, h, l, d): t_0 = M * ((0.5 / d) * D) return w0 * math.sqrt((1.0 - ((h * t_0) / (l / t_0))))
function code(w0, M, D, h, l, d) t_0 = Float64(M * Float64(Float64(0.5 / d) * D)) return Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(h * t_0) / Float64(l / t_0))))) end
function tmp = code(w0, M, D, h, l, d) t_0 = M * ((0.5 / d) * D); tmp = w0 * sqrt((1.0 - ((h * t_0) / (l / t_0)))); end
code[w0_, M_, D_, h_, l_, d_] := Block[{t$95$0 = N[(M * N[(N[(0.5 / d), $MachinePrecision] * D), $MachinePrecision]), $MachinePrecision]}, N[(w0 * N[Sqrt[N[(1.0 - N[(N[(h * t$95$0), $MachinePrecision] / N[(l / t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := M \cdot \left(\frac{0.5}{d} \cdot D\right)\\
w0 \cdot \sqrt{1 - \frac{h \cdot t\_0}{\frac{\ell}{t\_0}}}
\end{array}
\end{array}
Initial program 77.2%
Simplified76.5%
clear-num76.5%
un-div-inv76.5%
*-commutative76.5%
associate-*l/77.3%
associate-*r/76.5%
div-inv76.5%
metadata-eval76.5%
Applied egg-rr76.5%
associate-/r/84.7%
associate-*l/84.4%
*-commutative84.4%
associate-/l*84.7%
associate-*r/84.8%
*-commutative84.8%
associate-/l*84.4%
associate-*r/84.4%
Simplified84.4%
unpow284.4%
add-sqr-sqrt41.8%
times-frac42.5%
Applied egg-rr42.5%
unpow242.5%
Simplified42.5%
unpow242.5%
frac-times41.8%
add-sqr-sqrt84.4%
*-un-lft-identity84.4%
frac-times86.2%
clear-num86.2%
frac-times86.2%
metadata-eval86.2%
div-inv86.2%
/-rgt-identity86.2%
metadata-eval86.2%
times-frac86.2%
*-un-lft-identity86.2%
*-un-lft-identity86.2%
Applied egg-rr86.2%
div-inv86.2%
associate-*r*85.1%
clear-num85.1%
associate-*r*86.2%
clear-num86.2%
div-inv86.2%
associate-*r*85.1%
associate-*r/86.4%
*-commutative86.4%
associate-*r*87.5%
*-commutative87.5%
Applied egg-rr87.5%
associate-*r*86.4%
associate-*r*87.5%
Simplified87.5%
Final simplification87.5%
(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 77.2%
Simplified76.5%
Taylor expanded in D around 0 68.5%
Final simplification68.5%
herbie shell --seed 2024060
(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))))))