
(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 4 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}
D_m = (fabs.f64 D)
w0\_m = (fabs.f64 w0)
w0\_s = (copysign.f64 #s(literal 1 binary64) w0)
NOTE: w0_m, M, D_m, h, l, and d should be sorted in increasing order before calling this function.
(FPCore (w0_s w0_m M D_m h l d)
:precision binary64
(let* ((t_0 (* M (* D_m (/ 0.5 d)))))
(*
w0_s
(if (<=
(* w0_m (sqrt (- 1.0 (* (pow (/ (* M D_m) (* 2.0 d)) 2.0) (/ h l)))))
5e+183)
(* w0_m (sqrt (- 1.0 (* (/ h l) (pow (* D_m (/ (/ M 2.0) d)) 2.0)))))
(* w0_m (sqrt (- 1.0 (/ (* h t_0) (/ l t_0)))))))))D_m = fabs(D);
w0\_m = fabs(w0);
w0\_s = copysign(1.0, w0);
assert(w0_m < M && M < D_m && D_m < h && h < l && l < d);
double code(double w0_s, double w0_m, double M, double D_m, double h, double l, double d) {
double t_0 = M * (D_m * (0.5 / d));
double tmp;
if ((w0_m * sqrt((1.0 - (pow(((M * D_m) / (2.0 * d)), 2.0) * (h / l))))) <= 5e+183) {
tmp = w0_m * sqrt((1.0 - ((h / l) * pow((D_m * ((M / 2.0) / d)), 2.0))));
} else {
tmp = w0_m * sqrt((1.0 - ((h * t_0) / (l / t_0))));
}
return w0_s * tmp;
}
D_m = abs(d)
w0\_m = abs(w0)
w0\_s = copysign(1.0d0, w0)
NOTE: w0_m, M, D_m, h, l, and d should be sorted in increasing order before calling this function.
real(8) function code(w0_s, w0_m, m, d_m, h, l, d)
real(8), intent (in) :: w0_s
real(8), intent (in) :: w0_m
real(8), intent (in) :: m
real(8), intent (in) :: d_m
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: d
real(8) :: t_0
real(8) :: tmp
t_0 = m * (d_m * (0.5d0 / d))
if ((w0_m * sqrt((1.0d0 - ((((m * d_m) / (2.0d0 * d)) ** 2.0d0) * (h / l))))) <= 5d+183) then
tmp = w0_m * sqrt((1.0d0 - ((h / l) * ((d_m * ((m / 2.0d0) / d)) ** 2.0d0))))
else
tmp = w0_m * sqrt((1.0d0 - ((h * t_0) / (l / t_0))))
end if
code = w0_s * tmp
end function
D_m = Math.abs(D);
w0\_m = Math.abs(w0);
w0\_s = Math.copySign(1.0, w0);
assert w0_m < M && M < D_m && D_m < h && h < l && l < d;
public static double code(double w0_s, double w0_m, double M, double D_m, double h, double l, double d) {
double t_0 = M * (D_m * (0.5 / d));
double tmp;
if ((w0_m * Math.sqrt((1.0 - (Math.pow(((M * D_m) / (2.0 * d)), 2.0) * (h / l))))) <= 5e+183) {
tmp = w0_m * Math.sqrt((1.0 - ((h / l) * Math.pow((D_m * ((M / 2.0) / d)), 2.0))));
} else {
tmp = w0_m * Math.sqrt((1.0 - ((h * t_0) / (l / t_0))));
}
return w0_s * tmp;
}
D_m = math.fabs(D) w0\_m = math.fabs(w0) w0\_s = math.copysign(1.0, w0) [w0_m, M, D_m, h, l, d] = sort([w0_m, M, D_m, h, l, d]) def code(w0_s, w0_m, M, D_m, h, l, d): t_0 = M * (D_m * (0.5 / d)) tmp = 0 if (w0_m * math.sqrt((1.0 - (math.pow(((M * D_m) / (2.0 * d)), 2.0) * (h / l))))) <= 5e+183: tmp = w0_m * math.sqrt((1.0 - ((h / l) * math.pow((D_m * ((M / 2.0) / d)), 2.0)))) else: tmp = w0_m * math.sqrt((1.0 - ((h * t_0) / (l / t_0)))) return w0_s * tmp
D_m = abs(D) w0\_m = abs(w0) w0\_s = copysign(1.0, w0) w0_m, M, D_m, h, l, d = sort([w0_m, M, D_m, h, l, d]) function code(w0_s, w0_m, M, D_m, h, l, d) t_0 = Float64(M * Float64(D_m * Float64(0.5 / d))) tmp = 0.0 if (Float64(w0_m * sqrt(Float64(1.0 - Float64((Float64(Float64(M * D_m) / Float64(2.0 * d)) ^ 2.0) * Float64(h / l))))) <= 5e+183) tmp = Float64(w0_m * sqrt(Float64(1.0 - Float64(Float64(h / l) * (Float64(D_m * Float64(Float64(M / 2.0) / d)) ^ 2.0))))); else tmp = Float64(w0_m * sqrt(Float64(1.0 - Float64(Float64(h * t_0) / Float64(l / t_0))))); end return Float64(w0_s * tmp) end
D_m = abs(D);
w0\_m = abs(w0);
w0\_s = sign(w0) * abs(1.0);
w0_m, M, D_m, h, l, d = num2cell(sort([w0_m, M, D_m, h, l, d])){:}
function tmp_2 = code(w0_s, w0_m, M, D_m, h, l, d)
t_0 = M * (D_m * (0.5 / d));
tmp = 0.0;
if ((w0_m * sqrt((1.0 - ((((M * D_m) / (2.0 * d)) ^ 2.0) * (h / l))))) <= 5e+183)
tmp = w0_m * sqrt((1.0 - ((h / l) * ((D_m * ((M / 2.0) / d)) ^ 2.0))));
else
tmp = w0_m * sqrt((1.0 - ((h * t_0) / (l / t_0))));
end
tmp_2 = w0_s * tmp;
end
D_m = N[Abs[D], $MachinePrecision]
w0\_m = N[Abs[w0], $MachinePrecision]
w0\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[w0]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: w0_m, M, D_m, h, l, and d should be sorted in increasing order before calling this function.
code[w0$95$s_, w0$95$m_, M_, D$95$m_, h_, l_, d_] := Block[{t$95$0 = N[(M * N[(D$95$m * N[(0.5 / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, N[(w0$95$s * If[LessEqual[N[(w0$95$m * N[Sqrt[N[(1.0 - N[(N[Power[N[(N[(M * D$95$m), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 5e+183], N[(w0$95$m * N[Sqrt[N[(1.0 - N[(N[(h / l), $MachinePrecision] * N[Power[N[(D$95$m * N[(N[(M / 2.0), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(w0$95$m * N[Sqrt[N[(1.0 - N[(N[(h * t$95$0), $MachinePrecision] / N[(l / t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]]
\begin{array}{l}
D_m = \left|D\right|
\\
w0\_m = \left|w0\right|
\\
w0\_s = \mathsf{copysign}\left(1, w0\right)
\\
[w0_m, M, D_m, h, l, d] = \mathsf{sort}([w0_m, M, D_m, h, l, d])\\
\\
\begin{array}{l}
t_0 := M \cdot \left(D\_m \cdot \frac{0.5}{d}\right)\\
w0\_s \cdot \begin{array}{l}
\mathbf{if}\;w0\_m \cdot \sqrt{1 - {\left(\frac{M \cdot D\_m}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \leq 5 \cdot 10^{+183}:\\
\;\;\;\;w0\_m \cdot \sqrt{1 - \frac{h}{\ell} \cdot {\left(D\_m \cdot \frac{\frac{M}{2}}{d}\right)}^{2}}\\
\mathbf{else}:\\
\;\;\;\;w0\_m \cdot \sqrt{1 - \frac{h \cdot t\_0}{\frac{\ell}{t\_0}}}\\
\end{array}
\end{array}
\end{array}
if (*.f64 w0 (sqrt.f64 (-.f64 #s(literal 1 binary64) (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64)) (/.f64 h l))))) < 5.00000000000000009e183Initial program 95.7%
Simplified95.1%
if 5.00000000000000009e183 < (*.f64 w0 (sqrt.f64 (-.f64 #s(literal 1 binary64) (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64)) (/.f64 h l))))) Initial program 57.1%
Simplified58.8%
clear-num58.8%
un-div-inv62.5%
clear-num62.5%
un-div-inv62.5%
associate-/r/62.5%
Applied egg-rr62.5%
associate-/r/79.0%
associate-*l/79.0%
*-commutative79.0%
associate-/l*79.0%
associate-*l/79.0%
*-commutative79.0%
associate-*l/79.0%
associate-/l/79.0%
associate-/r/79.0%
associate-*l/79.0%
*-commutative79.0%
associate-*r/77.3%
*-commutative77.3%
associate-/l/77.3%
associate-/l*79.0%
Simplified79.0%
unpow279.0%
associate-/l*82.5%
div-inv82.5%
associate-/r*82.5%
metadata-eval82.5%
div-inv82.6%
associate-/r*82.6%
metadata-eval82.6%
Applied egg-rr82.6%
Taylor expanded in D around 0 75.5%
associate-*r/75.5%
associate-/r*79.1%
associate-*l/79.1%
*-commutative79.1%
associate-*r*82.6%
associate-*r/80.9%
associate-*r/80.9%
associate-/l/77.6%
*-commutative77.6%
*-commutative77.6%
Simplified77.6%
associate-*r*77.2%
div-inv77.2%
associate-*r*77.2%
metadata-eval77.2%
div-inv77.2%
clear-num77.2%
div-inv77.2%
associate-/r*77.2%
associate-/r*77.4%
*-commutative77.4%
associate-*r/77.4%
associate-/l*79.1%
associate-*r*79.1%
clear-num79.1%
Applied egg-rr86.1%
Final simplification93.2%
D_m = (fabs.f64 D) w0\_m = (fabs.f64 w0) w0\_s = (copysign.f64 #s(literal 1 binary64) w0) NOTE: w0_m, M, D_m, h, l, and d should be sorted in increasing order before calling this function. (FPCore (w0_s w0_m M D_m h l d) :precision binary64 (let* ((t_0 (* D_m (* M (/ 0.5 d))))) (* w0_s (* w0_m (sqrt (- 1.0 (* h (* t_0 (/ t_0 l)))))))))
D_m = fabs(D);
w0\_m = fabs(w0);
w0\_s = copysign(1.0, w0);
assert(w0_m < M && M < D_m && D_m < h && h < l && l < d);
double code(double w0_s, double w0_m, double M, double D_m, double h, double l, double d) {
double t_0 = D_m * (M * (0.5 / d));
return w0_s * (w0_m * sqrt((1.0 - (h * (t_0 * (t_0 / l))))));
}
D_m = abs(d)
w0\_m = abs(w0)
w0\_s = copysign(1.0d0, w0)
NOTE: w0_m, M, D_m, h, l, and d should be sorted in increasing order before calling this function.
real(8) function code(w0_s, w0_m, m, d_m, h, l, d)
real(8), intent (in) :: w0_s
real(8), intent (in) :: w0_m
real(8), intent (in) :: m
real(8), intent (in) :: d_m
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: d
real(8) :: t_0
t_0 = d_m * (m * (0.5d0 / d))
code = w0_s * (w0_m * sqrt((1.0d0 - (h * (t_0 * (t_0 / l))))))
end function
D_m = Math.abs(D);
w0\_m = Math.abs(w0);
w0\_s = Math.copySign(1.0, w0);
assert w0_m < M && M < D_m && D_m < h && h < l && l < d;
public static double code(double w0_s, double w0_m, double M, double D_m, double h, double l, double d) {
double t_0 = D_m * (M * (0.5 / d));
return w0_s * (w0_m * Math.sqrt((1.0 - (h * (t_0 * (t_0 / l))))));
}
D_m = math.fabs(D) w0\_m = math.fabs(w0) w0\_s = math.copysign(1.0, w0) [w0_m, M, D_m, h, l, d] = sort([w0_m, M, D_m, h, l, d]) def code(w0_s, w0_m, M, D_m, h, l, d): t_0 = D_m * (M * (0.5 / d)) return w0_s * (w0_m * math.sqrt((1.0 - (h * (t_0 * (t_0 / l))))))
D_m = abs(D) w0\_m = abs(w0) w0\_s = copysign(1.0, w0) w0_m, M, D_m, h, l, d = sort([w0_m, M, D_m, h, l, d]) function code(w0_s, w0_m, M, D_m, h, l, d) t_0 = Float64(D_m * Float64(M * Float64(0.5 / d))) return Float64(w0_s * Float64(w0_m * sqrt(Float64(1.0 - Float64(h * Float64(t_0 * Float64(t_0 / l))))))) end
D_m = abs(D);
w0\_m = abs(w0);
w0\_s = sign(w0) * abs(1.0);
w0_m, M, D_m, h, l, d = num2cell(sort([w0_m, M, D_m, h, l, d])){:}
function tmp = code(w0_s, w0_m, M, D_m, h, l, d)
t_0 = D_m * (M * (0.5 / d));
tmp = w0_s * (w0_m * sqrt((1.0 - (h * (t_0 * (t_0 / l))))));
end
D_m = N[Abs[D], $MachinePrecision]
w0\_m = N[Abs[w0], $MachinePrecision]
w0\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[w0]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: w0_m, M, D_m, h, l, and d should be sorted in increasing order before calling this function.
code[w0$95$s_, w0$95$m_, M_, D$95$m_, h_, l_, d_] := Block[{t$95$0 = N[(D$95$m * N[(M * N[(0.5 / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, N[(w0$95$s * N[(w0$95$m * N[Sqrt[N[(1.0 - N[(h * N[(t$95$0 * N[(t$95$0 / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
D_m = \left|D\right|
\\
w0\_m = \left|w0\right|
\\
w0\_s = \mathsf{copysign}\left(1, w0\right)
\\
[w0_m, M, D_m, h, l, d] = \mathsf{sort}([w0_m, M, D_m, h, l, d])\\
\\
\begin{array}{l}
t_0 := D\_m \cdot \left(M \cdot \frac{0.5}{d}\right)\\
w0\_s \cdot \left(w0\_m \cdot \sqrt{1 - h \cdot \left(t\_0 \cdot \frac{t\_0}{\ell}\right)}\right)
\end{array}
\end{array}
Initial program 87.4%
Simplified87.3%
clear-num86.9%
un-div-inv87.7%
clear-num87.7%
un-div-inv87.7%
associate-/r/87.7%
Applied egg-rr87.7%
associate-/r/90.9%
associate-*l/88.7%
*-commutative88.7%
associate-/l*90.9%
associate-*l/90.9%
*-commutative90.9%
associate-*l/90.9%
associate-/l/90.3%
associate-/r/90.3%
associate-*l/90.3%
*-commutative90.3%
associate-*r/91.4%
*-commutative91.4%
associate-/l/91.4%
associate-/l*90.9%
Simplified90.9%
unpow290.9%
associate-/l*91.7%
div-inv91.7%
associate-/r*91.7%
metadata-eval91.7%
div-inv91.7%
associate-/r*91.7%
metadata-eval91.7%
Applied egg-rr91.7%
D_m = (fabs.f64 D)
w0\_m = (fabs.f64 w0)
w0\_s = (copysign.f64 #s(literal 1 binary64) w0)
NOTE: w0_m, M, D_m, h, l, and d should be sorted in increasing order before calling this function.
(FPCore (w0_s w0_m M D_m h l d)
:precision binary64
(*
w0_s
(*
w0_m
(sqrt
(- 1.0 (* h (* (* D_m (* M (/ 0.5 d))) (* D_m (/ (* M 0.5) (* d l))))))))))D_m = fabs(D);
w0\_m = fabs(w0);
w0\_s = copysign(1.0, w0);
assert(w0_m < M && M < D_m && D_m < h && h < l && l < d);
double code(double w0_s, double w0_m, double M, double D_m, double h, double l, double d) {
return w0_s * (w0_m * sqrt((1.0 - (h * ((D_m * (M * (0.5 / d))) * (D_m * ((M * 0.5) / (d * l))))))));
}
D_m = abs(d)
w0\_m = abs(w0)
w0\_s = copysign(1.0d0, w0)
NOTE: w0_m, M, D_m, h, l, and d should be sorted in increasing order before calling this function.
real(8) function code(w0_s, w0_m, m, d_m, h, l, d)
real(8), intent (in) :: w0_s
real(8), intent (in) :: w0_m
real(8), intent (in) :: m
real(8), intent (in) :: d_m
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: d
code = w0_s * (w0_m * sqrt((1.0d0 - (h * ((d_m * (m * (0.5d0 / d))) * (d_m * ((m * 0.5d0) / (d * l))))))))
end function
D_m = Math.abs(D);
w0\_m = Math.abs(w0);
w0\_s = Math.copySign(1.0, w0);
assert w0_m < M && M < D_m && D_m < h && h < l && l < d;
public static double code(double w0_s, double w0_m, double M, double D_m, double h, double l, double d) {
return w0_s * (w0_m * Math.sqrt((1.0 - (h * ((D_m * (M * (0.5 / d))) * (D_m * ((M * 0.5) / (d * l))))))));
}
D_m = math.fabs(D) w0\_m = math.fabs(w0) w0\_s = math.copysign(1.0, w0) [w0_m, M, D_m, h, l, d] = sort([w0_m, M, D_m, h, l, d]) def code(w0_s, w0_m, M, D_m, h, l, d): return w0_s * (w0_m * math.sqrt((1.0 - (h * ((D_m * (M * (0.5 / d))) * (D_m * ((M * 0.5) / (d * l))))))))
D_m = abs(D) w0\_m = abs(w0) w0\_s = copysign(1.0, w0) w0_m, M, D_m, h, l, d = sort([w0_m, M, D_m, h, l, d]) function code(w0_s, w0_m, M, D_m, h, l, d) return Float64(w0_s * Float64(w0_m * sqrt(Float64(1.0 - Float64(h * Float64(Float64(D_m * Float64(M * Float64(0.5 / d))) * Float64(D_m * Float64(Float64(M * 0.5) / Float64(d * l))))))))) end
D_m = abs(D);
w0\_m = abs(w0);
w0\_s = sign(w0) * abs(1.0);
w0_m, M, D_m, h, l, d = num2cell(sort([w0_m, M, D_m, h, l, d])){:}
function tmp = code(w0_s, w0_m, M, D_m, h, l, d)
tmp = w0_s * (w0_m * sqrt((1.0 - (h * ((D_m * (M * (0.5 / d))) * (D_m * ((M * 0.5) / (d * l))))))));
end
D_m = N[Abs[D], $MachinePrecision]
w0\_m = N[Abs[w0], $MachinePrecision]
w0\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[w0]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: w0_m, M, D_m, h, l, and d should be sorted in increasing order before calling this function.
code[w0$95$s_, w0$95$m_, M_, D$95$m_, h_, l_, d_] := N[(w0$95$s * N[(w0$95$m * N[Sqrt[N[(1.0 - N[(h * N[(N[(D$95$m * N[(M * N[(0.5 / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(D$95$m * N[(N[(M * 0.5), $MachinePrecision] / N[(d * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
D_m = \left|D\right|
\\
w0\_m = \left|w0\right|
\\
w0\_s = \mathsf{copysign}\left(1, w0\right)
\\
[w0_m, M, D_m, h, l, d] = \mathsf{sort}([w0_m, M, D_m, h, l, d])\\
\\
w0\_s \cdot \left(w0\_m \cdot \sqrt{1 - h \cdot \left(\left(D\_m \cdot \left(M \cdot \frac{0.5}{d}\right)\right) \cdot \left(D\_m \cdot \frac{M \cdot 0.5}{d \cdot \ell}\right)\right)}\right)
\end{array}
Initial program 87.4%
Simplified87.3%
clear-num86.9%
un-div-inv87.7%
clear-num87.7%
un-div-inv87.7%
associate-/r/87.7%
Applied egg-rr87.7%
associate-/r/90.9%
associate-*l/88.7%
*-commutative88.7%
associate-/l*90.9%
associate-*l/90.9%
*-commutative90.9%
associate-*l/90.9%
associate-/l/90.3%
associate-/r/90.3%
associate-*l/90.3%
*-commutative90.3%
associate-*r/91.4%
*-commutative91.4%
associate-/l/91.4%
associate-/l*90.9%
Simplified90.9%
unpow290.9%
associate-/l*91.7%
div-inv91.7%
associate-/r*91.7%
metadata-eval91.7%
div-inv91.7%
associate-/r*91.7%
metadata-eval91.7%
Applied egg-rr91.7%
Taylor expanded in D around 0 88.7%
associate-*r/88.7%
associate-/r*90.6%
associate-*l/90.6%
*-commutative90.6%
associate-*r*91.7%
associate-*r/89.1%
associate-*r/89.1%
associate-/l/88.4%
*-commutative88.4%
*-commutative88.4%
Simplified88.4%
Final simplification88.4%
D_m = (fabs.f64 D) w0\_m = (fabs.f64 w0) w0\_s = (copysign.f64 #s(literal 1 binary64) w0) NOTE: w0_m, M, D_m, h, l, and d should be sorted in increasing order before calling this function. (FPCore (w0_s w0_m M D_m h l d) :precision binary64 (* w0_s w0_m))
D_m = fabs(D);
w0\_m = fabs(w0);
w0\_s = copysign(1.0, w0);
assert(w0_m < M && M < D_m && D_m < h && h < l && l < d);
double code(double w0_s, double w0_m, double M, double D_m, double h, double l, double d) {
return w0_s * w0_m;
}
D_m = abs(d)
w0\_m = abs(w0)
w0\_s = copysign(1.0d0, w0)
NOTE: w0_m, M, D_m, h, l, and d should be sorted in increasing order before calling this function.
real(8) function code(w0_s, w0_m, m, d_m, h, l, d)
real(8), intent (in) :: w0_s
real(8), intent (in) :: w0_m
real(8), intent (in) :: m
real(8), intent (in) :: d_m
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: d
code = w0_s * w0_m
end function
D_m = Math.abs(D);
w0\_m = Math.abs(w0);
w0\_s = Math.copySign(1.0, w0);
assert w0_m < M && M < D_m && D_m < h && h < l && l < d;
public static double code(double w0_s, double w0_m, double M, double D_m, double h, double l, double d) {
return w0_s * w0_m;
}
D_m = math.fabs(D) w0\_m = math.fabs(w0) w0\_s = math.copysign(1.0, w0) [w0_m, M, D_m, h, l, d] = sort([w0_m, M, D_m, h, l, d]) def code(w0_s, w0_m, M, D_m, h, l, d): return w0_s * w0_m
D_m = abs(D) w0\_m = abs(w0) w0\_s = copysign(1.0, w0) w0_m, M, D_m, h, l, d = sort([w0_m, M, D_m, h, l, d]) function code(w0_s, w0_m, M, D_m, h, l, d) return Float64(w0_s * w0_m) end
D_m = abs(D);
w0\_m = abs(w0);
w0\_s = sign(w0) * abs(1.0);
w0_m, M, D_m, h, l, d = num2cell(sort([w0_m, M, D_m, h, l, d])){:}
function tmp = code(w0_s, w0_m, M, D_m, h, l, d)
tmp = w0_s * w0_m;
end
D_m = N[Abs[D], $MachinePrecision]
w0\_m = N[Abs[w0], $MachinePrecision]
w0\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[w0]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: w0_m, M, D_m, h, l, and d should be sorted in increasing order before calling this function.
code[w0$95$s_, w0$95$m_, M_, D$95$m_, h_, l_, d_] := N[(w0$95$s * w0$95$m), $MachinePrecision]
\begin{array}{l}
D_m = \left|D\right|
\\
w0\_m = \left|w0\right|
\\
w0\_s = \mathsf{copysign}\left(1, w0\right)
\\
[w0_m, M, D_m, h, l, d] = \mathsf{sort}([w0_m, M, D_m, h, l, d])\\
\\
w0\_s \cdot w0\_m
\end{array}
Initial program 87.4%
Simplified87.3%
Taylor expanded in D around 0 73.1%
herbie shell --seed 2024093
(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))))))