Os propongo un desafío:
Producir una serie binaria de ceros y unos alternados usando sólo funciones trigonométricas. Cuanto más simples mejor!!!
P.e. micadena = Sumatorio(i=0, inf) { ??? }
Saludos!!
Jordi
posted by LabPen @ 2:48 PM
#!/usr/bin/env python# f(i) = [cos(pi*i) + 1] / 2import mathdef f(i):...return (math.cos(math.pi*i) + 1) / 2for i in range(0, 20):...print f(i),(sustituir los ... por un tabulador)
#!/usr/bin/env python# f(i) = sin(i*pi/2)*(-1)^(i/2)import mathdef f(i):...return math.sin(i*math.pi/2)*math.pow(-1, i/2)for i in range(0, 20):...print f(i),
Post a Comment
<< Home
2 Comments:
#!/usr/bin/env python
# f(i) = [cos(pi*i) + 1] / 2
import math
def f(i):
...return (math.cos(math.pi*i) + 1) / 2
for i in range(0, 20):
...print f(i),
(sustituir los ... por un tabulador)
#!/usr/bin/env python
# f(i) = sin(i*pi/2)*(-1)^(i/2)
import math
def f(i):
...return math.sin(i*math.pi/2)*math.pow(-1, i/2)
for i in range(0, 20):
...print f(i),
Post a Comment
<< Home