
(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 (* (/ M_m d) (/ D_m 2.0)))) (* w0 (sqrt (- 1.0 (* (/ t_0 l) (* t_0 h)))))))
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 = (M_m / d) * (D_m / 2.0);
return w0 * sqrt((1.0 - ((t_0 / l) * (t_0 * h))));
}
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 = (m_m / d) * (d_m / 2.0d0)
code = w0 * sqrt((1.0d0 - ((t_0 / l) * (t_0 * h))))
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 = (M_m / d) * (D_m / 2.0);
return w0 * Math.sqrt((1.0 - ((t_0 / l) * (t_0 * h))));
}
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 = (M_m / d) * (D_m / 2.0) return w0 * math.sqrt((1.0 - ((t_0 / l) * (t_0 * h))))
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(M_m / d) * Float64(D_m / 2.0)) return Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(t_0 / l) * Float64(t_0 * h))))) 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 = (M_m / d) * (D_m / 2.0);
tmp = w0 * sqrt((1.0 - ((t_0 / l) * (t_0 * h))));
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[(M$95$m / d), $MachinePrecision] * N[(D$95$m / 2.0), $MachinePrecision]), $MachinePrecision]}, N[(w0 * N[Sqrt[N[(1.0 - N[(N[(t$95$0 / l), $MachinePrecision] * N[(t$95$0 * h), $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{M\_m}{d} \cdot \frac{D\_m}{2}\\
w0 \cdot \sqrt{1 - \frac{t\_0}{\ell} \cdot \left(t\_0 \cdot h\right)}
\end{array}
\end{array}
Initial program 79.4%
Simplified79.0%
clear-num79.0%
un-div-inv80.0%
clear-num80.0%
un-div-inv80.4%
associate-/r/80.4%
Applied egg-rr80.4%
associate-*l/80.4%
*-commutative80.4%
associate-*l/80.4%
associate-/l/80.5%
associate-/r/80.5%
Simplified80.5%
unpow280.5%
div-inv80.5%
times-frac90.3%
associate-*l/90.3%
associate-*l/90.3%
Applied egg-rr90.3%
associate-*l/89.5%
associate-/l*88.1%
associate-*l/88.1%
*-commutative88.1%
associate-/r/88.1%
/-rgt-identity88.1%
associate-*l/88.8%
associate-/l*89.6%
associate-*l/89.6%
*-commutative89.6%
Simplified89.6%
Final simplification89.6%
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 1.3e-183)
(*
w0
(sqrt
(-
1.0
(* (/ (* (/ M_m d) (/ D_m 2.0)) l) (* 0.5 (/ (* D_m (* M_m h)) d))))))
(*
w0
(sqrt
(-
1.0
(* (* (/ D_m d) (/ (/ M_m 2.0) l)) (* h (* M_m (/ (* D_m 0.5) 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 <= 1.3e-183) {
tmp = w0 * sqrt((1.0 - ((((M_m / d) * (D_m / 2.0)) / l) * (0.5 * ((D_m * (M_m * h)) / d)))));
} else {
tmp = w0 * sqrt((1.0 - (((D_m / d) * ((M_m / 2.0) / l)) * (h * (M_m * ((D_m * 0.5) / 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 <= 1.3d-183) then
tmp = w0 * sqrt((1.0d0 - ((((m_m / d) * (d_m / 2.0d0)) / l) * (0.5d0 * ((d_m * (m_m * h)) / d)))))
else
tmp = w0 * sqrt((1.0d0 - (((d_m / d) * ((m_m / 2.0d0) / l)) * (h * (m_m * ((d_m * 0.5d0) / 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 <= 1.3e-183) {
tmp = w0 * Math.sqrt((1.0 - ((((M_m / d) * (D_m / 2.0)) / l) * (0.5 * ((D_m * (M_m * h)) / d)))));
} else {
tmp = w0 * Math.sqrt((1.0 - (((D_m / d) * ((M_m / 2.0) / l)) * (h * (M_m * ((D_m * 0.5) / 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 <= 1.3e-183: tmp = w0 * math.sqrt((1.0 - ((((M_m / d) * (D_m / 2.0)) / l) * (0.5 * ((D_m * (M_m * h)) / d))))) else: tmp = w0 * math.sqrt((1.0 - (((D_m / d) * ((M_m / 2.0) / l)) * (h * (M_m * ((D_m * 0.5) / 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 <= 1.3e-183) tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(Float64(Float64(M_m / d) * Float64(D_m / 2.0)) / l) * Float64(0.5 * Float64(Float64(D_m * Float64(M_m * h)) / d)))))); else tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(Float64(D_m / d) * Float64(Float64(M_m / 2.0) / l)) * Float64(h * Float64(M_m * Float64(Float64(D_m * 0.5) / 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 <= 1.3e-183)
tmp = w0 * sqrt((1.0 - ((((M_m / d) * (D_m / 2.0)) / l) * (0.5 * ((D_m * (M_m * h)) / d)))));
else
tmp = w0 * sqrt((1.0 - (((D_m / d) * ((M_m / 2.0) / l)) * (h * (M_m * ((D_m * 0.5) / 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, 1.3e-183], N[(w0 * N[Sqrt[N[(1.0 - N[(N[(N[(N[(M$95$m / d), $MachinePrecision] * N[(D$95$m / 2.0), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision] * N[(0.5 * N[(N[(D$95$m * N[(M$95$m * h), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(w0 * N[Sqrt[N[(1.0 - N[(N[(N[(D$95$m / d), $MachinePrecision] * N[(N[(M$95$m / 2.0), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision] * N[(h * N[(M$95$m * N[(N[(D$95$m * 0.5), $MachinePrecision] / d), $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 \leq 1.3 \cdot 10^{-183}:\\
\;\;\;\;w0 \cdot \sqrt{1 - \frac{\frac{M\_m}{d} \cdot \frac{D\_m}{2}}{\ell} \cdot \left(0.5 \cdot \frac{D\_m \cdot \left(M\_m \cdot h\right)}{d}\right)}\\
\mathbf{else}:\\
\;\;\;\;w0 \cdot \sqrt{1 - \left(\frac{D\_m}{d} \cdot \frac{\frac{M\_m}{2}}{\ell}\right) \cdot \left(h \cdot \left(M\_m \cdot \frac{D\_m \cdot 0.5}{d}\right)\right)}\\
\end{array}
\end{array}
if d < 1.2999999999999999e-183Initial program 78.2%
Simplified77.6%
clear-num77.5%
un-div-inv78.6%
clear-num78.6%
un-div-inv79.2%
associate-/r/79.2%
Applied egg-rr79.2%
associate-*l/79.2%
*-commutative79.2%
associate-*l/79.2%
associate-/l/79.5%
associate-/r/79.5%
Simplified79.5%
unpow279.5%
div-inv79.5%
times-frac88.8%
associate-*l/88.8%
associate-*l/88.8%
Applied egg-rr88.8%
associate-*l/87.5%
associate-/l*85.7%
associate-*l/85.7%
*-commutative85.7%
associate-/r/85.7%
/-rgt-identity85.7%
associate-*l/86.8%
associate-/l*88.1%
associate-*l/88.1%
*-commutative88.1%
Simplified88.1%
Taylor expanded in M around 0 82.6%
if 1.2999999999999999e-183 < d Initial program 81.1%
Simplified81.1%
clear-num81.1%
un-div-inv82.1%
clear-num82.1%
un-div-inv82.0%
associate-/r/82.0%
Applied egg-rr82.0%
associate-*l/82.0%
*-commutative82.0%
associate-*l/82.0%
associate-/l/82.1%
associate-/r/82.1%
Simplified82.1%
unpow282.1%
div-inv82.1%
times-frac92.6%
associate-*l/92.6%
associate-*l/92.6%
Applied egg-rr92.6%
associate-*l/92.6%
associate-/l*91.7%
associate-*l/91.7%
*-commutative91.7%
associate-/r/91.7%
/-rgt-identity91.7%
associate-*l/91.7%
associate-/l*91.7%
associate-*l/91.7%
*-commutative91.7%
Simplified91.7%
associate-*l/91.7%
div-inv91.7%
metadata-eval91.7%
Applied egg-rr91.7%
associate-/l*91.7%
*-commutative91.7%
Simplified91.7%
div-inv91.7%
frac-times92.6%
Applied egg-rr92.6%
associate-*r/92.6%
associate-/l*92.6%
*-commutative92.6%
associate-/l/92.6%
*-commutative92.6%
*-rgt-identity92.6%
associate-*l/92.6%
associate-*r/92.6%
associate-/l*88.8%
Simplified88.8%
Final simplification85.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
(* (* (/ D_m d) (/ (/ M_m 2.0) l)) (* h (* M_m (/ (* D_m 0.5) 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) {
return w0 * sqrt((1.0 - (((D_m / d) * ((M_m / 2.0) / l)) * (h * (M_m * ((D_m * 0.5) / d))))));
}
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 / d) * ((m_m / 2.0d0) / l)) * (h * (m_m * ((d_m * 0.5d0) / d))))))
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 / d) * ((M_m / 2.0) / l)) * (h * (M_m * ((D_m * 0.5) / d))))));
}
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 / d) * ((M_m / 2.0) / l)) * (h * (M_m * ((D_m * 0.5) / d))))))
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(Float64(D_m / d) * Float64(Float64(M_m / 2.0) / l)) * Float64(h * Float64(M_m * Float64(Float64(D_m * 0.5) / d))))))) 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 / d) * ((M_m / 2.0) / l)) * (h * (M_m * ((D_m * 0.5) / d))))));
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[(N[(D$95$m / d), $MachinePrecision] * N[(N[(M$95$m / 2.0), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision] * N[(h * N[(M$95$m * N[(N[(D$95$m * 0.5), $MachinePrecision] / d), $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(\frac{D\_m}{d} \cdot \frac{\frac{M\_m}{2}}{\ell}\right) \cdot \left(h \cdot \left(M\_m \cdot \frac{D\_m \cdot 0.5}{d}\right)\right)}
\end{array}
Initial program 79.4%
Simplified79.0%
clear-num79.0%
un-div-inv80.0%
clear-num80.0%
un-div-inv80.4%
associate-/r/80.4%
Applied egg-rr80.4%
associate-*l/80.4%
*-commutative80.4%
associate-*l/80.4%
associate-/l/80.5%
associate-/r/80.5%
Simplified80.5%
unpow280.5%
div-inv80.5%
times-frac90.3%
associate-*l/90.3%
associate-*l/90.3%
Applied egg-rr90.3%
associate-*l/89.5%
associate-/l*88.1%
associate-*l/88.1%
*-commutative88.1%
associate-/r/88.1%
/-rgt-identity88.1%
associate-*l/88.8%
associate-/l*89.6%
associate-*l/89.6%
*-commutative89.6%
Simplified89.6%
associate-*l/88.8%
div-inv88.8%
metadata-eval88.8%
Applied egg-rr88.8%
associate-/l*88.1%
*-commutative88.1%
Simplified88.1%
div-inv88.1%
frac-times89.6%
Applied egg-rr89.6%
associate-*r/89.6%
associate-/l*90.3%
*-commutative90.3%
associate-/l/90.3%
*-commutative90.3%
*-rgt-identity90.3%
associate-*l/90.3%
associate-*r/90.3%
associate-/l*86.4%
Simplified86.4%
Final simplification86.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 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.4%
Simplified79.0%
Taylor expanded in D around 0 68.8%
Final simplification68.8%
herbie shell --seed 2024073
(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))))))