
(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 (* D_m (/ M_m (* 2.0 d)))))
(if (<= (/ h l) -5e+71)
(* w0 (sqrt (- 1.0 (/ (* h (pow (/ M_m (/ (* 2.0 d) D_m)) 2.0)) l))))
(* w0 (sqrt (- 1.0 (* h (* t_0 (/ t_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) {
double t_0 = D_m * (M_m / (2.0 * d));
double tmp;
if ((h / l) <= -5e+71) {
tmp = w0 * sqrt((1.0 - ((h * pow((M_m / ((2.0 * d) / D_m)), 2.0)) / l)));
} else {
tmp = w0 * sqrt((1.0 - (h * (t_0 * (t_0 / 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 = d_m * (m_m / (2.0d0 * d))
if ((h / l) <= (-5d+71)) then
tmp = w0 * sqrt((1.0d0 - ((h * ((m_m / ((2.0d0 * d) / d_m)) ** 2.0d0)) / l)))
else
tmp = w0 * sqrt((1.0d0 - (h * (t_0 * (t_0 / 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 = D_m * (M_m / (2.0 * d));
double tmp;
if ((h / l) <= -5e+71) {
tmp = w0 * Math.sqrt((1.0 - ((h * Math.pow((M_m / ((2.0 * d) / D_m)), 2.0)) / l)));
} else {
tmp = w0 * Math.sqrt((1.0 - (h * (t_0 * (t_0 / 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 = D_m * (M_m / (2.0 * d)) tmp = 0 if (h / l) <= -5e+71: tmp = w0 * math.sqrt((1.0 - ((h * math.pow((M_m / ((2.0 * d) / D_m)), 2.0)) / l))) else: tmp = w0 * math.sqrt((1.0 - (h * (t_0 * (t_0 / 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(D_m * Float64(M_m / Float64(2.0 * d))) tmp = 0.0 if (Float64(h / l) <= -5e+71) tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(h * (Float64(M_m / Float64(Float64(2.0 * d) / D_m)) ^ 2.0)) / l)))); else tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(h * Float64(t_0 * Float64(t_0 / 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 = D_m * (M_m / (2.0 * d));
tmp = 0.0;
if ((h / l) <= -5e+71)
tmp = w0 * sqrt((1.0 - ((h * ((M_m / ((2.0 * d) / D_m)) ^ 2.0)) / l)));
else
tmp = w0 * sqrt((1.0 - (h * (t_0 * (t_0 / 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[(D$95$m * N[(M$95$m / N[(2.0 * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(h / l), $MachinePrecision], -5e+71], N[(w0 * N[Sqrt[N[(1.0 - N[(N[(h * N[Power[N[(M$95$m / N[(N[(2.0 * d), $MachinePrecision] / D$95$m), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(w0 * N[Sqrt[N[(1.0 - N[(h * N[(t$95$0 * N[(t$95$0 / 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 := D\_m \cdot \frac{M\_m}{2 \cdot d}\\
\mathbf{if}\;\frac{h}{\ell} \leq -5 \cdot 10^{+71}:\\
\;\;\;\;w0 \cdot \sqrt{1 - \frac{h \cdot {\left(\frac{M\_m}{\frac{2 \cdot d}{D\_m}}\right)}^{2}}{\ell}}\\
\mathbf{else}:\\
\;\;\;\;w0 \cdot \sqrt{1 - h \cdot \left(t\_0 \cdot \frac{t\_0}{\ell}\right)}\\
\end{array}
\end{array}
if (/.f64 h l) < -4.99999999999999972e71Initial program 62.0%
Simplified63.3%
clear-num63.3%
un-div-inv64.2%
associate-/r*64.2%
Applied egg-rr64.2%
associate-/r/75.6%
associate-/r*75.6%
Simplified75.6%
associate-/r*75.6%
associate-*r/75.7%
associate-*l/74.3%
clear-num74.3%
associate-*l/74.4%
*-un-lft-identity74.4%
*-un-lft-identity74.4%
times-frac74.4%
metadata-eval74.4%
Applied egg-rr74.4%
associate-*l/77.0%
associate-*r/77.0%
Applied egg-rr77.0%
if -4.99999999999999972e71 < (/.f64 h l) Initial program 87.3%
Simplified87.9%
clear-num87.9%
un-div-inv87.9%
associate-/r*87.9%
Applied egg-rr87.9%
associate-/r/91.2%
associate-/r*91.2%
Simplified91.2%
unpow291.2%
associate-/l/91.2%
associate-/l/91.2%
Applied egg-rr91.2%
associate-/l*93.3%
*-commutative93.3%
*-commutative93.3%
Applied egg-rr93.3%
Final simplification88.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 (if (<= d 2.4e+23) (+ w0 (* (/ -0.125 d) (/ (/ (* (* h w0) (pow (* M_m D_m) 2.0)) l) d))) 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 (d <= 2.4e+23) {
tmp = w0 + ((-0.125 / d) * ((((h * w0) * pow((M_m * D_m), 2.0)) / l) / d));
} 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 (d <= 2.4d+23) then
tmp = w0 + (((-0.125d0) / d) * ((((h * w0) * ((m_m * d_m) ** 2.0d0)) / l) / d))
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 (d <= 2.4e+23) {
tmp = w0 + ((-0.125 / d) * ((((h * w0) * Math.pow((M_m * D_m), 2.0)) / l) / d));
} 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 d <= 2.4e+23: tmp = w0 + ((-0.125 / d) * ((((h * w0) * math.pow((M_m * D_m), 2.0)) / l) / d)) 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 (d <= 2.4e+23) tmp = Float64(w0 + Float64(Float64(-0.125 / d) * Float64(Float64(Float64(Float64(h * w0) * (Float64(M_m * D_m) ^ 2.0)) / l) / d))); 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 (d <= 2.4e+23)
tmp = w0 + ((-0.125 / d) * ((((h * w0) * ((M_m * D_m) ^ 2.0)) / l) / d));
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[d, 2.4e+23], N[(w0 + N[(N[(-0.125 / d), $MachinePrecision] * N[(N[(N[(N[(h * w0), $MachinePrecision] * N[Power[N[(M$95$m * D$95$m), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision] / d), $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}\;d \leq 2.4 \cdot 10^{+23}:\\
\;\;\;\;w0 + \frac{-0.125}{d} \cdot \frac{\frac{\left(h \cdot w0\right) \cdot {\left(M\_m \cdot D\_m\right)}^{2}}{\ell}}{d}\\
\mathbf{else}:\\
\;\;\;\;w0\\
\end{array}
\end{array}
if d < 2.4e23Initial program 79.8%
Simplified80.4%
Taylor expanded in D around 0 50.1%
expm1-log1p-u43.0%
expm1-undefine43.0%
associate-*r*44.0%
unpow-prod-down51.0%
*-commutative51.0%
Applied egg-rr51.0%
expm1-define51.0%
associate-*r/51.0%
times-frac55.2%
*-commutative55.2%
Simplified55.2%
expm1-log1p-u63.0%
*-commutative63.0%
times-frac58.8%
associate-/r*63.0%
*-commutative63.0%
associate-*l*65.7%
*-commutative65.7%
Applied egg-rr65.7%
associate-/l*65.7%
unpow265.7%
times-frac76.0%
pow276.0%
associate-*r*72.8%
pow272.8%
*-commutative72.8%
Applied egg-rr72.8%
if 2.4e23 < d Initial program 81.6%
Simplified83.1%
Taylor expanded in D around 0 83.7%
Final simplification75.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 (let* ((t_0 (* D_m (/ M_m (* 2.0 d))))) (* w0 (sqrt (- 1.0 (* h (* t_0 (/ t_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) {
double t_0 = D_m * (M_m / (2.0 * d));
return w0 * sqrt((1.0 - (h * (t_0 * (t_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
real(8) :: t_0
t_0 = d_m * (m_m / (2.0d0 * d))
code = w0 * sqrt((1.0d0 - (h * (t_0 * (t_0 / 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) {
double t_0 = D_m * (M_m / (2.0 * d));
return w0 * Math.sqrt((1.0 - (h * (t_0 * (t_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): t_0 = D_m * (M_m / (2.0 * d)) return w0 * math.sqrt((1.0 - (h * (t_0 * (t_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) t_0 = Float64(D_m * Float64(M_m / Float64(2.0 * d))) return Float64(w0 * sqrt(Float64(1.0 - Float64(h * Float64(t_0 * Float64(t_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)
t_0 = D_m * (M_m / (2.0 * d));
tmp = w0 * sqrt((1.0 - (h * (t_0 * (t_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_] := Block[{t$95$0 = N[(D$95$m * N[(M$95$m / N[(2.0 * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, N[(w0 * N[Sqrt[N[(1.0 - N[(h * N[(t$95$0 * N[(t$95$0 / 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 := D\_m \cdot \frac{M\_m}{2 \cdot d}\\
w0 \cdot \sqrt{1 - h \cdot \left(t\_0 \cdot \frac{t\_0}{\ell}\right)}
\end{array}
\end{array}
Initial program 80.3%
Simplified81.1%
clear-num81.1%
un-div-inv81.3%
associate-/r*81.3%
Applied egg-rr81.3%
associate-/r/86.9%
associate-/r*86.9%
Simplified86.9%
unpow286.9%
associate-/l/86.9%
associate-/l/86.9%
Applied egg-rr86.9%
associate-/l*88.4%
*-commutative88.4%
*-commutative88.4%
Applied egg-rr88.4%
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
(if (<= M_m 2.3e-58)
w0
(+
w0
(/ (* -0.125 (* (* h w0) (* (* M_m D_m) (* M_m D_m)))) (* l (* d 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 (M_m <= 2.3e-58) {
tmp = w0;
} else {
tmp = w0 + ((-0.125 * ((h * w0) * ((M_m * D_m) * (M_m * D_m)))) / (l * (d * 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 (m_m <= 2.3d-58) then
tmp = w0
else
tmp = w0 + (((-0.125d0) * ((h * w0) * ((m_m * d_m) * (m_m * d_m)))) / (l * (d * 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 (M_m <= 2.3e-58) {
tmp = w0;
} else {
tmp = w0 + ((-0.125 * ((h * w0) * ((M_m * D_m) * (M_m * D_m)))) / (l * (d * 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 M_m <= 2.3e-58: tmp = w0 else: tmp = w0 + ((-0.125 * ((h * w0) * ((M_m * D_m) * (M_m * D_m)))) / (l * (d * 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 (M_m <= 2.3e-58) tmp = w0; else tmp = Float64(w0 + Float64(Float64(-0.125 * Float64(Float64(h * w0) * Float64(Float64(M_m * D_m) * Float64(M_m * D_m)))) / Float64(l * Float64(d * 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 (M_m <= 2.3e-58)
tmp = w0;
else
tmp = w0 + ((-0.125 * ((h * w0) * ((M_m * D_m) * (M_m * D_m)))) / (l * (d * 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[M$95$m, 2.3e-58], w0, N[(w0 + N[(N[(-0.125 * N[(N[(h * w0), $MachinePrecision] * N[(N[(M$95$m * D$95$m), $MachinePrecision] * N[(M$95$m * D$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(l * N[(d * d), $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.3 \cdot 10^{-58}:\\
\;\;\;\;w0\\
\mathbf{else}:\\
\;\;\;\;w0 + \frac{-0.125 \cdot \left(\left(h \cdot w0\right) \cdot \left(\left(M\_m \cdot D\_m\right) \cdot \left(M\_m \cdot D\_m\right)\right)\right)}{\ell \cdot \left(d \cdot d\right)}\\
\end{array}
\end{array}
if M < 2.2999999999999999e-58Initial program 83.1%
Simplified83.6%
Taylor expanded in D around 0 79.0%
if 2.2999999999999999e-58 < M Initial program 72.2%
Simplified73.9%
Taylor expanded in D around 0 56.5%
associate-*r/56.5%
associate-*r*58.1%
unpow-prod-down64.6%
*-commutative64.6%
Applied egg-rr64.6%
unpow264.6%
*-commutative64.6%
*-commutative64.6%
Applied egg-rr64.6%
unpow264.6%
Applied egg-rr64.6%
Final simplification75.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)
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.3%
Simplified81.1%
Taylor expanded in D around 0 71.3%
herbie shell --seed 2024181
(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))))))