Harj. 4 LV
pe 11.10.02
Alustukset
> | restart:with(LinearAlgebra): with(linalg): with(plots):setoptions(scaling=constrained):setoptions3d(axes=boxed,orientation=[-30,50]): alias(Inv=MatrixInverse,Id=IdentityMatrix,Diag=DiagonalMatrix): alias(rref=ReducedRowEchelonForm):alias(ref=GaussianElimination): alias(Id=IdentityMatrix): |
Warning, the name changecoords has been redefined
Warning, the previous binding of the name GramSchmidt has been removed and it now has an assigned value
Warning, the protected names norm and trace have been redefined and unprotected
1.
(a) Tehdään ensin 2 AV:
> | restart: |
Warning, the name changecoords has been redefined
> | EHY:=y(k+2)-a*(1+b)*y(k+1)+a*b*y(k)=1; |
> | karyht:=r^2-a*(1+b)*r+a*b=0; |
> | r:=solve(karyht,r); |
> | r:=subs(a=0.9,b=4/9,[%]); |
> |
> | Yh:=k->c1*r[1]^k + c2*r[2]^k; |
> | yp:=k->T: # yrite |
> | EHYyr:=subs(y=yp,EHY); |
> | eval(EHYyr); |
> | Tarvo:=solve(%,T); |
> | Yp:=k->Tarvo; |
> | Yp(k); |
> | a:=0.9; |
> | Yp(k); |
> | Y:=Yp+Yh; |
> | Y(k); |
Alkuarvot: Otetaan vaikka 1 ja 1 "bkt-yksikköä"..
> | c:=solve({Y(0)=1,Y(1)=1},{c1,c2}); |
> | plot(subs(c,[seq([k,Y(k)],k=0..10)])); |
> | plot(subs(c,[seq([k,Y(k)],k=10..20)])); |
> | plot(subs(c,[seq([k,Y(k)],k=20..30)])); |
> | kuva1:=plot(subs(c,[seq([k,Y(k)],k=0..30)]),title="b=4/9",color=blue): |
(B) Varsinainen alkuperäinen teht. 1 LV
> | a:='a': b:='b': y:='y':r:='r': |
> | EHY:=y(k+2)-a*(1+b)*y(k+1)+a*b*y(k)=1; |
> | karyht:=r^2-a*(1+b)*r+a*b=0; |
> | R:=solve(karyht,r); |
> | R:=subs(a=0.9,b=0.5,[R]); |
> |
> |
> | Yh:=k->c1*R[1]^k + c2*R[2]^k; |
> | yp:=k->T: # yrite |
> | EHYyr:=subs(y=yp,EHY); |
> | eval(EHYyr); |
> | Tarvo:=solve(%,T); |
> | Yp:=k->Tarvo; |
> | Yp(k); |
> | a:=0.9; |
> | Yp(k); |
> | Y:=Yp+Yh; |
> | Y(k); |
> | c:=solve({Y(0)=1,Y(1)=1},{c1,c2}); |
> | plot(subs(c,[seq([k,Y(k)],k=0..10)])); |
> | plot(subs(c,[seq([k,Y(k)],k=10..20)])); |
> | kuva2:=plot(subs(c,[seq([k,Y(k)],k=0..30)]),title="b=0.5",color=red): |
> | plots[display](kuva1,kuva2,title="AV ja LV teht 1"); |
> | kuva1; |
Lisätehtävä 1 c) b=5/9 (Lisäys annettu ma 7.10.)
> | a:='a': b:='b': y:='y':r:='r': |
> | EHY:=y(k+2)-a*(1+b)*y(k+1)+a*b*y(k)=1; |
> | karyht:=r^2-a*(1+b)*r+a*b=0; |
> | R:=solve(karyht,r); |
> | R:=subs(a=0.9,b=5/9,[R]); |
> |
Lisäys/muutos
> | yri:=k->a^k*cos(b*k); |
> | subs(y=yri,lhs(EHY));eval(%); |
> | karakt:=simplify(%/a^k,symbolic); |
> | karakt:=collect(%,cos(k*b));collect(%,sin(k*b)); |
> | {coeff(karakt,cos(b*k),1)=0,coeff(karakt,sin(b*k),1)=0}; |
Eipä tuo aivan yksinkertainen yhtälö ole!
2.
> | with(LinearAlgebra): with(linalg): |
Warning, the previous binding of the name GramSchmidt has been removed and it now has an assigned value
Warning, the protected names norm and trace have been redefined and unprotected
> | A:=<<0,0,0,9>|<1,0,0,-6>|<0,1,0,-8>|<0,0,1,6>>; |
> | X[0]:=<1,0,0,0>; |
> | n:=20: for i to n do X[i]:=A.X[i-1] end do: |
> | seq(X[i],i=0..10); |
b)
> | y[0]:=1: y[1]:=0: y[2]:=0: y[3]:=0: |
> | n:=20: for k from 0 to n do y[k+4]:=6*y[k+3]-8*y[k+2]-6*y[k+1]+9*y[k]: end do: |
> | seq(y[k],k=0..n); |
> |
> | Eigenvectors(A); |
> | eigenvectors(A); |
> |
3.
> | restart: |
Warning, the name changecoords has been redefined
> | dyht:=y(k+4)-6*y(k+3)+8*y(k+2)+6*y(k+1)-9*y(k)=0; |
> | karpol:=r^4-6*r^3+8*r^2+6*r-9; |
> | factor(karpol); |
> | yri:=k->k*3^k; |
> | yriy:=subs(y=yri,dyht); |
> | eval(yriy); |
> | expand(lhs(%)); |
Saadaan siis LRT ratlkaisut
> | y1:=k->1: y2:=k->(-1)^k: y3:=k->3^k: y4:=k->k*3^k: |
Miten perustellaan LRT
> | Casorati:=<<y1(k),y1(k+1),y1(k+2),y1(k+3)>|<y2(k),y2(k+1),y2(k+3),y2(k+4)>|<y3(k),y3(k+1),y3(k+2),y3(k+3)>|<y4(k),y4(k+1),y4(k+2),y4(k+3)>>; |
> | linalg[det](Casorati); |
> | simplify(%); |
> |
> |
> |