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.

I used

### code

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(x)
fns.append(map(lambda x: fn(i, x), x))

plot(*fns)
grid(True)
show()

### results

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