Tp=1.0
Nt=2**9-1
dt=Tp/(Nt-1)

f0=10.0
omp=2*PI/Tp

TimeHistoryPlot= new PlotFrame()
ResponsePlot = new PlotFrame()

f=[]
u=[]

k=1.0
T0=0.7
xsi=0.05
om0=2*PI/T0

Nterms=1
(0..Nt).each{
	fval=f0/2.0
	uval=f0/(2.0*k)
	for(n=1;n<=Nterms;n+=2){
		fval+=2.0*f0*sin(n*omp*it*dt)/(n*PI)
		beta_n=n*omp/om0
		uval+=2*f0*((1.0-beta_n**2)*sin(n*omp*it*dt)-2.0*xsi*beta_n*cos(n*omp*it*dt))/(n*PI*k*((1-beta_n**2)**2+(2*xsi*beta_n)**2))
	}
	f.add(fval)
	u.add(uval)
}

TimeHistoryPlot.addFunction(new plotfunction(dt,f))
TimeHistoryPlot.Title("f(t) for terms="+Nterms+" of Fourier trigonometric series")
//TimeHistoryPlot.setMarker(true)
TimeHistoryPlot.show()

ResponsePlot.addFunction(new plotfunction(dt,u))
ResponsePlot.Title("u(t) for terms="+Nterms+" of Fourier trigonometric series")
ResponsePlot.show()

