(*vypocty se spousti shift + enter nebp enter na num klavesnici*)

1+1

a=3;
(*strednik potlacuje zobrazeni vystupu*)

ClearAll[a]
(*vycisteni predchozich definic a informaci o a*)

kyncl je vul
(*mezera znamena nasobeni, radeji nepouzivat!!!*)

opice12=13;
12opice
12*opice
(*jmeno promenne nesmi zacinat cislici*)

Sin[Pi];
Sin@Pi;
Pi//Sin;
(*ruzne syntaxe mohou delat totez*)

(*klavesove zkratky*)
(*ctrl + shift 6*)
(*ctrl + / *)
(*ctrl + 2*)
(*esc o esp*)

Sin[5]
(*presny vstup presny vystup*)

Sin[5.]
(*5 Integer 5. Real*)

(*k vycisleni vysledku pomuze funkce N*)
N[Pi]

(*Math. umoznuje pretezovani funkci*)
N[Pi]
N[Pi,100]

(*Help:
F1
Help v hlavnim menu
?naCoSePtam
*)
(*Help Integrate*)
Integrate[(E^(a*(x^2)+b*x+c)),x]

Plot[ξ*Sin[ξ*(1+ξ)],{ξ,0,12}]

(*v AxesLabel radeji uvozovky*)
Plot[ξ*Sin[ξ*(1+ξ)],{ξ,0,12},AxesLabel->{"ξ","f[ξ]"}]

ξ=5+6*ovce;
Plot[ξ*Sin[ξ*(1+ξ)],{ξ,0,12},AxesLabel->{ξ,f[ξ]}]
(*bez uvozovek se dosadi*)

Plot[ξ*Sin[ξ*(1+ξ)],{ξ,0,12},AxesLabel->{"ξ","f[ξ]"},PlotStyle->{Red,Thick,Dashed}]
(*PlotStyle*)

Plot[ξ*Sin[ξ*(1+ξ)],{ξ,0,12},AxesLabel->{"ξ","f[ξ]"},PlotStyle->{Red,Thick,Dashed}]

(*Help a NajdiKoren, ergo FindRoot*)
(*prinesu si z Helpu*)
FindRoot[Cos[x]==x,{x,0}];
FindRoot[(E^x)==2*Cos[x],{x,0}]

(*pouziti Sum, esc inf esc*)
Sum[(1+x)*((((x/2)))^i),{i,1,∞}]

ClearAll["Global`*"];

f//TreeForm;

ClearAll["Global`*"];
f[x_]:=(Sqrt[x])*Sin[(x^(3/2))+1];
Plot[f[(Sqrt[t])],{t,1,10},AxesLabel->{"t",f[(Sqrt[t])]},PlotStyle->{Red,Thick},GridLines->Automatic]

ClearAll["Global`*"]

ClearAll["Global`*"];
vyr=Integrate[x*Sin[x],{x,1,x}];
f[x_]=vyr;
(*g[xx_]:=vyr/.x->xx
*)

ClearAll["Global`*"];
f[{t_,nx_,ny_}]:={Sin[nx*t],Cos[ny*t]};
ParametricPlot[f[{t,2,3}],{t,0,2*Pi},AxesLabel->{"x","y"},PlotStyle->{Magenta,Thick}]

ClearAll["Global`*"];
f[t_,nx_,ny_]:={Sin[nx*t],Cos[ny*t]};
ParametricPlot[f[t,2,3],{t,0,2*Pi},AxesLabel->{"x","y"},PlotStyle->{Magenta,Thick}]

ClearAll["Global`*"];

f[t_,nx_,ny_]:={Sin[nx*t],Cos[ny*t]};

Manipulate[
ParametricPlot[f[t,nx,ny],{t,0,2*Pi},AxesLabel->{"x","y"},PlotStyle->{Hue[hue],Thickness[tk]}]
,{nx,1,5},{ny,1,5},{hue,0,1},{tk,0.001,0.15}]

ClearAll["Global`*"];
f[n_]:=Normal[Series[Sin[x],{x,0,n}]]
Table[f[n],{n,1,10}];

Normal[Series[Sin[x]+Cos[x],{x,0,10}]]

ClearAll["Global`*"];
f[n_]:=Normal[Series[Sin[x]+Cos[x],{x,0,n}]];
nMax=15;
listProkladu=Table[f[n],{n,nMax}];
g[n_]:=Plot[{Sin[x]+Cos[x],listProkladu[[n]]},{x,0,2Pi},AxesLabel->{"x","f Taylor[f]"},PlotStyle->{{Red,Thick,Dashed},{Blue,Thick}},PlotLabel->"n= "<>ToString[n],PlotRange->{Automatic,{-1.5,1.5}}]
g[5]

