Aggiunti commenti.
Leonardo Robol [2010-02-23 11:09]
diff --git a/NewtonFractal.py b/NewtonFractal.py
index 2e124d0..be1032e 100755
--- a/NewtonFractal.py
+++ b/NewtonFractal.py
@@ -1,18 +1,18 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
-# Sample script to generate a PNM image
-# of the Newton's fractal associated with
-# x^\alpha - 1 polynomial.
+# Questo script genera il frattale di newton
+# associato al polinomio x^alpha - 1; Può essere
+# divertente cambiare alpha ed eventualemnte
+# anche il numero di pixel dell'immagine.
#
def GetNewtonConvergenceSpeed(z, maxit = 255, eps = 10e-11, alpha = 3):
"""
- This function returns, given a complex number z,
- an integer between 0 and maxit representing the
- number of iteration to approximate a root of
- the polynomial x^\alpha - 1 = f(x) so that
- |f(x)| < eps.
+ Ritorna, dato un numero complesso z ed un eps > 0, il numero
+ di iterazioni necessarie (del metodo di Newton) perché
+ |f(x_k)| < eps, oppure maxit se dopo maxit iterazioni
+ non si è ancora raggiunta la precisione desiderata.
"""
fz = pow(z, alpha) - 1
@@ -39,10 +39,11 @@ def GetNewtonConvergenceSpeed(z, maxit = 255, eps = 10e-11, alpha = 3):
return iterations
def Newton(size = 200):
- """Compute the newton's method on a net of points
- in the set { x + iy \in C | |x| < 2 and |y| < 2 }
- and fill the image matrix with the value returned
- by the GetNewtonConvergenceSpeed ()
+ """
+ Calcola la velocità di convergenza su una rete di punti
+ size x size sul quadrato di [-2,2]^2 attorno all'origine
+ del piano complesso. La salva poi in un'immagine dal nome
+ newton.pnm
"""
# Delta è l'ampiezza dell'intervallo fratto il numero di
@@ -74,4 +75,5 @@ def Newton(size = 200):
if __name__ == "__main__":
+ # Creiamo un'immagine 1024px x 1024px.
Newton (1024)