
(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)
d_m = (fabs.f64 d)
w0\_m = (fabs.f64 w0)
w0\_s = (copysign.f64 #s(literal 1 binary64) w0)
NOTE: w0_m, M_m, D_m, h, l, and d_m should be sorted in increasing order before calling this function.
(FPCore (w0_s w0_m M_m D_m h l d_m)
:precision binary64
(let* ((t_0 (/ (* M_m D_m) (* 2.0 d_m))) (t_1 (* M_m (/ (* D_m 0.5) d_m))))
(*
w0_s
(if (<= t_0 1e-54)
(* w0_m (sqrt (- 1.0 (/ (* h (* t_1 t_1)) l))))
(if (<= t_0 4e+144)
(* w0_m (sqrt (- 1.0 (* (* t_0 (* D_m (/ (* M_m 0.5) d_m))) (/ h l)))))
(pow
(*
(sqrt w0_m)
(pow
(exp 0.25)
(+
(log (* -0.25 (/ (* h (pow (* M_m D_m) 2.0)) l)))
(* -2.0 (log d_m)))))
2.0))))))M_m = fabs(M);
D_m = fabs(D);
d_m = fabs(d);
w0\_m = fabs(w0);
w0\_s = copysign(1.0, w0);
assert(w0_m < M_m && M_m < D_m && D_m < h && h < l && l < d_m);
double code(double w0_s, double w0_m, double M_m, double D_m, double h, double l, double d_m) {
double t_0 = (M_m * D_m) / (2.0 * d_m);
double t_1 = M_m * ((D_m * 0.5) / d_m);
double tmp;
if (t_0 <= 1e-54) {
tmp = w0_m * sqrt((1.0 - ((h * (t_1 * t_1)) / l)));
} else if (t_0 <= 4e+144) {
tmp = w0_m * sqrt((1.0 - ((t_0 * (D_m * ((M_m * 0.5) / d_m))) * (h / l))));
} else {
tmp = pow((sqrt(w0_m) * pow(exp(0.25), (log((-0.25 * ((h * pow((M_m * D_m), 2.0)) / l))) + (-2.0 * log(d_m))))), 2.0);
}
return w0_s * tmp;
}
M_m = abs(m)
D_m = abs(d)
d_m = abs(d)
w0\_m = abs(w0)
w0\_s = copysign(1.0d0, w0)
NOTE: w0_m, M_m, D_m, h, l, and d_m should be sorted in increasing order before calling this function.
real(8) function code(w0_s, w0_m, m_m, d_m, h, l, d_m_1)
real(8), intent (in) :: w0_s
real(8), intent (in) :: w0_m
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_m_1
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = (m_m * d_m) / (2.0d0 * d_m_1)
t_1 = m_m * ((d_m * 0.5d0) / d_m_1)
if (t_0 <= 1d-54) then
tmp = w0_m * sqrt((1.0d0 - ((h * (t_1 * t_1)) / l)))
else if (t_0 <= 4d+144) then
tmp = w0_m * sqrt((1.0d0 - ((t_0 * (d_m * ((m_m * 0.5d0) / d_m_1))) * (h / l))))
else
tmp = (sqrt(w0_m) * (exp(0.25d0) ** (log(((-0.25d0) * ((h * ((m_m * d_m) ** 2.0d0)) / l))) + ((-2.0d0) * log(d_m_1))))) ** 2.0d0
end if
code = w0_s * tmp
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
d_m = Math.abs(d);
w0\_m = Math.abs(w0);
w0\_s = Math.copySign(1.0, w0);
assert w0_m < M_m && M_m < D_m && D_m < h && h < l && l < d_m;
public static double code(double w0_s, double w0_m, double M_m, double D_m, double h, double l, double d_m) {
double t_0 = (M_m * D_m) / (2.0 * d_m);
double t_1 = M_m * ((D_m * 0.5) / d_m);
double tmp;
if (t_0 <= 1e-54) {
tmp = w0_m * Math.sqrt((1.0 - ((h * (t_1 * t_1)) / l)));
} else if (t_0 <= 4e+144) {
tmp = w0_m * Math.sqrt((1.0 - ((t_0 * (D_m * ((M_m * 0.5) / d_m))) * (h / l))));
} else {
tmp = Math.pow((Math.sqrt(w0_m) * Math.pow(Math.exp(0.25), (Math.log((-0.25 * ((h * Math.pow((M_m * D_m), 2.0)) / l))) + (-2.0 * Math.log(d_m))))), 2.0);
}
return w0_s * tmp;
}
M_m = math.fabs(M) D_m = math.fabs(D) d_m = math.fabs(d) w0\_m = math.fabs(w0) w0\_s = math.copysign(1.0, w0) [w0_m, M_m, D_m, h, l, d_m] = sort([w0_m, M_m, D_m, h, l, d_m]) def code(w0_s, w0_m, M_m, D_m, h, l, d_m): t_0 = (M_m * D_m) / (2.0 * d_m) t_1 = M_m * ((D_m * 0.5) / d_m) tmp = 0 if t_0 <= 1e-54: tmp = w0_m * math.sqrt((1.0 - ((h * (t_1 * t_1)) / l))) elif t_0 <= 4e+144: tmp = w0_m * math.sqrt((1.0 - ((t_0 * (D_m * ((M_m * 0.5) / d_m))) * (h / l)))) else: tmp = math.pow((math.sqrt(w0_m) * math.pow(math.exp(0.25), (math.log((-0.25 * ((h * math.pow((M_m * D_m), 2.0)) / l))) + (-2.0 * math.log(d_m))))), 2.0) return w0_s * tmp
M_m = abs(M) D_m = abs(D) d_m = abs(d) w0\_m = abs(w0) w0\_s = copysign(1.0, w0) w0_m, M_m, D_m, h, l, d_m = sort([w0_m, M_m, D_m, h, l, d_m]) function code(w0_s, w0_m, M_m, D_m, h, l, d_m) t_0 = Float64(Float64(M_m * D_m) / Float64(2.0 * d_m)) t_1 = Float64(M_m * Float64(Float64(D_m * 0.5) / d_m)) tmp = 0.0 if (t_0 <= 1e-54) tmp = Float64(w0_m * sqrt(Float64(1.0 - Float64(Float64(h * Float64(t_1 * t_1)) / l)))); elseif (t_0 <= 4e+144) tmp = Float64(w0_m * sqrt(Float64(1.0 - Float64(Float64(t_0 * Float64(D_m * Float64(Float64(M_m * 0.5) / d_m))) * Float64(h / l))))); else tmp = Float64(sqrt(w0_m) * (exp(0.25) ^ Float64(log(Float64(-0.25 * Float64(Float64(h * (Float64(M_m * D_m) ^ 2.0)) / l))) + Float64(-2.0 * log(d_m))))) ^ 2.0; end return Float64(w0_s * tmp) end
M_m = abs(M);
D_m = abs(D);
d_m = abs(d);
w0\_m = abs(w0);
w0\_s = sign(w0) * abs(1.0);
w0_m, M_m, D_m, h, l, d_m = num2cell(sort([w0_m, M_m, D_m, h, l, d_m])){:}
function tmp_2 = code(w0_s, w0_m, M_m, D_m, h, l, d_m)
t_0 = (M_m * D_m) / (2.0 * d_m);
t_1 = M_m * ((D_m * 0.5) / d_m);
tmp = 0.0;
if (t_0 <= 1e-54)
tmp = w0_m * sqrt((1.0 - ((h * (t_1 * t_1)) / l)));
elseif (t_0 <= 4e+144)
tmp = w0_m * sqrt((1.0 - ((t_0 * (D_m * ((M_m * 0.5) / d_m))) * (h / l))));
else
tmp = (sqrt(w0_m) * (exp(0.25) ^ (log((-0.25 * ((h * ((M_m * D_m) ^ 2.0)) / l))) + (-2.0 * log(d_m))))) ^ 2.0;
end
tmp_2 = w0_s * tmp;
end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
d_m = N[Abs[d], $MachinePrecision]
w0\_m = N[Abs[w0], $MachinePrecision]
w0\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[w0]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: w0_m, M_m, D_m, h, l, and d_m should be sorted in increasing order before calling this function.
code[w0$95$s_, w0$95$m_, M$95$m_, D$95$m_, h_, l_, d$95$m_] := Block[{t$95$0 = N[(N[(M$95$m * D$95$m), $MachinePrecision] / N[(2.0 * d$95$m), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(M$95$m * N[(N[(D$95$m * 0.5), $MachinePrecision] / d$95$m), $MachinePrecision]), $MachinePrecision]}, N[(w0$95$s * If[LessEqual[t$95$0, 1e-54], N[(w0$95$m * N[Sqrt[N[(1.0 - N[(N[(h * N[(t$95$1 * t$95$1), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 4e+144], N[(w0$95$m * N[Sqrt[N[(1.0 - N[(N[(t$95$0 * N[(D$95$m * N[(N[(M$95$m * 0.5), $MachinePrecision] / d$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[Power[N[(N[Sqrt[w0$95$m], $MachinePrecision] * N[Power[N[Exp[0.25], $MachinePrecision], N[(N[Log[N[(-0.25 * N[(N[(h * N[Power[N[(M$95$m * D$95$m), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] + N[(-2.0 * N[Log[d$95$m], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]]]), $MachinePrecision]]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
d_m = \left|d\right|
\\
w0\_m = \left|w0\right|
\\
w0\_s = \mathsf{copysign}\left(1, w0\right)
\\
[w0_m, M_m, D_m, h, l, d_m] = \mathsf{sort}([w0_m, M_m, D_m, h, l, d_m])\\
\\
\begin{array}{l}
t_0 := \frac{M\_m \cdot D\_m}{2 \cdot d\_m}\\
t_1 := M\_m \cdot \frac{D\_m \cdot 0.5}{d\_m}\\
w0\_s \cdot \begin{array}{l}
\mathbf{if}\;t\_0 \leq 10^{-54}:\\
\;\;\;\;w0\_m \cdot \sqrt{1 - \frac{h \cdot \left(t\_1 \cdot t\_1\right)}{\ell}}\\
\mathbf{elif}\;t\_0 \leq 4 \cdot 10^{+144}:\\
\;\;\;\;w0\_m \cdot \sqrt{1 - \left(t\_0 \cdot \left(D\_m \cdot \frac{M\_m \cdot 0.5}{d\_m}\right)\right) \cdot \frac{h}{\ell}}\\
\mathbf{else}:\\
\;\;\;\;{\left(\sqrt{w0\_m} \cdot {\left(e^{0.25}\right)}^{\left(\log \left(-0.25 \cdot \frac{h \cdot {\left(M\_m \cdot D\_m\right)}^{2}}{\ell}\right) + -2 \cdot \log d\_m\right)}\right)}^{2}\\
\end{array}
\end{array}
\end{array}
if (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) < 1e-54Initial program 84.6%
Simplified83.6%
unpow283.6%
unpow283.6%
*-commutative83.6%
associate-*l/84.6%
associate-*r/84.1%
times-frac84.6%
associate-*r/90.1%
*-commutative90.1%
associate-/l*89.8%
div-inv89.8%
associate-/r*89.8%
metadata-eval89.8%
Applied egg-rr89.8%
unpow289.8%
associate-*r/89.8%
associate-*r/89.8%
Applied egg-rr89.8%
if 1e-54 < (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) < 4.00000000000000009e144Initial program 99.8%
Simplified95.8%
*-commutative95.8%
associate-*l/99.8%
associate-*r/99.8%
times-frac99.8%
unpow299.8%
associate-/r*99.8%
frac-times60.1%
div-inv60.1%
*-commutative60.1%
metadata-eval60.1%
associate-*r*60.1%
*-commutative60.1%
Applied egg-rr60.1%
times-frac99.8%
*-commutative99.8%
*-commutative99.8%
Applied egg-rr99.8%
associate-/l*95.8%
*-commutative95.8%
*-commutative95.8%
Simplified95.8%
if 4.00000000000000009e144 < (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) Initial program 49.4%
Simplified46.0%
unpow246.0%
unpow246.0%
*-commutative46.0%
associate-*l/49.4%
associate-*r/49.4%
times-frac49.4%
associate-*r/49.5%
*-commutative49.5%
associate-/l*49.5%
div-inv49.5%
associate-/r*49.5%
metadata-eval49.5%
Applied egg-rr49.5%
unpow249.5%
associate-*r/49.5%
associate-*r/49.5%
Applied egg-rr49.5%
add-sqr-sqrt33.7%
pow233.7%
Applied egg-rr33.7%
Taylor expanded in d around 0 22.0%
exp-prod22.0%
distribute-lft-neg-in22.0%
metadata-eval22.0%
associate-*r*22.0%
*-commutative22.0%
unpow222.0%
unpow222.0%
swap-sqr25.1%
unpow225.1%
*-commutative25.1%
*-commutative25.1%
Simplified25.1%
Final simplification83.3%
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
d_m = (fabs.f64 d)
w0\_m = (fabs.f64 w0)
w0\_s = (copysign.f64 #s(literal 1 binary64) w0)
NOTE: w0_m, M_m, D_m, h, l, and d_m should be sorted in increasing order before calling this function.
(FPCore (w0_s w0_m M_m D_m h l d_m)
:precision binary64
(let* ((t_0 (/ (* M_m D_m) (* 2.0 d_m))) (t_1 (* M_m (/ (* D_m 0.5) d_m))))
(*
w0_s
(if (<= (- 1.0 (* (/ h l) (pow t_0 2.0))) 4e+303)
(* w0_m (sqrt (- 1.0 (* (* t_0 (* D_m (/ (* M_m 0.5) d_m))) (/ h l)))))
(* w0_m (sqrt (- 1.0 (/ (* h (* t_1 t_1)) l))))))))M_m = fabs(M);
D_m = fabs(D);
d_m = fabs(d);
w0\_m = fabs(w0);
w0\_s = copysign(1.0, w0);
assert(w0_m < M_m && M_m < D_m && D_m < h && h < l && l < d_m);
double code(double w0_s, double w0_m, double M_m, double D_m, double h, double l, double d_m) {
double t_0 = (M_m * D_m) / (2.0 * d_m);
double t_1 = M_m * ((D_m * 0.5) / d_m);
double tmp;
if ((1.0 - ((h / l) * pow(t_0, 2.0))) <= 4e+303) {
tmp = w0_m * sqrt((1.0 - ((t_0 * (D_m * ((M_m * 0.5) / d_m))) * (h / l))));
} else {
tmp = w0_m * sqrt((1.0 - ((h * (t_1 * t_1)) / l)));
}
return w0_s * tmp;
}
M_m = abs(m)
D_m = abs(d)
d_m = abs(d)
w0\_m = abs(w0)
w0\_s = copysign(1.0d0, w0)
NOTE: w0_m, M_m, D_m, h, l, and d_m should be sorted in increasing order before calling this function.
real(8) function code(w0_s, w0_m, m_m, d_m, h, l, d_m_1)
real(8), intent (in) :: w0_s
real(8), intent (in) :: w0_m
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_m_1
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = (m_m * d_m) / (2.0d0 * d_m_1)
t_1 = m_m * ((d_m * 0.5d0) / d_m_1)
if ((1.0d0 - ((h / l) * (t_0 ** 2.0d0))) <= 4d+303) then
tmp = w0_m * sqrt((1.0d0 - ((t_0 * (d_m * ((m_m * 0.5d0) / d_m_1))) * (h / l))))
else
tmp = w0_m * sqrt((1.0d0 - ((h * (t_1 * t_1)) / l)))
end if
code = w0_s * tmp
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
d_m = Math.abs(d);
w0\_m = Math.abs(w0);
w0\_s = Math.copySign(1.0, w0);
assert w0_m < M_m && M_m < D_m && D_m < h && h < l && l < d_m;
public static double code(double w0_s, double w0_m, double M_m, double D_m, double h, double l, double d_m) {
double t_0 = (M_m * D_m) / (2.0 * d_m);
double t_1 = M_m * ((D_m * 0.5) / d_m);
double tmp;
if ((1.0 - ((h / l) * Math.pow(t_0, 2.0))) <= 4e+303) {
tmp = w0_m * Math.sqrt((1.0 - ((t_0 * (D_m * ((M_m * 0.5) / d_m))) * (h / l))));
} else {
tmp = w0_m * Math.sqrt((1.0 - ((h * (t_1 * t_1)) / l)));
}
return w0_s * tmp;
}
M_m = math.fabs(M) D_m = math.fabs(D) d_m = math.fabs(d) w0\_m = math.fabs(w0) w0\_s = math.copysign(1.0, w0) [w0_m, M_m, D_m, h, l, d_m] = sort([w0_m, M_m, D_m, h, l, d_m]) def code(w0_s, w0_m, M_m, D_m, h, l, d_m): t_0 = (M_m * D_m) / (2.0 * d_m) t_1 = M_m * ((D_m * 0.5) / d_m) tmp = 0 if (1.0 - ((h / l) * math.pow(t_0, 2.0))) <= 4e+303: tmp = w0_m * math.sqrt((1.0 - ((t_0 * (D_m * ((M_m * 0.5) / d_m))) * (h / l)))) else: tmp = w0_m * math.sqrt((1.0 - ((h * (t_1 * t_1)) / l))) return w0_s * tmp
M_m = abs(M) D_m = abs(D) d_m = abs(d) w0\_m = abs(w0) w0\_s = copysign(1.0, w0) w0_m, M_m, D_m, h, l, d_m = sort([w0_m, M_m, D_m, h, l, d_m]) function code(w0_s, w0_m, M_m, D_m, h, l, d_m) t_0 = Float64(Float64(M_m * D_m) / Float64(2.0 * d_m)) t_1 = Float64(M_m * Float64(Float64(D_m * 0.5) / d_m)) tmp = 0.0 if (Float64(1.0 - Float64(Float64(h / l) * (t_0 ^ 2.0))) <= 4e+303) tmp = Float64(w0_m * sqrt(Float64(1.0 - Float64(Float64(t_0 * Float64(D_m * Float64(Float64(M_m * 0.5) / d_m))) * Float64(h / l))))); else tmp = Float64(w0_m * sqrt(Float64(1.0 - Float64(Float64(h * Float64(t_1 * t_1)) / l)))); end return Float64(w0_s * tmp) end
M_m = abs(M);
D_m = abs(D);
d_m = abs(d);
w0\_m = abs(w0);
w0\_s = sign(w0) * abs(1.0);
w0_m, M_m, D_m, h, l, d_m = num2cell(sort([w0_m, M_m, D_m, h, l, d_m])){:}
function tmp_2 = code(w0_s, w0_m, M_m, D_m, h, l, d_m)
t_0 = (M_m * D_m) / (2.0 * d_m);
t_1 = M_m * ((D_m * 0.5) / d_m);
tmp = 0.0;
if ((1.0 - ((h / l) * (t_0 ^ 2.0))) <= 4e+303)
tmp = w0_m * sqrt((1.0 - ((t_0 * (D_m * ((M_m * 0.5) / d_m))) * (h / l))));
else
tmp = w0_m * sqrt((1.0 - ((h * (t_1 * t_1)) / l)));
end
tmp_2 = w0_s * tmp;
end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
d_m = N[Abs[d], $MachinePrecision]
w0\_m = N[Abs[w0], $MachinePrecision]
w0\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[w0]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: w0_m, M_m, D_m, h, l, and d_m should be sorted in increasing order before calling this function.
code[w0$95$s_, w0$95$m_, M$95$m_, D$95$m_, h_, l_, d$95$m_] := Block[{t$95$0 = N[(N[(M$95$m * D$95$m), $MachinePrecision] / N[(2.0 * d$95$m), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(M$95$m * N[(N[(D$95$m * 0.5), $MachinePrecision] / d$95$m), $MachinePrecision]), $MachinePrecision]}, N[(w0$95$s * If[LessEqual[N[(1.0 - N[(N[(h / l), $MachinePrecision] * N[Power[t$95$0, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 4e+303], N[(w0$95$m * N[Sqrt[N[(1.0 - N[(N[(t$95$0 * N[(D$95$m * N[(N[(M$95$m * 0.5), $MachinePrecision] / d$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(w0$95$m * N[Sqrt[N[(1.0 - N[(N[(h * N[(t$95$1 * t$95$1), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
d_m = \left|d\right|
\\
w0\_m = \left|w0\right|
\\
w0\_s = \mathsf{copysign}\left(1, w0\right)
\\
[w0_m, M_m, D_m, h, l, d_m] = \mathsf{sort}([w0_m, M_m, D_m, h, l, d_m])\\
\\
\begin{array}{l}
t_0 := \frac{M\_m \cdot D\_m}{2 \cdot d\_m}\\
t_1 := M\_m \cdot \frac{D\_m \cdot 0.5}{d\_m}\\
w0\_s \cdot \begin{array}{l}
\mathbf{if}\;1 - \frac{h}{\ell} \cdot {t\_0}^{2} \leq 4 \cdot 10^{+303}:\\
\;\;\;\;w0\_m \cdot \sqrt{1 - \left(t\_0 \cdot \left(D\_m \cdot \frac{M\_m \cdot 0.5}{d\_m}\right)\right) \cdot \frac{h}{\ell}}\\
\mathbf{else}:\\
\;\;\;\;w0\_m \cdot \sqrt{1 - \frac{h \cdot \left(t\_1 \cdot t\_1\right)}{\ell}}\\
\end{array}
\end{array}
\end{array}
if (-.f64 #s(literal 1 binary64) (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64)) (/.f64 h l))) < 4e303Initial program 99.9%
Simplified97.1%
*-commutative97.1%
associate-*l/99.9%
associate-*r/98.8%
times-frac99.9%
unpow299.9%
associate-/r*99.9%
frac-times81.8%
div-inv81.8%
*-commutative81.8%
metadata-eval81.8%
associate-*r*81.8%
*-commutative81.8%
Applied egg-rr81.8%
times-frac99.9%
*-commutative99.9%
*-commutative99.9%
Applied egg-rr99.9%
associate-/l*97.2%
*-commutative97.2%
*-commutative97.2%
Simplified97.2%
if 4e303 < (-.f64 #s(literal 1 binary64) (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64)) (/.f64 h l))) Initial program 41.7%
Simplified43.0%
unpow243.0%
unpow243.0%
*-commutative43.0%
associate-*l/41.7%
associate-*r/43.0%
times-frac41.7%
associate-*r/58.7%
*-commutative58.7%
associate-/l*59.1%
div-inv59.1%
associate-/r*59.1%
metadata-eval59.1%
Applied egg-rr59.1%
unpow259.1%
associate-*r/59.1%
associate-*r/59.1%
Applied egg-rr59.1%
Final simplification85.6%
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
d_m = (fabs.f64 d)
w0\_m = (fabs.f64 w0)
w0\_s = (copysign.f64 #s(literal 1 binary64) w0)
NOTE: w0_m, M_m, D_m, h, l, and d_m should be sorted in increasing order before calling this function.
(FPCore (w0_s w0_m M_m D_m h l d_m)
:precision binary64
(*
w0_s
(if (<= (* M_m D_m) 5e-128)
w0_m
(*
w0_m
(sqrt
(-
1.0
(*
(* M_m D_m)
(* (/ h l) (* (/ (* M_m (* D_m 0.5)) d_m) (/ 0.5 d_m))))))))))M_m = fabs(M);
D_m = fabs(D);
d_m = fabs(d);
w0\_m = fabs(w0);
w0\_s = copysign(1.0, w0);
assert(w0_m < M_m && M_m < D_m && D_m < h && h < l && l < d_m);
double code(double w0_s, double w0_m, double M_m, double D_m, double h, double l, double d_m) {
double tmp;
if ((M_m * D_m) <= 5e-128) {
tmp = w0_m;
} else {
tmp = w0_m * sqrt((1.0 - ((M_m * D_m) * ((h / l) * (((M_m * (D_m * 0.5)) / d_m) * (0.5 / d_m))))));
}
return w0_s * tmp;
}
M_m = abs(m)
D_m = abs(d)
d_m = abs(d)
w0\_m = abs(w0)
w0\_s = copysign(1.0d0, w0)
NOTE: w0_m, M_m, D_m, h, l, and d_m should be sorted in increasing order before calling this function.
real(8) function code(w0_s, w0_m, m_m, d_m, h, l, d_m_1)
real(8), intent (in) :: w0_s
real(8), intent (in) :: w0_m
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_m_1
real(8) :: tmp
if ((m_m * d_m) <= 5d-128) then
tmp = w0_m
else
tmp = w0_m * sqrt((1.0d0 - ((m_m * d_m) * ((h / l) * (((m_m * (d_m * 0.5d0)) / d_m_1) * (0.5d0 / d_m_1))))))
end if
code = w0_s * tmp
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
d_m = Math.abs(d);
w0\_m = Math.abs(w0);
w0\_s = Math.copySign(1.0, w0);
assert w0_m < M_m && M_m < D_m && D_m < h && h < l && l < d_m;
public static double code(double w0_s, double w0_m, double M_m, double D_m, double h, double l, double d_m) {
double tmp;
if ((M_m * D_m) <= 5e-128) {
tmp = w0_m;
} else {
tmp = w0_m * Math.sqrt((1.0 - ((M_m * D_m) * ((h / l) * (((M_m * (D_m * 0.5)) / d_m) * (0.5 / d_m))))));
}
return w0_s * tmp;
}
M_m = math.fabs(M) D_m = math.fabs(D) d_m = math.fabs(d) w0\_m = math.fabs(w0) w0\_s = math.copysign(1.0, w0) [w0_m, M_m, D_m, h, l, d_m] = sort([w0_m, M_m, D_m, h, l, d_m]) def code(w0_s, w0_m, M_m, D_m, h, l, d_m): tmp = 0 if (M_m * D_m) <= 5e-128: tmp = w0_m else: tmp = w0_m * math.sqrt((1.0 - ((M_m * D_m) * ((h / l) * (((M_m * (D_m * 0.5)) / d_m) * (0.5 / d_m)))))) return w0_s * tmp
M_m = abs(M) D_m = abs(D) d_m = abs(d) w0\_m = abs(w0) w0\_s = copysign(1.0, w0) w0_m, M_m, D_m, h, l, d_m = sort([w0_m, M_m, D_m, h, l, d_m]) function code(w0_s, w0_m, M_m, D_m, h, l, d_m) tmp = 0.0 if (Float64(M_m * D_m) <= 5e-128) tmp = w0_m; else tmp = Float64(w0_m * sqrt(Float64(1.0 - Float64(Float64(M_m * D_m) * Float64(Float64(h / l) * Float64(Float64(Float64(M_m * Float64(D_m * 0.5)) / d_m) * Float64(0.5 / d_m))))))); end return Float64(w0_s * tmp) end
M_m = abs(M);
D_m = abs(D);
d_m = abs(d);
w0\_m = abs(w0);
w0\_s = sign(w0) * abs(1.0);
w0_m, M_m, D_m, h, l, d_m = num2cell(sort([w0_m, M_m, D_m, h, l, d_m])){:}
function tmp_2 = code(w0_s, w0_m, M_m, D_m, h, l, d_m)
tmp = 0.0;
if ((M_m * D_m) <= 5e-128)
tmp = w0_m;
else
tmp = w0_m * sqrt((1.0 - ((M_m * D_m) * ((h / l) * (((M_m * (D_m * 0.5)) / d_m) * (0.5 / d_m))))));
end
tmp_2 = w0_s * tmp;
end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
d_m = N[Abs[d], $MachinePrecision]
w0\_m = N[Abs[w0], $MachinePrecision]
w0\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[w0]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: w0_m, M_m, D_m, h, l, and d_m should be sorted in increasing order before calling this function.
code[w0$95$s_, w0$95$m_, M$95$m_, D$95$m_, h_, l_, d$95$m_] := N[(w0$95$s * If[LessEqual[N[(M$95$m * D$95$m), $MachinePrecision], 5e-128], w0$95$m, N[(w0$95$m * N[Sqrt[N[(1.0 - N[(N[(M$95$m * D$95$m), $MachinePrecision] * N[(N[(h / l), $MachinePrecision] * N[(N[(N[(M$95$m * N[(D$95$m * 0.5), $MachinePrecision]), $MachinePrecision] / d$95$m), $MachinePrecision] * N[(0.5 / d$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
d_m = \left|d\right|
\\
w0\_m = \left|w0\right|
\\
w0\_s = \mathsf{copysign}\left(1, w0\right)
\\
[w0_m, M_m, D_m, h, l, d_m] = \mathsf{sort}([w0_m, M_m, D_m, h, l, d_m])\\
\\
w0\_s \cdot \begin{array}{l}
\mathbf{if}\;M\_m \cdot D\_m \leq 5 \cdot 10^{-128}:\\
\;\;\;\;w0\_m\\
\mathbf{else}:\\
\;\;\;\;w0\_m \cdot \sqrt{1 - \left(M\_m \cdot D\_m\right) \cdot \left(\frac{h}{\ell} \cdot \left(\frac{M\_m \cdot \left(D\_m \cdot 0.5\right)}{d\_m} \cdot \frac{0.5}{d\_m}\right)\right)}\\
\end{array}
\end{array}
if (*.f64 M D) < 5.0000000000000001e-128Initial program 84.4%
Simplified82.3%
Taylor expanded in D around 0 76.2%
if 5.0000000000000001e-128 < (*.f64 M D) Initial program 76.2%
Simplified76.2%
unpow276.2%
unpow276.2%
*-commutative76.2%
associate-*l/76.2%
associate-*r/77.7%
times-frac76.2%
associate-*r/80.6%
*-commutative80.6%
associate-/l*82.0%
div-inv82.0%
associate-/r*82.0%
metadata-eval82.0%
Applied egg-rr82.0%
unpow282.0%
associate-*r/82.0%
associate-*r/82.0%
Applied egg-rr82.0%
*-commutative82.0%
associate-*r/82.0%
associate-*r*80.6%
*-commutative80.6%
associate-*r/80.6%
associate-*r*79.6%
associate-*r/76.3%
associate-*l*79.1%
*-commutative79.1%
*-commutative79.1%
associate-*r/79.1%
associate-*r/79.1%
Applied egg-rr79.1%
Final simplification77.0%
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
d_m = (fabs.f64 d)
w0\_m = (fabs.f64 w0)
w0\_s = (copysign.f64 #s(literal 1 binary64) w0)
NOTE: w0_m, M_m, D_m, h, l, and d_m should be sorted in increasing order before calling this function.
(FPCore (w0_s w0_m M_m D_m h l d_m)
:precision binary64
(*
w0_s
(if (<= (* M_m D_m) 3.6e-125)
w0_m
(fma
-0.125
(/ (* (* (* M_m D_m) (* M_m D_m)) (* w0_m h)) (* l (* d_m d_m)))
w0_m))))M_m = fabs(M);
D_m = fabs(D);
d_m = fabs(d);
w0\_m = fabs(w0);
w0\_s = copysign(1.0, w0);
assert(w0_m < M_m && M_m < D_m && D_m < h && h < l && l < d_m);
double code(double w0_s, double w0_m, double M_m, double D_m, double h, double l, double d_m) {
double tmp;
if ((M_m * D_m) <= 3.6e-125) {
tmp = w0_m;
} else {
tmp = fma(-0.125, ((((M_m * D_m) * (M_m * D_m)) * (w0_m * h)) / (l * (d_m * d_m))), w0_m);
}
return w0_s * tmp;
}
M_m = abs(M) D_m = abs(D) d_m = abs(d) w0\_m = abs(w0) w0\_s = copysign(1.0, w0) w0_m, M_m, D_m, h, l, d_m = sort([w0_m, M_m, D_m, h, l, d_m]) function code(w0_s, w0_m, M_m, D_m, h, l, d_m) tmp = 0.0 if (Float64(M_m * D_m) <= 3.6e-125) tmp = w0_m; else tmp = fma(-0.125, Float64(Float64(Float64(Float64(M_m * D_m) * Float64(M_m * D_m)) * Float64(w0_m * h)) / Float64(l * Float64(d_m * d_m))), w0_m); end return Float64(w0_s * tmp) end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
d_m = N[Abs[d], $MachinePrecision]
w0\_m = N[Abs[w0], $MachinePrecision]
w0\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[w0]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: w0_m, M_m, D_m, h, l, and d_m should be sorted in increasing order before calling this function.
code[w0$95$s_, w0$95$m_, M$95$m_, D$95$m_, h_, l_, d$95$m_] := N[(w0$95$s * If[LessEqual[N[(M$95$m * D$95$m), $MachinePrecision], 3.6e-125], w0$95$m, N[(-0.125 * N[(N[(N[(N[(M$95$m * D$95$m), $MachinePrecision] * N[(M$95$m * D$95$m), $MachinePrecision]), $MachinePrecision] * N[(w0$95$m * h), $MachinePrecision]), $MachinePrecision] / N[(l * N[(d$95$m * d$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + w0$95$m), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
d_m = \left|d\right|
\\
w0\_m = \left|w0\right|
\\
w0\_s = \mathsf{copysign}\left(1, w0\right)
\\
[w0_m, M_m, D_m, h, l, d_m] = \mathsf{sort}([w0_m, M_m, D_m, h, l, d_m])\\
\\
w0\_s \cdot \begin{array}{l}
\mathbf{if}\;M\_m \cdot D\_m \leq 3.6 \cdot 10^{-125}:\\
\;\;\;\;w0\_m\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-0.125, \frac{\left(\left(M\_m \cdot D\_m\right) \cdot \left(M\_m \cdot D\_m\right)\right) \cdot \left(w0\_m \cdot h\right)}{\ell \cdot \left(d\_m \cdot d\_m\right)}, w0\_m\right)\\
\end{array}
\end{array}
if (*.f64 M D) < 3.6000000000000002e-125Initial program 84.4%
Simplified82.3%
Taylor expanded in D around 0 76.2%
if 3.6000000000000002e-125 < (*.f64 M D) Initial program 76.2%
Simplified76.2%
Taylor expanded in D around 0 50.2%
+-commutative50.2%
fma-define50.2%
associate-*r*50.2%
unpow250.2%
unpow250.2%
swap-sqr61.4%
unpow261.4%
Simplified61.4%
unpow261.4%
*-commutative61.4%
*-commutative61.4%
Applied egg-rr61.4%
unpow261.4%
Applied egg-rr61.4%
Final simplification72.2%
M_m = (fabs.f64 M) D_m = (fabs.f64 D) d_m = (fabs.f64 d) w0\_m = (fabs.f64 w0) w0\_s = (copysign.f64 #s(literal 1 binary64) w0) NOTE: w0_m, M_m, D_m, h, l, and d_m should be sorted in increasing order before calling this function. (FPCore (w0_s w0_m M_m D_m h l d_m) :precision binary64 (* w0_s w0_m))
M_m = fabs(M);
D_m = fabs(D);
d_m = fabs(d);
w0\_m = fabs(w0);
w0\_s = copysign(1.0, w0);
assert(w0_m < M_m && M_m < D_m && D_m < h && h < l && l < d_m);
double code(double w0_s, double w0_m, double M_m, double D_m, double h, double l, double d_m) {
return w0_s * w0_m;
}
M_m = abs(m)
D_m = abs(d)
d_m = abs(d)
w0\_m = abs(w0)
w0\_s = copysign(1.0d0, w0)
NOTE: w0_m, M_m, D_m, h, l, and d_m should be sorted in increasing order before calling this function.
real(8) function code(w0_s, w0_m, m_m, d_m, h, l, d_m_1)
real(8), intent (in) :: w0_s
real(8), intent (in) :: w0_m
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_m_1
code = w0_s * w0_m
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
d_m = Math.abs(d);
w0\_m = Math.abs(w0);
w0\_s = Math.copySign(1.0, w0);
assert w0_m < M_m && M_m < D_m && D_m < h && h < l && l < d_m;
public static double code(double w0_s, double w0_m, double M_m, double D_m, double h, double l, double d_m) {
return w0_s * w0_m;
}
M_m = math.fabs(M) D_m = math.fabs(D) d_m = math.fabs(d) w0\_m = math.fabs(w0) w0\_s = math.copysign(1.0, w0) [w0_m, M_m, D_m, h, l, d_m] = sort([w0_m, M_m, D_m, h, l, d_m]) def code(w0_s, w0_m, M_m, D_m, h, l, d_m): return w0_s * w0_m
M_m = abs(M) D_m = abs(D) d_m = abs(d) w0\_m = abs(w0) w0\_s = copysign(1.0, w0) w0_m, M_m, D_m, h, l, d_m = sort([w0_m, M_m, D_m, h, l, d_m]) function code(w0_s, w0_m, M_m, D_m, h, l, d_m) return Float64(w0_s * w0_m) end
M_m = abs(M);
D_m = abs(D);
d_m = abs(d);
w0\_m = abs(w0);
w0\_s = sign(w0) * abs(1.0);
w0_m, M_m, D_m, h, l, d_m = num2cell(sort([w0_m, M_m, D_m, h, l, d_m])){:}
function tmp = code(w0_s, w0_m, M_m, D_m, h, l, d_m)
tmp = w0_s * w0_m;
end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
d_m = N[Abs[d], $MachinePrecision]
w0\_m = N[Abs[w0], $MachinePrecision]
w0\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[w0]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: w0_m, M_m, D_m, h, l, and d_m should be sorted in increasing order before calling this function.
code[w0$95$s_, w0$95$m_, M$95$m_, D$95$m_, h_, l_, d$95$m_] := N[(w0$95$s * w0$95$m), $MachinePrecision]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
d_m = \left|d\right|
\\
w0\_m = \left|w0\right|
\\
w0\_s = \mathsf{copysign}\left(1, w0\right)
\\
[w0_m, M_m, D_m, h, l, d_m] = \mathsf{sort}([w0_m, M_m, D_m, h, l, d_m])\\
\\
w0\_s \cdot w0\_m
\end{array}
Initial program 82.2%
Simplified80.7%
Taylor expanded in D around 0 68.2%
herbie shell --seed 2024129
(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))))))