
(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)
d_m = (fabs.f64 d)
NOTE: w0, M_m, D_m, h, l, and d_m should be sorted in increasing order before calling this function.
(FPCore (w0 M_m D_m h l d_m)
:precision binary64
(let* ((t_0 (/ (* 0.5 M_m) (/ d_m D_m))))
(if (<= (* 2.0 d_m) 5e-112)
(*
w0
(sqrt
(-
1.0
(*
(* 0.5 (/ D_m (* l (/ d_m M_m))))
(/ 0.5 (/ d_m (* M_m (* D_m h))))))))
(* w0 (sqrt (- 1.0 (/ (* t_0 (* h t_0)) l)))))))M_m = fabs(M);
D_m = fabs(D);
d_m = fabs(d);
assert(w0 < M_m && M_m < D_m && D_m < h && h < l && l < d_m);
double code(double w0, double M_m, double D_m, double h, double l, double d_m) {
double t_0 = (0.5 * M_m) / (d_m / D_m);
double tmp;
if ((2.0 * d_m) <= 5e-112) {
tmp = w0 * sqrt((1.0 - ((0.5 * (D_m / (l * (d_m / M_m)))) * (0.5 / (d_m / (M_m * (D_m * h)))))));
} else {
tmp = w0 * sqrt((1.0 - ((t_0 * (h * t_0)) / l)));
}
return tmp;
}
M_m = abs(M)
D_m = abs(D)
d_m = abs(d)
NOTE: w0, M_m, D_m, h, l, and d_m should be sorted in increasing order before calling this function.
real(8) function code(w0, m_m, d_m, h, l, d_m_1)
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_m_1
real(8) :: t_0
real(8) :: tmp
t_0 = (0.5d0 * m_m) / (d_m_1 / d_m)
if ((2.0d0 * d_m_1) <= 5d-112) then
tmp = w0 * sqrt((1.0d0 - ((0.5d0 * (d_m / (l * (d_m_1 / m_m)))) * (0.5d0 / (d_m_1 / (m_m * (d_m * h)))))))
else
tmp = w0 * sqrt((1.0d0 - ((t_0 * (h * t_0)) / l)))
end if
code = tmp
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
d_m = Math.abs(d);
assert w0 < M_m && M_m < D_m && D_m < h && h < l && l < d_m;
public static double code(double w0, double M_m, double D_m, double h, double l, double d_m) {
double t_0 = (0.5 * M_m) / (d_m / D_m);
double tmp;
if ((2.0 * d_m) <= 5e-112) {
tmp = w0 * Math.sqrt((1.0 - ((0.5 * (D_m / (l * (d_m / M_m)))) * (0.5 / (d_m / (M_m * (D_m * h)))))));
} else {
tmp = w0 * Math.sqrt((1.0 - ((t_0 * (h * t_0)) / l)));
}
return tmp;
}
M_m = math.fabs(M) D_m = math.fabs(D) d_m = math.fabs(d) [w0, M_m, D_m, h, l, d_m] = sort([w0, M_m, D_m, h, l, d_m]) def code(w0, M_m, D_m, h, l, d_m): t_0 = (0.5 * M_m) / (d_m / D_m) tmp = 0 if (2.0 * d_m) <= 5e-112: tmp = w0 * math.sqrt((1.0 - ((0.5 * (D_m / (l * (d_m / M_m)))) * (0.5 / (d_m / (M_m * (D_m * h))))))) else: tmp = w0 * math.sqrt((1.0 - ((t_0 * (h * t_0)) / l))) return tmp
M_m = abs(M) D_m = abs(D) d_m = abs(d) w0, M_m, D_m, h, l, d_m = sort([w0, M_m, D_m, h, l, d_m]) function code(w0, M_m, D_m, h, l, d_m) t_0 = Float64(Float64(0.5 * M_m) / Float64(d_m / D_m)) tmp = 0.0 if (Float64(2.0 * d_m) <= 5e-112) tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(0.5 * Float64(D_m / Float64(l * Float64(d_m / M_m)))) * Float64(0.5 / Float64(d_m / Float64(M_m * Float64(D_m * h)))))))); else tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(t_0 * Float64(h * t_0)) / l)))); end return tmp end
M_m = abs(M);
D_m = abs(D);
d_m = abs(d);
w0, M_m, D_m, h, l, d_m = num2cell(sort([w0, M_m, D_m, h, l, d_m])){:}
function tmp_2 = code(w0, M_m, D_m, h, l, d_m)
t_0 = (0.5 * M_m) / (d_m / D_m);
tmp = 0.0;
if ((2.0 * d_m) <= 5e-112)
tmp = w0 * sqrt((1.0 - ((0.5 * (D_m / (l * (d_m / M_m)))) * (0.5 / (d_m / (M_m * (D_m * h)))))));
else
tmp = w0 * sqrt((1.0 - ((t_0 * (h * t_0)) / l)));
end
tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
d_m = N[Abs[d], $MachinePrecision]
NOTE: w0, M_m, D_m, h, l, and d_m should be sorted in increasing order before calling this function.
code[w0_, M$95$m_, D$95$m_, h_, l_, d$95$m_] := Block[{t$95$0 = N[(N[(0.5 * M$95$m), $MachinePrecision] / N[(d$95$m / D$95$m), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(2.0 * d$95$m), $MachinePrecision], 5e-112], N[(w0 * N[Sqrt[N[(1.0 - N[(N[(0.5 * N[(D$95$m / N[(l * N[(d$95$m / M$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(0.5 / N[(d$95$m / N[(M$95$m * N[(D$95$m * h), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(w0 * N[Sqrt[N[(1.0 - N[(N[(t$95$0 * N[(h * t$95$0), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
d_m = \left|d\right|
\\
[w0, M_m, D_m, h, l, d_m] = \mathsf{sort}([w0, M_m, D_m, h, l, d_m])\\
\\
\begin{array}{l}
t_0 := \frac{0.5 \cdot M\_m}{\frac{d\_m}{D\_m}}\\
\mathbf{if}\;2 \cdot d\_m \leq 5 \cdot 10^{-112}:\\
\;\;\;\;w0 \cdot \sqrt{1 - \left(0.5 \cdot \frac{D\_m}{\ell \cdot \frac{d\_m}{M\_m}}\right) \cdot \frac{0.5}{\frac{d\_m}{M\_m \cdot \left(D\_m \cdot h\right)}}}\\
\mathbf{else}:\\
\;\;\;\;w0 \cdot \sqrt{1 - \frac{t\_0 \cdot \left(h \cdot t\_0\right)}{\ell}}\\
\end{array}
\end{array}
if (*.f64 2 d) < 5.00000000000000044e-112Initial program 77.7%
Simplified75.2%
*-commutative75.2%
frac-times77.7%
*-commutative77.7%
associate-*l/84.3%
div-inv84.3%
*-commutative84.3%
associate-*l*81.9%
associate-/r*81.9%
metadata-eval81.9%
Applied egg-rr81.9%
*-commutative81.9%
associate-/l*75.1%
unpow275.1%
div-inv75.1%
times-frac85.6%
associate-*r/85.6%
associate-*r/85.6%
Applied egg-rr85.6%
Taylor expanded in D around 0 81.3%
associate-*r/81.3%
associate-/l*81.3%
associate-*r*81.3%
*-commutative81.3%
associate-*l*81.1%
Simplified81.1%
Taylor expanded in D around 0 80.4%
associate-/r*82.5%
associate-/l*81.1%
associate-/l/80.1%
Simplified80.1%
if 5.00000000000000044e-112 < (*.f64 2 d) Initial program 88.6%
Simplified88.6%
add-cbrt-cube87.6%
pow1/387.4%
Applied egg-rr87.4%
unpow1/387.6%
Simplified87.6%
*-commutative87.6%
clear-num87.6%
div-inv87.6%
unpow287.6%
associate-/l*88.6%
associate-*r/88.6%
associate-*r/88.6%
Applied egg-rr88.6%
pow1/388.3%
pow-pow89.6%
metadata-eval89.6%
pow1/289.6%
associate-/r/89.6%
associate-*r/88.7%
*-commutative88.7%
associate-/l*88.2%
associate-*r/87.3%
*-commutative87.3%
associate-/l*88.2%
Applied egg-rr88.2%
associate-/r/94.0%
associate-/r/94.0%
*-commutative94.0%
associate-/r/95.3%
*-commutative95.3%
associate-*r*95.3%
associate-*l/95.4%
*-commutative95.4%
associate-/r/94.1%
*-commutative94.1%
*-commutative94.1%
*-commutative94.1%
associate-/r/94.1%
*-commutative94.1%
Applied egg-rr94.1%
Final simplification85.7%
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
d_m = (fabs.f64 d)
NOTE: w0, M_m, D_m, h, l, and d_m should be sorted in increasing order before calling this function.
(FPCore (w0 M_m D_m h l d_m)
:precision binary64
(if (<= d_m 1e+167)
(*
w0
(sqrt
(-
1.0
(*
(* 0.5 (/ D_m (* l (/ d_m M_m))))
(/ 0.5 (/ d_m (* M_m (* D_m h))))))))
w0))M_m = fabs(M);
D_m = fabs(D);
d_m = fabs(d);
assert(w0 < M_m && M_m < D_m && D_m < h && h < l && l < d_m);
double code(double w0, double M_m, double D_m, double h, double l, double d_m) {
double tmp;
if (d_m <= 1e+167) {
tmp = w0 * sqrt((1.0 - ((0.5 * (D_m / (l * (d_m / M_m)))) * (0.5 / (d_m / (M_m * (D_m * h)))))));
} else {
tmp = w0;
}
return tmp;
}
M_m = abs(M)
D_m = abs(D)
d_m = abs(d)
NOTE: w0, M_m, D_m, h, l, and d_m should be sorted in increasing order before calling this function.
real(8) function code(w0, m_m, d_m, h, l, d_m_1)
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_m_1
real(8) :: tmp
if (d_m_1 <= 1d+167) then
tmp = w0 * sqrt((1.0d0 - ((0.5d0 * (d_m / (l * (d_m_1 / m_m)))) * (0.5d0 / (d_m_1 / (m_m * (d_m * h)))))))
else
tmp = w0
end if
code = tmp
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
d_m = Math.abs(d);
assert w0 < M_m && M_m < D_m && D_m < h && h < l && l < d_m;
public static double code(double w0, double M_m, double D_m, double h, double l, double d_m) {
double tmp;
if (d_m <= 1e+167) {
tmp = w0 * Math.sqrt((1.0 - ((0.5 * (D_m / (l * (d_m / M_m)))) * (0.5 / (d_m / (M_m * (D_m * h)))))));
} else {
tmp = w0;
}
return tmp;
}
M_m = math.fabs(M) D_m = math.fabs(D) d_m = math.fabs(d) [w0, M_m, D_m, h, l, d_m] = sort([w0, M_m, D_m, h, l, d_m]) def code(w0, M_m, D_m, h, l, d_m): tmp = 0 if d_m <= 1e+167: tmp = w0 * math.sqrt((1.0 - ((0.5 * (D_m / (l * (d_m / M_m)))) * (0.5 / (d_m / (M_m * (D_m * h))))))) else: tmp = w0 return tmp
M_m = abs(M) D_m = abs(D) d_m = abs(d) w0, M_m, D_m, h, l, d_m = sort([w0, M_m, D_m, h, l, d_m]) function code(w0, M_m, D_m, h, l, d_m) tmp = 0.0 if (d_m <= 1e+167) tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(0.5 * Float64(D_m / Float64(l * Float64(d_m / M_m)))) * Float64(0.5 / Float64(d_m / Float64(M_m * Float64(D_m * h)))))))); else tmp = w0; end return tmp end
M_m = abs(M);
D_m = abs(D);
d_m = abs(d);
w0, M_m, D_m, h, l, d_m = num2cell(sort([w0, M_m, D_m, h, l, d_m])){:}
function tmp_2 = code(w0, M_m, D_m, h, l, d_m)
tmp = 0.0;
if (d_m <= 1e+167)
tmp = w0 * sqrt((1.0 - ((0.5 * (D_m / (l * (d_m / M_m)))) * (0.5 / (d_m / (M_m * (D_m * h)))))));
else
tmp = w0;
end
tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision] D_m = N[Abs[D], $MachinePrecision] d_m = N[Abs[d], $MachinePrecision] NOTE: w0, M_m, D_m, h, l, and d_m should be sorted in increasing order before calling this function. code[w0_, M$95$m_, D$95$m_, h_, l_, d$95$m_] := If[LessEqual[d$95$m, 1e+167], N[(w0 * N[Sqrt[N[(1.0 - N[(N[(0.5 * N[(D$95$m / N[(l * N[(d$95$m / M$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(0.5 / N[(d$95$m / N[(M$95$m * N[(D$95$m * h), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], w0]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
d_m = \left|d\right|
\\
[w0, M_m, D_m, h, l, d_m] = \mathsf{sort}([w0, M_m, D_m, h, l, d_m])\\
\\
\begin{array}{l}
\mathbf{if}\;d\_m \leq 10^{+167}:\\
\;\;\;\;w0 \cdot \sqrt{1 - \left(0.5 \cdot \frac{D\_m}{\ell \cdot \frac{d\_m}{M\_m}}\right) \cdot \frac{0.5}{\frac{d\_m}{M\_m \cdot \left(D\_m \cdot h\right)}}}\\
\mathbf{else}:\\
\;\;\;\;w0\\
\end{array}
\end{array}
if d < 1e167Initial program 80.3%
Simplified78.5%
*-commutative78.5%
frac-times80.3%
*-commutative80.3%
associate-*l/86.2%
div-inv86.2%
*-commutative86.2%
associate-*l*84.4%
associate-/r*84.4%
metadata-eval84.4%
Applied egg-rr84.4%
*-commutative84.4%
associate-/l*78.5%
unpow278.5%
div-inv78.5%
times-frac87.1%
associate-*r/87.1%
associate-*r/87.1%
Applied egg-rr87.1%
Taylor expanded in D around 0 83.5%
associate-*r/83.5%
associate-/l*83.5%
associate-*r*83.5%
*-commutative83.5%
associate-*l*83.3%
Simplified83.3%
Taylor expanded in D around 0 81.8%
associate-/r*84.4%
associate-/l*83.3%
associate-/l/82.6%
Simplified82.6%
if 1e167 < d Initial program 89.6%
Simplified89.6%
Taylor expanded in D around 0 91.2%
Final simplification84.2%
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
d_m = (fabs.f64 d)
NOTE: w0, M_m, D_m, h, l, and d_m should be sorted in increasing order before calling this function.
(FPCore (w0 M_m D_m h l d_m)
:precision binary64
(let* ((t_0 (* D_m (/ (* 0.5 M_m) d_m))))
(if (<= D_m 5e+29)
(*
w0
(sqrt
(-
1.0
(*
(* 0.5 (/ D_m (* l (/ d_m M_m))))
(/ 0.5 (/ d_m (* M_m (* D_m h))))))))
(* w0 (sqrt (- 1.0 (* t_0 (* t_0 (/ h l)))))))))M_m = fabs(M);
D_m = fabs(D);
d_m = fabs(d);
assert(w0 < M_m && M_m < D_m && D_m < h && h < l && l < d_m);
double code(double w0, double M_m, double D_m, double h, double l, double d_m) {
double t_0 = D_m * ((0.5 * M_m) / d_m);
double tmp;
if (D_m <= 5e+29) {
tmp = w0 * sqrt((1.0 - ((0.5 * (D_m / (l * (d_m / M_m)))) * (0.5 / (d_m / (M_m * (D_m * h)))))));
} else {
tmp = w0 * sqrt((1.0 - (t_0 * (t_0 * (h / l)))));
}
return tmp;
}
M_m = abs(M)
D_m = abs(D)
d_m = abs(d)
NOTE: w0, M_m, D_m, h, l, and d_m should be sorted in increasing order before calling this function.
real(8) function code(w0, m_m, d_m, h, l, d_m_1)
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_m_1
real(8) :: t_0
real(8) :: tmp
t_0 = d_m * ((0.5d0 * m_m) / d_m_1)
if (d_m <= 5d+29) then
tmp = w0 * sqrt((1.0d0 - ((0.5d0 * (d_m / (l * (d_m_1 / m_m)))) * (0.5d0 / (d_m_1 / (m_m * (d_m * h)))))))
else
tmp = w0 * sqrt((1.0d0 - (t_0 * (t_0 * (h / l)))))
end if
code = tmp
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
d_m = Math.abs(d);
assert w0 < M_m && M_m < D_m && D_m < h && h < l && l < d_m;
public static double code(double w0, double M_m, double D_m, double h, double l, double d_m) {
double t_0 = D_m * ((0.5 * M_m) / d_m);
double tmp;
if (D_m <= 5e+29) {
tmp = w0 * Math.sqrt((1.0 - ((0.5 * (D_m / (l * (d_m / M_m)))) * (0.5 / (d_m / (M_m * (D_m * h)))))));
} else {
tmp = w0 * Math.sqrt((1.0 - (t_0 * (t_0 * (h / l)))));
}
return tmp;
}
M_m = math.fabs(M) D_m = math.fabs(D) d_m = math.fabs(d) [w0, M_m, D_m, h, l, d_m] = sort([w0, M_m, D_m, h, l, d_m]) def code(w0, M_m, D_m, h, l, d_m): t_0 = D_m * ((0.5 * M_m) / d_m) tmp = 0 if D_m <= 5e+29: tmp = w0 * math.sqrt((1.0 - ((0.5 * (D_m / (l * (d_m / M_m)))) * (0.5 / (d_m / (M_m * (D_m * h))))))) else: tmp = w0 * math.sqrt((1.0 - (t_0 * (t_0 * (h / l))))) return tmp
M_m = abs(M) D_m = abs(D) d_m = abs(d) w0, M_m, D_m, h, l, d_m = sort([w0, M_m, D_m, h, l, d_m]) function code(w0, M_m, D_m, h, l, d_m) t_0 = Float64(D_m * Float64(Float64(0.5 * M_m) / d_m)) tmp = 0.0 if (D_m <= 5e+29) tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(0.5 * Float64(D_m / Float64(l * Float64(d_m / M_m)))) * Float64(0.5 / Float64(d_m / Float64(M_m * Float64(D_m * h)))))))); else tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(t_0 * Float64(t_0 * Float64(h / l)))))); end return tmp end
M_m = abs(M);
D_m = abs(D);
d_m = abs(d);
w0, M_m, D_m, h, l, d_m = num2cell(sort([w0, M_m, D_m, h, l, d_m])){:}
function tmp_2 = code(w0, M_m, D_m, h, l, d_m)
t_0 = D_m * ((0.5 * M_m) / d_m);
tmp = 0.0;
if (D_m <= 5e+29)
tmp = w0 * sqrt((1.0 - ((0.5 * (D_m / (l * (d_m / M_m)))) * (0.5 / (d_m / (M_m * (D_m * h)))))));
else
tmp = w0 * sqrt((1.0 - (t_0 * (t_0 * (h / l)))));
end
tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
d_m = N[Abs[d], $MachinePrecision]
NOTE: w0, M_m, D_m, h, l, and d_m should be sorted in increasing order before calling this function.
code[w0_, M$95$m_, D$95$m_, h_, l_, d$95$m_] := Block[{t$95$0 = N[(D$95$m * N[(N[(0.5 * M$95$m), $MachinePrecision] / d$95$m), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[D$95$m, 5e+29], N[(w0 * N[Sqrt[N[(1.0 - N[(N[(0.5 * N[(D$95$m / N[(l * N[(d$95$m / M$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(0.5 / N[(d$95$m / N[(M$95$m * N[(D$95$m * h), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(w0 * N[Sqrt[N[(1.0 - N[(t$95$0 * N[(t$95$0 * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
d_m = \left|d\right|
\\
[w0, M_m, D_m, h, l, d_m] = \mathsf{sort}([w0, M_m, D_m, h, l, d_m])\\
\\
\begin{array}{l}
t_0 := D\_m \cdot \frac{0.5 \cdot M\_m}{d\_m}\\
\mathbf{if}\;D\_m \leq 5 \cdot 10^{+29}:\\
\;\;\;\;w0 \cdot \sqrt{1 - \left(0.5 \cdot \frac{D\_m}{\ell \cdot \frac{d\_m}{M\_m}}\right) \cdot \frac{0.5}{\frac{d\_m}{M\_m \cdot \left(D\_m \cdot h\right)}}}\\
\mathbf{else}:\\
\;\;\;\;w0 \cdot \sqrt{1 - t\_0 \cdot \left(t\_0 \cdot \frac{h}{\ell}\right)}\\
\end{array}
\end{array}
if D < 5.0000000000000001e29Initial program 82.8%
Simplified80.9%
*-commutative80.9%
frac-times82.8%
*-commutative82.8%
associate-*l/91.1%
div-inv91.1%
*-commutative91.1%
associate-*l*89.3%
associate-/r*89.3%
metadata-eval89.3%
Applied egg-rr89.3%
*-commutative89.3%
associate-/l*81.4%
unpow281.4%
div-inv81.4%
times-frac91.1%
associate-*r/91.1%
associate-*r/91.1%
Applied egg-rr91.1%
Taylor expanded in D around 0 86.5%
associate-*r/86.5%
associate-/l*86.5%
associate-*r*87.9%
*-commutative87.9%
associate-*l*86.3%
Simplified86.3%
Taylor expanded in D around 0 84.8%
associate-/r*87.8%
associate-/l*86.3%
associate-/l/84.7%
Simplified84.7%
if 5.0000000000000001e29 < D Initial program 79.0%
Simplified79.0%
*-commutative79.0%
frac-times79.0%
*-commutative79.0%
associate-*l/79.4%
div-inv79.4%
*-commutative79.4%
associate-*l*79.4%
associate-/r*79.4%
metadata-eval79.4%
Applied egg-rr79.4%
associate-*l/79.0%
unpow279.0%
associate-*r*83.0%
associate-*r/83.0%
associate-*r/83.0%
Applied egg-rr83.0%
Final simplification84.3%
M_m = (fabs.f64 M) D_m = (fabs.f64 D) d_m = (fabs.f64 d) NOTE: w0, M_m, D_m, h, l, and d_m should be sorted in increasing order before calling this function. (FPCore (w0 M_m D_m h l d_m) :precision binary64 (let* ((t_0 (* D_m (/ (* 0.5 M_m) d_m)))) (* w0 (sqrt (- 1.0 (* (/ t_0 l) (* h t_0)))))))
M_m = fabs(M);
D_m = fabs(D);
d_m = fabs(d);
assert(w0 < M_m && M_m < D_m && D_m < h && h < l && l < d_m);
double code(double w0, double M_m, double D_m, double h, double l, double d_m) {
double t_0 = D_m * ((0.5 * M_m) / d_m);
return w0 * sqrt((1.0 - ((t_0 / l) * (h * t_0))));
}
M_m = abs(M)
D_m = abs(D)
d_m = abs(d)
NOTE: w0, M_m, D_m, h, l, and d_m should be sorted in increasing order before calling this function.
real(8) function code(w0, m_m, d_m, h, l, d_m_1)
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_m_1
real(8) :: t_0
t_0 = d_m * ((0.5d0 * m_m) / d_m_1)
code = w0 * sqrt((1.0d0 - ((t_0 / l) * (h * t_0))))
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
d_m = Math.abs(d);
assert w0 < M_m && M_m < D_m && D_m < h && h < l && l < d_m;
public static double code(double w0, double M_m, double D_m, double h, double l, double d_m) {
double t_0 = D_m * ((0.5 * M_m) / d_m);
return w0 * Math.sqrt((1.0 - ((t_0 / l) * (h * t_0))));
}
M_m = math.fabs(M) D_m = math.fabs(D) d_m = math.fabs(d) [w0, M_m, D_m, h, l, d_m] = sort([w0, M_m, D_m, h, l, d_m]) def code(w0, M_m, D_m, h, l, d_m): t_0 = D_m * ((0.5 * M_m) / d_m) return w0 * math.sqrt((1.0 - ((t_0 / l) * (h * t_0))))
M_m = abs(M) D_m = abs(D) d_m = abs(d) w0, M_m, D_m, h, l, d_m = sort([w0, M_m, D_m, h, l, d_m]) function code(w0, M_m, D_m, h, l, d_m) t_0 = Float64(D_m * Float64(Float64(0.5 * M_m) / d_m)) return Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(t_0 / l) * Float64(h * t_0))))) end
M_m = abs(M);
D_m = abs(D);
d_m = abs(d);
w0, M_m, D_m, h, l, d_m = num2cell(sort([w0, M_m, D_m, h, l, d_m])){:}
function tmp = code(w0, M_m, D_m, h, l, d_m)
t_0 = D_m * ((0.5 * M_m) / d_m);
tmp = w0 * sqrt((1.0 - ((t_0 / l) * (h * t_0))));
end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
d_m = N[Abs[d], $MachinePrecision]
NOTE: w0, M_m, D_m, h, l, and d_m should be sorted in increasing order before calling this function.
code[w0_, M$95$m_, D$95$m_, h_, l_, d$95$m_] := Block[{t$95$0 = N[(D$95$m * N[(N[(0.5 * M$95$m), $MachinePrecision] / d$95$m), $MachinePrecision]), $MachinePrecision]}, N[(w0 * N[Sqrt[N[(1.0 - N[(N[(t$95$0 / l), $MachinePrecision] * N[(h * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
d_m = \left|d\right|
\\
[w0, M_m, D_m, h, l, d_m] = \mathsf{sort}([w0, M_m, D_m, h, l, d_m])\\
\\
\begin{array}{l}
t_0 := D\_m \cdot \frac{0.5 \cdot M\_m}{d\_m}\\
w0 \cdot \sqrt{1 - \frac{t\_0}{\ell} \cdot \left(h \cdot t\_0\right)}
\end{array}
\end{array}
Initial program 82.1%
Simplified80.6%
*-commutative80.6%
frac-times82.1%
*-commutative82.1%
associate-*l/88.8%
div-inv88.8%
*-commutative88.8%
associate-*l*87.3%
associate-/r*87.3%
metadata-eval87.3%
Applied egg-rr87.3%
*-commutative87.3%
associate-/l*80.5%
unpow280.5%
div-inv80.5%
times-frac89.5%
associate-*r/89.5%
associate-*r/89.5%
Applied egg-rr89.5%
div-inv89.5%
associate-*r/88.4%
*-commutative88.4%
associate-/l*87.2%
inv-pow87.2%
pow-flip87.2%
metadata-eval87.2%
pow187.2%
Applied egg-rr87.2%
*-commutative87.2%
associate-/r/89.5%
*-commutative89.5%
Simplified89.5%
Final simplification89.5%
M_m = (fabs.f64 M) D_m = (fabs.f64 D) d_m = (fabs.f64 d) NOTE: w0, M_m, D_m, h, l, and d_m should be sorted in increasing order before calling this function. (FPCore (w0 M_m D_m h l d_m) :precision binary64 w0)
M_m = fabs(M);
D_m = fabs(D);
d_m = fabs(d);
assert(w0 < M_m && M_m < D_m && D_m < h && h < l && l < d_m);
double code(double w0, double M_m, double D_m, double h, double l, double d_m) {
return w0;
}
M_m = abs(M)
D_m = abs(D)
d_m = abs(d)
NOTE: w0, M_m, D_m, h, l, and d_m should be sorted in increasing order before calling this function.
real(8) function code(w0, m_m, d_m, h, l, d_m_1)
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_m_1
code = w0
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
d_m = Math.abs(d);
assert w0 < M_m && M_m < D_m && D_m < h && h < l && l < d_m;
public static double code(double w0, double M_m, double D_m, double h, double l, double d_m) {
return w0;
}
M_m = math.fabs(M) D_m = math.fabs(D) d_m = math.fabs(d) [w0, M_m, D_m, h, l, d_m] = sort([w0, M_m, D_m, h, l, d_m]) def code(w0, M_m, D_m, h, l, d_m): return w0
M_m = abs(M) D_m = abs(D) d_m = abs(d) w0, M_m, D_m, h, l, d_m = sort([w0, M_m, D_m, h, l, d_m]) function code(w0, M_m, D_m, h, l, d_m) return w0 end
M_m = abs(M);
D_m = abs(D);
d_m = abs(d);
w0, M_m, D_m, h, l, d_m = num2cell(sort([w0, M_m, D_m, h, l, d_m])){:}
function tmp = code(w0, M_m, D_m, h, l, d_m)
tmp = w0;
end
M_m = N[Abs[M], $MachinePrecision] D_m = N[Abs[D], $MachinePrecision] d_m = N[Abs[d], $MachinePrecision] NOTE: w0, M_m, D_m, h, l, and d_m should be sorted in increasing order before calling this function. code[w0_, M$95$m_, D$95$m_, h_, l_, d$95$m_] := w0
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
d_m = \left|d\right|
\\
[w0, M_m, D_m, h, l, d_m] = \mathsf{sort}([w0, M_m, D_m, h, l, d_m])\\
\\
w0
\end{array}
Initial program 82.1%
Simplified80.6%
Taylor expanded in D around 0 65.6%
Final simplification65.6%
herbie shell --seed 2024036
(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))))))