1201-Day1 What's a Sequence?

2643 days ago by MATH4R2013

#1) a(n)=(n-1)/n a(n) 
       
print "n\ta(n)\ta(n).n()" for n in range(1,10): print n,"\t",a(n),"\t",a(n).n() 
       
n	a(n)	a(n).n()
1 	0 	0.000000000000000
2 	1/2 	0.500000000000000
3 	2/3 	0.666666666666667
4 	3/4 	0.750000000000000
5 	4/5 	0.800000000000000
6 	5/6 	0.833333333333333
7 	6/7 	0.857142857142857
8 	7/8 	0.875000000000000
9 	8/9 	0.888888888888889
n	a(n)	a(n).n()
1 	0 	0.000000000000000
2 	1/2 	0.500000000000000
3 	2/3 	0.666666666666667
4 	3/4 	0.750000000000000
5 	4/5 	0.800000000000000
6 	5/6 	0.833333333333333
7 	6/7 	0.857142857142857
8 	7/8 	0.875000000000000
9 	8/9 	0.888888888888889
#discrete N=range(1,100) A=[a(n) for n in N] AN=zip(N,A) plot(point(AN)) 
       
show(sum([a(n) for n in range(1,10)]).n()) show(sum([a(n) for n in range(1,100)]).n()) show(sum([a(n) for n in range(1,1000)]).n()) 
       


#not discrete N=range(1,100) A=[a(n) for n in N] AN=zip(N,A) g=Graphics() g+=point(AN) for k in range(1,len(AN)): g+=line((AN[k-1],AN[k])) show(g) 
       
#2) b(n)=(-1)^(n+1)*2/n b(n) 
       
print "n\tb(n)\tb(n).n()" for n in range(1,10): print n,"\t",b(n),"\t",b(n).n() 
       
n	b(n)	b(n).n()
1 	2 	2.00000000000000
2 	-1 	-1.00000000000000
3 	2/3 	0.666666666666667
4 	-1/2 	-0.500000000000000
5 	2/5 	0.400000000000000
6 	-1/3 	-0.333333333333333
7 	2/7 	0.285714285714286
8 	-1/4 	-0.250000000000000
9 	2/9 	0.222222222222222
n	b(n)	b(n).n()
1 	2 	2.00000000000000
2 	-1 	-1.00000000000000
3 	2/3 	0.666666666666667
4 	-1/2 	-0.500000000000000
5 	2/5 	0.400000000000000
6 	-1/3 	-0.333333333333333
7 	2/7 	0.285714285714286
8 	-1/4 	-0.250000000000000
9 	2/9 	0.222222222222222
show(sum([b(n) for n in range(1,10)]).n()) show(sum([b(n) for n in range(1,100)]).n()) show(sum([b(n) for n in range(1,1000)]).n())