Hello,
I need to integrate sinc(x) twice. To do this I have used the series
expansion for sinc, which is a summation that includes a factorial term. I
have attached my current code.
If I use the factorial function in sympy, this sequence does not appear to
converge. If I use mpmath.factorial, it appears to converge after 8 terms
(the number of terms can be changed on line 14). However this "convergence"
is very abrupt - there is a large relative change between 7 & 8 terms, and
then absolutely no change for 9 terms. Hence I am concerned I am hitting
some precision limit and not actual convergence.
I would be very grateful if someone can sanity check my code. I am
unfamiliar with the mpmath module, I only stumbled across the
mpmath.factorial function through Google.
Thanks in advance,
Toby Wood
--
You received this message because you are subscribed to the Google Groups
"sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sympy.
To view this discussion on the web visit
https://groups.google.com/d/msgid/sympy/05839053-a5ed-4c34-b02b-fe49773fa5c6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
# coding: utf-8
from sympy import *
import numpy as np
init_printing()
N, sig, pi, T_rf, t, v, x, k = symbols('N sigma pi T_rf t v x k', real=True, positive=True)
def Si(u, k):
if k==0:
return 0
else:
l=(2*k - 1)
return (-1)**(k-1) * (x**l)/(l*mpmath.fac(l)) + Si(u, k - 1)
Si_x = Si(x, 7)
Si_t = Si_x.subs(x, pi*v/sig).subs(v, t).simplify()
Si_f = Si_x.subs(x, pi*v/sig).subs(v, N*sig/2).simplify()
M_av = ((2 / (N*sig)) * integrate(Si_t/Si_f, (t, 0, (N*sig/2)))).simplify()
T_rfe = (2*T_rf* (1 - M_av)).simplify()
print 'Example = ', T_rfe.subs({N: 8, pi: np.pi})