1+1

2+4

6+1
a+b

(Sqrt[5])

(25^(1/4))

(Sqrt[5.])

N[(Sqrt[5])]

N[(Sqrt[5]),20]

?Sin

(a+1)-(b-c)
((a+1)-(b-c))*(a/3)

MatrixForm[{{2,4},{5,13}}]

ClearAll[a,b,soucet](*tohle je komentar*)
a=5;
b=7;
soucet=a+b
2*soucet
soucet1

a=3

ClearAll[a]

Sin[Pi/3]
N[Sin[Pi/3],50]

LaplaceTransform[(E^(t+2))*(t^4)+Sin[2*t+0.4],t,s]

e;
E;
N[E];
E//N;
N@E;

100!//N

Plot[(t^4)*Cos[5*t+1]-3,{t,0,3Pi}]

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

(*2.cviceni*)

mujlist={1,2,{auto,pocitac,{hop,skok}},Praha,Brno};
mujlist[[1]]
mujlist[[3]]
mujlist//TreeForm

mujlist[[3,1]]
mujlist[[3]][[1]]

mujlist//Length

mujlist[[-1]]

mujlist[[6]]

mujlist[[0]]

xylist={y,x,y,y,x,x,x,y}

xylist/.x->3

prirazeni={a->1,b->3,x->10,z->-2}

xylist/.prirazeni

xylist/.{x->1,x->3}
xylist/.{x->s,s->5}
(*xylist//.{x->s,s->5}
xylist//.{x->s,s->x}*)(*pro zajimavost*)

rce=(x^4)+((x^2)/(k^2))+k*x+(2/3)==0;
res=Solve[rce,x];
x1=x/.res[[1]];
x2=x/.res[[2]];
x3=x/.res[[3]];
x4=x/.res[[4]];
soucet=Abs[x1]+Abs[x2]+Abs[x3]-Abs[x4];
Plot[soucet,{k,-5,5},PlotStyle-> {Orange,Thick,DotDashed},AxesLabel->{"k","f(k)"},GridLines-> Automatic]

res=Solve[{2(x^2)-(y^2)-(3/5)==4k,y-(x^2)==k},{x,y}];
xka=x/.res;
Plot[xka,{k,-15,1},PlotStyle-> {{Blue,Thick},{Red,Thick},{Black,Thick,Dashed},{Brown,Thick,Dashed}},GridLines-> Automatic, AxesLabel-> {"k","f(k)"}]

xka

ClearAll[f,g]
f[x_]:=(x/3)*Tanh[2x+1]
g[psi_]:=((Sin[psi]+psi)/(Cos[psi]-(psi^2)))
Plot[g[6*f[((Sqrt[t+1])/t)]],{t,1,9},PlotStyle-> {Green,Thick,Dashed},GridLines-> Automatic,AxesLabel-> {"t","g(6*f(((Sqrt[t - 1])/t)))"}]

(*Treti cviceni*)

res=x/.Solve[((x*t)/5)+(((2*t*x))^2)-((4(x^3))/((t^3)-3))==Tanh[(t^2)],x][[1]];
f[t_]=((Abs[res[[1]]]-Abs[res[[2]]])/(1-Abs[res[[3]]]));
Plot[f[(1/3)*(Sin[2*x]+Cos[(x/2)])],{x,-20,20},PlotStyle-> {Green,Thick},GridLines-> Automatic,AxesLabel-> {"x","f(x)"}]

res=Solve[((x*t)/5)+(((2*t*x))^2)-((4(x^3))/((t^3)-3))==Tanh[(t^2)],x];
Length[%];
x1=x/.res[[1]];
x/.res[[1]];

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

FindRoot[Sin[x]==x,{x,20}]

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

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

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

ClearAll[f,g]
f[fce_,x0_]:=fce'[x0]*(x-x0)+fce[x0];
g[t_]:=(t^3)-3(t^2);
Plot[{f[g,1],g[x]},{x,-1,3},PlotStyle-> {{Blue,Dashed},{Red,Thick}},GridLines-> Automatic,AxesLabel-> {"x","f(x)"},Epilog->{PointSize[Medium],Point[{1,g[1]}]},PlotRange-> {Automatic,{-6,2}}]

Manipulate[
Plot[{f[g,Man],g[x]},{x,-1,3},PlotStyle-> {{Blue,Dashed},{Red,Thick}},GridLines-> Automatic,AxesLabel-> {"x","f(x)"},Epilog->{PointSize[Medium],Point[{Man,g[Man]}]},PlotRange-> {Automatic,{-6,2}}] ,{Man,-1,3}
]

rada=Table[{i,(Sqrt[i])},{i,0,10,1}];

list={2,5,8,9,12};
ListPlot[list];

body=ListPlot[rada(*,Joined->True*)];
proklad=Fit[rada,{1,(Sqrt[x])},x]
Show[body,Plot[proklad,{x,0,10}]]

SeedRandom[1]
radaNova=Table[{i,(Sqrt[i])+Random[]},{i,0,10,.1}];

bodyNova=ListPlot[radaNova,PlotStyle->{PointSize[.01],Green}];
prokladNova=Fit[radaNova,{1,(Sqrt[x]),x},x];
graf=Plot[prokladNova,{x,0,10},PlotStyle->Red];
Show[bodyNova,graf]

bodyNova=ListPlot[radaNova];
prokladNova=Fit[radaNova,Table[(x^i),{i,0,4,1}],x];
graf=Plot[prokladNova,{x,0,10},PlotStyle->Red];
Show[bodyNova,graf]

(*Ctvrte cviceni*)

f[a_]:=FindRoot[Cos[x]==a*x,{x,1}]
vysl=Table[{a,x/.f[a]},{a,1,20,0.5}];
(*vysl=Table[{a,f[a][[1,2]]},{a,1,20,0.5}]*)
ListPlot[vysl](*,PlotStyle-> {Red,PointSize[0.05]},AxesLabel-> {"x","f(x)"},PlotRange-> All]*)

(*4. cviceni*)

R1=100;
R2=230;
R3=90;
L1=50*(10^(-3));
L2=(10^(-2));
C1=(10^(-6));
C2=5*(10^(-7));
Uz=Tanh[50*Sin[314*t+0.2]];
Iz=0.06*Sin[314*t];

Plot[{Uz,100*Iz},{t,0,0.040}];

Plot[Uz,{t,0,0.040}];

rceUzly={Iuz[t]==IR1[t],IR1[t]==IL1[t],IL1[t]==IC1[t]+IR3[t]-Iz,IC1[t]-IC2[t]-IR2[t]==0,IC2[t]-IL2[t]==0};

rcePrvky={R1*IR1[t]==U1[t]-U2[t],L1*D[IL1[t],t]==U2[t]-U3[t],IC1[t]==C1*Uc1'[t],Uc1[t]==(U3[t]-U4[t]),IC2[t]==C2*Uc2'[t],Uc2[t]==U4[t]-U5[t],R2*IR2[t]==U4[t],L2*D[IL2[t],t]==U5[t],IR3[t]*R3==U3[t],Uz==U1[t]};

rcePP={IL1[0]==0,IL2[0]==0,Uc1[0]==0,Uc2[0]==0};

Union[{1,3,5,8,9,2,3,5,9}];

rce=Union[rceUzly,rcePrvky,rcePP];
nezname=Union[Cases[rce,_Symbol[t],{0,Infinity}]];
rce//TreeForm;
tmax=0.1;
res=NDSolve[rce,nezname,{t,0,tmax},StartingStepSize->(10^(-9))][[1]];

Plot[{Uz,Uc1[t]/.res},{t,0,tmax},PlotStyle->{{Black,Thick},{Red,Thick}},AxesLabel->{"t [s]","U[V]"},PlotLegends->{"Uz","Uc1"}]

R1=1500;
R2=2000;
L=0.2;
kap1=0.5*(10^(-12));
kap2=22*(10^(-6));
Uz=150*Sin[314*t-0.6];

