Skip to content

, ,

Pythonic function series

11 novembre 2007

Let’s start with a simple python snippet. (ah, first of all, why am I writing in English? Because I’m a dunce at English and I hope this blog will help).

This week Prof. Kuhn talked to us about the “function series“. I’m not here to explain the theory behind this subject (well… I’m not able to do this) but I’ll try and give you my pythonic experience for the “function series”. I’m a Informatics student and, as anyone in Computer Science, I’m lazy.

There is too much work to draw manually 2 or 3 functions. My computer can do this better and faster, and with python even cooler ;)

One of the examples Prof. Kuhn showed us was: f_n(x)=\frac{x-n}{x^2+3n^2}
The goal of this example is to draw those function series.

tools & libraries

I used


Now we are ready for the snippet :). I think the code is straightforward

from pylab import *

fn = lambda n, x: (x-n)/(x**2+3*n**2)
x = arange(-100, 100, 0.1)
n = range(1, 10)
fns = []
for i in n:
    fns.append(map(lambda x: fn(i, x), x))



Function series 1-detail
function series 1
As you can see, the function converges uniformly.

beware of asymptote

This script is simple, too much simple: you must be very careful to the asymptotes if you try other functions!


From → computer, English

Lascia un commento


Inserisci i tuoi dati qui sotto o clicca su un'icona per effettuare l'accesso:


Stai commentando usando il tuo account Chiudi sessione /  Modifica )

Google+ photo

Stai commentando usando il tuo account Google+. Chiudi sessione /  Modifica )

Foto Twitter

Stai commentando usando il tuo account Twitter. Chiudi sessione /  Modifica )

Foto di Facebook

Stai commentando usando il tuo account Facebook. Chiudi sessione /  Modifica )


Connessione a %s...

%d blogger hanno fatto clic su Mi Piace per questo: