Table of Contents

Lektion 9

Tannenbaum

In [1]:
import numpy as np
import matplotlib.pyplot as plt
%matplotlib notebook
In [2]:
A = np.array([[0,1],[1,1]])
A
Out[2]:
array([[0, 1],
       [1, 1]])
In [3]:
A = np.array([[1e-20,1],[1,1]])
A
Out[3]:
array([[1.e-20, 1.e+00],
       [1.e+00, 1.e+00]])
In [4]:
L = np.array([[1,0],[1e20,1]])
L
Out[4]:
array([[1.e+00, 0.e+00],
       [1.e+20, 1.e+00]])
In [5]:
R = np.array([[1e-20,1],[0,1-1e20]])
R
Out[5]:
array([[ 1.e-20,  1.e+00],
       [ 0.e+00, -1.e+20]])
In [6]:
L@R
Out[6]:
array([[1.e-20, 1.e+00],
       [1.e+00, 0.e+00]])
In [7]:
L@R - A
Out[7]:
array([[ 0.,  0.],
       [ 0., -1.]])
In [8]:
x = np.linspace(-19.57,0,500)
f = 1/7*(-x)**(3/2)* ( (3/2)**(np.sqrt(-x))-np.floor((3/2)**(np.sqrt(-x))))
plt.figure()
plt.plot(x,f);
In [9]:
plt.figure()
plt.fill(x,f,x,-f,linewidth=3,color='green');
In [10]:
fig = plt.figure(1)
ax = fig.add_subplot(111)
ax.fill(f,x,-f,x,linewidth=3,color='green');
In [11]:
fig = plt.figure(1)
ax = fig.add_subplot(111)
ax.fill(f,x,-f,x,linewidth=3,color='green');
ax.fill([-.5,.5,.5,-.5,-.5],[-19.5,-19.5,-22,-22,-19.5],color='brown',linewidth='4');
In [12]:
def n_stern(n):
    x = [(0.5+ j % 2)*np.sin(np.pi*2*j/n) for j in range(2*n+1)]
    y = [(0.5+ j % 2)*np.cos(np.pi*2*j/n) for j in range(2*n+1)]
    return x ,y
In [13]:
#' Hintergrund
In [14]:
fig = plt.figure(1)
ax = fig.add_subplot(111)
ax.fill(f,x,-f,x,linewidth=3,color='green');
ax.fill([-.5,.5,.5,-.5,-.5],[-19.5,-19.5,-22,-22,-19.5],color='brown',linewidth='4');
fig.set_facecolor('darkblue')
ax.axis('off');
In [15]:
from mpl_toolkits.mplot3d import Axes3D
from numpy.random import rand

fig = plt.figure(100)
ax = fig.add_subplot(111,projection='3d')

theta = np.linspace(-np.pi,np.pi, 50)
X = f.reshape((-1,1)) * np.sin(theta).reshape(1,-1)
Y = f.reshape((-1,1)) * np.cos(theta).reshape(1,-1)
Z = x.reshape((-1,1)) * np.ones_like(theta).reshape(1,-1)
sc = ax.plot_surface(X, Y, Z, color='green');

nFlocken = 10
xs = 20*rand(nFlocken,1)-10
ys = 20*rand(nFlocken,1)-10
zs = -20*rand(nFlocken,1)+2
sc = ax.scatter3D(xs,ys,zs,'b*')

ax.axis('off');