In [1]:
%pylab
%matplotlib inline


Using matplotlib backend: MacOSX
Populating the interactive namespace from numpy and matplotlib

In [2]:
3**3


Out[2]:
27

In [3]:
3**3.1


Out[3]:
30.135325698915423

In [4]:
3**3.14


Out[4]:
31.489135652454948

In [5]:
3**pi


Out[5]:
31.54428070019754

Kan definere $f(x) = 3^x$


In [6]:
x = linspace(-2,2,200)
y1 = 1.1**x
y2 = 2**x
y3 = 3**x
plot(x,y1,x,y2,x,y3)


Out[6]:
[<matplotlib.lines.Line2D at 0x10a533198>,
 <matplotlib.lines.Line2D at 0x10a533358>,
 <matplotlib.lines.Line2D at 0x10a533cc0>]

In [7]:
x = linspace(-2,2,200)
y1 = 0.8**x
y2 = 0.3**x
y3 = 3**x
plot(x,y1,x,y2,x,y3)


Out[7]:
[<matplotlib.lines.Line2D at 0x10a5e4710>,
 <matplotlib.lines.Line2D at 0x10a5e48d0>,
 <matplotlib.lines.Line2D at 0x10a5eb940>]

a negativ? Litt mystisk, komplekse tall, la oss helst ikke gjøre dette!


In [8]:
x = linspace(-2,2,200)
y = (-3)**x
plot(x,y)


/Users/olivier/anaconda/envs/python3/lib/python3.4/site-packages/ipykernel/__main__.py:2: RuntimeWarning: invalid value encountered in power
  from ipykernel import kernelapp as app
Out[8]:
[<matplotlib.lines.Line2D at 0x10a6e3f98>]

$f(x) = e^x$


In [9]:
x = linspace(-2,2,200)
y = exp(x)
plot(x,y)
axis('equal')


Out[9]:
(-2.0, 2.0, 0.0, 8.0)

$e^{2.4}$ er grensen av $(1+2.4/n)^n$:


In [10]:
n = arange(1,5000)
y = (1+2.4/n)**n
plot(n,y)
plot(n,[exp(2.4)]*len(n))


Out[10]:
[<matplotlib.lines.Line2D at 0x10a807908>]

Potensfunksjoner


In [11]:
x = linspace(.3,3,200)
y1 = x**1.2
y2 = x**2
y3 = x**(-2)
plot(x,y1,x,y2,x,y3)


Out[11]:
[<matplotlib.lines.Line2D at 0x10a6f9828>,
 <matplotlib.lines.Line2D at 0x10a6f9ac8>,
 <matplotlib.lines.Line2D at 0x10a582b38>]

In [12]:
x = linspace(.1,3,200)
y = x**0.7
plot(x,y)


Out[12]:
[<matplotlib.lines.Line2D at 0x10a94b748>]

For noen ok også for $x <0$:


In [13]:
x = linspace(-2,2,200)
y = x**(-2)
plot(x,y)


Out[13]:
[<matplotlib.lines.Line2D at 0x10ac29cc0>]

Potensfunksjoner og eksponentialfunksjoner


In [14]:
x = linspace(0,100,200)
y = (x**10)/(1.2**x)
plot(x,y)


Out[14]:
[<matplotlib.lines.Line2D at 0x10ade5e48>]

Kontinuerlig rentesrente:


In [15]:
p = 0.05
t = 6
# årlig rente:
(1+p)**t
# månedlig rente
(1+p/12)**(12*t)
# daglig rente
(1+p/365)**(365*t)
# kontinuerlig:
exp(p*t)


Out[15]:
1.3498588075760032

In [ ]: