
(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}
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 (* M_m (/ D_m d)))))
(if (<= M_m 2e-43)
(* w0 (sqrt (- 1.0 (/ (* (pow (/ (* M_m (* D_m 0.5)) d) 2.0) h) l))))
(* w0 (sqrt (- 1.0 (* t_0 (* t_0 (/ 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 * (M_m * (D_m / d));
double tmp;
if (M_m <= 2e-43) {
tmp = w0 * sqrt((1.0 - ((pow(((M_m * (D_m * 0.5)) / d), 2.0) * h) / l)));
} else {
tmp = w0 * sqrt((1.0 - (t_0 * (t_0 * (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 * (m_m * (d_m / d))
if (m_m <= 2d-43) then
tmp = w0 * sqrt((1.0d0 - (((((m_m * (d_m * 0.5d0)) / d) ** 2.0d0) * h) / l)))
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);
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 * (M_m * (D_m / d));
double tmp;
if (M_m <= 2e-43) {
tmp = w0 * Math.sqrt((1.0 - ((Math.pow(((M_m * (D_m * 0.5)) / d), 2.0) * h) / l)));
} 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) [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 * (M_m * (D_m / d)) tmp = 0 if M_m <= 2e-43: tmp = w0 * math.sqrt((1.0 - ((math.pow(((M_m * (D_m * 0.5)) / d), 2.0) * h) / l))) else: tmp = w0 * math.sqrt((1.0 - (t_0 * (t_0 * (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(0.5 * Float64(M_m * Float64(D_m / d))) tmp = 0.0 if (M_m <= 2e-43) tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(Float64((Float64(Float64(M_m * Float64(D_m * 0.5)) / d) ^ 2.0) * h) / l)))); 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);
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 * (M_m * (D_m / d));
tmp = 0.0;
if (M_m <= 2e-43)
tmp = w0 * sqrt((1.0 - (((((M_m * (D_m * 0.5)) / d) ^ 2.0) * h) / l)));
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]
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[(0.5 * N[(M$95$m * N[(D$95$m / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[M$95$m, 2e-43], N[(w0 * N[Sqrt[N[(1.0 - N[(N[(N[Power[N[(N[(M$95$m * N[(D$95$m * 0.5), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision], 2.0], $MachinePrecision] * h), $MachinePrecision] / l), $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|
\\
[w0, M_m, D_m, h, l, d] = \mathsf{sort}([w0, M_m, D_m, h, l, d])\\
\\
\begin{array}{l}
t_0 := 0.5 \cdot \left(M\_m \cdot \frac{D\_m}{d}\right)\\
\mathbf{if}\;M\_m \leq 2 \cdot 10^{-43}:\\
\;\;\;\;w0 \cdot \sqrt{1 - \frac{{\left(\frac{M\_m \cdot \left(D\_m \cdot 0.5\right)}{d}\right)}^{2} \cdot h}{\ell}}\\
\mathbf{else}:\\
\;\;\;\;w0 \cdot \sqrt{1 - t\_0 \cdot \left(t\_0 \cdot \frac{h}{\ell}\right)}\\
\end{array}
\end{array}
if M < 2.00000000000000015e-43Initial program 81.5%
Simplified81.0%
associate-*r/81.5%
associate-/r*81.5%
add-sqr-sqrt43.6%
associate-/r*43.6%
associate-/l*43.6%
div-inv43.6%
metadata-eval43.6%
Applied egg-rr43.6%
associate-*r/46.4%
associate-/l/46.4%
add-sqr-sqrt86.1%
Applied egg-rr86.1%
if 2.00000000000000015e-43 < M Initial program 77.8%
Simplified80.3%
clear-num80.3%
un-div-inv80.3%
associate-/l*80.3%
Applied egg-rr80.3%
clear-num80.3%
inv-pow80.3%
Applied egg-rr80.3%
associate-*r/84.2%
pow-pow84.2%
associate-/l*84.2%
unpow-prod-down84.2%
metadata-eval84.2%
metadata-eval84.2%
metadata-eval84.2%
Applied egg-rr84.2%
associate-/l*80.3%
add-sqr-sqrt80.3%
associate-*l*80.3%
sqrt-prod80.3%
metadata-eval80.3%
sqrt-pow164.3%
metadata-eval64.3%
unpow-164.3%
clear-num64.4%
div-inv64.4%
clear-num64.4%
sqrt-prod64.4%
metadata-eval64.4%
sqrt-pow185.2%
metadata-eval85.2%
unpow-185.2%
clear-num85.1%
div-inv85.1%
clear-num85.2%
Applied egg-rr85.2%
Final simplification85.8%
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 (* M_m (/ D_m d)))))
(if (<= (pow (/ (* M_m D_m) (* d 2.0)) 2.0) 1e-19)
(* w0 (sqrt (- 1.0 (/ (* h (* 0.25 (pow (/ (/ d D_m) M_m) -2.0))) l))))
(* w0 (sqrt (- 1.0 (* t_0 (* t_0 (/ 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 * (M_m * (D_m / d));
double tmp;
if (pow(((M_m * D_m) / (d * 2.0)), 2.0) <= 1e-19) {
tmp = w0 * sqrt((1.0 - ((h * (0.25 * pow(((d / D_m) / M_m), -2.0))) / l)));
} else {
tmp = w0 * sqrt((1.0 - (t_0 * (t_0 * (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 * (m_m * (d_m / d))
if ((((m_m * d_m) / (d * 2.0d0)) ** 2.0d0) <= 1d-19) then
tmp = w0 * sqrt((1.0d0 - ((h * (0.25d0 * (((d / d_m) / m_m) ** (-2.0d0)))) / l)))
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);
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 * (M_m * (D_m / d));
double tmp;
if (Math.pow(((M_m * D_m) / (d * 2.0)), 2.0) <= 1e-19) {
tmp = w0 * Math.sqrt((1.0 - ((h * (0.25 * Math.pow(((d / D_m) / M_m), -2.0))) / l)));
} 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) [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 * (M_m * (D_m / d)) tmp = 0 if math.pow(((M_m * D_m) / (d * 2.0)), 2.0) <= 1e-19: tmp = w0 * math.sqrt((1.0 - ((h * (0.25 * math.pow(((d / D_m) / M_m), -2.0))) / l))) else: tmp = w0 * math.sqrt((1.0 - (t_0 * (t_0 * (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(0.5 * Float64(M_m * Float64(D_m / d))) tmp = 0.0 if ((Float64(Float64(M_m * D_m) / Float64(d * 2.0)) ^ 2.0) <= 1e-19) tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(h * Float64(0.25 * (Float64(Float64(d / D_m) / M_m) ^ -2.0))) / l)))); 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);
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 * (M_m * (D_m / d));
tmp = 0.0;
if ((((M_m * D_m) / (d * 2.0)) ^ 2.0) <= 1e-19)
tmp = w0 * sqrt((1.0 - ((h * (0.25 * (((d / D_m) / M_m) ^ -2.0))) / l)));
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]
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[(0.5 * N[(M$95$m * N[(D$95$m / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[Power[N[(N[(M$95$m * D$95$m), $MachinePrecision] / N[(d * 2.0), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision], 1e-19], N[(w0 * N[Sqrt[N[(1.0 - N[(N[(h * N[(0.25 * N[Power[N[(N[(d / D$95$m), $MachinePrecision] / M$95$m), $MachinePrecision], -2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / l), $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|
\\
[w0, M_m, D_m, h, l, d] = \mathsf{sort}([w0, M_m, D_m, h, l, d])\\
\\
\begin{array}{l}
t_0 := 0.5 \cdot \left(M\_m \cdot \frac{D\_m}{d}\right)\\
\mathbf{if}\;{\left(\frac{M\_m \cdot D\_m}{d \cdot 2}\right)}^{2} \leq 10^{-19}:\\
\;\;\;\;w0 \cdot \sqrt{1 - \frac{h \cdot \left(0.25 \cdot {\left(\frac{\frac{d}{D\_m}}{M\_m}\right)}^{-2}\right)}{\ell}}\\
\mathbf{else}:\\
\;\;\;\;w0 \cdot \sqrt{1 - t\_0 \cdot \left(t\_0 \cdot \frac{h}{\ell}\right)}\\
\end{array}
\end{array}
if (pow.f64 (/.f64 (*.f64 M D) (*.f64 2 d)) 2) < 9.9999999999999998e-20Initial program 90.7%
Simplified90.7%
clear-num90.7%
un-div-inv90.7%
associate-/l*90.7%
Applied egg-rr90.7%
clear-num90.7%
inv-pow90.7%
Applied egg-rr90.7%
associate-*r/98.7%
pow-pow98.8%
associate-/l*98.8%
unpow-prod-down98.8%
metadata-eval98.8%
metadata-eval98.8%
metadata-eval98.8%
Applied egg-rr98.8%
if 9.9999999999999998e-20 < (pow.f64 (/.f64 (*.f64 M D) (*.f64 2 d)) 2) Initial program 63.3%
Simplified64.2%
clear-num64.2%
un-div-inv64.2%
associate-/l*64.2%
Applied egg-rr64.2%
clear-num64.2%
inv-pow64.2%
Applied egg-rr64.2%
associate-*r/62.3%
pow-pow62.4%
associate-/l*62.4%
unpow-prod-down62.4%
metadata-eval62.4%
metadata-eval62.4%
metadata-eval62.4%
Applied egg-rr62.4%
associate-/l*64.2%
add-sqr-sqrt64.2%
associate-*l*64.2%
sqrt-prod64.2%
metadata-eval64.2%
sqrt-pow140.4%
metadata-eval40.4%
unpow-140.4%
clear-num40.4%
div-inv40.4%
clear-num40.4%
sqrt-prod40.4%
metadata-eval40.4%
sqrt-pow171.2%
metadata-eval71.2%
unpow-171.2%
clear-num71.2%
div-inv71.1%
clear-num71.2%
Applied egg-rr71.2%
Final simplification88.4%
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 (* M_m (/ D_m d)))))
(if (<= (* (/ h l) (pow (/ (* M_m D_m) (* d 2.0)) 2.0)) -2e-12)
(* w0 (sqrt (- 1.0 (* t_0 (* t_0 (/ 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 t_0 = 0.5 * (M_m * (D_m / d));
double tmp;
if (((h / l) * pow(((M_m * D_m) / (d * 2.0)), 2.0)) <= -2e-12) {
tmp = w0 * sqrt((1.0 - (t_0 * (t_0 * (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) :: t_0
real(8) :: tmp
t_0 = 0.5d0 * (m_m * (d_m / d))
if (((h / l) * (((m_m * d_m) / (d * 2.0d0)) ** 2.0d0)) <= (-2d-12)) then
tmp = w0 * sqrt((1.0d0 - (t_0 * (t_0 * (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 t_0 = 0.5 * (M_m * (D_m / d));
double tmp;
if (((h / l) * Math.pow(((M_m * D_m) / (d * 2.0)), 2.0)) <= -2e-12) {
tmp = w0 * Math.sqrt((1.0 - (t_0 * (t_0 * (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): t_0 = 0.5 * (M_m * (D_m / d)) tmp = 0 if ((h / l) * math.pow(((M_m * D_m) / (d * 2.0)), 2.0)) <= -2e-12: tmp = w0 * math.sqrt((1.0 - (t_0 * (t_0 * (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) t_0 = Float64(0.5 * Float64(M_m * Float64(D_m / d))) tmp = 0.0 if (Float64(Float64(h / l) * (Float64(Float64(M_m * D_m) / Float64(d * 2.0)) ^ 2.0)) <= -2e-12) tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(t_0 * Float64(t_0 * 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)
t_0 = 0.5 * (M_m * (D_m / d));
tmp = 0.0;
if (((h / l) * (((M_m * D_m) / (d * 2.0)) ^ 2.0)) <= -2e-12)
tmp = w0 * sqrt((1.0 - (t_0 * (t_0 * (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_] := Block[{t$95$0 = N[(0.5 * N[(M$95$m * N[(D$95$m / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(N[(h / l), $MachinePrecision] * N[Power[N[(N[(M$95$m * D$95$m), $MachinePrecision] / N[(d * 2.0), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision], -2e-12], N[(w0 * N[Sqrt[N[(1.0 - N[(t$95$0 * N[(t$95$0 * N[(h / l), $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}
t_0 := 0.5 \cdot \left(M\_m \cdot \frac{D\_m}{d}\right)\\
\mathbf{if}\;\frac{h}{\ell} \cdot {\left(\frac{M\_m \cdot D\_m}{d \cdot 2}\right)}^{2} \leq -2 \cdot 10^{-12}:\\
\;\;\;\;w0 \cdot \sqrt{1 - t\_0 \cdot \left(t\_0 \cdot \frac{h}{\ell}\right)}\\
\mathbf{else}:\\
\;\;\;\;w0\\
\end{array}
\end{array}
if (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 2 d)) 2) (/.f64 h l)) < -1.99999999999999996e-12Initial program 56.7%
Simplified59.0%
clear-num58.9%
un-div-inv59.0%
associate-/l*58.9%
Applied egg-rr58.9%
clear-num58.9%
inv-pow58.9%
Applied egg-rr58.9%
associate-*r/60.1%
pow-pow60.2%
associate-/l*60.2%
unpow-prod-down60.2%
metadata-eval60.2%
metadata-eval60.2%
metadata-eval60.2%
Applied egg-rr60.2%
associate-/l*58.9%
add-sqr-sqrt58.9%
associate-*l*58.9%
sqrt-prod58.9%
metadata-eval58.9%
sqrt-pow127.5%
metadata-eval27.5%
unpow-127.5%
clear-num27.5%
div-inv27.5%
clear-num27.5%
sqrt-prod27.5%
metadata-eval27.5%
sqrt-pow165.6%
metadata-eval65.6%
unpow-165.6%
clear-num65.6%
div-inv65.5%
clear-num65.6%
Applied egg-rr65.6%
if -1.99999999999999996e-12 < (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 2 d)) 2) (/.f64 h l)) Initial program 92.4%
Simplified91.8%
Taylor expanded in M around 0 98.1%
Final simplification87.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 80.4%
Simplified80.8%
Taylor expanded in M around 0 67.5%
Final simplification67.5%
herbie shell --seed 2024043
(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))))))