ClearAll["Global`*"];
SetDirectory[NotebookDirectory[]];
$HistoryLength=3;

vyr=(x^2)+Sin[a+Log[7]];

TreeForm[vyr];

a+b//TreeForm;

a+b=5

FullForm[vyr]

nahoda1=Random[]

?nahoda1

?:=

nahoda2:=Random[]
?nahoda2

a==b//FullForm

?===

1==1

?_

ClearAll[f];
f[x_]:=5+x;
f[u]

ClearAll[f];
x=10;
f[x_]=5+x
?f

ClearAll[f,x];
f[x_]:=Integrate[x*Sin[((x^2)/((x^2)+1))],x];
f[1]

ClearAll[f]
f[x_]:=(x^2);
f[0]:=5;
f[x_,y_]:=(x^y);
f[x_,x_]:=2x;
f[0,0]:=4;

f[E,E]

g[x_,y_]:=x+y;
?g

ClearAll[myFact];
myFact[n_]:=n*myFact[n-1];
myFact[0]:=1;

Trace[myFact[3]]

ClearAll[myFact];
myFact[n_]:=myFact[n]=n*myFact[n-1];
myFact[0]:=1;

Trace[myFact[8]]

ClearAll[f];
f[{x_,y_}]:={y,x}
f[{E,Pi}]

?/;

ClearAll[f];
f[x_]:=1-(x^2)/;-1≤x<1;
f[x_]:=f[x-2]/;x≥1;
f[x_]:=f[x+2]/;x<-1;
Plot[f[x],{x,-5,5}];
Trace[f[2.5]];

Attributes[Plus]

Attributes[List]

list1={1,2,5,7};
FullForm[list1]

Part[list1,3]
First[list1]
Last[list1]

list1[[3]]
list1[[-2]]
list1[[0]]

list2={{1,2,{on,ona}},{alfa,romeo}};
list2[[1,-1,-1]]

Table[opice,{12}]

Table[2i,{i,10}]

Table[i,{i,2,10,0.3}]

vv=Table[(E^i)+(Pi^j),{i,1,5,1},{j,1,6,(1/2)}];
MatrixForm[vv];
TableForm[vv];

