
(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
(let* ((t_0 (* D_m (* 0.5 (/ M_m d)))))
(if (<= (* (pow (/ (* M_m D_m) (* 2.0 d)) 2.0) (/ h l)) -5e+87)
(* w0 (sqrt (- 1.0 (* (* (/ h l) t_0) (/ (* D_m 0.5) (/ d M_m))))))
(* w0 (sqrt (- 1.0 (/ (* t_0 (* h 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 * (0.5 * (M_m / d));
double tmp;
if ((pow(((M_m * D_m) / (2.0 * d)), 2.0) * (h / l)) <= -5e+87) {
tmp = w0 * sqrt((1.0 - (((h / l) * t_0) * ((D_m * 0.5) / (d / M_m)))));
} else {
tmp = w0 * sqrt((1.0 - ((t_0 * (h * 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 * (0.5d0 * (m_m / d))
if (((((m_m * d_m) / (2.0d0 * d)) ** 2.0d0) * (h / l)) <= (-5d+87)) then
tmp = w0 * sqrt((1.0d0 - (((h / l) * t_0) * ((d_m * 0.5d0) / (d / m_m)))))
else
tmp = w0 * sqrt((1.0d0 - ((t_0 * (h * 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 * (0.5 * (M_m / d));
double tmp;
if ((Math.pow(((M_m * D_m) / (2.0 * d)), 2.0) * (h / l)) <= -5e+87) {
tmp = w0 * Math.sqrt((1.0 - (((h / l) * t_0) * ((D_m * 0.5) / (d / M_m)))));
} else {
tmp = w0 * Math.sqrt((1.0 - ((t_0 * (h * 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 * (0.5 * (M_m / d)) tmp = 0 if (math.pow(((M_m * D_m) / (2.0 * d)), 2.0) * (h / l)) <= -5e+87: tmp = w0 * math.sqrt((1.0 - (((h / l) * t_0) * ((D_m * 0.5) / (d / M_m))))) else: tmp = w0 * math.sqrt((1.0 - ((t_0 * (h * 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(0.5 * Float64(M_m / d))) tmp = 0.0 if (Float64((Float64(Float64(M_m * D_m) / Float64(2.0 * d)) ^ 2.0) * Float64(h / l)) <= -5e+87) tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(Float64(h / l) * t_0) * Float64(Float64(D_m * 0.5) / Float64(d / M_m)))))); else tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(t_0 * Float64(h * 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 * (0.5 * (M_m / d));
tmp = 0.0;
if (((((M_m * D_m) / (2.0 * d)) ^ 2.0) * (h / l)) <= -5e+87)
tmp = w0 * sqrt((1.0 - (((h / l) * t_0) * ((D_m * 0.5) / (d / M_m)))));
else
tmp = w0 * sqrt((1.0 - ((t_0 * (h * 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[(0.5 * N[(M$95$m / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(N[Power[N[(N[(M$95$m * D$95$m), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision], -5e+87], N[(w0 * N[Sqrt[N[(1.0 - N[(N[(N[(h / l), $MachinePrecision] * t$95$0), $MachinePrecision] * N[(N[(D$95$m * 0.5), $MachinePrecision] / N[(d / M$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(w0 * N[Sqrt[N[(1.0 - N[(N[(t$95$0 * N[(h * t$95$0), $MachinePrecision]), $MachinePrecision] / l), $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 \left(0.5 \cdot \frac{M\_m}{d}\right)\\
\mathbf{if}\;{\left(\frac{M\_m \cdot D\_m}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell} \leq -5 \cdot 10^{+87}:\\
\;\;\;\;w0 \cdot \sqrt{1 - \left(\frac{h}{\ell} \cdot t\_0\right) \cdot \frac{D\_m \cdot 0.5}{\frac{d}{M\_m}}}\\
\mathbf{else}:\\
\;\;\;\;w0 \cdot \sqrt{1 - \frac{t\_0 \cdot \left(h \cdot t\_0\right)}{\ell}}\\
\end{array}
\end{array}
if (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 2 d)) 2) (/.f64 h l)) < -4.9999999999999998e87Initial program 65.9%
Simplified67.3%
unpow267.3%
associate-*l*74.1%
frac-times70.0%
*-commutative70.0%
associate-*l/74.1%
associate-/r/70.1%
frac-times67.4%
*-commutative67.4%
associate-*l/70.1%
associate-/r/71.4%
associate-*l*63.3%
unpow263.3%
associate-*r/59.3%
Applied egg-rr59.3%
associate-*l/63.3%
unpow263.3%
associate-*r*71.4%
div-inv71.4%
metadata-eval71.4%
div-inv71.4%
metadata-eval71.4%
Applied egg-rr71.4%
*-commutative71.4%
associate-*l/67.3%
associate-*l/67.4%
frac-times61.8%
*-commutative61.8%
associate-*r*61.8%
associate-*l/64.4%
associate-*r/63.1%
*-commutative63.1%
*-un-lft-identity63.1%
times-frac63.1%
metadata-eval63.1%
Applied egg-rr63.1%
*-commutative63.1%
*-commutative63.1%
times-frac68.7%
associate-*l/70.0%
associate-/l*74.1%
*-commutative74.1%
Simplified74.1%
if -4.9999999999999998e87 < (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 2 d)) 2) (/.f64 h l)) Initial program 88.2%
Simplified87.9%
unpow287.9%
associate-*l*88.6%
frac-times88.0%
*-commutative88.0%
associate-*l/88.6%
associate-/r/88.6%
frac-times88.8%
*-commutative88.8%
associate-*l/88.6%
associate-/r/89.4%
associate-*l*88.7%
unpow288.7%
associate-*r/97.0%
Applied egg-rr97.0%
add-sqr-sqrt81.4%
pow281.4%
*-commutative81.4%
sqrt-prod52.2%
unpow252.2%
sqrt-prod34.9%
add-sqr-sqrt52.7%
div-inv52.7%
metadata-eval52.7%
Applied egg-rr52.7%
associate-*l/53.2%
*-commutative53.2%
associate-*l/53.0%
*-commutative53.0%
Simplified53.0%
unpow253.0%
associate-*r/53.0%
associate-*l/52.4%
*-commutative52.4%
associate-*r/52.7%
associate-*l/52.7%
*-commutative52.7%
swap-sqr52.2%
add-sqr-sqrt97.0%
associate-*r*98.4%
Applied egg-rr98.2%
Final simplification91.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 (or (<= (/ h l) (- INFINITY)) (not (<= (/ h l) -1e-310)))
(* w0 (+ 1.0 (* -0.125 (/ (* h (pow (* M_m (/ D_m d)) 2.0)) l))))
(*
w0
(sqrt
(-
1.0
(* (* (/ h l) (* D_m (* 0.5 (/ M_m d)))) (/ (* D_m 0.5) (/ d M_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 tmp;
if (((h / l) <= -((double) INFINITY)) || !((h / l) <= -1e-310)) {
tmp = w0 * (1.0 + (-0.125 * ((h * pow((M_m * (D_m / d)), 2.0)) / l)));
} else {
tmp = w0 * sqrt((1.0 - (((h / l) * (D_m * (0.5 * (M_m / d)))) * ((D_m * 0.5) / (d / M_m)))));
}
return tmp;
}
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) <= -Double.POSITIVE_INFINITY) || !((h / l) <= -1e-310)) {
tmp = w0 * (1.0 + (-0.125 * ((h * Math.pow((M_m * (D_m / d)), 2.0)) / l)));
} else {
tmp = w0 * Math.sqrt((1.0 - (((h / l) * (D_m * (0.5 * (M_m / d)))) * ((D_m * 0.5) / (d / M_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): tmp = 0 if ((h / l) <= -math.inf) or not ((h / l) <= -1e-310): tmp = w0 * (1.0 + (-0.125 * ((h * math.pow((M_m * (D_m / d)), 2.0)) / l))) else: tmp = w0 * math.sqrt((1.0 - (((h / l) * (D_m * (0.5 * (M_m / d)))) * ((D_m * 0.5) / (d / M_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) tmp = 0.0 if ((Float64(h / l) <= Float64(-Inf)) || !(Float64(h / l) <= -1e-310)) tmp = Float64(w0 * Float64(1.0 + Float64(-0.125 * Float64(Float64(h * (Float64(M_m * Float64(D_m / d)) ^ 2.0)) / l)))); else tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(Float64(h / l) * Float64(D_m * Float64(0.5 * Float64(M_m / d)))) * Float64(Float64(D_m * 0.5) / Float64(d / M_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)
tmp = 0.0;
if (((h / l) <= -Inf) || ~(((h / l) <= -1e-310)))
tmp = w0 * (1.0 + (-0.125 * ((h * ((M_m * (D_m / d)) ^ 2.0)) / l)));
else
tmp = w0 * sqrt((1.0 - (((h / l) * (D_m * (0.5 * (M_m / d)))) * ((D_m * 0.5) / (d / M_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_] := If[Or[LessEqual[N[(h / l), $MachinePrecision], (-Infinity)], N[Not[LessEqual[N[(h / l), $MachinePrecision], -1e-310]], $MachinePrecision]], N[(w0 * N[(1.0 + N[(-0.125 * N[(N[(h * N[Power[N[(M$95$m * N[(D$95$m / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(w0 * N[Sqrt[N[(1.0 - N[(N[(N[(h / l), $MachinePrecision] * N[(D$95$m * N[(0.5 * N[(M$95$m / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[(D$95$m * 0.5), $MachinePrecision] / N[(d / M$95$m), $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}\;\frac{h}{\ell} \leq -\infty \lor \neg \left(\frac{h}{\ell} \leq -1 \cdot 10^{-310}\right):\\
\;\;\;\;w0 \cdot \left(1 + -0.125 \cdot \frac{h \cdot {\left(M\_m \cdot \frac{D\_m}{d}\right)}^{2}}{\ell}\right)\\
\mathbf{else}:\\
\;\;\;\;w0 \cdot \sqrt{1 - \left(\frac{h}{\ell} \cdot \left(D\_m \cdot \left(0.5 \cdot \frac{M\_m}{d}\right)\right)\right) \cdot \frac{D\_m \cdot 0.5}{\frac{d}{M\_m}}}\\
\end{array}
\end{array}
if (/.f64 h l) < -inf.0 or -9.999999999999969e-311 < (/.f64 h l) Initial program 81.5%
Simplified81.5%
Taylor expanded in D around 0 60.1%
associate-*r*64.0%
add-sqr-sqrt29.7%
times-frac28.9%
pow-prod-down35.1%
sqrt-prod35.1%
unpow235.1%
sqrt-prod17.1%
add-sqr-sqrt34.3%
sqrt-prod35.1%
unpow235.1%
sqrt-prod20.2%
add-sqr-sqrt39.8%
Applied egg-rr39.8%
Taylor expanded in D around 0 60.1%
associate-*r*64.0%
unpow264.0%
unpow264.0%
swap-sqr77.2%
unpow277.2%
*-commutative77.2%
*-commutative77.2%
times-frac69.1%
unpow269.1%
associate-/r*80.0%
unpow280.0%
associate-*r/80.7%
associate-*l/80.7%
associate-*l/81.5%
associate-*l/82.3%
unpow282.3%
*-commutative82.3%
Simplified82.3%
associate-*l/94.3%
Applied egg-rr94.3%
if -inf.0 < (/.f64 h l) < -9.999999999999969e-311Initial program 82.6%
Simplified83.0%
unpow283.0%
associate-*l*86.8%
frac-times84.5%
*-commutative84.5%
associate-*l/86.8%
associate-/r/84.6%
frac-times83.4%
*-commutative83.4%
associate-*l/84.6%
associate-/r/85.7%
associate-*l*81.2%
unpow281.2%
associate-*r/79.0%
Applied egg-rr79.0%
associate-*l/81.2%
unpow281.2%
associate-*r*85.7%
div-inv85.7%
metadata-eval85.7%
div-inv85.7%
metadata-eval85.7%
Applied egg-rr85.7%
*-commutative85.7%
associate-*l/83.4%
associate-*l/83.4%
frac-times78.0%
*-commutative78.0%
associate-*r*78.0%
associate-*l/79.5%
associate-*r/78.4%
*-commutative78.4%
*-un-lft-identity78.4%
times-frac78.4%
metadata-eval78.4%
Applied egg-rr78.4%
*-commutative78.4%
*-commutative78.4%
times-frac83.8%
associate-*l/84.5%
associate-/l*86.8%
*-commutative86.8%
Simplified86.8%
Final simplification90.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
(if (<= (/ h l) -1e+209)
(*
w0
(sqrt
(-
1.0
(* (/ (* h (* M_m (* D_m 0.5))) (* d l)) (* (/ D_m d) (* M_m 0.5))))))
(if (<= (/ h l) -1e-310)
(*
w0
(sqrt
(-
1.0
(* (* (/ h l) (* D_m (* 0.5 (/ M_m d)))) (/ (* D_m 0.5) (/ d M_m))))))
(* w0 (+ 1.0 (* -0.125 (/ (* h (pow (* M_m (/ D_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) {
double tmp;
if ((h / l) <= -1e+209) {
tmp = w0 * sqrt((1.0 - (((h * (M_m * (D_m * 0.5))) / (d * l)) * ((D_m / d) * (M_m * 0.5)))));
} else if ((h / l) <= -1e-310) {
tmp = w0 * sqrt((1.0 - (((h / l) * (D_m * (0.5 * (M_m / d)))) * ((D_m * 0.5) / (d / M_m)))));
} else {
tmp = w0 * (1.0 + (-0.125 * ((h * pow((M_m * (D_m / d)), 2.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) :: tmp
if ((h / l) <= (-1d+209)) then
tmp = w0 * sqrt((1.0d0 - (((h * (m_m * (d_m * 0.5d0))) / (d * l)) * ((d_m / d) * (m_m * 0.5d0)))))
else if ((h / l) <= (-1d-310)) then
tmp = w0 * sqrt((1.0d0 - (((h / l) * (d_m * (0.5d0 * (m_m / d)))) * ((d_m * 0.5d0) / (d / m_m)))))
else
tmp = w0 * (1.0d0 + ((-0.125d0) * ((h * ((m_m * (d_m / d)) ** 2.0d0)) / 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 tmp;
if ((h / l) <= -1e+209) {
tmp = w0 * Math.sqrt((1.0 - (((h * (M_m * (D_m * 0.5))) / (d * l)) * ((D_m / d) * (M_m * 0.5)))));
} else if ((h / l) <= -1e-310) {
tmp = w0 * Math.sqrt((1.0 - (((h / l) * (D_m * (0.5 * (M_m / d)))) * ((D_m * 0.5) / (d / M_m)))));
} else {
tmp = w0 * (1.0 + (-0.125 * ((h * Math.pow((M_m * (D_m / d)), 2.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): tmp = 0 if (h / l) <= -1e+209: tmp = w0 * math.sqrt((1.0 - (((h * (M_m * (D_m * 0.5))) / (d * l)) * ((D_m / d) * (M_m * 0.5))))) elif (h / l) <= -1e-310: tmp = w0 * math.sqrt((1.0 - (((h / l) * (D_m * (0.5 * (M_m / d)))) * ((D_m * 0.5) / (d / M_m))))) else: tmp = w0 * (1.0 + (-0.125 * ((h * math.pow((M_m * (D_m / d)), 2.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) tmp = 0.0 if (Float64(h / l) <= -1e+209) tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(Float64(h * Float64(M_m * Float64(D_m * 0.5))) / Float64(d * l)) * Float64(Float64(D_m / d) * Float64(M_m * 0.5)))))); elseif (Float64(h / l) <= -1e-310) tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(Float64(h / l) * Float64(D_m * Float64(0.5 * Float64(M_m / d)))) * Float64(Float64(D_m * 0.5) / Float64(d / M_m)))))); else tmp = Float64(w0 * Float64(1.0 + Float64(-0.125 * Float64(Float64(h * (Float64(M_m * Float64(D_m / d)) ^ 2.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)
tmp = 0.0;
if ((h / l) <= -1e+209)
tmp = w0 * sqrt((1.0 - (((h * (M_m * (D_m * 0.5))) / (d * l)) * ((D_m / d) * (M_m * 0.5)))));
elseif ((h / l) <= -1e-310)
tmp = w0 * sqrt((1.0 - (((h / l) * (D_m * (0.5 * (M_m / d)))) * ((D_m * 0.5) / (d / M_m)))));
else
tmp = w0 * (1.0 + (-0.125 * ((h * ((M_m * (D_m / d)) ^ 2.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_] := If[LessEqual[N[(h / l), $MachinePrecision], -1e+209], N[(w0 * N[Sqrt[N[(1.0 - N[(N[(N[(h * N[(M$95$m * N[(D$95$m * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(d * l), $MachinePrecision]), $MachinePrecision] * N[(N[(D$95$m / d), $MachinePrecision] * N[(M$95$m * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(h / l), $MachinePrecision], -1e-310], N[(w0 * N[Sqrt[N[(1.0 - N[(N[(N[(h / l), $MachinePrecision] * N[(D$95$m * N[(0.5 * N[(M$95$m / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[(D$95$m * 0.5), $MachinePrecision] / N[(d / M$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(w0 * N[(1.0 + N[(-0.125 * N[(N[(h * N[Power[N[(M$95$m * N[(D$95$m / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / l), $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}\;\frac{h}{\ell} \leq -1 \cdot 10^{+209}:\\
\;\;\;\;w0 \cdot \sqrt{1 - \frac{h \cdot \left(M\_m \cdot \left(D\_m \cdot 0.5\right)\right)}{d \cdot \ell} \cdot \left(\frac{D\_m}{d} \cdot \left(M\_m \cdot 0.5\right)\right)}\\
\mathbf{elif}\;\frac{h}{\ell} \leq -1 \cdot 10^{-310}:\\
\;\;\;\;w0 \cdot \sqrt{1 - \left(\frac{h}{\ell} \cdot \left(D\_m \cdot \left(0.5 \cdot \frac{M\_m}{d}\right)\right)\right) \cdot \frac{D\_m \cdot 0.5}{\frac{d}{M\_m}}}\\
\mathbf{else}:\\
\;\;\;\;w0 \cdot \left(1 + -0.125 \cdot \frac{h \cdot {\left(M\_m \cdot \frac{D\_m}{d}\right)}^{2}}{\ell}\right)\\
\end{array}
\end{array}
if (/.f64 h l) < -1.0000000000000001e209Initial program 61.2%
Simplified62.6%
unpow262.6%
associate-*l*63.4%
frac-times60.7%
*-commutative60.7%
associate-*l/63.4%
associate-/r/60.9%
frac-times59.6%
*-commutative59.6%
associate-*l/60.9%
associate-/r/62.2%
associate-*l*61.4%
unpow261.4%
associate-*r/78.0%
Applied egg-rr78.0%
associate-*l/61.4%
unpow261.4%
associate-*r*62.2%
div-inv62.2%
metadata-eval62.2%
div-inv62.2%
metadata-eval62.2%
Applied egg-rr62.2%
*-commutative62.2%
associate-*l/59.6%
frac-times82.4%
*-commutative82.4%
associate-*r*82.4%
Applied egg-rr82.4%
if -1.0000000000000001e209 < (/.f64 h l) < -9.999999999999969e-311Initial program 82.1%
Simplified83.0%
unpow283.0%
associate-*l*87.4%
frac-times84.7%
*-commutative84.7%
associate-*l/87.4%
associate-/r/85.7%
frac-times83.9%
*-commutative83.9%
associate-*l/85.7%
associate-/r/86.5%
associate-*l*81.3%
unpow281.3%
associate-*r/78.6%
Applied egg-rr78.6%
associate-*l/81.3%
unpow281.3%
associate-*r*86.5%
div-inv86.5%
metadata-eval86.5%
div-inv86.5%
metadata-eval86.5%
Applied egg-rr86.5%
*-commutative86.5%
associate-*l/83.9%
associate-*l/83.9%
frac-times77.5%
*-commutative77.5%
associate-*r*77.5%
associate-*l/78.3%
associate-*r/77.5%
*-commutative77.5%
*-un-lft-identity77.5%
times-frac77.5%
metadata-eval77.5%
Applied egg-rr77.5%
*-commutative77.5%
*-commutative77.5%
times-frac83.9%
associate-*l/84.7%
associate-/l*87.5%
*-commutative87.5%
Simplified87.5%
if -9.999999999999969e-311 < (/.f64 h l) Initial program 89.2%
Simplified88.3%
Taylor expanded in D around 0 59.5%
associate-*r*64.1%
add-sqr-sqrt30.7%
times-frac30.7%
pow-prod-down37.0%
sqrt-prod37.0%
unpow237.0%
sqrt-prod18.0%
add-sqr-sqrt36.9%
sqrt-prod37.8%
unpow237.8%
sqrt-prod21.6%
add-sqr-sqrt42.4%
Applied egg-rr42.4%
Taylor expanded in D around 0 59.5%
associate-*r*64.1%
unpow264.1%
unpow264.1%
swap-sqr78.5%
unpow278.5%
*-commutative78.5%
*-commutative78.5%
times-frac74.8%
unpow274.8%
associate-/r*87.4%
unpow287.4%
associate-*r/88.3%
associate-*l/88.3%
associate-*l/89.2%
associate-*l/89.2%
unpow289.2%
*-commutative89.2%
Simplified89.2%
associate-*l/97.4%
Applied egg-rr97.4%
Final simplification91.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 (+ 1.0 (* -0.125 (/ (* h (pow (* M_m (/ D_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 * (1.0 + (-0.125 * ((h * pow((M_m * (D_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 * (1.0d0 + ((-0.125d0) * ((h * ((m_m * (d_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 * (1.0 + (-0.125 * ((h * Math.pow((M_m * (D_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 * (1.0 + (-0.125 * ((h * math.pow((M_m * (D_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(1.0 + Float64(-0.125 * Float64(Float64(h * (Float64(M_m * Float64(D_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 * (1.0 + (-0.125 * ((h * ((M_m * (D_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[(1.0 + N[(-0.125 * N[(N[(h * N[Power[N[(M$95$m * N[(D$95$m / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / l), $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 \left(1 + -0.125 \cdot \frac{h \cdot {\left(M\_m \cdot \frac{D\_m}{d}\right)}^{2}}{\ell}\right)
\end{array}
Initial program 82.1%
Simplified82.3%
Taylor expanded in D around 0 53.3%
associate-*r*56.0%
add-sqr-sqrt28.0%
times-frac27.6%
pow-prod-down32.8%
sqrt-prod32.8%
unpow232.8%
sqrt-prod17.6%
add-sqr-sqrt30.2%
sqrt-prod30.6%
unpow230.6%
sqrt-prod20.0%
add-sqr-sqrt35.9%
Applied egg-rr35.9%
Taylor expanded in D around 0 53.3%
associate-*r*56.0%
unpow256.0%
unpow256.0%
swap-sqr67.3%
unpow267.3%
*-commutative67.3%
*-commutative67.3%
times-frac63.7%
unpow263.7%
associate-/r*73.4%
unpow273.4%
associate-*r/75.0%
associate-*l/74.9%
associate-*l/75.3%
associate-*l/75.8%
unpow275.8%
*-commutative75.8%
Simplified75.8%
associate-*l/81.8%
Applied egg-rr81.8%
Final simplification81.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 (* M_m (/ D_m d))))
(if (<= (* M_m D_m) 1e-13)
w0
(* w0 (+ 1.0 (* -0.125 (* (/ h l) (* t_0 t_0))))))))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_m / d);
double tmp;
if ((M_m * D_m) <= 1e-13) {
tmp = w0;
} else {
tmp = w0 * (1.0 + (-0.125 * ((h / l) * (t_0 * t_0))));
}
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 = m_m * (d_m / d)
if ((m_m * d_m) <= 1d-13) then
tmp = w0
else
tmp = w0 * (1.0d0 + ((-0.125d0) * ((h / l) * (t_0 * t_0))))
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 = M_m * (D_m / d);
double tmp;
if ((M_m * D_m) <= 1e-13) {
tmp = w0;
} else {
tmp = w0 * (1.0 + (-0.125 * ((h / l) * (t_0 * t_0))));
}
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 = M_m * (D_m / d) tmp = 0 if (M_m * D_m) <= 1e-13: tmp = w0 else: tmp = w0 * (1.0 + (-0.125 * ((h / l) * (t_0 * t_0)))) 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(M_m * Float64(D_m / d)) tmp = 0.0 if (Float64(M_m * D_m) <= 1e-13) tmp = w0; else tmp = Float64(w0 * Float64(1.0 + Float64(-0.125 * Float64(Float64(h / l) * Float64(t_0 * t_0))))); 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 = M_m * (D_m / d);
tmp = 0.0;
if ((M_m * D_m) <= 1e-13)
tmp = w0;
else
tmp = w0 * (1.0 + (-0.125 * ((h / l) * (t_0 * t_0))));
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[(M$95$m * N[(D$95$m / d), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(M$95$m * D$95$m), $MachinePrecision], 1e-13], w0, N[(w0 * N[(1.0 + N[(-0.125 * N[(N[(h / l), $MachinePrecision] * N[(t$95$0 * t$95$0), $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 := M\_m \cdot \frac{D\_m}{d}\\
\mathbf{if}\;M\_m \cdot D\_m \leq 10^{-13}:\\
\;\;\;\;w0\\
\mathbf{else}:\\
\;\;\;\;w0 \cdot \left(1 + -0.125 \cdot \left(\frac{h}{\ell} \cdot \left(t\_0 \cdot t\_0\right)\right)\right)\\
\end{array}
\end{array}
if (*.f64 M D) < 1e-13Initial program 84.2%
Simplified83.9%
Taylor expanded in D around 0 75.0%
if 1e-13 < (*.f64 M D) Initial program 72.5%
Simplified74.7%
Taylor expanded in D around 0 41.2%
associate-*r*45.6%
add-sqr-sqrt25.8%
times-frac27.9%
pow-prod-down34.5%
sqrt-prod34.5%
unpow234.5%
sqrt-prod19.0%
add-sqr-sqrt27.7%
sqrt-prod27.7%
unpow227.7%
sqrt-prod21.2%
add-sqr-sqrt36.8%
Applied egg-rr36.8%
Taylor expanded in D around 0 41.2%
associate-*r*45.6%
unpow245.6%
unpow245.6%
swap-sqr58.7%
unpow258.7%
*-commutative58.7%
*-commutative58.7%
times-frac56.5%
unpow256.5%
associate-/r*58.9%
unpow258.9%
associate-*r/63.2%
associate-*l/63.2%
associate-*l/65.3%
associate-*l/65.5%
unpow265.5%
*-commutative65.5%
Simplified65.5%
unpow265.5%
Applied egg-rr65.5%
Final simplification73.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 82.1%
Simplified82.3%
Taylor expanded in D around 0 68.2%
Final simplification68.2%
herbie shell --seed 2024039
(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))))))