blatt04.mw

Blatt 4 und Vorlesung Kapitel 14.3 Differenzierbarkeit / Gradientenverfahren

> restart:

> with(plots):with(linalg):

Warning, the name changecoords has been redefined

Warning, the protected names norm and trace have been redefined and unprotected

Gradient von f

> f:=x^2+y^2;

f := x^2+y^2

> p1:=gradplot( f ,x=-2..2,y=-2..2):

> p2:=contourplot( f , x=-2..2,y=-2..2, filled=true,
 coloring=[white,blue]):

> display(p1,p2);

[Plot]

Tangente an implizit gegebene Kurve:

> f:=x^3+x*y-y^3; f:=unapply(f,[x,y]);

f := x^3+x*y-y^3

f := proc (x, y) options operator, arrow; x^3+y*x-y^3 end proc

> m:=-1/2; x0:=-m/(1-m^3); y0:=m*x0; "f(x0,y0)"=f(x0,y0);

m := (-1)/2

x0 := 4/9

y0 := (-2)/9

> g:=grad(f(x,y),[x,y]);

g := vector([3*x^2+y, x-3*y^2])

> g1:=unapply(g[1],x,y); g2:=unapply(g[2],x,y);

g1 := proc (x, y) options operator, arrow; 3*x^2+y end proc

g2 := proc (x, y) options operator, arrow; x-3*y^2 end proc

> T:=g1(x0,y0)*(x-x0)+g2(x0,y0)*(y-y0);

T := 10/27*x-8/81+8/27*y

> p:=implicitplot( f(x,y)=0,x=-1..1,y=-1..1,grid=[50,50],thickness=3,color=red, scaling=constrained):

> q:=implicitplot( T=0,x=-1..1,y=-1..1,grid=[50,50],thickness=2,color=blue):

> n1:=plot([x0+t*g1(x0,y0),y0+t*g2(x0,y0), t=0..0.5], thickness=2, color=green):

> Stelle:=plot([x0+0.02*cos(t),y0+0.02*sin(t),t=0..2*Pi],thickness=2,color=black):

> display(p,q,n1,Stelle);

[Plot]

Tangentenebene an implizit gegebenes Ellipsoid

> F:=1/2*x^2+2*y^2+z^2-8; F:=unapply(F,[x,y,z]);

F := 1/2*x^2+2*y^2+z^2-8

F := proc (x, y, z) options operator, arrow; 1/2*x^2+2*y^2+z^2-8 end proc

> x0:=2; y0:=1; z0:=2; "F(x0,y0,z0)"=F(x0,y0,z0);

x0 := 2

y0 := 1

z0 := 2

> g:=grad(F(x,y,z),[x,y,z]);

g := vector([x, 4*y, 2*z])

> g1:=unapply(g[1],[x,y,z]); g2:=unapply(g[2],[x,y,z]); g3:=unapply(g[3],[x,y,z]);

g1 := proc (x, y, z) options operator, arrow; x end proc

g2 := proc (x, y, z) options operator, arrow; 4*y end proc

g3 := proc (x, y, z) options operator, arrow; 2*z end proc

> T:=g1(x0,y0,z0)*(x-x0)+g2(x0,y0,z0)*(y-y0)+g3(x0,y0,z0)*(z-z0);

T := 2*x-16+4*y+4*z

> p:=implicitplot3d(F(x,y,z)=0, x=-5..5, y=-4..4, z=-3..3 , grid=[20,20,20], axes=normal, style=patchcontour, scaling=constrained, tickmarks=[1, 1, 1], transparency=0.7):

> q:=implicitplot3d(T=0, x=0..4, y=-1..3, z=1..3 , grid=[20,20,20], style=patchnogrid, shading=Z):

> n1:=spacecurve([x0+t*g1(x0,y0,z0),y0+t*g2(x0,y0,z0),z0+t*g3(x0,y0,z0)], t=-0.2..0.2, thickness=2, color=green):

> Stelle:=spacecurve([x0+0.02*cos(t),y0+0.02*sin(t),z0],t=0..2*Pi,thickness=5,color=black):

> display(p,q,n1,Stelle);

[Plot]

T13 Gradient, Richtungsableitung, Tangentenebene

> f:=x^2*y+x*y^3+x; f:=unapply(f,[x,y]);

f := x^2*y+x*y^3+x

f := proc (x, y) options operator, arrow; x^2*y+x*y^3+x end proc

> g:=grad(f(x,y),[x,y]);

g := vector([2*x*y+y^3+1, x^2+3*x*y^2])

> g1:=unapply(g[1],[x,y]); g2:=unapply(g[2],[x,y]);

g1 := proc (x, y) options operator, arrow; 2*y*x+y^3+1 end proc

g2 := proc (x, y) options operator, arrow; x^2+3*x*y^2 end proc

> ar:=[1,-1]; a:=ar/sqrt(dotprod(ar,ar,orthogonal));

ar := [1, -1]

a := 1/2*[1, -1]*2^(1/2)

> x0:=1; y0:=2; simplify(dotprod([g1(x0,y0),g2(x0,y0)],a,orthogonal));

x0 := 1

y0 := 2

0

> z(t):=f(1+sin(t),1-cos(t)); diff(z(t),t); simplify(diff(z(t),t));

z(t) := (1+sin(t))^2*(1-cos(t))+(1+sin(t))*(1-cos(t))^3+1+sin(t)

2*(1+sin(t))*(1-cos(t))*cos(t)+(1+sin(t))^2*sin(t)+cos(t)*(1-cos(t))^3+3*(1+sin(t))*(1-cos(t))^2*sin(t)+cos(t)

-4*sin(t)*cos(t)+5*sin(t)+9*cos(t)^3-4*cos(t)^4-2*cos(t)-7*cos(t)^2+5

> z0:=f(x0,y0); T:=g1(x0,y0)*(x-x0)+g2(x0,y0)*(y-y0)-(z-z0);

z0 := 11

T := 13*x-28+13*y-z

> p:=plot3d(f(x,y), x=-4..4,y=-4..4, view=-3..17,grid=[50,50], style=patchcontour):

> q:=plot3d(g1(x0,y0)*(x-x0)+g2(x0,y0)*(y-y0)+z0, x=-4..4,y=-4..4,grid=[50,50],transparency=0.7):

> n1:=spacecurve([x0+t*g1(x0,y0),y0+t*g2(x0,y0),z0-t], t=-0.2..0.2, thickness=2, color=green):

> Stelle:=spacecurve([x0+0.02*cos(t),y0+0.02*sin(t),z0],t=0..2*Pi,thickness=5,color=black):

> c:=spacecurve([1+sin(t),1-cos(t),f(1+sin(t),1-cos(t))], t=-4..4, thickness=2, color=red):

> display(p,q,n1,Stelle,c);

[Plot]

T 14 Lösung der Korteweg-De-Vries-Gleichung

> u:=-2/(cosh(x-4*t))^2;

u := -2/cosh(-x+4*t)^2

> plot3d(u(x,t),x=-1..1,t=-1..1,view=-2..2, axes=normal, grid=[30,30]);

[Plot]

> u_x:=diff(u,x); u_xx:=diff(u_x,x); u_xxx:=diff(u_xx,x);
u_t:=diff(u,t);

u_x := -4*sinh(-x+4*t)/cosh(-x+4*t)^3

u_xx := -12*sinh(-x+4*t)^2/cosh(-x+4*t)^4+4/cosh(-x+4*t)^2

u_xxx := -48*sinh(-x+4*t)^3/cosh(-x+4*t)^5+32*sinh(-x+4*t)/cosh(-x+4*t)^3

u_t := 16*sinh(-x+4*t)/cosh(-x+4*t)^3

> rS:=simplify(6*u*u_x-u_xxx);

rS := 16*sinh(-x+4*t)/cosh(-x+4*t)^3

> u_t-rS;

0

T15 Tangentenebene an implizit gegebenes Hyperboloid

> F:=x^2+y^2-z^2-1; F:=unapply(F,[x,y,z]);

F := x^2+y^2-z^2-1

F := proc (x, y, z) options operator, arrow; x^2+y^2-z^2-1 end proc

> x0:=1;y0:=1;z0:=1; "F(x0,y0,z0)"=F(x0,y0,z0);

x0 := 1

y0 := 1

z0 := 1

> g:=grad(F(x,y,z),[x,y,z]);

g := vector([2*x, 2*y, -2*z])

> g1:=unapply(g[1],[x,y,z]); g2:=unapply(g[2],[x,y,z]); g3:=unapply(g[3],[x,y,z]);

g1 := proc (x, y, z) options operator, arrow; 2*x end proc

g2 := proc (x, y, z) options operator, arrow; 2*y end proc

g3 := proc (x, y, z) options operator, arrow; -2*z end proc

> T:=g1(x0,y0,z0)*(x-x0)+g2(x0,y0,z0)*(y-y0)+g3(x0,y0,z0)*(z-z0);

T := 2*x-2+2*y-2*z

> factor(simplify(F(x,y,x+y-1)));

-2*(y-1)*(x-1)

> p:=plot3d([cos(u)*cosh(v),sin(u)*cosh(v),sinh(v)],u=0..2*Pi,v=-1..2, axes=normal, grid=[100,100]):

> q:=plot3d(x+y-1, x=-2..4,y=0-2..4, view=-1..3,grid=[50,50], style=patchnogrid):

> s1:=spacecurve([1,t,t], t=-1..3, thickness=2, color=blue):

> s2:=spacecurve([t,1,t], t=-1..3, thickness=2, color=blue):

> n1:=spacecurve([x0+t*g1(x0,y0,z0),y0+t*g2(x0,y0,z0),z0+t*g3(x0,y0,z0)], t=-0.2..0.2, thickness=2, color=green):

> Stelle:=spacecurve([x0+0.02*cos(t),y0+0.02*sin(t),z0],t=0..2*Pi,thickness=5,color=black):

> display(p,q,s1,s2,n1,Stelle);

[Plot]

H07 Gradient, Richtungsableitung, Tangentenebene

> f:=y*sin(Pi*x); f:=unapply(f,[x,y]);

f := y*sin(Pi*x)

f := proc (x, y) options operator, arrow; y*sin(Pi*x) end proc

> g:=grad(f(x,y),[x,y]);

> g1:=unapply(g[1],[x,y]); g2:=unapply(g[2],[x,y]);

g1 := proc (x, y) options operator, arrow; y*cos(Pi*x)*Pi end proc

g2 := proc (x, y) options operator, arrow; sin(Pi*x) end proc

> ar:=[3/5,-4/5]; a:=ar/sqrt(dotprod(ar,ar,orthogonal));

ar := [3/5, (-4)/5]

a := [3/5, (-4)/5]

> x0:=1/2; y0:=1/2; simplify(dotprod([g1(x0,y0),g2(x0,y0)],a,orthogonal));

x0 := 1/2

y0 := 1/2

(-4)/5

> z(t):=f(t,cos(Pi*t)); diff(z(t),t); simplify(diff(z(t),t));

z(t) := cos(Pi*t)*sin(Pi*t)

-sin(Pi*t)^2*Pi+cos(Pi*t)^2*Pi

Pi*(-1+2*cos(Pi*t)^2)

> z0:=f(x0,y0); T:=g1(x0,y0)*(x-x0)+g2(x0,y0)*(y-y0)-(z-z0);

z0 := 1/2

T := y-z

> plot3d(f(x,y), x=-3..3,y=-2..2, view=-2..2,grid=[30,30],scaling=constrained);

[Plot]

> p:=plot3d(f(x,y), x=-4..4,y=-4..4, view=-4..4,grid=[50,50], style=patchcontour,scaling=constrained):

> q:=plot3d(g1(x0,y0)*(x-x0)+g2(x0,y0)*(y-y0)+z0, x=-1..2,y=-1..2,grid=[50,50],transparency=0.7):

> n1:=spacecurve([x0+t*g1(x0,y0),y0+t*g2(x0,y0),z0-t], t=-1..1, thickness=2, color=green):

> Stelle:=spacecurve([x0+0.02*cos(t),y0+0.02*sin(t),z0],t=0..2*Pi,thickness=5,color=black):

> c:=spacecurve([t,cos(Pi*t),f(t,cos(Pi*t))], t=-4..4, thickness=2, color=red):

> display(p,q,n1,Stelle,c);

[Plot]

E04 Sombrero

> f:=sin(2*sqrt(x^2+y^2))/(sqrt(x^2+y^2)); f:=unapply(f,[x,y]);

f := sin(2*(x^2+y^2)^(1/2))/(x^2+y^2)^(1/2)

f := proc (x, y) options operator, arrow; sin(2*(x^2+y^2)^(1/2))/(x^2+y^2)^(1/2) end proc

> g:=grad(f(x,y),[x,y]);

g := vector([2*cos(2*(x^2+y^2)^(1/2))*x/(x^2+y^2)-sin(2*(x^2+y^2)^(1/2))*x/(x^2+y^2)^(3/2), 2*cos(2*(x^2+y^2)^(1/2))*y/(x^2+y^2)-sin(2*(x^2+y^2)^(1/2))*y/(x^2+y^2)^(3/2)])

> g1:=unapply(g[1],[x,y]); g2:=unapply(g[2],[x,y]);

g1 := proc (x, y) options operator, arrow; 2*cos(2*(x^2+y^2)^(1/2))*x/(x^2+y^2)-sin(2*(x^2+y^2)^(1/2))*x/(x^2+y^2)^(3/2) end proc

g2 := proc (x, y) options operator, arrow; 2*cos(2*(x^2+y^2)^(1/2))*y/(x^2+y^2)-sin(2*(x^2+y^2)^(1/2))*y/(x^2+y^2)^(3/2) end proc

> ar:=[1,1]; a:=ar/sqrt(dotprod(ar,ar,orthogonal));

ar := [1, 1]

a := 1/2*[1, 1]*2^(1/2)

> x0:=Pi/2; y0:=0; simplify(dotprod([g1(x0,y0),g2(x0,y0)],a,orthogonal));

x0 := 1/2*Pi

y0 := 0

-2*2^(1/2)/Pi

> z(t):=f(t*cos(t),t*sin(Pi*t)); diff(z(t),t); simplify(diff(z(t),t));

z(t) := sin(2*(t^2*cos(t)^2+t^2*sin(Pi*t)^2)^(1/2))/(t^2*cos(t)^2+t^2*sin(Pi*t)^2)^(1/2)

cos(2*(t^2*cos(t)^2+t^2*sin(Pi*t)^2)^(1/2))*(2*t*cos(t)^2-2*t^2*cos(t)*sin(t)+2*t*sin(Pi*t)^2+2*t^2*sin(Pi*t)*cos(Pi*t)*Pi)/(t^2*cos(t)^2+t^2*sin(Pi*t)^2)-1/2*sin(2*(t^2*cos(t)^2+t^2*sin(Pi*t)^2)^(1/2...cos(2*(t^2*cos(t)^2+t^2*sin(Pi*t)^2)^(1/2))*(2*t*cos(t)^2-2*t^2*cos(t)*sin(t)+2*t*sin(Pi*t)^2+2*t^2*s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-(sin(2*(t^2*(cos(t)^2+1-cos(Pi*t)^2))^(1/2))*cos(t)^2-2*cos(t)^2*cos(2*(t^2*(cos(t)^2+1-cos(Pi*t)^2))^(1/2))*(t^2*(cos(t)^2+1-cos(Pi*t)^2))^(1/2)+2*t*cos(t)*sin(t)*cos(2*(t^2*(cos(t)^2+1-cos(Pi*t)^2)...

> z0:=simplify(f(x0,y0)); T:=simplify(g1(x0,y0)*(x-x0)+g2(x0,y0)*(y-y0)-(z-z0));

z0 := 0

T := -(4*x-2*Pi+z*Pi)/Pi

Graph von f(x,y) in kartesischen Koordinaten:

> plot3d(f(x,y), x=-5..5,y=-5..5, view=-2..2,grid=[30,30],scaling=constrained);

[Plot]

Graph von f(x,y) in Polarkoordinaten:

> plot3d([u*cos(v),u*sin(v),f(u*cos(v),u*sin(v))], u=0..3,v=-Pi..Pi, view=-1..2,grid=[30,30],scaling=constrained);

[Plot]

> p:=plot3d([u*cos(v),u*sin(v),f(u*cos(v),u*sin(v))], u=0..3,v=-Pi..Pi, view=-1..2,grid=[30,30],scaling=constrained):

> q:=plot3d(g1(x0,y0)*(x-x0)+g2(x0,y0)*(y-y0)+z0, x=-1..2,y=-1..2,grid=[50,50],transparency=0.7):

> n1:=spacecurve([x0+t*g1(x0,y0),y0+t*g2(x0,y0),z0-t], t=-1..1, thickness=2, color=green):

> Stelle:=spacecurve([x0+0.02*cos(t),y0+0.02*sin(t),z0],t=0..2*Pi,thickness=5,color=black):

> c:=spacecurve([t*cos(t),t*sin(t),f(t*cos(t),t*sin(t))], t=-3..3, thickness=2, color=red):

> display(p,q,n1,Stelle,c);

[Plot]

>