Skip to content

Instantly share code, notes, and snippets.

@ydm
Created September 10, 2015 08:09
Show Gist options
  • Select an option

  • Save ydm/0ce6687b38583f7d3f5a to your computer and use it in GitHub Desktop.

Select an option

Save ydm/0ce6687b38583f7d3f5a to your computer and use it in GitHub Desktop.
# -*- coding: utf-8 -*-
import cmath
import math
import matplotlib.pyplot as plt
def linear(a, z, n=100):
yield z
for _ in range(n):
z = a * z
yield z
def main():
length = 0.9
angle = 1
a = complex(math.sin(angle), math.cos(angle)) * length
seed = complex(1, 0)
sequence = [c for c in linear(a, seed, 100)]
real = [c.real for c in sequence]
imag = [c.imag for c in sequence]
plt.plot(real, imag)
plt.show()
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment