(*1.cviceni 22. 2. 2016*)
1+1

1+2

(* Takto se pise komentar. *)

(Sqrt[2])

(Sqrt[2.])

N[(Sqrt[2])]

Sin[1.5]

N[(Sqrt[2]),50]

LaplaceTransform
laplacetransform

a=5
b=3

a*b

c*d

c*a

Clear[a]

E=5

E

N[E]

21a

a21

a+6*f*(5+1a-(5-f))

{7,3,5}

Solve[2*x+y==4,3*x+y==5,x,y]

Solve[{2*x+y==4,3*x+y==5},{x,y}]

List[1,2.3,5]

TreeForm[{{5.5,5,8},3,{1,2,8.9,{4,5}}}]

DSolve[{y''[x]+(3+x)*y'[x]+2*y[x]==(x^2)+1,y[0]==1,y'[0]==2},y[x],x]

(*zkratky: (Sqrt[\[Placeholder]]) ctrl+2, (x^\[Placeholder]) ctrl+6, (\[Placeholder]/\[Placeholder]) ctrl+/*)

(*recka pismena: κ Esc+pismeno+Esc)*)

N[π]

π//N

N@π

Plot[{Sin[x],Cos[x],Sin[x]*Cos[x]},{x,0,6Pi}]

(*zde zacina cviceni 2, 29.2.2016*)

Solve[{a*(x^2)+3*y+4==0,x+y-4==0},{x,y}]

Plot[((3-(Sqrt[9-64 a]))/(2 a)),{a,-10,5}](*chyba v syntaxi*)

res=Solve[{a*(x^2)+3*y+4==0,x+y-4==0},{x,y}]

{1,5,4,8,9}[[4]]
{1,5,4,{1,9,5,4},9}[[4,2]]

res[[2]]

x+y/.{x->3, y->5}

z+y/.{x->3, y->5}

x/.{x->3,x->4}

x/.{x->3,x->4}[[2]]

x1=x/.res[[1]];

x2=x/.res[[2]];
y1=y/.res[[1]];
y2=y/.res[[2]];

Plot[{x1,x2,y1,y2},{a,-5,10},AxesLabel->{"a","x1, x2, y1, y2"},PlotStyle->{{Red,Thick},{Green,Dashed},RGBColor[0.4,0.1,0.6],Hue[0.3]},PlotRange->{Automatic,{-10,15}}]

Plot[{x1,x2,y1,y2},{a,-5,10}]

Solve[a*(x^2)+b*x+c==0,x]

Plot[2*(x^2)+3*x+1,{x,-5,5}]

Manipulate[Plot[a*(x^2)+b*x+c,{x,-5,5},PlotRange->{Automatic,{-10,10}}],{a,-1,1},{b,-2,2},{c,-5,5}]

res=y[t]/.DSolve[{y''[t]+2y'[t]+3y[t]==Sin[3t],y[0]==5,y'[0]==4},y[t],t][[1]];

Plot[res,{t,0,15},PlotStyle->{Red,Thick,Dashed},AxesLabel->{"t","y"}]

resDif=DSolve[{y''[t]+2*y'[t]+3*y[t]==Sin[3*t],y[0]==5,y'[0]==4},y[t],t];

proPlotDif=y[t]/.resDif[[1]];

Plot[proPlotDif,{t,0,15},PlotStyle->{Red,Thick,Dashed},AxesLabel->{"t","y"}]

Plot[Evaluate[y[t]/.DSolve[{y''[t]+2*y'[t]+3*y[t]==Sin[3*t],y[0]==5,y'[0]==4},y[t],t][[1]]],{t,0,15},PlotStyle->{Red,Thick,Dashed},AxesLabel->{"t","y"}]

ClearAll[funkce]
funkce[a_]:=(a^2)

funkce[5]

funkce[k]

funkce[a_,b_]:=a+b

funkce[5]

funkce[5,2]

funkce[{a_,b_}]:=a*b

funkce[5,2]

funkce[{5,2}]

(*treti cviceni 7.3.2016*)

res=Solve[a*(x^3)+b*(x^2)+c*x+d==0,x];

x1=x/.res[[1]];
x2=x/.res[[2]];
x3=x/.res[[3]];

dosad={b->2.,c->3.,d->4.};
x1Plot=x1/.dosad;
x2Plot=x2/.dosad;
x3Plot=x3/.dosad;

Plot[{Abs[x1Plot],Abs[x2Plot],Abs[x3Plot]},{a,2,6},AxesLabel->{"a","x1, x2, x3"},PlotStyle->{{Thick,Red},{Thick,Red},{Thick,Red}}]

ClearAll[fceKubicka]
fceKubicka[b_,c_,d_]:=Module[{res,a,x,x1,x2,x3},
res=Solve[a*(x^3)+b*(x^2)+c*x+d==0,x];
x1=x/.res[[1]];
x2=x/.res[[2]];
x3=x/.res[[3]];
Plot[{Abs[x1],Abs[x2],Abs[x3]},{a,2,6},AxesLabel->{"a","x1, x2, x3"},PlotStyle->{{Thick,Red},{Thick,Red},{Thick,Red}}]
]

fceKubicka[2,3,4]

fceKubicka[4,3,2]

data=Table[{i,(Sqrt[i])},{i,1,15,0.5}];

a=ListPlot[data,PlotStyle->{Red,PointSize[0.025]},PlotLabel->"Graf",AxesLabel->{"x","y"}];

line = Fit[data, {(Sqrt[x])},x];

b=Plot[line,{x,0,15},PlotStyle->{Blue,Thick}];

Show[a,b]

SeedRandom[1];
data2=Table[{i,(Sqrt[i])+Random[]*2},{i,1,15,0.5}];

a=ListPlot[data2,PlotStyle->{Red,PointSize[0.025]},PlotLabel->"Graf",AxesLabel->{"x","y"}];

line2 = Fit[data2, {(Sqrt[x])},x];

b=Plot[line2,{x,0,15},PlotStyle->{Blue,Thick}];

Show[a,b]

proFit=Table[(x^i),{i,0,100,1}];
line3=Fit[data2, proFit,x]
b=Plot[line3,{x,0,15},PlotStyle->{Blue,Thick}];
Show[a,b]

FindRoot[Sin[x]==0,{x,Pi/2}]

Solve[Sin[x]==0,x]

FindRoot[(x^3)==27.,{x,1}]

(*Zde zacina 4. cv  14.3. *)

R1=100;
R2=1000;
R3=0.5;
kap=20*(10^(-6));
L=3*(10^(-3));
Uz1=40Tanh[50*Sin[314*t]];
Uz2=65;
Iz=2*Sin[314*t];
Uzly={IU1[t]==IR1[t]+IL[t],IR1[t]==IR2[t],IU2[t]+Ic[t]==0,0==Ic[t]+IR2[t]+Iz,IL[t]+IR2[t]==IR3[t]};

Soucastky={(*R1*)U1[t]-U2[t]==R1*IR1[t],(*R2*)U4[t]-U5[t]==R2*IR2[t],(*R3*)U5[t]==R3*IR3[t],(*L*)U1[t]-U5[t]==L*D[IL[t],t],(*C*)
U4[t]-U3[t]==Uc[t],Ic[t]==kap*(D[Uc[t],t]),Uz1==0-U1[t],Uz2==U2[t]-U3[t]};
PocPodm={IL[0]==0,Uc[0]==0};

rce=Union[Uzly,Soucastky,PocPodm];
nezname=Union[Cases[rce,_Symbol[t],{1,Infinity}]];

rce//TreeForm;

res=NDSolve[rce,nezname,{t,0,0.6},StartingStepSize->(10^(-12)),MaxSteps->100000];

proPlot={Uc[t],IL[t],Uz1,U1[t]-U5[t]}/.res;

Plot[proPlot,{t,0,0.06},PlotStyle->{Red,Green,Blue,Orange},PlotRange->All]

Manipulate[Plot[Tanh[k*Sin[314*t]],{t,0,0.04}],{k,1,100}]

(*Zde zacina cv.4 21.3.2016*)

ClearAll[Uz,R1,R2,L1,C1]

Uz=231*(Sqrt[2])*Sin[314*t+0.4];

R1=0.5;
R2=((-2Tanh[1000(t-0.04)]+2)/2);
L1=1*(10^(-3));
C1=10*(10^(-6));

rceUzly={Iuz[t]==IR1[t],IR1[t]==IR2[t]+Ic[t],IR2[t]==IL[t]};
pocPodm={U2[0]==0,IL[0]==0.5};
rceSoucastky={U1[t]-U2[t]==R1*IR1[t],U2[t]-U3[t]==R2*IR2[t],Ic[t]==C1*U2'[t],U3[t]==L1*IL'[t],U1[t]==Uz};

rce=Union[rceUzly,rceSoucastky,pocPodm];
nezname=Union[Cases[rce,_Symbol[t],{1,Infinity}]];

res=NDSolve[rce,nezname,{t,0,0.1},StartingStepSize->(10^(-12)),MaxSteps->1000000];

proPlot={nezname}/.res;
grafCasova=Plot[proPlot,{t,0,0.06},PlotStyle->{Red,Green,Blue,Orange},PlotRange->All]

sinusovka=Um*Sin[ω*t+fi]

D[sinusovka,t]

Uz=231*(Sqrt[2])*(E^(I*0.4));

R1=0.5;
R2=2;
L1=1*(10^(-3));
C1=10*(10^(-6));
ω=314.;

rceUzlyHUS={Iuz==IR1,IR1==IR2+Ic,IR2==IL};
rceSoucastkyHUS={U1-U2==R1*IR1,U2-U3==R2*IR2,Ic==C1*U2*ω*I,U3==L1*IL*ω*I,U1==Uz};
rceVseHUS=Union[rceUzlyHUS,rceSoucastkyHUS];

nezname={Ic,IL,IR1,IR2,Iuz,U1,U2,U3};

resHUS=Solve[rceVseHUS,nezname]

proPlotHUS=Im[{Ic,IL,IR1,IR2,Iuz,U1,U2,U3}*(E^(I*ω*t))/.resHUS[[1]]]

ComplexExpand[proPlot]

grafHUS=Plot[proPlotHUS,{t,0,0.06}]

Show[grafCasova,grafHUS]

Plot[((-2Tanh[1000(t-0.04)]+2)/2),{t,0,0.06}]

R11+R22+((I*ω*L*I*ω*kap)/(I*ω*L+I*ω*kap))

.