rceSoucastky={Uz==-U1[t],U1[t]-U2[t]==R1*IR1[t],IC1[t]==kap1*U2'[t],U2[t]-U3[t]==L*IL'[t],U3[t]==R2*IR2[t],IC2[t]==kap2*U3'[t]};
rceUzly={Iz[t]==IR1[t],IR1[t]==IL[t]+IC1[t],IL[t]==IR2[t]+IC2[t]};
rcepoc={IL[0]==0,U3[0]==0,U2[0]==0};

rce=Union[rceSoucastky,rceUzly,rcepoc];
nezname=Union[Cases[rce,_Symbol[t],{0,Infinity}]];
tmax=0.1;
res=NDSolve[rce,nezname,{t,0,tmax},StartingStepSize->(10^(-15)),MaxStepSize->(10^9)][[1]];

Plot[{Uz,U3[t]/.res},{t,0,tmax},PlotStyle->{{Blue,Thick},{Red,Thick}},AxesLabel->{"t [s]","U [V]"},PlotLegends->{"Uz","Uvyst"}]

(*5.cviceni*)

R1=1000;
R2=2000;
R3=3000;
C1=20*(10^(-6));
C2=220*(10^(-6));
L=12*(10^(-3));
Iz=0.6*Sin[314*t+0.6];
Uz=112*Sin[314*t+0.1];

rceUzl={IR1[t]==-Iu[t],Iu[t]+IR3[t]==0,IR3[t]+IC1[t]+Iz==0,IC1[t]==IL[t]+IR2[t],IL[t]+IR3[t]==IC2[t]};
rceSouc={U1[t]-U3[t]==R1*IR1[t],U4[t]==R2*IR2[t],U2[t]-U5[t]==R3*IR3[t],U4[t]-U5[t]==L*D[IL[t],t],UC1[t]==U3[t]-U4[t],IC1[t]==C1*D[UC1[t],t],UC2[t]==U5[t],IC2[t]==C2*D[UC2[t],t],Uz==-(U1[t]-U2[t])};
pocPodm={IL[0]==0,UC1[0]==0,UC2[0]==0};

rce=Union[rceUzl,rceSouc,pocPodm];
nezname=Union[Cases[rce,_Symbol[t],{0,Infinity}]];
tmax=0.1;
res=NDSolve[rce,nezname,{t,0,tmax},StartingStepSize->(10^(-15)),MaxSteps->(10^9)];
grafCas=Plot[{Iz,IL[t]/.res},{t,0,tmax},PlotStyle->{{Red,Thick},{Blue,Thick}},AxesLabel->{"t [s]","Iz, IL [A]"},PlotLegends->{"Iz","IL"}]

rceSouc

rceSoucHUS=rceSouc/.{Symbol_'[t]:>Symbol*314*I,a_*Sin[b_*t+c_]:>a*(E^(I*c)),Symbol_[t]:>Symbol};

rceUzlHUS=rceUzl/.{Symbol_[t]:>Symbol,a_*Sin[314*t+c_]:>a*(E^(I*c))}

rovniceHUS=Union[rceSoucHUS,rceUzlHUS];

nezname=Union[Cases[rovniceHUS,_Symbol,{0,Infinity}]];

reseniHUS=Solve[rovniceHUS,nezname][[1]]

grafHUS=Plot[{Im[(IL/.reseniHUS)*(E^(I*314*t))],Iz},{t,0,tmax}]

mujgraf=Show[grafCas,grafHUS]

SetDirectory[NotebookDirectory[]]

Export["mujgraf.png",mujgraf,ImageResolution->300]

Export["mujgraf.jpg",mujgraf]

SetDirectory[NotebookDirectory[]]

data=Import["scope_7.csv"];

data2=Cases[data,{_Real,_Real,_Real,_Real}];

proudnacase=data2/.{t_,u1_,i_,u2_}:>{t,i};

{{1,3,5,8},{5,9,9,1},{4,8,9,2},{1,1,1,1}}/.{t_,u1_,i_,u2_}:>{t,i}

{{1,3,5,8},{5,9,9,1}}/.{t_,u1_,i_,u2_}:>{t,i*u1}

ListPlot[proudnacase]

proudnacase[[1]]
proudnacase[[11]]

n=Length[proudnacase]

kazdy10=Table[proudnacase[[i]],{i,1,n,10}];

ListPlot[kazdy10]

interproud=Interpolation[kazdy10];
{tmin,tmax}=interproud[[1,1]];
Plot[interproud[t],{t,tmin,tmax}]

(*Cviceni 7*)

ClearAll["Global`*"];
par[list_]:=(((Plus@@(list^(-1))))^(-1));
ser[list_]:=Plus@@list;
k=1000;
μ=(10^(-6));
m=0.001;

R1=300k;
R2=R2=R3=R4=100k;
C1=1.5μ;
C2=5μ;
C3=4μ;
L1=10m;
L2=8m;
L3=9m;

za=ser[{R1,I*ω*L1}];
zb=par[{za,(1/(I*ω*C1))}];
z1=ser[{zb,R2,(1/(I*ω*C2))}];
zc=ser[{R3,I*ω*L2}];
zd=ser[{R4,I*ω*L3,(1/(I*ω*C3))}];
z2=par[{zc,zd}];
prenos=(z2/(z1+z2));

LogLogPlot[Abs[prenos],{ω,0.1,(10^10)},PlotStyle->{Thick,Orange},AxesLabel->{"ω [(s^(-1))]","Abs[P] [-]"},GridLines->Automatic]