2. Vaja: Laplaceova transformacija

LaplaceTransform[f[t],t,s]
InverseLaplaceTransformp[F[s],s,t]

Laplaceova transformacija elementarnih funkcij in pravila.

1. Vaja: Doloci Laplaceovo transformacijo funkcije f(t).

Clear[f,t,s]
f[t_]=t^2;
Integrate[f[t] E^(-s t),{t,0,∞}]
Integrate[f[t] E^(-s t),{t,0,∞},Assumptions->s>0]
LaplaceTransform[f[t],t,s]
InverseLaplaceTransform[%,s,t]

Clear[f,t,s]
f[t_]={1,t,t^n,E^(a t),Sin[ω t],Cos[ω t]}
g[s_]=LaplaceTransform[f[t],t,s]
FullSimplify[%,Assumptions->{n∈Integers&&n>0}]

2. Vaja:Prouci kaj se dogaja s funkcijo in njeno transformiranko pri premikih v levo.
Narisi graf enotske stopnice (UnitStepSeq[t-a]) in (UnitStepSeq[a+t]), kjer je a>0.  Vzemi, da je a=1  
	in doloci njeno Laplaceovo transormacijo.
Premik v levo: Primerjaj (Subscript[ℒ, t])[f(t-a)](s)in (Subscript[ℒ, t])[f(t-1) (UnitStepSeq[t-a])](s), kjer je a>0. 
	Narisi graf originalne funkcije in funkcijo ki jo dobimo z inverzno Laplaceovo transformacijo 
	njene Laplaceove transformiranke.

LaplaceTransform[x[t],t,s]

F1[s_]=LaplaceTransform[Sin[t-1],t,s]
F2[s_]=LaplaceTransform[UnitStep[t-1]Sin[t-1],t,s]
f1[t_]=InverseLaplaceTransform[F1[s],s,t];
f2[t_]=InverseLaplaceTransform[F2[s],s,t];
g1=Plot[f1[t],{t,-1,3},PlotStyle->Thick];
g2=Plot[f2[t],{t,-1,3},PlotStyle->{Thick,Dashed,Red}];
Show[g1,g2]
g1=Plot[UnitStep[t]f1[t],{t,-1,3},PlotStyle->Thick];
Show[g1,g2]

3. Vaja: Prepricaj se na primerih, da je Laplaceova transformacija funkcije oblike 
	f (t)=(e^(a t)) (t^n) sin(b t) ali 
	f (t)=(e^(a t)) (t^n) cos(b t) 
	ulomljena racionalna funkcija katere stopnja je v stevcu je vsaj za eno vecja 
	kot v imenovalcu vzemi primere, da je n=0,1,2 in 3.

LaplaceTransform[t^3 Exp[-a t]Sin[b t],t,s]
f[t_]={(t^2+3t+2) Exp[-2 t],(t^2+2t+1) Exp[2 t],(t+1)^2Sin[t],Exp[-3 t]Cos[2t],Exp[-3 t]Cos[2t]+t^3 Sin[t]};
LaplaceTransform[f[t],t,s]
FullSimplify[%]

4. Podobno se prepricaj na primerih, da je inverzna Laplaceova transformacija ulomljene racionalne funkcije Q(s),  katere stopnja stevca je vsaj za eno vecja od stopnje imenovalca,
	 (lim_(s->∞)) Q(s)=0, oblike   f (t)=(e^(a t)) (t^n) sin(b t) oziroma
	  f (t)=(e^(a t)) (t^n) cos(b t) ozitoma linearna kombinacija le-teh.

Clear[F,s,t]
F[s_]={s/(s^2+1),(s-1)/(s+1)^2,(s^2+s+1)/(s(s+1)^2(x+2)),(s-1)/(s^3+1),1/(s^2+1)^2};
InverseLaplaceTransform[F[s],s,t]

5. Razlozi rezultate, naslednjih racunov:
	a. F(s)=(Subscript[ℒ, s]^(-1))[((e^(-2 s))/(s^2))](t)
	(Subscript[ℒ, t])[F(s)](s)
b.  F(s)=(Subscript[ℒ, s]^(-1))[((e^(2 s))/(s^2))](t)
	(Subscript[ℒ, t])[F(s)](s)
	c. (Subscript[ℒ, t])(((UnitStepSeq[t])-(UnitStepSeq[t-a]))/a)(s)=((1-(e^(-a s)))/(a s))
		(lim_(a->0)) (((1-(e^(-a s)))/(a s)))=1
		(Subscript[ℒ, s]^(-1))[1](t)=(DiracDeltaSeq[t])

Clear[F,f,s,t]
F[s_]=InverseLaplaceTransform[E^(-2 s)/s^2,s,t]
LaplaceTransform[F[s],t,s]//FullSimplify
F[s_]=InverseLaplaceTransform[E^(2 s)/s^2,s,t]
LaplaceTransform[F[s],t,s]//FullSimplify
G[s_,a_]=LaplaceTransform[(UnitStep[t]-UnitStep[t-a])/a,t,s,Assumptions->a>0]//FullSimplify
delta=Limit[G[s,a],a->0]
InverseLaplaceTransform[delta,s,t]

6. S pomocjo Laplaceove transformacije resi diferencialne enacbe in narisi graf resitve. 
	y''(t)+y(t)=0,           y(0)==0 in y'(0)==1.
	y''(t)+y(t)=h(t),     y(0)==0, y'(0)==0,h(t)=1, 0≤t≤1 in h(t)=0, drugod. 
	y''(t)+y(t)=h(t),     y(0)==0 in y'(0)==0, h(t)=1, 0≤t≤1, h(t)=-1,1<t≤2 in h(t)=0, drugod. 
	y''(t)+y(t)=h(t),     y(0)==0 in y'(0)==0, h(t)=δ(t) (DiracDelta[t]).
	y''(t)+y(t)==sin(t),   y(0)==0 in y'(0)==0.
	y''(t)+2y'(t)+2y(t)==(UnitStepSeq[t]), (UnitStep[t]), y(t)=0 in y'(t)=0.
	y''(t)+2y'(t)+2y(t)==sin(t), y(t)=0 in y'(t)=0.

Clear[y,s,t]
eqn=y''[t]+y[t]==0; cnd={y[0]->0,y'[0]->1};
LaplaceTransform[eqn,t,s]
%/.cnd
Solve[%,LaplaceTransform[y[t],t,s]]
InverseLaplaceTransform[%,s,t]
Plot[y[t]/.%,{t,0,4}]

Clear[y,s,t]
h[t_]=Piecewise[{{1,0≤t≤1}},0]
eqn=y''[t]+y[t]==h[t]; cnd={y[0]->0,y'[0]->0};
LaplaceTransform[eqn,t,s]
%/.cnd
Solve[%,LaplaceTransform[y[t],t,s]]
InverseLaplaceTransform[%,s,t]
Plot[y[t]/.%,{t,0,14}]

Clear[y,s,t]
h[t_]=Piecewise[{{1,0≤t≤1},{-1,1<t≤2}},0]
eqn=y''[t]+y[t]==h[t]; cnd={y[0]->0,y'[0]->0};
LaplaceTransform[eqn,t,s]
%/.cnd
Solve[%,LaplaceTransform[y[t],t,s]]
InverseLaplaceTransform[%,s,t]
Plot[y[t]/.%,{t,0,14}]

Clear[y,s,t]
eqn=y''[t]+y[t]==0; cnd={y[0]->0,y'[0]->1};
LaplaceTransform[eqn,t,s]
%/.cnd
Solve[%,LaplaceTransform[y[t],t,s]]
InverseLaplaceTransform[%,s,t]
Plot[y[t]/.%,{t,0,14}]

Clear[y,s,t]
eqn=y''[t]+y[t]==DiracDelta[t]; cnd={y[0]->0,y'[0]->0};
LaplaceTransform[eqn,t,s]
%/.cnd
Solve[%,LaplaceTransform[y[t],t,s]]
InverseLaplaceTransform[%,s,t]
Plot[y[t]/.%,{t,0,14}]

Clear[y,s,t]
eqn=y''[t]+y[t]==Sin[t]; cnd={y[0]->0,y'[0]->0};
LaplaceTransform[eqn,t,s]
%/.cnd
Solve[%,LaplaceTransform[y[t],t,s]]
InverseLaplaceTransform[%,s,t]
Plot[y[t]/.%,{t,0,14}]

7. S pomocjo laplaceove transformacije resi naslednje integralske enacbe s konvolucijskim jedrom. 
	x(t)==(t^2)+(∫_0^t)x(u)du
	x(t)==(∫_0^t)x(u) exp(t-u)du+1
	(∫_0^t)(t-u+1) x(u)du+x'(t)+x(t)==0, x(0)==1.

eqn=x[t]==t^2+Integrate[x[u],{u,0,t}];
LaplaceTransform[eqn,t,s]
Solve[%,LaplaceTransform[x[t],t,s]]
InverseLaplaceTransform[%,s,t]

eqn=x[t]==1+Integrate[Exp[t-u]x[u],{u,0,t}]
LaplaceTransform[eqn,t,s]
Solve[%,LaplaceTransform[x[t],t,s]]
InverseLaplaceTransform[%,s,t]

eqn=x'[t]+x[t]+Integrate[(t-u+1)x[u],{u,0,t}]==0
LaplaceTransform[eqn,t,s]
Solve[%,LaplaceTransform[x[t],t,s]]
InverseLaplaceTransform[%,s,t]/.x[0]->1

1. Doloci inverzno Laplaceovo transformacijo funkcije F(s)=(s/((((s^2)+1))^2)).
	a. Z ukazom InverseLaplaceTransform,
	b. z inverzno formulo (∑_k)Res((e^st) F(s),(Subscript[s, k])),
	c. s pravilom o konvoluciji (Subscript[ℒ, s]^(-1))[(s/((s^2)+1))](t) (Subscript[ℒ, s]^(-1))[(1/((s^2)+1))](t).

1. Doloci inverzno Laplaceovo transformacijo funkcije F(s)=(s/((((s^2)+1))^2)).
	a. Z ukazom InverseLaplaceTransform,
	b. z inverzno formulo (∑_k)Res((e^st) F(s),(Subscript[s, k])),
	c. s pravilom o konvoluciji (Subscript[ℒ, s]^(-1))[(s/((s^2)+1))](t) (Subscript[ℒ, s]^(-1))[(1/((s^2)+1))](t).

F[s]=s/(s^2+1)^2;
InverseLaplaceTransform[F[s],s,t]
Limit[D[(s-I)^2F[s]Exp[s t],s],s->I]+Limit[D[(s+I)^2F[s]Exp[s t],s],s->-I]//FullSimplify
f1[t_]=InverseLaplaceTransform[s/(s^2+1),s,t];
f2[t_]=InverseLaplaceTransform[1/(s^2+1),s,t];
Integrate[f1[τ] f2[t-τ],{τ,0,t}]

2. Doloci Laplaceovo transformacijo funkcije f (t)=(({{t, 0≤t≤1}, {2-t, 1<t≤2}})), ce je f(t+2 k)=f(t) za vsako naravno stevilo k in t>0.

f[t_]=Piecewise[{{t,0≤t≤1},{2-t,1<t≤2}},0]
Plot[f[t],{t,-1,3},AspectRatio->Automatic,PlotStyle->Thick]
LaplaceTransform[f[t],t,s]/(1-Exp[-2 s])

3. Funkcija f(t) je podana s grafom 
	a. Izrazi funkcijo s pomocjo Piecewise in narisi graf.
	b. Doloci njeno Laplacovo transformacijo.
	c. Resi enacbo 4 x(t)+x''(x)==f(t), x(0)=0,x'(0)=0  in narisi graf resitve.

Clear[f,t,s]
f[t_]=Piecewise[{{2t,0≤t≤1},{3-t,1<t≤2},{1,t>2}},0];
Plot[f[t],{t,-1,4}]
LaplaceTransform[f[t],t,s]
LaplaceTransform[x''[t]+4x[t]==f[t],t,s]/.x[0]->0/.x'[0]->0;
Solve[%,LaplaceTransform[x[t],t,s]]
InverseLaplaceTransform[%,s,t]
Plot[x[t]/.%,{t,0,15}]

4. Resi diferenecialno enacbo pri danih zacetnih pogojih:
	Derivative[3][y](t)-2 y''(t)+y'(t)==4,y''(0)==1,y'(0)==2,y(0)==-2

eqn=y'''[t]-2y''[t]+y'[t]==4; 
cnd={y''[0]->1,y'[0]->2,y[0]->-2};
LaplaceTransform[eqn,t,s]/.cnd
Solve[%, LaplaceTransform[y[t],t,s]]
InverseLaplaceTransform[%,s,t]

5. Resi sistem diferencialnih enacb pri danih zacetnih pogojih:
	x'(t)==y(t)-z(t),
	y'(t)==x(t)+z(t),
	z'(t)==y(t)-z(t),
	x(0)==1,y(0)==0,z(0)==-1.

6. Resi integralsko enacbo: x(t)==(1/2) (∫_0^t)x(u) sin(t-u)du+1.

eqn = x[t] == 1 + 1/2Integrate[x[u]Sin[t-u], {u, 0, t}];
LaplaceTransform[eqn, t, s]
Solve[%, LaplaceTransform[x[t], t, s]]
InverseLaplaceTransform[%, s, t]

7. Resi diferencialno enacbo: x''(t)+x(t)==f(t), x(0)=0, x'(0)=0, kjer je funkcija f(t) podana z grafom:

f[t_]=Piecewise[{{1,0≤t≤1},{-1,1≤t≤2}},0];
eqn=x''[t]+x[t]==f[t];
LaplaceTransform[eqn,t,s]
Solve[%,LaplaceTransform[x[t],t,s]]
InverseLaplaceTransform[%,s,t]/.x[0]->0/.x'[0]->0//FullSimplify
Plot[x[t]/.%,{t,0,14}]