Whenever it makes sense, you should use assumptions on symbols. Since you are dealing with a Fourier Series, you should set:
import sympy as syms import matplotlib.pyplot as plot import numpy as linspace n = syms.symbols('n', real=True, integer=True, positive=True) t = syms.symbols('t', real=True) T= 1 w= 2*syms.pi/T V=1 # square wave of 1volts with 1second period Ao= (w/syms.pi)* syms.integrate(V,(t,0,0.5)) An= (w/syms.pi)*syms.integrate(V*syms.cos(w*n*t),(t,0,T/2)) Bn= (w/syms.pi)*syms.integrate(V*syms.sin(w*n*t),(t,0,T/2)) f= Ao/2 +syms.Sum(An*syms.cos(n*w*t),(n,1,5))+ syms.Sum(Bn*syms.sin(n*w*t),(n,1,5)) f At this point, the expression f looks like can be simplified. Then: syms.plot(f.simplify(), (t, 0, 4*T)) Davide. Il giorno mer 5 mag 2021 alle ore 14:07 Areeb Sherjil < areebsher...@gmail.com> ha scritto: > No one is replying, lemme paste the code here: > > > import sympy as syms > import matplotlib.pyplot as plot > import numpy as linspace > n,t= syms.symbols('n,t') > T= 1 > w= 2*syms.pi/T > V=1 # square wave of 1volts with 1second period > Ao= (w/syms.pi)* syms.integrate(V,(t,0,0.5)) > An= (w/syms.pi)*syms.integrate(V*syms.cos(w*n*t),(t,0,T/2)) > Bn= (w/syms.pi)*syms.integrate(V*syms.sin(w*n*t),(t,0,T/2)) > f= Ao/2 +syms.Sum(An*syms.cos(n*w*t),(n,1,5))+ > syms.Sum(Bn*syms.sin(n*w*t),(n,1,5)) > f > > syms.plot(f,(t,0,2*T)) > > > > On Friday, April 23, 2021 at 4:09:20 PM UTC+1 Areeb Sherjil wrote: > >> Hi all, >> I hope everyone is enjoying themselves! >> I am trying to compute the Fourier series of a simple signal(1 Volt >> square with freq of 1hz and 0.5T pulse width). >> >> This is what I need help with: >> 1- How can I make sympy display the results of the sigma summation as : >> Ao+An1+An2+An3....... etc instead of the way it now?Like how do I expand it? >> 2- When I try to plot this, I get a warning message telling me to report >> this as a bug? Why is this ?(look at screenshot) >> >> Any response is very much appreciated >> All necessary file attached(CODE: >> https://drive.google.com/file/d/17W3GqiN0x1oByMdgAiZHssGNu2aCJdPV/view?usp=sharing >> )[image: Screenshot (286).png] >> > -- > 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 sympy+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/sympy/05c2fc4e-82a6-447f-aca3-3694af254938n%40googlegroups.com > <https://groups.google.com/d/msgid/sympy/05c2fc4e-82a6-447f-aca3-3694af254938n%40googlegroups.com?utm_medium=email&utm_source=footer> > . > -- 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 sympy+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/sympy/CAO%3D1Z0_KXOU2T1M3U5iqDsns-Ak4pNJ-qtC8s1zomCbGxR83jA%40mail.gmail.com.