1+1

a=1
β=d

Sin[4]

Series[Sin[x],{x,0,10}]

Sin[4.]

N[Sin[4],100]
Sin[4]//N

Pi

π

lubos=3;

franta=5;

ClearAll[lubos]

Pi=3

DSolve[x''[t]+5x'[t]+4x[t]== ((Sin[Cos[t]])/(E^t)),x[t],t]

DSolve[x''[t]+5x'[t]+4x[t]==((Sin[Cos[t]])/(E^t)),x[t],t]

DSolve[{x'[t]==Sin[t],x[0]==1},x[t],t]

Solve[{x+y==4, 3x-y==4},{x,y}]

{x+y==4, 3x-y==4}//TreeForm

list={{a,b},{c,d},e};

list[[1]]

list[[2]]

list[[1,2]]

list[[-1]]==list[[3]]

rce=Sin[x]==0;

Solve[rce,x]

FindRoot[rce,{x,1}]

FindRoot[rce,{x,2}]

Plot[{2,Sin[x],Log[x],(E^(-x))},{x,0,10},PlotStyle->{{Blue,Dashed},{Red},{Purple,Thick},{Orange,Dotted}},AxesLabel->{"osa x","osa y"}]

(*Zde začíná druhé cviko*)

resUkol=Solve[{a+b==k,(a^2)-b==2},{a,b}]

a/.a->3

a+b/.{a->3,b->2}

a/.{a->2,a->3}

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

x/.res[[2]]

proPlot1res={a,b}/.resUkol[[1]]

proPlot2res={a,b}/.resUkol[[2]]

gr1=Plot[proPlot1res,{k,0,5}]

gr2=Plot[proPlot2res,{k,0,5}]

Show[gr1,gr2]

proPlot3=Union[proPlot1res,proPlot2res]

Union[{a,b,c,d},{b,c,e,f}]

xxx=3;
Plot[proPlot3,{k,0,5},AxesLabel->{"xxx","yyy"},PlotLabel->"Graph",PlotStyle->{{Thick,RGBColor[0,1,0.5]},{Thick,Blue},{Thick,Dashed},{Hue[0.25],Dashed}}]

Manipulate[Graphics[{Hue[k],Disk[]}],{k,0,1,0.002}]

Manipulate[Graphics[{RGBColor[red,green,blue],Rectangle[]}],{red,0,1,0.002},{green,0,1,0.002},{blue,0,1,0.002}]

Manipulate[Plot[A*Sin[2Pi*f*t+fi]+str,{t,-0.01,0.04},PlotRange->{Automatic,{-1,1}}],{A,0,1},{f,50,100,10},{fi,0,2Pi},{str,-2,2}]

Table[{i,(i^2),(i^3),(Sqrt[i]),i},{i,1,100,5}];

proListPlot=Table[{i,(i^2)},{i,-5,5,0.1}];
ListPlot[proListPlot,AxesLabel->{"xxx","yyy"},PlotLabel->"Graph",PlotStyle->{PointSize[0.05],Green},Joined->True]

proListPlot=Table[{i,(i^2)+Random[Real,{-5,5}]},{i,-5,5,0.1}];
ListPlot[proListPlot,AxesLabel->{"xxx","yyy"},PlotLabel->"Graph",PlotStyle->{PointSize[0.01],Green}]

(*zde zacina 3. cviceni*)

rce={y'''[t]+4y''[t]+2y'[t]-y[t]==4(E^(-3t)),y[0]==1,y'[0]==4,y''[0]==2};

res=y[t]/.DSolve[rce,y[t],t][[1]]

Plot[res,{t,0,100},PlotLabel->"graf",AxesLabel->{"t","y"},PlotStyle->{Green,Thick},PlotRange->All]

polynom[{k_}]:=0==Plus@@Table[(Subscript[a, i])*(x^i),{i,0,k}]

Solve[polynom[{1}],x]

polynom2[k_]:=Module[{polnom,res},
polnom=0==Plus@@Table[(Subscript[a, i])*(x^i),{i,0,k}];
res=Solve[polnom,x];
x/.res
]

polynom2[6]

rce={UA[t]==U,((UA[t]-UB[t])/R)==kap*D[UB[t],t],UB[0]==0}/.{U->5,R->1,kap->10*(10^(-3))};
res=DSolve[rce,{UB[t],UA[t]},t];
Plot[{UA[t]/.res,UB[t]/.res},{t,0,.1},PlotRange->All]

(*Zde zacína ctvrté cvičení 12.3.2018*)

res=y[t]/.DSolve[{5y'[t]+4y[t]==Cos[t]+Sin[t],y[0]==1},y[t],t][[1]];
Plot[res,{t,0,10},PlotStyle->{Green,Thick},AxesLabel->{"osa x","osa y"}]

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

x=3;

graf=Plot[res,{t,0,10},PlotStyle->{Green,Thick},AxesLabel->{"osa x","osa y"}]

SetDirectory[NotebookDirectory[]]
Export["Graf3cv.jpg",graf,ImageResolution->300]

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

graf=Plot[res,{t,0,100},PlotStyle->{Green,Thick},AxesLabel->{"osa x","osa y"},PlotRange->All]

resNDSOLve=y[t]/.NDSolve[{5y'[t]+4y[t]==Cos[t]+Sin[t],y[0]==1},y[t],{t,0,100}][[1]]

Plot[resNDSOLve,{t,0,100}]

NDSolve[{5y'[t]+4Sin[y[t]]==Cos[t]+Sin[t],y[0]==1},y[t],{t,0,100}][[1]]

DSolve[{5y'[t]+4Sin[y[t]]==Cos[t]+Sin[t],y[0]==1},y[t],t]

(*obvod z tabule- bilance proudu*)

rceUzly={
iL1[t]==iC1[t]+iR2[t]+iUz2[t],(*uzel 1*)
iR1[t]==iL1[t],(*uzel 2*)
iz1==iR1[t],(*uzel 3*)
iUz1[t]+iz1==iR4[t],(*uzel 4*)
iR4[t]==iC2[t](*uzel 5*)
};

(*obvod - soucastky*)

rceSouc={
iR1[t]==((u3[t]-u2[t])/R1),(*R1*)
iR2[t]==((u1[t]-0)/R2),(*R2*)
iR4[t]==((u5[t]-u4[t])/R4),(*R4*)
u2[t]-u1[t]==L1*iL1'[t],(*L1*)
iL1[0]==0,
iC1[t]==c1*u1'[t],(*C1*)
u1[0]==0,
iC2[t]==c2*u5'[t],(*C2*)
u5[0]==0,
uz1==0-u4[t],
uz2==u1[t]-0
};

(* 5. cv. 19.3.2018 16:15 *)

souc={R1->10,R2->5,R4->2,c1->10*(10^(-6)),c2->25*(10^(-6)),L1->1 *(10^(-3))};

(*zdroje={uz1->5,uz2->20,iz1->1};*)
zdroje={uz1->5*Sin[50*Pi*2*t],uz2->E*Cos[50*Pi*2*t],iz1->0.05*Sin[50*Pi*2*t]};

rceDohr=Union[rceUzly,rceSouc]/.souc/.zdroje
nezname=Union[Cases[rceDohr,_Symbol[t],{1,Infinity}]];

{Length[rceDohr],Length[nezname]}
sol=NDSolve[rceDohr,nezname,{t,0,0.1},StartingStepSize->(10^(-10))][[1]]

Plot[u3[t]-u2[t]/.sol,{t,0,0.1},AxesOrigin->{0,0}]

ClearAll["Global`*"]

R1=100;
R2=200;
c=0.001;
L=0.2;
Iz=10*Sin[314*t+0.1];
(*Iz=10;*)
Uz=150*Sin[314*t];
(*Uz=150;*)

Uzly={IUz[t]==IL[t]+IR1[t],IR2[t]==IL[t]+Iz,IR1[t]==Iz+IC[t]};

Souc={Uz==-U1[t],U2[t]==R2*IR2[t],U1[t]-U3[t]==R1*IR1[t],U1[t]-U2[t]==L*D[IL[t],t],IC[t]==c*D[UC[t],t],UC[t]==U3[t]};

pom=Union[Uzly,Souc];
nezname=Cases[pom,_Symbol[t],{0,∞}]//Union;
{Length[pom],Length[nezname]};
poc=Cases[pom,a_'[t]:>a[0]==0,{0,∞}]//Union;
dohr=Union[pom,poc];
tmax=0.2;

res=NDSolve[dohr,nezname,{t,0,tmax},StartingStepSize->(10^(-15)),Method->{"IndexReduction"->Automatic},MaxSteps->(10^7)];

Plot[{IL[t]/.res,IC[t]/.res},{t,0,0.02}]

$HistoryLength=4;
SetDirectory[NotebookDirectory[]]

x=5
x+5

%

%/2

%/2

data=Import["scope0.xls"][[1]];

PrubehIaU=Show[ListLinePlot[Thread[{data[[All,1]],data[[All,2]]}],PlotStyle->{Purple,Thickness[0.002]},AspectRatio->0.4],ListLinePlot[Thread[{data[[All,1]],300*data[[All,3]]}],PlotStyle->{Orange,Thickness[0.002]}],AxesOrigin->{Min[data[[All,1]]],0},GridLines->Automatic,AxesStyle->{Thickness[0.002],Thickness[0.002]},AxesLabel->{"t [s]","Ui [V], I [A] /300"}]

ClearAll[Evaluate[Context[]<>"*"]]

uzly={
iL1[t]==ic1[t]+iR3[t]+iR2[t],
0==iL1[t]+iR1[t],
iR1[t]-iUz[t]==0,
iUz[t]+iR2[t]+iz==0
};
sou={
u3[t]-u2[t]==-iR1[t]*R1,
u1[t]-u4[t]==iR2[t]*R2,
u1[t]==iR3[t]*R3,
u2[t]-u1[t]==L1*iL1'[t],
iL1[0]==0,
ic1[t]==c1*u1'[t],
u1[0]==0,
u3[t]-u4[t]==Uz
};
hod={iz->0.05,Uz->5*(Sqrt[2])*Sin[2*Pi*50*t],R1->10,R2->470,R3->1000,c1->(10^(-5)),L1->(10^(-3))};
rceDohr=Union[uzly,sou]/.hod

nezname=Cases[rceDohr,_Symbol[t],{0,∞}]//Union
{Length[rceDohr],Length[nezname]}

res=NDSolve[rceDohr,nezname,{t,0,0.1},Method->{"IndexReduction"->{True, "ConstraintMethod"->"Projection"}}];

Plot[{ic1[t]/.res,u1[t]/.res},{t,0,0.05}]

(* 6.cv 26.3.2018 16:15 *)

par[listZ_]:=((((listZ^(-1))/.List->Plus))^(-1));
ser[listZ_]:=listZ/.List->Plus;

par[{a,b,c}]
ser[{d,e,f}]

Z1=ser[{R1,R3,I*ω*L2,par[{I*ω*L1,R2,(1/(I*ω*c1))}]}];
Z2=par[{ser[{R5,I*ω*L4}],ser[{R4,(1/(I*ω*c3))}],ser[{(1/(I*ω*c3)),I*ω*L3}]}];

dos={R1->10,R2->1700,R3->47,R4->680,R5->4.7,c1->(10^(-6)),c2->100*(10^(-6)),c3->100*(10^(-9)),L1->470*(10^(-3)),L2->4.7*(10^(-3)),L3->10*(10^(-3)),L4->50*(10^(-3))};

prenos=(Z2/(Z1+Z2))/.dos;

LogLogPlot[Abs[prenos],{ω,(10^(-2)),(10^5)},GridLines->Automatic]

LogLinearPlot[Arg[prenos],{ω,(10^(-2)),(10^5)}]

Plot[Sin[t],{t,-2Pi,4Pi},Ticks->{{-2Pi,-Pi,0,Pi,2Pi,3Pi,4Pi},Automatic}]

rceUzly={
iUz1==iR,
iR==iC+iL,
iC+iUz2==0
};
rceSouc={
u1==uA,
u2==uC,
uA-uB==R*iR,
uB==I*ω*L*iL,
uB-uC==(1/(I*ω*c))
};
souc={
R->1,L->20*(10^(-3)),c->100*(10^(-6)),u1->10*(E^(I*0.1)),u2->5*(E^(I*0.9)),ω->100Pi
};
rce=Union[rceSouc,rceUzly]/.souc;

res=Solve[rce];

prodCivka=iL/.res[[1]];
napetiCivka=uB/.res[[1]];

Plot[{Im[prodCivka*(E^(I*314*t))],Im[napetiCivka*(E^(I*314*t))]},{t,0,0.06},PlotStyle->{{Thick,Red},{Thick,Blue}}]

(1./(Sqrt[L*c]))/.souc

Plot[230*(Sqrt[2])Tanh[2Sin[314*t]],{t,0,0.02}]

sum[n_]:=Plus@@Table[(1/k)*Sin[k*314*t+k*0.5],{k,1,n}]
Manipulate[Plot[sum[k],{t,-0.02,0.04}],{k,1,20,1}]

sum[3]