
(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 6 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
(if (<= M_m 2e-86)
(* w0 (sqrt (- 1.0 (/ (* (pow (* M_m (* 0.5 (/ D_m d))) 2.0) h) l))))
(*
w0
(sqrt
(-
1.0
(* (* (/ D_m d) (/ (* M_m 0.5) l)) (* h (* (/ D_m d) (* M_m 0.5)))))))))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 (M_m <= 2e-86) {
tmp = w0 * sqrt((1.0 - ((pow((M_m * (0.5 * (D_m / d))), 2.0) * h) / l)));
} else {
tmp = w0 * sqrt((1.0 - (((D_m / d) * ((M_m * 0.5) / l)) * (h * ((D_m / d) * (M_m * 0.5))))));
}
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 (m_m <= 2d-86) then
tmp = w0 * sqrt((1.0d0 - ((((m_m * (0.5d0 * (d_m / d))) ** 2.0d0) * h) / l)))
else
tmp = w0 * sqrt((1.0d0 - (((d_m / d) * ((m_m * 0.5d0) / l)) * (h * ((d_m / d) * (m_m * 0.5d0))))))
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 (M_m <= 2e-86) {
tmp = w0 * Math.sqrt((1.0 - ((Math.pow((M_m * (0.5 * (D_m / d))), 2.0) * h) / l)));
} else {
tmp = w0 * Math.sqrt((1.0 - (((D_m / d) * ((M_m * 0.5) / l)) * (h * ((D_m / d) * (M_m * 0.5))))));
}
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 M_m <= 2e-86: tmp = w0 * math.sqrt((1.0 - ((math.pow((M_m * (0.5 * (D_m / d))), 2.0) * h) / l))) else: tmp = w0 * math.sqrt((1.0 - (((D_m / d) * ((M_m * 0.5) / l)) * (h * ((D_m / d) * (M_m * 0.5)))))) 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 (M_m <= 2e-86) tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(Float64((Float64(M_m * Float64(0.5 * Float64(D_m / d))) ^ 2.0) * h) / l)))); else tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(Float64(D_m / d) * Float64(Float64(M_m * 0.5) / l)) * Float64(h * Float64(Float64(D_m / d) * Float64(M_m * 0.5))))))); 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 (M_m <= 2e-86)
tmp = w0 * sqrt((1.0 - ((((M_m * (0.5 * (D_m / d))) ^ 2.0) * h) / l)));
else
tmp = w0 * sqrt((1.0 - (((D_m / d) * ((M_m * 0.5) / l)) * (h * ((D_m / d) * (M_m * 0.5))))));
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[M$95$m, 2e-86], N[(w0 * N[Sqrt[N[(1.0 - N[(N[(N[Power[N[(M$95$m * N[(0.5 * N[(D$95$m / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * h), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(w0 * N[Sqrt[N[(1.0 - N[(N[(N[(D$95$m / d), $MachinePrecision] * N[(N[(M$95$m * 0.5), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision] * N[(h * N[(N[(D$95$m / d), $MachinePrecision] * N[(M$95$m * 0.5), $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}\;M\_m \leq 2 \cdot 10^{-86}:\\
\;\;\;\;w0 \cdot \sqrt{1 - \frac{{\left(M\_m \cdot \left(0.5 \cdot \frac{D\_m}{d}\right)\right)}^{2} \cdot h}{\ell}}\\
\mathbf{else}:\\
\;\;\;\;w0 \cdot \sqrt{1 - \left(\frac{D\_m}{d} \cdot \frac{M\_m \cdot 0.5}{\ell}\right) \cdot \left(h \cdot \left(\frac{D\_m}{d} \cdot \left(M\_m \cdot 0.5\right)\right)\right)}\\
\end{array}
\end{array}
if M < 2.00000000000000017e-86Initial program 84.1%
Simplified84.1%
associate-*r/88.0%
add-sqr-sqrt88.0%
pow288.0%
sqrt-pow188.0%
metadata-eval88.0%
pow188.0%
*-un-lft-identity88.0%
times-frac88.0%
metadata-eval88.0%
Applied egg-rr88.0%
if 2.00000000000000017e-86 < M Initial program 79.5%
Simplified82.1%
associate-*r/83.7%
add-sqr-sqrt83.7%
pow283.7%
sqrt-pow183.7%
metadata-eval83.7%
pow183.7%
*-un-lft-identity83.7%
times-frac83.7%
metadata-eval83.7%
Applied egg-rr83.7%
associate-*r/82.1%
clear-num82.1%
div-inv82.1%
unpow282.1%
div-inv82.1%
times-frac90.0%
*-commutative90.0%
*-commutative90.0%
associate-*l*90.0%
*-commutative90.0%
*-commutative90.0%
associate-*l*90.0%
Applied egg-rr90.0%
associate-/l*82.2%
*-commutative82.2%
associate-/r/82.2%
/-rgt-identity82.2%
*-commutative82.2%
Simplified82.2%
Final simplification86.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
(*
w0
(sqrt
(-
1.0
(* (* (/ D_m d) (/ (* M_m 0.5) l)) (* 0.5 (/ (* D_m (* M_m h)) 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 * 0.5) / l)) * (0.5 * ((D_m * (M_m * h)) / 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 * 0.5d0) / l)) * (0.5d0 * ((d_m * (m_m * h)) / 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 * 0.5) / l)) * (0.5 * ((D_m * (M_m * h)) / 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 * 0.5) / l)) * (0.5 * ((D_m * (M_m * h)) / 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 * 0.5) / l)) * Float64(0.5 * Float64(Float64(D_m * Float64(M_m * h)) / 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 * 0.5) / l)) * (0.5 * ((D_m * (M_m * h)) / 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 * 0.5), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision] * N[(0.5 * N[(N[(D$95$m * N[(M$95$m * h), $MachinePrecision]), $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])\\
\\
w0 \cdot \sqrt{1 - \left(\frac{D\_m}{d} \cdot \frac{M\_m \cdot 0.5}{\ell}\right) \cdot \left(0.5 \cdot \frac{D\_m \cdot \left(M\_m \cdot h\right)}{d}\right)}
\end{array}
Initial program 82.8%
Simplified83.5%
associate-*r/86.7%
add-sqr-sqrt86.7%
pow286.7%
sqrt-pow186.7%
metadata-eval86.7%
pow186.7%
*-un-lft-identity86.7%
times-frac86.7%
metadata-eval86.7%
Applied egg-rr86.7%
associate-*r/83.5%
clear-num83.5%
div-inv83.5%
unpow283.5%
div-inv83.5%
times-frac88.9%
*-commutative88.9%
*-commutative88.9%
associate-*l*88.9%
*-commutative88.9%
*-commutative88.9%
associate-*l*88.9%
Applied egg-rr88.9%
associate-/l*84.5%
*-commutative84.5%
associate-/r/84.5%
/-rgt-identity84.5%
*-commutative84.5%
Simplified84.5%
Taylor expanded in D around 0 81.4%
Final simplification81.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
(sqrt
(-
1.0
(* (* (/ D_m d) (/ (* M_m 0.5) l)) (* h (* (/ D_m d) (* M_m 0.5))))))))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 * 0.5) / l)) * (h * ((D_m / d) * (M_m * 0.5))))));
}
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 * 0.5d0) / l)) * (h * ((d_m / d) * (m_m * 0.5d0))))))
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 * 0.5) / l)) * (h * ((D_m / d) * (M_m * 0.5))))));
}
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 * 0.5) / l)) * (h * ((D_m / d) * (M_m * 0.5))))))
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 * 0.5) / l)) * Float64(h * Float64(Float64(D_m / d) * Float64(M_m * 0.5))))))) 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 * 0.5) / l)) * (h * ((D_m / d) * (M_m * 0.5))))));
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 * 0.5), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision] * N[(h * N[(N[(D$95$m / d), $MachinePrecision] * N[(M$95$m * 0.5), $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{M\_m \cdot 0.5}{\ell}\right) \cdot \left(h \cdot \left(\frac{D\_m}{d} \cdot \left(M\_m \cdot 0.5\right)\right)\right)}
\end{array}
Initial program 82.8%
Simplified83.5%
associate-*r/86.7%
add-sqr-sqrt86.7%
pow286.7%
sqrt-pow186.7%
metadata-eval86.7%
pow186.7%
*-un-lft-identity86.7%
times-frac86.7%
metadata-eval86.7%
Applied egg-rr86.7%
associate-*r/83.5%
clear-num83.5%
div-inv83.5%
unpow283.5%
div-inv83.5%
times-frac88.9%
*-commutative88.9%
*-commutative88.9%
associate-*l*88.9%
*-commutative88.9%
*-commutative88.9%
associate-*l*88.9%
Applied egg-rr88.9%
associate-/l*84.5%
*-commutative84.5%
associate-/r/84.5%
/-rgt-identity84.5%
*-commutative84.5%
Simplified84.5%
Final simplification84.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 (+ w0 (* -0.125 (* w0 (* h (/ (pow (* D_m (/ M_m d)) 2.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) {
return w0 + (-0.125 * (w0 * (h * (pow((D_m * (M_m / d)), 2.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
code = w0 + ((-0.125d0) * (w0 * (h * (((d_m * (m_m / d)) ** 2.0d0) / 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 + (-0.125 * (w0 * (h * (Math.pow((D_m * (M_m / d)), 2.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): return w0 + (-0.125 * (w0 * (h * (math.pow((D_m * (M_m / d)), 2.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) return Float64(w0 + Float64(-0.125 * Float64(w0 * Float64(h * Float64((Float64(D_m * Float64(M_m / d)) ^ 2.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)
tmp = w0 + (-0.125 * (w0 * (h * (((D_m * (M_m / d)) ^ 2.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_] := N[(w0 + N[(-0.125 * N[(w0 * N[(h * N[(N[Power[N[(D$95$m * N[(M$95$m / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] / l), $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 + -0.125 \cdot \left(w0 \cdot \left(h \cdot \frac{{\left(D\_m \cdot \frac{M\_m}{d}\right)}^{2}}{\ell}\right)\right)
\end{array}
Initial program 82.8%
Simplified83.5%
Taylor expanded in M around 0 48.3%
associate-/l*49.0%
times-frac50.1%
Simplified50.1%
associate-*r*49.7%
clear-num49.7%
un-div-inv49.7%
add-sqr-sqrt49.7%
pow249.7%
sqrt-div49.7%
sqrt-pow156.4%
metadata-eval56.4%
pow156.4%
sqrt-pow161.2%
metadata-eval61.2%
pow161.2%
Applied egg-rr61.2%
pow261.2%
Applied egg-rr61.2%
associate-/r/62.4%
pow262.4%
unpow-prod-down73.7%
associate-*r*80.4%
Applied egg-rr80.4%
Final simplification80.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 (* D_m (/ M_m d)))) (if (<= D_m 2.6e+90) w0 (+ w0 (* -0.125 (* (/ (* t_0 t_0) l) (* w0 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 = D_m * (M_m / d);
double tmp;
if (D_m <= 2.6e+90) {
tmp = w0;
} else {
tmp = w0 + (-0.125 * (((t_0 * t_0) / l) * (w0 * h)));
}
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 = d_m * (m_m / d)
if (d_m <= 2.6d+90) then
tmp = w0
else
tmp = w0 + ((-0.125d0) * (((t_0 * t_0) / l) * (w0 * h)))
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 = D_m * (M_m / d);
double tmp;
if (D_m <= 2.6e+90) {
tmp = w0;
} else {
tmp = w0 + (-0.125 * (((t_0 * t_0) / l) * (w0 * h)));
}
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 = D_m * (M_m / d) tmp = 0 if D_m <= 2.6e+90: tmp = w0 else: tmp = w0 + (-0.125 * (((t_0 * t_0) / l) * (w0 * h))) 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(D_m * Float64(M_m / d)) tmp = 0.0 if (D_m <= 2.6e+90) tmp = w0; else tmp = Float64(w0 + Float64(-0.125 * Float64(Float64(Float64(t_0 * t_0) / l) * Float64(w0 * h)))); 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 = D_m * (M_m / d);
tmp = 0.0;
if (D_m <= 2.6e+90)
tmp = w0;
else
tmp = w0 + (-0.125 * (((t_0 * t_0) / l) * (w0 * h)));
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[(D$95$m * N[(M$95$m / d), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[D$95$m, 2.6e+90], w0, N[(w0 + N[(-0.125 * N[(N[(N[(t$95$0 * t$95$0), $MachinePrecision] / l), $MachinePrecision] * N[(w0 * h), $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 \frac{M\_m}{d}\\
\mathbf{if}\;D\_m \leq 2.6 \cdot 10^{+90}:\\
\;\;\;\;w0\\
\mathbf{else}:\\
\;\;\;\;w0 + -0.125 \cdot \left(\frac{t\_0 \cdot t\_0}{\ell} \cdot \left(w0 \cdot h\right)\right)\\
\end{array}
\end{array}
if D < 2.5999999999999998e90Initial program 84.6%
Simplified85.0%
Taylor expanded in M around 0 72.8%
if 2.5999999999999998e90 < D Initial program 74.4%
Simplified76.5%
Taylor expanded in M around 0 45.2%
associate-/l*47.5%
times-frac45.1%
Simplified45.1%
unpow245.1%
unpow245.1%
times-frac47.7%
Applied egg-rr47.7%
Taylor expanded in D around 0 45.2%
associate-*r*45.2%
times-frac45.1%
associate-*r/44.9%
unpow244.9%
unpow244.9%
unpow244.9%
times-frac47.6%
swap-sqr68.2%
unpow268.2%
associate-*r/66.1%
associate-*l/68.2%
Simplified68.2%
unpow268.2%
Applied egg-rr68.2%
Final simplification72.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 82.8%
Simplified83.5%
Taylor expanded in M around 0 66.1%
Final simplification66.1%
herbie shell --seed 2024066
(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))))))