
(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}
M_m = (fabs.f64 M) D_m = (fabs.f64 D) NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function. (FPCore (w0 M_m D_m h l d) :precision binary64 (let* ((t_0 (* D_m (* 0.5 (/ M_m d))))) (* w0 (sqrt (- 1.0 (* t_0 (* h (/ t_0 l))))))))
M_m = fabs(M);
D_m = fabs(D);
assert(w0 < M_m && M_m < D_m && D_m < h && h < l && l < d);
double code(double w0, double M_m, double D_m, double h, double l, double d) {
double t_0 = D_m * (0.5 * (M_m / d));
return w0 * sqrt((1.0 - (t_0 * (h * (t_0 / l)))));
}
M_m = abs(m)
D_m = abs(d)
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, m_m, d_m, h, l, d)
real(8), intent (in) :: w0
real(8), intent (in) :: m_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 * (0.5d0 * (m_m / d))
code = w0 * sqrt((1.0d0 - (t_0 * (h * (t_0 / l)))))
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
assert w0 < M_m && M_m < D_m && D_m < h && h < l && l < d;
public static double code(double w0, double M_m, double D_m, double h, double l, double d) {
double t_0 = D_m * (0.5 * (M_m / d));
return w0 * Math.sqrt((1.0 - (t_0 * (h * (t_0 / l)))));
}
M_m = math.fabs(M) D_m = math.fabs(D) [w0, M_m, D_m, h, l, d] = sort([w0, M_m, D_m, h, l, d]) def code(w0, M_m, D_m, h, l, d): t_0 = D_m * (0.5 * (M_m / d)) return w0 * math.sqrt((1.0 - (t_0 * (h * (t_0 / l)))))
M_m = abs(M) D_m = abs(D) w0, M_m, D_m, h, l, d = sort([w0, M_m, D_m, h, l, d]) function code(w0, M_m, D_m, h, l, d) t_0 = Float64(D_m * Float64(0.5 * Float64(M_m / d))) return Float64(w0 * sqrt(Float64(1.0 - Float64(t_0 * Float64(h * Float64(t_0 / l)))))) end
M_m = abs(M);
D_m = abs(D);
w0, M_m, D_m, h, l, d = num2cell(sort([w0, M_m, D_m, h, l, d])){:}
function tmp = code(w0, M_m, D_m, h, l, d)
t_0 = D_m * (0.5 * (M_m / d));
tmp = w0 * sqrt((1.0 - (t_0 * (h * (t_0 / l)))));
end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
code[w0_, M$95$m_, D$95$m_, h_, l_, d_] := Block[{t$95$0 = N[(D$95$m * N[(0.5 * N[(M$95$m / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, N[(w0 * N[Sqrt[N[(1.0 - N[(t$95$0 * N[(h * N[(t$95$0 / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\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(0.5 \cdot \frac{M\_m}{d}\right)\\
w0 \cdot \sqrt{1 - t\_0 \cdot \left(h \cdot \frac{t\_0}{\ell}\right)}
\end{array}
\end{array}
Initial program 81.0%
Simplified81.4%
unpow281.4%
unpow281.4%
associate-/r*81.4%
associate-*r/81.0%
*-commutative81.0%
associate-*r/85.5%
*-commutative85.5%
associate-*l/85.5%
associate-/r*85.5%
clear-num85.5%
associate-*l/85.8%
*-un-lft-identity85.8%
associate-/r/85.7%
Applied egg-rr85.7%
associate-*l/81.6%
unpow281.6%
associate-*r*83.4%
div-inv83.2%
associate-*l/83.2%
*-commutative83.2%
clear-num83.2%
*-un-lft-identity83.2%
times-frac83.2%
metadata-eval83.2%
div-inv83.2%
associate-*l/83.2%
*-commutative83.2%
clear-num83.2%
*-un-lft-identity83.2%
times-frac83.2%
metadata-eval83.2%
Applied egg-rr83.2%
associate-*l/88.1%
associate-*r/88.1%
Applied egg-rr88.1%
associate-/l*88.5%
associate-/l*88.5%
Simplified88.5%
Final simplification88.5%
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
(FPCore (w0 M_m D_m h l d)
:precision binary64
(if (<= D_m 2.4e-28)
w0
(*
w0
(sqrt
(-
1.0
(* (* D_m (* 0.5 (/ M_m d))) (* 0.5 (/ (* D_m (* h M_m)) (* d l)))))))))M_m = fabs(M);
D_m = fabs(D);
assert(w0 < M_m && M_m < D_m && D_m < h && h < l && l < d);
double code(double w0, double M_m, double D_m, double h, double l, double d) {
double tmp;
if (D_m <= 2.4e-28) {
tmp = w0;
} else {
tmp = w0 * sqrt((1.0 - ((D_m * (0.5 * (M_m / d))) * (0.5 * ((D_m * (h * M_m)) / (d * l))))));
}
return tmp;
}
M_m = abs(m)
D_m = abs(d)
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, m_m, d_m, h, l, d)
real(8), intent (in) :: w0
real(8), intent (in) :: m_m
real(8), intent (in) :: d_m
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: d
real(8) :: tmp
if (d_m <= 2.4d-28) then
tmp = w0
else
tmp = w0 * sqrt((1.0d0 - ((d_m * (0.5d0 * (m_m / d))) * (0.5d0 * ((d_m * (h * m_m)) / (d * l))))))
end if
code = tmp
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
assert w0 < M_m && M_m < D_m && D_m < h && h < l && l < d;
public static double code(double w0, double M_m, double D_m, double h, double l, double d) {
double tmp;
if (D_m <= 2.4e-28) {
tmp = w0;
} else {
tmp = w0 * Math.sqrt((1.0 - ((D_m * (0.5 * (M_m / d))) * (0.5 * ((D_m * (h * M_m)) / (d * l))))));
}
return tmp;
}
M_m = math.fabs(M) D_m = math.fabs(D) [w0, M_m, D_m, h, l, d] = sort([w0, M_m, D_m, h, l, d]) def code(w0, M_m, D_m, h, l, d): tmp = 0 if D_m <= 2.4e-28: tmp = w0 else: tmp = w0 * math.sqrt((1.0 - ((D_m * (0.5 * (M_m / d))) * (0.5 * ((D_m * (h * M_m)) / (d * l)))))) return tmp
M_m = abs(M) D_m = abs(D) w0, M_m, D_m, h, l, d = sort([w0, M_m, D_m, h, l, d]) function code(w0, M_m, D_m, h, l, d) tmp = 0.0 if (D_m <= 2.4e-28) tmp = w0; else tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(D_m * Float64(0.5 * Float64(M_m / d))) * Float64(0.5 * Float64(Float64(D_m * Float64(h * M_m)) / Float64(d * l))))))); end return tmp end
M_m = abs(M);
D_m = abs(D);
w0, M_m, D_m, h, l, d = num2cell(sort([w0, M_m, D_m, h, l, d])){:}
function tmp_2 = code(w0, M_m, D_m, h, l, d)
tmp = 0.0;
if (D_m <= 2.4e-28)
tmp = w0;
else
tmp = w0 * sqrt((1.0 - ((D_m * (0.5 * (M_m / d))) * (0.5 * ((D_m * (h * M_m)) / (d * l))))));
end
tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision] D_m = N[Abs[D], $MachinePrecision] NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function. code[w0_, M$95$m_, D$95$m_, h_, l_, d_] := If[LessEqual[D$95$m, 2.4e-28], w0, N[(w0 * N[Sqrt[N[(1.0 - N[(N[(D$95$m * N[(0.5 * N[(M$95$m / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(0.5 * N[(N[(D$95$m * N[(h * M$95$m), $MachinePrecision]), $MachinePrecision] / N[(d * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[w0, M_m, D_m, h, l, d] = \mathsf{sort}([w0, M_m, D_m, h, l, d])\\
\\
\begin{array}{l}
\mathbf{if}\;D\_m \leq 2.4 \cdot 10^{-28}:\\
\;\;\;\;w0\\
\mathbf{else}:\\
\;\;\;\;w0 \cdot \sqrt{1 - \left(D\_m \cdot \left(0.5 \cdot \frac{M\_m}{d}\right)\right) \cdot \left(0.5 \cdot \frac{D\_m \cdot \left(h \cdot M\_m\right)}{d \cdot \ell}\right)}\\
\end{array}
\end{array}
if D < 2.4000000000000002e-28Initial program 82.5%
Simplified82.1%
Taylor expanded in D around 0 75.1%
if 2.4000000000000002e-28 < D Initial program 75.8%
Simplified79.0%
unpow279.0%
unpow279.0%
associate-/r*79.0%
associate-*r/75.8%
*-commutative75.8%
associate-*r/77.7%
*-commutative77.7%
associate-*l/80.9%
associate-/r*80.9%
clear-num80.9%
associate-*l/81.0%
*-un-lft-identity81.0%
associate-/r/81.0%
Applied egg-rr81.0%
associate-*l/79.1%
unpow279.1%
associate-*r*82.5%
div-inv82.5%
associate-*l/82.5%
*-commutative82.5%
clear-num82.5%
*-un-lft-identity82.5%
times-frac82.5%
metadata-eval82.5%
div-inv82.4%
associate-*l/82.4%
*-commutative82.4%
clear-num82.4%
*-un-lft-identity82.4%
times-frac82.4%
metadata-eval82.4%
Applied egg-rr82.4%
Taylor expanded in h around 0 79.3%
Final simplification76.1%
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
(FPCore (w0 M_m D_m h l d)
:precision binary64
(if (<= D_m 6.5e-29)
w0
(*
w0
(sqrt
(-
1.0
(* (* 0.5 (/ (* D_m (* h M_m)) (* d l))) (* 0.5 (/ (* D_m M_m) d))))))))M_m = fabs(M);
D_m = fabs(D);
assert(w0 < M_m && M_m < D_m && D_m < h && h < l && l < d);
double code(double w0, double M_m, double D_m, double h, double l, double d) {
double tmp;
if (D_m <= 6.5e-29) {
tmp = w0;
} else {
tmp = w0 * sqrt((1.0 - ((0.5 * ((D_m * (h * M_m)) / (d * l))) * (0.5 * ((D_m * M_m) / d)))));
}
return tmp;
}
M_m = abs(m)
D_m = abs(d)
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, m_m, d_m, h, l, d)
real(8), intent (in) :: w0
real(8), intent (in) :: m_m
real(8), intent (in) :: d_m
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: d
real(8) :: tmp
if (d_m <= 6.5d-29) then
tmp = w0
else
tmp = w0 * sqrt((1.0d0 - ((0.5d0 * ((d_m * (h * m_m)) / (d * l))) * (0.5d0 * ((d_m * m_m) / d)))))
end if
code = tmp
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
assert w0 < M_m && M_m < D_m && D_m < h && h < l && l < d;
public static double code(double w0, double M_m, double D_m, double h, double l, double d) {
double tmp;
if (D_m <= 6.5e-29) {
tmp = w0;
} else {
tmp = w0 * Math.sqrt((1.0 - ((0.5 * ((D_m * (h * M_m)) / (d * l))) * (0.5 * ((D_m * M_m) / d)))));
}
return tmp;
}
M_m = math.fabs(M) D_m = math.fabs(D) [w0, M_m, D_m, h, l, d] = sort([w0, M_m, D_m, h, l, d]) def code(w0, M_m, D_m, h, l, d): tmp = 0 if D_m <= 6.5e-29: tmp = w0 else: tmp = w0 * math.sqrt((1.0 - ((0.5 * ((D_m * (h * M_m)) / (d * l))) * (0.5 * ((D_m * M_m) / d))))) return tmp
M_m = abs(M) D_m = abs(D) w0, M_m, D_m, h, l, d = sort([w0, M_m, D_m, h, l, d]) function code(w0, M_m, D_m, h, l, d) tmp = 0.0 if (D_m <= 6.5e-29) tmp = w0; else tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(0.5 * Float64(Float64(D_m * Float64(h * M_m)) / Float64(d * l))) * Float64(0.5 * Float64(Float64(D_m * M_m) / d)))))); end return tmp end
M_m = abs(M);
D_m = abs(D);
w0, M_m, D_m, h, l, d = num2cell(sort([w0, M_m, D_m, h, l, d])){:}
function tmp_2 = code(w0, M_m, D_m, h, l, d)
tmp = 0.0;
if (D_m <= 6.5e-29)
tmp = w0;
else
tmp = w0 * sqrt((1.0 - ((0.5 * ((D_m * (h * M_m)) / (d * l))) * (0.5 * ((D_m * M_m) / d)))));
end
tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision] D_m = N[Abs[D], $MachinePrecision] NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function. code[w0_, M$95$m_, D$95$m_, h_, l_, d_] := If[LessEqual[D$95$m, 6.5e-29], w0, N[(w0 * N[Sqrt[N[(1.0 - N[(N[(0.5 * N[(N[(D$95$m * N[(h * M$95$m), $MachinePrecision]), $MachinePrecision] / N[(d * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(0.5 * N[(N[(D$95$m * M$95$m), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[w0, M_m, D_m, h, l, d] = \mathsf{sort}([w0, M_m, D_m, h, l, d])\\
\\
\begin{array}{l}
\mathbf{if}\;D\_m \leq 6.5 \cdot 10^{-29}:\\
\;\;\;\;w0\\
\mathbf{else}:\\
\;\;\;\;w0 \cdot \sqrt{1 - \left(0.5 \cdot \frac{D\_m \cdot \left(h \cdot M\_m\right)}{d \cdot \ell}\right) \cdot \left(0.5 \cdot \frac{D\_m \cdot M\_m}{d}\right)}\\
\end{array}
\end{array}
if D < 6.5e-29Initial program 82.5%
Simplified82.1%
Taylor expanded in D around 0 75.1%
if 6.5e-29 < D Initial program 75.8%
Simplified79.0%
unpow279.0%
unpow279.0%
associate-/r*79.0%
associate-*r/75.8%
*-commutative75.8%
associate-*r/77.7%
*-commutative77.7%
associate-*l/80.9%
associate-/r*80.9%
clear-num80.9%
associate-*l/81.0%
*-un-lft-identity81.0%
associate-/r/81.0%
Applied egg-rr81.0%
associate-*l/79.1%
unpow279.1%
associate-*r*82.5%
div-inv82.5%
associate-*l/82.5%
*-commutative82.5%
clear-num82.5%
*-un-lft-identity82.5%
times-frac82.5%
metadata-eval82.5%
div-inv82.4%
associate-*l/82.4%
*-commutative82.4%
clear-num82.4%
*-un-lft-identity82.4%
times-frac82.4%
metadata-eval82.4%
Applied egg-rr82.4%
Taylor expanded in h around 0 79.3%
Taylor expanded in D around 0 74.3%
Final simplification74.9%
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
(FPCore (w0 M_m D_m h l d)
:precision binary64
(*
w0
(sqrt
(-
1.0
(* (* D_m (* 0.5 (/ M_m d))) (* h (* D_m (/ (/ (* 0.5 M_m) d) l))))))))M_m = fabs(M);
D_m = fabs(D);
assert(w0 < M_m && M_m < D_m && D_m < h && h < l && l < d);
double code(double w0, double M_m, double D_m, double h, double l, double d) {
return w0 * sqrt((1.0 - ((D_m * (0.5 * (M_m / d))) * (h * (D_m * (((0.5 * M_m) / d) / l))))));
}
M_m = abs(m)
D_m = abs(d)
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, m_m, d_m, h, l, d)
real(8), intent (in) :: w0
real(8), intent (in) :: m_m
real(8), intent (in) :: d_m
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: d
code = w0 * sqrt((1.0d0 - ((d_m * (0.5d0 * (m_m / d))) * (h * (d_m * (((0.5d0 * m_m) / d) / l))))))
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
assert w0 < M_m && M_m < D_m && D_m < h && h < l && l < d;
public static double code(double w0, double M_m, double D_m, double h, double l, double d) {
return w0 * Math.sqrt((1.0 - ((D_m * (0.5 * (M_m / d))) * (h * (D_m * (((0.5 * M_m) / d) / l))))));
}
M_m = math.fabs(M) D_m = math.fabs(D) [w0, M_m, D_m, h, l, d] = sort([w0, M_m, D_m, h, l, d]) def code(w0, M_m, D_m, h, l, d): return w0 * math.sqrt((1.0 - ((D_m * (0.5 * (M_m / d))) * (h * (D_m * (((0.5 * M_m) / d) / l))))))
M_m = abs(M) D_m = abs(D) w0, M_m, D_m, h, l, d = sort([w0, M_m, D_m, h, l, d]) function code(w0, M_m, D_m, h, l, d) return Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(D_m * Float64(0.5 * Float64(M_m / d))) * Float64(h * Float64(D_m * Float64(Float64(Float64(0.5 * M_m) / d) / l))))))) end
M_m = abs(M);
D_m = abs(D);
w0, M_m, D_m, h, l, d = num2cell(sort([w0, M_m, D_m, h, l, d])){:}
function tmp = code(w0, M_m, D_m, h, l, d)
tmp = w0 * sqrt((1.0 - ((D_m * (0.5 * (M_m / d))) * (h * (D_m * (((0.5 * M_m) / d) / l))))));
end
M_m = N[Abs[M], $MachinePrecision] D_m = N[Abs[D], $MachinePrecision] NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function. code[w0_, M$95$m_, D$95$m_, h_, l_, d_] := N[(w0 * N[Sqrt[N[(1.0 - N[(N[(D$95$m * N[(0.5 * N[(M$95$m / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(h * N[(D$95$m * N[(N[(N[(0.5 * M$95$m), $MachinePrecision] / d), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[w0, M_m, D_m, h, l, d] = \mathsf{sort}([w0, M_m, D_m, h, l, d])\\
\\
w0 \cdot \sqrt{1 - \left(D\_m \cdot \left(0.5 \cdot \frac{M\_m}{d}\right)\right) \cdot \left(h \cdot \left(D\_m \cdot \frac{\frac{0.5 \cdot M\_m}{d}}{\ell}\right)\right)}
\end{array}
Initial program 81.0%
Simplified81.4%
unpow281.4%
unpow281.4%
associate-/r*81.4%
associate-*r/81.0%
*-commutative81.0%
associate-*r/85.5%
*-commutative85.5%
associate-*l/85.5%
associate-/r*85.5%
clear-num85.5%
associate-*l/85.8%
*-un-lft-identity85.8%
associate-/r/85.7%
Applied egg-rr85.7%
associate-*l/81.6%
unpow281.6%
associate-*r*83.4%
div-inv83.2%
associate-*l/83.2%
*-commutative83.2%
clear-num83.2%
*-un-lft-identity83.2%
times-frac83.2%
metadata-eval83.2%
div-inv83.2%
associate-*l/83.2%
*-commutative83.2%
clear-num83.2%
*-un-lft-identity83.2%
times-frac83.2%
metadata-eval83.2%
Applied egg-rr83.2%
associate-*l/88.1%
associate-*r/88.1%
Applied egg-rr88.1%
associate-/l*88.5%
associate-/l*88.5%
Simplified88.5%
associate-/l*86.2%
associate-*r/86.2%
Applied egg-rr86.2%
Final simplification86.2%
M_m = (fabs.f64 M) D_m = (fabs.f64 D) NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function. (FPCore (w0 M_m D_m h l d) :precision binary64 w0)
M_m = fabs(M);
D_m = fabs(D);
assert(w0 < M_m && M_m < D_m && D_m < h && h < l && l < d);
double code(double w0, double M_m, double D_m, double h, double l, double d) {
return w0;
}
M_m = abs(m)
D_m = abs(d)
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, m_m, d_m, h, l, d)
real(8), intent (in) :: w0
real(8), intent (in) :: m_m
real(8), intent (in) :: d_m
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: d
code = w0
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
assert w0 < M_m && M_m < D_m && D_m < h && h < l && l < d;
public static double code(double w0, double M_m, double D_m, double h, double l, double d) {
return w0;
}
M_m = math.fabs(M) D_m = math.fabs(D) [w0, M_m, D_m, h, l, d] = sort([w0, M_m, D_m, h, l, d]) def code(w0, M_m, D_m, h, l, d): return w0
M_m = abs(M) D_m = abs(D) w0, M_m, D_m, h, l, d = sort([w0, M_m, D_m, h, l, d]) function code(w0, M_m, D_m, h, l, d) return w0 end
M_m = abs(M);
D_m = abs(D);
w0, M_m, D_m, h, l, d = num2cell(sort([w0, M_m, D_m, h, l, d])){:}
function tmp = code(w0, M_m, D_m, h, l, d)
tmp = w0;
end
M_m = N[Abs[M], $MachinePrecision] D_m = N[Abs[D], $MachinePrecision] NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function. code[w0_, M$95$m_, D$95$m_, h_, l_, d_] := w0
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[w0, M_m, D_m, h, l, d] = \mathsf{sort}([w0, M_m, D_m, h, l, d])\\
\\
w0
\end{array}
Initial program 81.0%
Simplified81.4%
Taylor expanded in D around 0 68.4%
herbie shell --seed 2024103
(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))))))