On Tuesday, March 31, 2015 at 2:40:34 AM UTC+3, Julien Hillairet wrote:
>
> Dear all,
>
> First of all, many thanks for Sympy, which is a great tools !
>
>
> I try to integrate a product of two sinus functions such as :
>
> f(x) = sin(pi*n/L*x) * sin(pi*m/L*x)
>
> where n and m are two positive integer (and L>0). I've found the correct 
> expected values (L/2 if m=n, 0 otherwise). But if I make a small change of 
> variable, moving x to x+L/2, then Sympy fails to provide me an answer. Is 
> there a way to "help" Sympy finding the correct solution ? 
>
> An example is below :
>
> ----
>
> z = symbols('z')
> m, n = symbols('m n', positive=True, integer=True)
> L = symbols('L', positive=True, real=True)
>
> def e1(z, n, L):
>     k_n = n*pi/L
>     return sin(k_n*(z))
>
> def e2(z, n, L):
>     k_n = n*pi/L
>     return sin(k_n*(z+L/2))
>
> Imn1 = integrate(fu(e1(z, n, L)*e1(z, m, L)), (z, 0, L))
> Imn2 = integrate(fu(e2(z, n, L)*e2(z, m, L)), (z, -L/2, L/2))
>
> ---
>
> In [16]: Imn1
> Out[16]: Piecewise((L/2, m == n), (0, True))
>
> In [17]: Imn2
> Out[17]: Integral(sin(pi*m*(L/2 + z)/L)*sin(pi*n*(L/2 + z)/L), (z, -L/2, 
> L/2))
>
> Best regards,
>
> Julien
>

It seems that SymPy can compute the integral if you write  sin(pi*m/2 + 
pi*m*z/L)  instead of
sin(pi*m*(L/2 + z)/L). Apparently its pattern matching does not cover the 
latter form. (fu will
not be needed.)

Kalevi Suominen

-- 
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/4595cb88-5e0a-4b8d-9ad1-56f28ac98eb2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to