File: series_cos.py

package info (click to toggle)
pycode-browser 20120614%2Bgit%2Bb041dd2-7
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 6,236 kB
  • ctags: 1,194
  • sloc: python: 2,220; xml: 152; makefile: 39
file content (20 lines) | stat: -rwxr-xr-x 324 bytes parent folder | download | duplicates (12)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import scipy, pylab

def mycos(x):
	res = 0.0
	for n in range(18):
		res = res + (-1)**n *	(x ** (2*n)) / scipy.factorial(2*n)
	return res

def vmycos(ax):
	y = []
	for x in ax:
		y.append(mycos(x))
	return y
	
x = scipy.linspace(0,4*scipy.pi,100)
y = vmycos(x)
pylab.plot(x,y)
pylab.plot(x,scipy.cos(x),'+')
pylab.show()