Select[{1,2,4,7,6,2},#>2&]

test[x_]:=x>2;
Select[{1,2,4,7,6,2},test]

((#)^2)&[2]

((#1)^2)+((#2)^2)&[1,2]

ff[x_,y_]:=(x^2)+(y^2);
Plot3D[ff[x,y],{x,-2,2},{y,-2,2}];

Plot3D[((#1)^2)+((#2)^2)&[x,y],{x,-2,2},{y,-2,2}];

ClearAll["Global`*"];

Map[ostrihej,{ja,ty,on, ona,ono}]

ostrihej/@{ja,ty,on, ona,ono}

Apply[natocpecko,{ja,ty,on, ona,ono}]

natocpecko@@{ja,ty,on, ona,ono}

Plus@@Range[100]

Plus@@((1/((#)^3))&/@Range[100])//N

ClearAll["Global`*"];
SetDirectory[NotebookDirectory[]];
$HistoryLength=3;

a={1,1,2};
FullForm[a]
a[[0]]
Head[a]

2[[0]]
2.[[0]]
E[[0]]

ClearAll[f];
f[x_Integer]:=(2^x);
f[x_Real]:=(2^(-x));f/@{2,3.,E,Pi}

ClearAll[f];
test[x_]:=x>5;
f[x_?test]:=x+20;
f[2]

ClearAll[f];
f[x_?(#>5&)]:=x+20;
f[10]
f[2]

ClearAll[g];
g[x_]:=Module[{f,y},
f[y_]:=(y^2);
f[1-Tanh[x]]

];
g[1.]

a=Module[{x,y},
x=5;
Print["x= ",x," y= ",y];
y=3]

ClearAll[EulerStep];
tmax=2.;
nKroku=20;
Δt=(tmax/nKroku);
pocStav={0.,10};
EulerStep[{t_,y_}]:={t+Δt,y+Δt*(-5y)};
res=NestList[EulerStep,pocStav,nKroku];
pl1=ListPlot[res,PlotRange->All];
pl2=Plot[10*(E^(-5t)),{t,0,tmax},PlotStyle->{Red,Thickness[0.005]},AxesLabel->{"t [s]","y [V]"},PlotRange->All];
Show[pl2,pl1]

(*NestList[Cos,0.,50]//ListPlot*)

NestList[h,x0,5]

DSolve[y'[t]==-(1+y[t])*(2-3Cos[y[t]]),y[t],t]

res=NDSolve[{y[0]==1,y'[t]==-(1+y[t])*(2-3Cos[y[t]])},{y},{t,0,10}][[1]]

res[[1,2]]

Plot[res[[1,2]][t],{t,0,10},PlotRange->All]

Plot[y[t]/.res,{t,0,10},PlotRange->All]

(*zde zacina treti prednes*)
ClearAll["Global`*"];

uz=20*Tanh[100Sin[2*Pi*50*t]];
iz=0.05*Tanh[30Sin[2*Pi*55*t+0.6]];
R1=2000;
R2=500;
R3=1500;
c=4.7*(10^(-6));
L=0.05;
uzel1={0==iR1[t]+iU[t]};
uzel2={iU[t]+iz==iL[t]};uzel3={0==iC[t]+iz+iR2[t]};
uzel4={iL[t]+iR2[t]==iR3[t]};
odporR1={u1[t]==R1*iR1[t]};
odporR2={u3[t]-u4[t]==R2*iR2[t]};
odporR3={u4[t]==R3*iR3[t]};
kond={iC[t]==c*u3'[t]};
civka={u2[t]-u4[t]==L*iL'[t]};
zdrojU={uz==u1[t]-u2[t]};
rceDohr=Union[uzel1,uzel2,uzel3,uzel4,odporR1,odporR2,odporR3,kond,civka,zdrojU];

nezname=Cases[rceDohr,_Symbol[t],{0,∞}]//Union;
poc=Cases[rceDohr,a_'[t]:>a[0]==0,{0,∞}]//Union;

proNDSolve=Union[rceDohr,poc];
f0=50;
T=(1/f0);
tmax=5T;
res=NDSolve[proNDSolve,nezname,{t,0,tmax},StartingStepSize->(10^(-12)),MaxSteps->(10^6)];
Plot[u2[t]-u4[t]/.res,{t,0,tmax},PlotRange->All,PlotStyle->{Red,Thickness[0.005]},AxesLabel->{"t [s]","uL [V]"}]
Plot[u3[t]/.res,{t,0,tmax},PlotRange->All,PlotStyle->{Red,Thickness[0.005]},AxesLabel->{"t [s]","uC [V]"}]

Plot[Tanh[100*Sin[x]],{x,0,4Pi}]

ClearAll["Global`*"];
ClearAll[iD];
iD[uD_]:=(10^(-7))*(Exp[19*uD]-1);
Plot[iD[uD],{uD,-1,1},PlotRange->{Automatic,{-0.1,3}},PlotStyle->Thick,AxesLabel->{"uD[V]","iD[A]"}];
Plot[iD[uD],{uD,-1,0.1},PlotRange->All,PlotStyle->Thick,AxesLabel->{"uD[V]","iD[A]"}];

R=100;
c=1000*(10^(-6));
uz=12*(Sqrt[2])*Sin[2*Pi*50*t];
uzel1={0==iu[t]+id[t]};
uzel2={id[t]==ic[t]+iR[t]};
odporR={u2[t]==R*iR[t]};
kond={ic[t]==c*u2'[t]};
zdroj={uz==u1[t]};
dioda={id[t]==iD[u1[t]-u2[t]]};

rceDohr=Union[uzel1,uzel2,odporR,kond,zdroj,dioda];

nezname=Cases[rceDohr,_Symbol[t],{0,∞}]//Union;
poc=Cases[rceDohr,a_'[t]:>a[0]==0,{0,∞}]//Union;

proNDSolve=Union[rceDohr,poc];
f0=50;
T=(1/f0);
tmax=5T;
res=NDSolve[proNDSolve,nezname,{t,0,tmax},StartingStepSize->(10^(-12)),MaxSteps->(10^6)];
Plot[u2[t]/.res,{t,0,tmax},PlotRange->All,PlotStyle->{Red,Thickness[0.005]},AxesLabel->{"t [s]","uC [V]"}]

rceDohr

Manipulate[

R=100;
uz=12*(Sqrt[2])*Sin[2*Pi*50*t];
uzel1={0==iu[t]+id[t]};
uzel2={id[t]==ic[t]+iR[t]};
odporR={u2[t]==R*iR[t]};
kond={ic[t]==c*u2'[t]};
zdroj={uz==u1[t]};
dioda={D[id[t],t]==D[iD[u1[t]-u2[t]],t]};
rceDohr=Union[uzel1,uzel2,odporR,kond,zdroj,dioda];

nezname=Cases[rceDohr,_Symbol[t],{0,∞}]//Union;
poc=Cases[rceDohr,a_'[t]:>a[0]==0,{0,∞}]//Union;

proNDSolve=Union[rceDohr,poc];
f0=50;
T=(1/f0);
tmax=5T;
res=NDSolve[proNDSolve,nezname,{t,0,tmax},StartingStepSize->(10^(-12)),MaxSteps->(10^6)];
Plot[u2[t]/.res,{t,0,tmax},PlotRange->All,PlotStyle->{Red,Thickness[0.005]},AxesLabel->{"t [s]","uC [V]"},PerformanceGoal->"Speed"]
,{{c,1000*(10^(-6))},100*(10^(-6)),10000*(10^(-6))},ControlPlacement->Top]

(*zde zacina....4. prednes*)
ClearAll["Global`*"];

rce={
iz==iR1+iuz,
iuz==iR2,
iR2==iR3+iz,
iR3==iR4+iout,
u4==iR4*R4,
u3-u4==iR3*R3,
u2-u3==iR2*R2,
u1==iR1*R1,
uz==u1-u2

};

rceciselne=rce/.{R1->100,R2->100,R3->100,R4->100,uz->10,iz->0.01}

Length[rceciselne];
nezncelkem=Cases[rceciselne,_Symbol,{0,∞}]//Union;
Length[nezncelkem];
neznvys=DeleteCases[nezncelkem,iout];
Solve[rceciselne,neznvys]

try={R1,R2,R3};
par[list_]:=(((Plus@@((list^(-1)))))^(-1));
ser[list_]:=Plus@@list;
za=par[{R1,I*ω*L1}];
z1=ser[{za,(1/(I*ω*c1))}];
z2=par[{(1/(I*ω*c2)),ser[{R2,I*ω*L2}]}];
Uin=1;
Uout=Uin*(z2/(z1+z2))/.{R1->1000,L1->0.1,L2->0.001,c1->(10^(-6)),R2->0.1,c2->3*(10^(-9))};

LogLogPlot[Abs[Uout],{ω,0.001,(10^9)},PlotRange->All,PlotStyle->{Red,Thick},GridLines->Automatic,AxesLabel->{"ω [(s^(-1))]","Abs[Uout] [V]"}]

(*zde paty prednes*)
ClearAll["Global`*"];

rce={IR1==IR2+iout,
R1*IR1==uz-U1,
R2*IR2==U1
};
res=Solve[rce,{IR1,IR2,U1}]
Simplify[U1/.res][[1]]

ClearAll["Global`*"];
R2=k*1000;
R1=(1-k)*1000;
Uz=12;
Ri=((R1*R2)/(R1+R2));
uz2=Uz*(R2/(R1+R2));
RL=660;
i0=(uz2/(Ri+RL));
Plot[Ri,{k,0,1},PlotStyle->Thick];
Plot[i0,{k,0,1},PlotStyle->Thick];
R1clovek=5000;
L=5;
rce[n_,k_]={uz2-u1[t]==(Ri+RL)*iR1[t],
u1[t]-u2[t]==L*iL'[t],
iclovek[t]*n*R1clovek==u2[t],
iR1[t]==iL[t],
iL[t]==iclovek[t],
iL[0]==i0
};
res[n_,k_]:=NDSolve[rce[n,k],{u1[t],u2[t],iR1[t],iL[t],iclovek[t]},{t,0,5*(L/(n*R1clovek))}][[1]];

pl[n_,k_]:=
Module[{reseni},
reseni=res[n,k];
Plot[(10^3)iclovek[t]/.reseni,{t,0,5*(L/(n*R1clovek))},AxesLabel->{"t [s]","iclovek [mA]"},PlotStyle->{Red,Thick},GridLines->Automatic,PlotRange->{Automatic,{0,20}}]]

pl[5,1]

i0/.k->0.5

ClearAll["Global`*"];
par[list_]:=(((Plus@@((list^(-1)))))^(-1));
ser[list_]:=Plus@@list;
z1=par[{(1/(I*ω*c1)),ser[{R,I*ω*L}]}];
z2=(1/(I*ω*c2));
prenos=(z2/(z1+z2))//Simplify;
Limit[prenos,ω->∞];
dos={R->1000,L->0.05,c1->5*(10^(-9)),c2->100*(10^(-12))};
prenosciselne=prenos/.dos;
LogLogPlot[Abs[prenosciselne],{ω,1000,(10^10)},PlotRange->All]

Play[Sin[110 2Pi t*(2^(Round[t]))],{t,0,5}];

LogLinearPlot[Arg[prenosciselne],{ω,1000,(10^10)},PlotRange->All]

Play[Sin[440 2Pi t+(Pi/2)],{t,0,2}];

Plot[Sin[314*t]*Sin[314t],{t,0,0.04},PlotStyle->Thick]

(*zde sesty*)
ClearAll["Global`*"];
((Sin[x])^2)//TrigReduce

par[list_]:=(((Plus@@((list^(-1)))))^(-1));
ser[list_]:=Plus@@list;
Ufazor=100;
ω=314;
T=Tpom/.Solve[{ω==2.*Pi*f,Tpom==(1/f)}][[1]];
Z=par[{R,I*ω*L,(1/(I*ω*c))}];
u[t_]:=Im[Ufazor*(E^(I*ω*t))];
Plot[u[t],{t,0,2T}];
Manipulate[
Z=par[{R,I*ω*L,(1/(I*ω*c))}];
proud[t_]:=Im[(Ufazor/Z)*(E^(I*ω*t))];
Plot[u[t]*proud[t],{t,0,2T},PlotRange->{Automatic,{-200,300}},PlotStyle->Thick,AxesLabel->{"t [s]","p [W]"}]


,{{R,100},20,200},{{L,0.1},0.05,0.2},{{c,100*(10^(-6))},50*(10^(-6)),200*(10^(-6))},ControlPlacement->Top]

D[((i[t])^2),t]

ClearAll["Global`*"];

vyr[x_]:=a*(x^2)+b*x+c;
rce={vyr[x0]==f0,vyr[x0+Δx]==fplus,vyr[x0-Δx]==fminus};
resabc=Solve[rce,{a,b,c}][[1]];
parabola=vyr[x]/.resabc;
Integrate[parabola,{x,x0-Δx,x0+Δx}]

FindSequenceFunction[{4,2,4,2,4}]

ClearAll[vahy,mySimpson]
vahy[n_]:=Append[Prepend[3-(((-1))^(#1))&/@Range[n],1],1];
mySimpson[f_,n_,x1_,x2_]:=Module[{nBodu,vazky,Δx,ixy,ypsilony},
vazky=vahy[n];
nBodu=Length[vazky];
Δx=1.*((x2-x1)/(nBodu-1));
ixy=Range[x1,x2,Δx];
ypsilony=f/@ixy;
((Δx)/3.)*vazky.ypsilony

];
fce=Sin[((#)^3)+0.236]&;
mySimpson[fce,131,1,4];
NIntegrate[fce[x],{x,1,4}];
100*((%%-%)/(%))

(*zde zacina sedmy-osmy prednes*)
ClearAll["Global`*"];
rce=a*y''[t]+b*y'[t]+c*y[t]==f[t];
laplasirce=LaplaceTransform[rce,t,p]/.{LaplaceTransform[y[t],t,p]->Y[p],LaplaceTransform[f[t],t,p]->F[p],y[0]->0,y'[0]->0}
Solve[laplasirce,Y[p]]

nd=5;
data=Flatten[Table[{x,y,Sin[x*y]},{x,-Pi,Pi,((2.Pi)/nd)},{y,-Pi,Pi,((2.Pi)/nd)}],1];
intfce=Interpolation[data,InterpolationOrder->2];
Plot3D[intfce[x,y],{x,-Pi,Pi},{y,-Pi,Pi},PlotRange->All];
intfce[2,1]

Solve[Y==P1*(u-P2*Y),Y]

Expand[(p+2)*(p+3)]

Apart[(1/(6+5 p+(p^2)))]

laplrce={p*x1==-2x1+x2+u,p*x2==-x2-u+3x1};
Solve[laplrce,{x1,x2}]

prenos=(1/((p^2)+p+1))/.p->I*ω

ParametricPlot[{Re[prenos],Im[prenos]},{ω,0,10},AspectRatio->0.5];

prenos=((p+6)/((p^3)+0.65(p^2)+9p-1))

Solve[Denominator[prenos]==0]

A=(({{1, 2}, {3, 4}}));
xvect={x1[t],x2[t]};
uvect={u1,u2};
Thread[D[xvect,t]==A.xvect+uvect]

Solve[{p*x1==u1+x1+2 x2,p*x2==u2+3 x1+4 x2},{x1,x2}][[1]];
Solve[Denominator[x1/.%]==0]
Eigenvalues[A]