
(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 (* (/ 0.5 d) (* M_m D_m))))
(if (<= M_m 5e-58)
(* w0 (sqrt (- 1.0 (* (* h t_0) (/ t_0 l)))))
(*
w0
(sqrt
(-
1.0
(*
(* h (/ (* M_m (* 0.5 (/ D_m d))) l))
(* M_m (/ 0.5 (/ d D_m))))))))))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 = (0.5 / d) * (M_m * D_m);
double tmp;
if (M_m <= 5e-58) {
tmp = w0 * sqrt((1.0 - ((h * t_0) * (t_0 / l))));
} else {
tmp = w0 * sqrt((1.0 - ((h * ((M_m * (0.5 * (D_m / d))) / l)) * (M_m * (0.5 / (d / D_m))))));
}
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) :: t_0
real(8) :: tmp
t_0 = (0.5d0 / d) * (m_m * d_m)
if (m_m <= 5d-58) then
tmp = w0 * sqrt((1.0d0 - ((h * t_0) * (t_0 / l))))
else
tmp = w0 * sqrt((1.0d0 - ((h * ((m_m * (0.5d0 * (d_m / d))) / l)) * (m_m * (0.5d0 / (d / d_m))))))
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 t_0 = (0.5 / d) * (M_m * D_m);
double tmp;
if (M_m <= 5e-58) {
tmp = w0 * Math.sqrt((1.0 - ((h * t_0) * (t_0 / l))));
} else {
tmp = w0 * Math.sqrt((1.0 - ((h * ((M_m * (0.5 * (D_m / d))) / l)) * (M_m * (0.5 / (d / D_m))))));
}
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): t_0 = (0.5 / d) * (M_m * D_m) tmp = 0 if M_m <= 5e-58: tmp = w0 * math.sqrt((1.0 - ((h * t_0) * (t_0 / l)))) else: tmp = w0 * math.sqrt((1.0 - ((h * ((M_m * (0.5 * (D_m / d))) / l)) * (M_m * (0.5 / (d / D_m)))))) 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) t_0 = Float64(Float64(0.5 / d) * Float64(M_m * D_m)) tmp = 0.0 if (M_m <= 5e-58) tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(h * t_0) * Float64(t_0 / l))))); else tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(h * Float64(Float64(M_m * Float64(0.5 * Float64(D_m / d))) / l)) * Float64(M_m * Float64(0.5 / Float64(d / D_m))))))); 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)
t_0 = (0.5 / d) * (M_m * D_m);
tmp = 0.0;
if (M_m <= 5e-58)
tmp = w0 * sqrt((1.0 - ((h * t_0) * (t_0 / l))));
else
tmp = w0 * sqrt((1.0 - ((h * ((M_m * (0.5 * (D_m / d))) / l)) * (M_m * (0.5 / (d / D_m))))));
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_] := Block[{t$95$0 = N[(N[(0.5 / d), $MachinePrecision] * N[(M$95$m * D$95$m), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[M$95$m, 5e-58], N[(w0 * N[Sqrt[N[(1.0 - N[(N[(h * t$95$0), $MachinePrecision] * N[(t$95$0 / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(w0 * N[Sqrt[N[(1.0 - N[(N[(h * N[(N[(M$95$m * N[(0.5 * N[(D$95$m / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision] * N[(M$95$m * N[(0.5 / N[(d / D$95$m), $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}
t_0 := \frac{0.5}{d} \cdot \left(M\_m \cdot D\_m\right)\\
\mathbf{if}\;M\_m \leq 5 \cdot 10^{-58}:\\
\;\;\;\;w0 \cdot \sqrt{1 - \left(h \cdot t\_0\right) \cdot \frac{t\_0}{\ell}}\\
\mathbf{else}:\\
\;\;\;\;w0 \cdot \sqrt{1 - \left(h \cdot \frac{M\_m \cdot \left(0.5 \cdot \frac{D\_m}{d}\right)}{\ell}\right) \cdot \left(M\_m \cdot \frac{0.5}{\frac{d}{D\_m}}\right)}\\
\end{array}
\end{array}
if M < 4.99999999999999977e-58Initial program 79.9%
Simplified80.5%
associate-*r/86.9%
*-commutative86.9%
associate-*l/86.1%
associate-*r/86.4%
div-inv86.4%
metadata-eval86.4%
Applied egg-rr86.4%
associate-/l*79.9%
*-commutative79.9%
unpow279.9%
associate-*r*81.4%
associate-*l*81.4%
clear-num81.4%
un-div-inv81.4%
associate-*l*81.4%
clear-num81.4%
un-div-inv81.4%
Applied egg-rr81.4%
associate-*r/81.4%
associate-*l/89.4%
div-inv89.4%
clear-num89.4%
associate-*l*89.4%
Applied egg-rr89.4%
*-un-lft-identity89.4%
associate-*l/88.5%
clear-num88.5%
div-inv88.5%
associate-*r*86.1%
associate-/r/86.1%
associate-/r/86.1%
Applied egg-rr86.1%
*-lft-identity86.1%
associate-/l*86.6%
associate-*l*88.9%
*-commutative88.9%
associate-*l*87.0%
*-commutative87.0%
associate-*l*89.0%
Simplified89.0%
if 4.99999999999999977e-58 < M Initial program 78.2%
Simplified76.8%
associate-*r/80.2%
*-commutative80.2%
associate-*l/80.2%
associate-*r/79.4%
div-inv79.4%
metadata-eval79.4%
Applied egg-rr79.4%
associate-/l*77.4%
*-commutative77.4%
unpow277.4%
associate-*r*82.1%
associate-*l*82.1%
clear-num81.6%
un-div-inv81.6%
associate-*l*81.6%
clear-num81.6%
un-div-inv81.6%
Applied egg-rr81.6%
associate-*r/81.6%
associate-*l/90.2%
div-inv90.2%
clear-num90.2%
associate-*l*90.2%
Applied egg-rr90.2%
associate-/l*90.2%
Simplified90.2%
Final simplification89.3%
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 (<= (/ h l) -1e+135)
(*
w0
(sqrt
(-
1.0
(* (* 0.5 (* D_m (/ (* M_m h) (* d l)))) (/ (* D_m (* M_m 0.5)) d)))))
(if (<= (/ h l) -2e-296)
(*
w0
(sqrt
(-
1.0
(* (* M_m (/ 0.5 (/ d D_m))) (* M_m (* (* 0.5 (/ D_m d)) (/ h l)))))))
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) {
double tmp;
if ((h / l) <= -1e+135) {
tmp = w0 * sqrt((1.0 - ((0.5 * (D_m * ((M_m * h) / (d * l)))) * ((D_m * (M_m * 0.5)) / d))));
} else if ((h / l) <= -2e-296) {
tmp = w0 * sqrt((1.0 - ((M_m * (0.5 / (d / D_m))) * (M_m * ((0.5 * (D_m / d)) * (h / l))))));
} else {
tmp = w0;
}
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 ((h / l) <= (-1d+135)) then
tmp = w0 * sqrt((1.0d0 - ((0.5d0 * (d_m * ((m_m * h) / (d * l)))) * ((d_m * (m_m * 0.5d0)) / d))))
else if ((h / l) <= (-2d-296)) then
tmp = w0 * sqrt((1.0d0 - ((m_m * (0.5d0 / (d / d_m))) * (m_m * ((0.5d0 * (d_m / d)) * (h / l))))))
else
tmp = w0
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 ((h / l) <= -1e+135) {
tmp = w0 * Math.sqrt((1.0 - ((0.5 * (D_m * ((M_m * h) / (d * l)))) * ((D_m * (M_m * 0.5)) / d))));
} else if ((h / l) <= -2e-296) {
tmp = w0 * Math.sqrt((1.0 - ((M_m * (0.5 / (d / D_m))) * (M_m * ((0.5 * (D_m / d)) * (h / l))))));
} else {
tmp = w0;
}
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 (h / l) <= -1e+135: tmp = w0 * math.sqrt((1.0 - ((0.5 * (D_m * ((M_m * h) / (d * l)))) * ((D_m * (M_m * 0.5)) / d)))) elif (h / l) <= -2e-296: tmp = w0 * math.sqrt((1.0 - ((M_m * (0.5 / (d / D_m))) * (M_m * ((0.5 * (D_m / d)) * (h / l)))))) else: tmp = w0 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 (Float64(h / l) <= -1e+135) tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(0.5 * Float64(D_m * Float64(Float64(M_m * h) / Float64(d * l)))) * Float64(Float64(D_m * Float64(M_m * 0.5)) / d))))); elseif (Float64(h / l) <= -2e-296) tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(M_m * Float64(0.5 / Float64(d / D_m))) * Float64(M_m * Float64(Float64(0.5 * Float64(D_m / d)) * Float64(h / l))))))); else tmp = w0; 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 ((h / l) <= -1e+135)
tmp = w0 * sqrt((1.0 - ((0.5 * (D_m * ((M_m * h) / (d * l)))) * ((D_m * (M_m * 0.5)) / d))));
elseif ((h / l) <= -2e-296)
tmp = w0 * sqrt((1.0 - ((M_m * (0.5 / (d / D_m))) * (M_m * ((0.5 * (D_m / d)) * (h / l))))));
else
tmp = w0;
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[N[(h / l), $MachinePrecision], -1e+135], N[(w0 * N[Sqrt[N[(1.0 - N[(N[(0.5 * N[(D$95$m * N[(N[(M$95$m * h), $MachinePrecision] / N[(d * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[(D$95$m * N[(M$95$m * 0.5), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(h / l), $MachinePrecision], -2e-296], N[(w0 * N[Sqrt[N[(1.0 - N[(N[(M$95$m * N[(0.5 / N[(d / D$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(M$95$m * N[(N[(0.5 * N[(D$95$m / d), $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 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])\\
\\
\begin{array}{l}
\mathbf{if}\;\frac{h}{\ell} \leq -1 \cdot 10^{+135}:\\
\;\;\;\;w0 \cdot \sqrt{1 - \left(0.5 \cdot \left(D\_m \cdot \frac{M\_m \cdot h}{d \cdot \ell}\right)\right) \cdot \frac{D\_m \cdot \left(M\_m \cdot 0.5\right)}{d}}\\
\mathbf{elif}\;\frac{h}{\ell} \leq -2 \cdot 10^{-296}:\\
\;\;\;\;w0 \cdot \sqrt{1 - \left(M\_m \cdot \frac{0.5}{\frac{d}{D\_m}}\right) \cdot \left(M\_m \cdot \left(\left(0.5 \cdot \frac{D\_m}{d}\right) \cdot \frac{h}{\ell}\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;w0\\
\end{array}
\end{array}
if (/.f64 h l) < -9.99999999999999962e134Initial program 70.9%
Simplified67.6%
associate-*r/76.4%
*-commutative76.4%
associate-*l/76.7%
associate-*r/77.0%
div-inv77.0%
metadata-eval77.0%
Applied egg-rr77.0%
associate-/l*69.9%
*-commutative69.9%
unpow269.9%
associate-*r*70.1%
associate-*l*70.0%
clear-num69.4%
un-div-inv69.4%
associate-*l*69.4%
clear-num69.4%
un-div-inv69.4%
Applied egg-rr69.4%
Taylor expanded in h around 0 69.3%
associate-/l*69.4%
Simplified69.4%
div-inv69.4%
clear-num69.4%
associate-*l*69.4%
associate-*r/69.4%
Applied egg-rr69.4%
if -9.99999999999999962e134 < (/.f64 h l) < -2e-296Initial program 86.0%
Simplified86.0%
associate-*r/85.0%
*-commutative85.0%
associate-*l/85.0%
associate-*r/84.0%
div-inv84.0%
metadata-eval84.0%
Applied egg-rr84.0%
associate-/l*85.0%
*-commutative85.0%
unpow285.0%
associate-*r*89.0%
associate-*l*89.0%
clear-num89.0%
un-div-inv89.0%
associate-*l*89.0%
clear-num89.0%
un-div-inv89.0%
Applied egg-rr89.0%
associate-*r/89.0%
associate-*l/89.0%
div-inv89.0%
clear-num89.0%
associate-*l*89.0%
Applied egg-rr89.0%
*-commutative89.0%
associate-*r/89.0%
associate-*l*87.1%
Simplified87.1%
if -2e-296 < (/.f64 h l) Initial program 78.2%
Simplified80.0%
Taylor expanded in D around 0 89.6%
Final simplification84.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
(let* ((t_0 (* (/ 0.5 d) (* M_m D_m))))
(if (<= M_m 1.25e+70)
(* w0 (sqrt (- 1.0 (* (* h t_0) (/ t_0 l)))))
(*
w0
(sqrt
(-
1.0
(*
(* M_m (/ 0.5 (/ d D_m)))
(* M_m (* (* 0.5 (/ D_m d)) (/ h 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 = (0.5 / d) * (M_m * D_m);
double tmp;
if (M_m <= 1.25e+70) {
tmp = w0 * sqrt((1.0 - ((h * t_0) * (t_0 / l))));
} else {
tmp = w0 * sqrt((1.0 - ((M_m * (0.5 / (d / D_m))) * (M_m * ((0.5 * (D_m / d)) * (h / 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) :: t_0
real(8) :: tmp
t_0 = (0.5d0 / d) * (m_m * d_m)
if (m_m <= 1.25d+70) then
tmp = w0 * sqrt((1.0d0 - ((h * t_0) * (t_0 / l))))
else
tmp = w0 * sqrt((1.0d0 - ((m_m * (0.5d0 / (d / d_m))) * (m_m * ((0.5d0 * (d_m / d)) * (h / 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 t_0 = (0.5 / d) * (M_m * D_m);
double tmp;
if (M_m <= 1.25e+70) {
tmp = w0 * Math.sqrt((1.0 - ((h * t_0) * (t_0 / l))));
} else {
tmp = w0 * Math.sqrt((1.0 - ((M_m * (0.5 / (d / D_m))) * (M_m * ((0.5 * (D_m / d)) * (h / 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): t_0 = (0.5 / d) * (M_m * D_m) tmp = 0 if M_m <= 1.25e+70: tmp = w0 * math.sqrt((1.0 - ((h * t_0) * (t_0 / l)))) else: tmp = w0 * math.sqrt((1.0 - ((M_m * (0.5 / (d / D_m))) * (M_m * ((0.5 * (D_m / d)) * (h / 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) t_0 = Float64(Float64(0.5 / d) * Float64(M_m * D_m)) tmp = 0.0 if (M_m <= 1.25e+70) tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(h * t_0) * Float64(t_0 / l))))); else tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(M_m * Float64(0.5 / Float64(d / D_m))) * Float64(M_m * Float64(Float64(0.5 * Float64(D_m / d)) * Float64(h / 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)
t_0 = (0.5 / d) * (M_m * D_m);
tmp = 0.0;
if (M_m <= 1.25e+70)
tmp = w0 * sqrt((1.0 - ((h * t_0) * (t_0 / l))));
else
tmp = w0 * sqrt((1.0 - ((M_m * (0.5 / (d / D_m))) * (M_m * ((0.5 * (D_m / d)) * (h / 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_] := Block[{t$95$0 = N[(N[(0.5 / d), $MachinePrecision] * N[(M$95$m * D$95$m), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[M$95$m, 1.25e+70], N[(w0 * N[Sqrt[N[(1.0 - N[(N[(h * t$95$0), $MachinePrecision] * N[(t$95$0 / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(w0 * N[Sqrt[N[(1.0 - N[(N[(M$95$m * N[(0.5 / N[(d / D$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(M$95$m * N[(N[(0.5 * N[(D$95$m / d), $MachinePrecision]), $MachinePrecision] * N[(h / 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}
t_0 := \frac{0.5}{d} \cdot \left(M\_m \cdot D\_m\right)\\
\mathbf{if}\;M\_m \leq 1.25 \cdot 10^{+70}:\\
\;\;\;\;w0 \cdot \sqrt{1 - \left(h \cdot t\_0\right) \cdot \frac{t\_0}{\ell}}\\
\mathbf{else}:\\
\;\;\;\;w0 \cdot \sqrt{1 - \left(M\_m \cdot \frac{0.5}{\frac{d}{D\_m}}\right) \cdot \left(M\_m \cdot \left(\left(0.5 \cdot \frac{D\_m}{d}\right) \cdot \frac{h}{\ell}\right)\right)}\\
\end{array}
\end{array}
if M < 1.2500000000000001e70Initial program 81.2%
Simplified81.7%
associate-*r/87.9%
*-commutative87.9%
associate-*l/87.1%
associate-*r/87.4%
div-inv87.4%
metadata-eval87.4%
Applied egg-rr87.4%
associate-/l*81.2%
*-commutative81.2%
unpow281.2%
associate-*r*82.5%
associate-*l*82.5%
clear-num82.5%
un-div-inv82.5%
associate-*l*82.5%
clear-num82.5%
un-div-inv82.5%
Applied egg-rr82.5%
associate-*r/82.5%
associate-*l/90.1%
div-inv90.1%
clear-num90.1%
associate-*l*90.1%
Applied egg-rr90.1%
*-un-lft-identity90.1%
associate-*l/89.3%
clear-num89.3%
div-inv89.3%
associate-*r*87.2%
associate-/r/87.2%
associate-/r/87.2%
Applied egg-rr87.2%
*-lft-identity87.2%
associate-/l*87.6%
associate-*l*89.7%
*-commutative89.7%
associate-*l*88.0%
*-commutative88.0%
associate-*l*89.8%
Simplified89.8%
if 1.2500000000000001e70 < M Initial program 71.2%
Simplified69.1%
associate-*r/72.0%
*-commutative72.0%
associate-*l/72.0%
associate-*r/70.8%
div-inv70.8%
metadata-eval70.8%
Applied egg-rr70.8%
associate-/l*70.0%
*-commutative70.0%
unpow270.0%
associate-*r*77.2%
associate-*l*77.1%
clear-num76.3%
un-div-inv76.3%
associate-*l*76.3%
clear-num76.3%
un-div-inv76.3%
Applied egg-rr76.3%
associate-*r/76.3%
associate-*l/87.2%
div-inv87.2%
clear-num87.2%
associate-*l*87.2%
Applied egg-rr87.2%
*-commutative87.2%
associate-*r/76.3%
associate-*l*74.2%
Simplified74.2%
Final simplification87.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
(*
w0
(sqrt
(-
1.0
(* (* M_m (/ 0.5 (/ d D_m))) (* 0.5 (* D_m (/ (* M_m h) (* 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 - ((M_m * (0.5 / (d / D_m))) * (0.5 * (D_m * ((M_m * h) / (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 - ((m_m * (0.5d0 / (d / d_m))) * (0.5d0 * (d_m * ((m_m * h) / (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 - ((M_m * (0.5 / (d / D_m))) * (0.5 * (D_m * ((M_m * h) / (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 - ((M_m * (0.5 / (d / D_m))) * (0.5 * (D_m * ((M_m * h) / (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(M_m * Float64(0.5 / Float64(d / D_m))) * Float64(0.5 * Float64(D_m * Float64(Float64(M_m * h) / Float64(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 - ((M_m * (0.5 / (d / D_m))) * (0.5 * (D_m * ((M_m * h) / (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[(M$95$m * N[(0.5 / N[(d / D$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(0.5 * N[(D$95$m * N[(N[(M$95$m * h), $MachinePrecision] / N[(d * l), $MachinePrecision]), $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(M\_m \cdot \frac{0.5}{\frac{d}{D\_m}}\right) \cdot \left(0.5 \cdot \left(D\_m \cdot \frac{M\_m \cdot h}{d \cdot \ell}\right)\right)}
\end{array}
Initial program 79.5%
Simplified79.5%
associate-*r/85.2%
*-commutative85.2%
associate-*l/84.5%
associate-*r/84.6%
div-inv84.6%
metadata-eval84.6%
Applied egg-rr84.6%
associate-/l*79.3%
*-commutative79.3%
unpow279.3%
associate-*r*81.6%
associate-*l*81.6%
clear-num81.4%
un-div-inv81.4%
associate-*l*81.4%
clear-num81.4%
un-div-inv81.4%
Applied egg-rr81.4%
Taylor expanded in h around 0 80.1%
associate-/l*81.0%
Simplified81.0%
Final simplification81.0%
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 79.5%
Simplified79.5%
Taylor expanded in D around 0 65.4%
Final simplification65.4%
herbie shell --seed 2024081
(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))))))