Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupport News AboutSign UpSign In
| Download

All published worksheets from http://sagenb.org

Views: 168733
Image: ubuntu2004

[This worksheet contains sample solutions for a computer algebra class in the winter semester 2011/12 at Leibniz Universität Hannover]

1.a) Funktionsdefinitionen

g(x) = ln(x) print g h(x) = x^3-2*x+1 print h
x |--> log(x) x |--> x^3 - 2*x + 1

1.b) Funktionsgraphen

G = Graphics() G = G + plot(g,(x,.1,1.2)) G.show() H = Graphics() H += plot(h,(x,.1,1.2)) H.show()

2.a) Geraden

def gerade(m,t): f(x) = m*x+t return f print gerade(1,1) print gerade(2,-2)
x |--> x + 1 x |--> 2*x - 2

2.b) Strecken

def plotstrecke(m,t,x0,x1): return plot(gerade(m,t),(x,x0,x1),color="red") G_tangente = G + plotstrecke(1,-1,.1,1.2) G_tangente.show()

2.c) Achsenabschnitt einer Geraden

def achsenabschnitt(m,x0,y0): return y0-x0*m print achsenabschnitt(1,2,3) print achsenabschnitt(2,3,4)
1 -2

2.d) Tangente an einen Graphen

def tangente(f,x0): m = f.derivative()(x0) t = achsenabschnitt(m,x0,f(x0)) return m,t m,t = tangente(g,.2) G_tangente = G + plotstrecke(m,t,.1,1.2) G_tangente.show()

2.e) Zeichnung mit Tangenten

G_tangente = G for n in range(2,10): m,t = tangente(g,n/10) G_tangente = G_tangente + plotstrecke(m,t,.1,1.2) G_tangente.show()

3.a) Schnittpunkt einer Geraden mit der xx-Achse

def schnitt(m,t): return -t/m m,t = tangente(g,1/2) print schnitt(m,t)
-1/2*log(1/2) + 1/2

3.b) Angepasste Zeichnungsfunktion

def plotschnitt(m,t,x0): x1 = schnitt(m,t) return plot(gerade(m,t),(x,min(x0,x1),max(x0,x1)),color=(1,0,0))

3.c) Zeichnung mit Tangenten

G_tangente = G for n in range(2,10): m,t = tangente(g,n/10) G_tangente = G_tangente + plotschnitt(m,t,n/10) G_tangente.show()

4.b) Newton-Verfahren

def newton(f,x0): for n in range(4): m,t = tangente(f,x0) x0 = schnitt(m,t) return x0 print h(newton(h,.1)) print h(newton(h,.9))
5.39322980941392e-7 1.95499922472919e-7

4.c) Newton-Verfahren mit Tangenten

def newton(f,x0): graph = Graphics() graph = graph + plot(f,(x,.1,1.2)) for n in range(4): m,t = tangente(f,x0) graph = graph + plotschnitt(m,t,x0) x0 = schnitt(m,t) graph.show() return x0 newton(g,.1) newton(h,.1) newton(h,.9)
1.00000019549981

4.d) Extremstellen

newton(h.derivative(),.45)
0.816496584876287

4.e) Newton-Vefahren mit Tangenten (skaliert)

newton(g,2) newton(h,.8)
0.618033933288612
def newton(f,x0): graph = Graphics() a,b = +infinity,-infinity for n in range(4): m,t = tangente(f,x0) s = schnitt(m,t) a = min(a,x0,s) b = max(b,x0,s) graph = graph + plotschnitt(m,t,x0) x0 = schnitt(m,t) graph = plot(f,(x,a,b)) + graph # die Tangenten werden _über_ den Graphen gezeichnet graph.show() return x0 newton(g,2) newton(h,.8)
0.618033933288612