Manipulate[g[n],{n,1,nMax,1}]

fz=1000;
uz[t_]:=(10^(-7))*(Exp[19*(1.1Sin[fz*2*Pi*t]-0.2)]-1);
Plot[uz[t],{t,0,0.003},PlotRange->All];

ClearAll["Global`*"];
 (*resime nas prvnio obvod*)

R1=5000;
R2=.1;
L=0.033;
c=4.7*(10^(-6));
fz=(1/(2*Pi*(Sqrt[L*c])));
uz[t_]:=(10^(-7))*(Exp[19*(1.1Sin[fz*2*Pi*t]-0.2)]-1);
Plot[uz[t],{t,0,0.003},PlotRange->All];
rce={iu[t]==iR1[t],
iR1[t]==iC[t]+iR2[t],
iR2[t]==iL1[t],
uz[t]==u1[t],
u1[t]-u2[t]==R1*iR1[t],
u2[t]-u3[t]==R2*iR2[t],
iC[t]==c*u2'[t],
u3[t]==L*iL1'[t]
};
nezname=Union[Cases[rce,_Symbol[t],{0,∞}]];
poc=Union[Cases[rce,a_'[t]:>a[0]==0,{0,∞}]];
tmax=0.05;
sol=NDSolve[Union[rce,poc],nezname,{t,0,tmax}];
Plot[{u2[t]/.sol,0.05*uz[t]},{t,0,tmax},PlotStyle->{{Thickness[0.004],Red},{Thickness[0.003],Blue}},AxesLabel->{"t [s]","0.05uz u3 [V]"}]

ClearAll["Global`*"];
 (*resime nas prvnio obvod*)

R1=5000;
R2=1000;
c=4.7*(10^(-6));
L=0.033;
fz=(1/(2*Pi*(Sqrt[L*c])));
uz[t_]:=(10^(-7))*(Exp[19*(1.1Sin[fz*2*Pi*t]-0.2)]-1);
Plot[uz[t],{t,0,0.003},PlotRange->All];
rce={iu[t]==iR2[t],
iR2[t]==iC[t]+iR1[t],
uz[t]==u1[t],
u1[t]-u2[t]==R2*iR2[t],
iC[t]==c*u2'[t],
u2[t]==R1*iR1[t]
};
nezname=Union[Cases[rce,_Symbol[t],{0,∞}]];
poc=Union[Cases[rce,a_'[t]:>a[0]==0,{0,∞}]];
tmax=0.01;
sol=NDSolve[Union[rce,poc],nezname,{t,0,tmax},MaxSteps->(10^6)];
Plot[{u2[t]/.sol,uz[t]},{t,0,tmax},PlotStyle->{{Thickness[0.004],Red,Opacity[1]},{Thickness[0.003],Blue,Dashed,Opacity[1]}},AxesLabel->{"t [s]","u2 [V]"},PlotRange->All]

Attributes[Power]
TreeForm[(1/x)]

ClearAll["Global`*"];

par[list_List]:=((Total[(list^(-1))])^(-1));
ser[list_List]:=Total[list];
z1=par[{R3,R4}];
z2=ser[{z1,R5}];
z3=par[{R2,z2}];
z4=ser[{z3,R1}]/.{R1->100,R2->200,R3->300,R4->400,R5->500}

z1=par[{R5,R6}];
z2=ser[{z1,R4}];
z3=par[{R1,R2}];
z4=par[{z3,R3}];
zv=ser[{z2,z4}]/.{R1->100,R2->200,R3->300,R4->400,R5->500,R6->600}

z1=par[{R5,R6}];
z2=ser[{z1,R4}];
z3=par[{R1,R2,R3}];
zv=ser[{z2,z3}]/.{R1->100,R2->200,R3->300,R4->400,R5->500,R6->600}

cisla=IntegerDigits[Round[(10^5000)Pi]];
Partition[cisla,3,1];
Position[%,{1,2,3}]

ClearAll["Global`*"];
rce={iR1==iZ+iR2,
iUz==iR1,
iR3+iZ==iR4+iOut,
0==iR3+iUz,
u2-u1==R1*iR1,
u1==R2*iR2,
u3-u4==R3*iR3,
u4==R4*iR4,
uZ==u3-u2
}/.{R1->100,R2->200,R3->300,R4->400,uZ->10,iZ->0.01};
neznameAll=Cases[rce,_Symbol,{0,∞}]//Union
nezname=DeleteCases[neznameAll,iOut]
Solve[rce,nezname]

ClearAll["Global`*"];
rce={0==iR1+iZ+iR3,
iR3+iZ==iOut+iR2,
u1==R1*iR1,
u2==R2*iR2,
u1-u2==R3*iR3
}/.{R1->100,R2->200,R3->300,iZ->0.01};
neznameAll=Cases[rce,_Symbol,{0,∞}]//Union;
nezname=DeleteCases[neznameAll,iOut];
out=Solve[rce,nezname]

(*SetDirectory[NotebookDirectory[]];
plot=Plot[Sin[x],{x,0,6}]
Export["plot.png",plot,ImageResolution->300]*)

ClearAll["Global`*"];
R1=100;
R2=200;
R3=300;
C1=10*(10^(-6));
C2=0.1*C1;
L1=0.1;
L2=0.1L1;
ω=100.Pi;
Uz=230*(Sqrt[2])*Exp[I*0.1];
Iz=0.1*(Sqrt[2])*Exp[-I*0.1];
rce={iR1==iL1+iC2+iUz,
iUz==iR2,
iC2+iR2==iL2,
iL2+Iz+iR3==0,
iL1+iC1==Iz+iR3+Iout,
-U1==R1*iR1,
U1-U2==Uz,
U2-U3==R2*iR2,
U3-U4==I*ω*L2,
U1-U3==(1/(I*ω*C2))*iC2,
U1-U5==I*ω*L1*iL1,
-U5==(1/(I*ω*C1))*iC1,
U5-U4==R3*iR3
};
neznameAll=Cases[rce,_Symbol,{0,∞}]//Union;
nezname=DeleteCases[neznameAll,Iout];
reseni=Solve[rce,nezname][[1]];
Uin=U5/.reseni;
amplUout=Abs[Uin/.Iout->0];
argUout=Arg[Uin/.Iout->0];
Zin=D[-Uin,Iout]
Print["Re[Zin]= ",Re[Zin]," Ω,  Im[Zin]= ",Im[Zin]," Ω"]

Zin=111.398 -4.821 I;
sol=Solve[{Re[Zin]==Rin,Im[Zin]==((-1)/(ω*Cin))}][[1]];
Print["Rin= ",Rin/.sol," Ω, Cin= ",(10^6)Cin/.sol," μF"]

z1=Rin;
z2=(1/(I*ω*Cin));
z=((z1*z2)/(z1+z2));
sol=FindRoot[{Re[z]==Re[Zin],Im[z]==Im[Zin]},{Rin,100},{Cin,(10^(-6))}];

Print["Rin= ",Rin/.sol," Ω, Cin= ",(10^6)Cin/.sol," μF"]

(*sol=Reduce[{Re[z]==Re[Zin],Im[z]==Im[Zin]},{Rin,Cin}]*)

Solve[{ComplexExpand[Im[z]]==Im[Zin],ComplexExpand[Re[z]]==Re[Zin]}]

ClearAll["Global`*"];
SetDirectory[NotebookDirectory[]];
FileNames[];
data=Import["zarovka2.csv"];
data//MatrixForm;
intI=Interpolation[data,InterpolationOrder->1];
{minU,maxU}=intI[[1,1]];
pliInt=Plot[intI[U],{U,minU,maxU},PlotStyle->{Red,Thick},AxesLabel->{"U [V]","I [A]"},GridLines->Automatic];
model=a*(u^b);
dosFit=FindFit[data,model,{a,b},u];
proklad=model/.dosFit;
plProklad=Plot[proklad,{u,minU,maxU},PlotStyle->{Black,Thick},AxesLabel->{"U [V]","I [A]"},GridLines->Automatic];
Show[plProklad,pliInt];
iZarovka[u_]=proklad;
Uz=10;
FindMaximum[{R*(i^2),i==iZarovka[Uz-R*i]},{R,11},{i,1}]

ClearAll["Global`*"];
par[list_List]:=((Total[(list^(-1))])^(-1));
ser[list_List]:=Total[list];
za=ser[{I*ω*L1,(1/(I*ω*c1))}];
z1=par[{R,za}];
z2=ser[{I*ω*L2,(1/(I*ω*c2))}];
R=100;
L1=0.1;
L2=0.01;
c1=(10^(-6));
c2=(10^(-7));
prenos=(z2/(z1+z2));
LogLogPlot[Abs[prenos],{ω,1,(10^6)},AxesLabel->{"ω [(s^(-1))]","Abs[P] [-]"},PlotStyle->{Thick,Black},GridLines->Automatic,PlotRange->All];
Print["P[ω=453]= ",prenos/.ω->453]