Quiet@Remove["Global`*"];
$HistoryLength=2;
SetDirectory[NotebookDirectory[]]

Quiet@Remove["Global`*"];
FileNames["*.xls"];
dataReal=Import["koeficientyReal.xls"][[1]];
info=dataReal[[1]];
data1=Drop[dataReal,1];
A=Transpose[Drop[pom=Transpose[data1],-1]];
b=pom[[-1]];
LinearSolve[A,b]

nezname=(Subscript[x, #])&/@Range[Length[b]];
rovnice=Thread[A.nezname==b];
Solve[rovnice]

Quiet@Remove["Global`*"];
FileNames["*.xls"];
dataReal=Import["koeficientyReal.xls"][[1]];
maticeA=dataReal[[2;;,;;-2]];
b=dataReal[[2;;,-1]];
LinearSolve[maticeA,b];

Quiet@Remove["Global`*"];
FileNames["*.xls"];
dataReal=Import["koeficientyReal.xls"][[1]];
data1=Drop[dataReal,1];
A=Drop[#,-1]&/@data1;
b=Flatten@(Take[#,-1]&/@data1);
LinearSolve[A,b]

Quiet@Remove["Global`*"];
FileNames["*.xls"];
dataComplex=Import["koeficientyKomplex.xls"][[1]];
data1=Drop[dataComplex,{1,2}];
data2=(Partition[#,2]&/@data1)/.{re_Real,im_}:>re+I*im;
data1=data2;
A=Transpose[Drop[pom=Transpose[data1],-1]];
b=pom[[-1]];
reseni1=LinearSolve[A,b];
reseni1>>"res1";

Range[20]
Partition[%,2]

Quiet@Remove["Global`*"];
FileNames["*.xls"];
dataReal=Import["koeficientyKomplex.xls"][[1]];

maticeAre=dataReal[[3;;,1;;-4;;2]];
maticeAim=dataReal[[3;;,2;;-3;;2]];
maticeA=maticeAre+I*maticeAim;

Bre=dataReal[[3;;,-2]];
Bim=dataReal[[3;;,-1]];
B=Bre+I*Bim;
reseni2=LinearSolve[maticeA,B];
reseni1=<<"res1";
reseni1==reseni2
Union[reseni1-reseni2//Chop]

Quiet@Remove["Global`*"];
rce={{5,11,2}.{y''[t],y'[t],y[t]}==((Sin[t])/(t+1))};
pocs={y[0]==1,y'[0]==5};
tmax=50;
sol=NDSolve[Union[rce,pocs],y,{t,0,tmax}][[1]];
Plot[y[t]/.sol,{t,0,tmax},PlotRange->All];

Quiet@Remove["Global`*"];
rce={{5,11,2}.{y''[t],y'[t],y[t]}==((Sin[t])/(t+1))};
pocs={y[0]==1,y[1]==5};
tmax=50;
sol=NDSolve[Union[rce,pocs],y,{t,0,tmax}][[1]];
Plot[y[t]/.sol,{t,0,tmax},PlotRange->All];

Quiet@Remove["Global`*"];
pom=MatrixPower[(({{1, 2}, {7, 13}})),(1/5)]//N
pom.pom.pom.pom.pom//Chop

(x^3)//TreeForm

Attributes[Sin]
Sin[{1,2,3}]

Attributes[Power]

Quiet@Remove["Global`*"];

(((({{1, 2}, {7, 13}})))^(1/5))

a==b//FullForm

Quiet@Remove["Global`*"];
expr=x+2y;
constr=(x^2)+(y^2)==1;
podminka=constr/.Equal[lhs_,rhs_]:>lhs-rhs;
podminka=constr/.lhs_==rhs_:>lhs-rhs;
lagrange=expr+λ*podminka;
rovnice=0==D[lagrange,#]&/@{x,y,λ}
Solve[rovnice]//N
expr/.%

Quiet@Remove["Global`*"];
expr=x+2y;
constr=(x^2)+(y^2)==1;
NMinimize[{expr,constr},{x,y}]
NMaximize[{expr,constr},{x,y}]

Quiet@Remove["Global`*"];
$HistoryLength=2;
SetDirectory[NotebookDirectory[]];

FileNames["*.xls"];
teploty=Import["teploty.xls"][[1]];
teploty/.{T_}:>T;(**)
Flatten[teploty];
teploty[[;;,1]];
First/@teploty;
Last/@teploty;
#[[1]]&/@teploty;
Transpose[teploty][[1]]>>"teploty";

teploty=<<teploty;
ListPlot[teploty,PlotRange->All,Joined->True];
P[T_]:=If[-Infinity<T&&T<=-15,20,
If[-15<T<=-12,15,
If[-12<T<=-8,12,
If[-8<T<=-2,9,
If[-2<T<=5,5,
If[5<T<=13,3,
If[T>13,0
]
]
]
]
]
]
];

?P

ClearAll[P1]
P1[T_]:=Which[-Infinity<T&&T<=-15,20,
-15<T<=-12,15,
-12<T<=-8,12,
-8<T<=-2,9,
-2<T<=5,5,
5<T<=13,3,
T>13,0
];
Plot[P1[T],{T,-20,20}]

P2[T_]:=Piecewise[Reverse/@Partition[{-Infinity<T&&T<=-15,20,
-15<T<=-12,15,
-12<T<=-8,12,
-8<T<=-2,9,
-2<T<=5,5,
5<T<=13,3,
T>13,0},2]];
Plot[P2[T],{T,-20,20}];

Piecewise

ClearAll[P];
P[T_]:=20/;T<=-15;
P[T_]:=15/;-15<T<=-12;
P[T_]:=12/;-12<T<=-8;
P[T_]:=9/;-8<T<=-2;
P[T_]:=5/;-2<T<=+5;
P[T_]:=3/;5<T<=13;
P[T_]:=0/;13<T;
Plot[P[T],{T,-20,20}];
Plot[P[T]-P1[T],{T,-20,20}];

hodinoveEnergie=P/@teploty;
 celkem=Total[hodinoveEnergie];
Print["celkem spotreba= ",((celkem*3600)/(10^6))//N," GJ"]

n=Length[teploty];
dvojice=Table[{(i-1)*3600,teploty[[i]]},{i,1,n}];
teplota=Interpolation[dvojice,InterpolationOrder->0];
{tmin,tmax}=teplota[[1,1]];
energie=NIntegrate[P[teplota[t]],{t,tmin,tmax}]

sol=NDSolve[{e'[t]==P[teplota[t]],e[tmin]==0},e,{t,tmin, tmax},MaxStepSize->10][[1]];
Print["celkem spotreba= ",((e[tmax]/.sol)/(10^6))//N," GJ"]

Quiet@Remove["Global`*"];
$HistoryLength=2;
SetDirectory[NotebookDirectory[]];

FileNames["*.xls"];
mereni=Import["DataStatistika.xls"][[1,;;,1]];
mean=Mean[mereni];
var=Variance[mereni];
sd=StandardDeviation[mereni];
n=Length[mereni];
((Total[mereni])/n)-mean

var

((Total[(((mereni-mean))^2)])/(n-1))

(Sqrt[((Total[(((mereni-mean))^2)])/(n-1))])
sd

z=1+2*I;
Print["z= ",TraditionalForm[Abs[z]*(E^(I*Arg[z]))]]
Print["z= ",Abs[z]*(E^(I*Arg[z]))]

Quiet@Remove["Global`*"];
points={a,b,c,d}={{{-1,-1.5},8.9},{{3,1.},4.5},{{1.,-2},8.1},{{-1.5,-1.5},9.2}};

Quiet@Remove["Global`*"];

A=1+I;
B=1-3I;

((A*B)/(A+B))

(I^I)//ComplexExpand

Quiet@Remove["Global`*"];
lhs=x;
rhs=1+Tanh[0.5x];
Plot[{lhs,rhs},{x,-5,5}];
FindRoot[lhs==rhs,{x,2}];

Quiet@Remove["Global`*"];
vect={1,2,3};
b1={0,(1/2),0};
b2={2,0,0};
b3={0,0,1};
rce=vect==λ1*b1+λ2*b2+λ3*b3//Thread
Solve[rce]

Quiet@Remove["Global`*"];
Integrate[((Sin[x])/x),{x,1,2}]//N

Quiet@Remove["Global`*"];
f[τ_]=Integrate[((Sin[x])/x),{x,1,τ}];
{Plot[f'[τ],{τ,1,2}],Plot[((Sin[τ])/τ),{τ,1,2}]}

Quiet@Remove["Global`*"];
rce=2*y''[t]+c*y'[t]+5y[t]==0;
poly=rce/.{Derivative[n_][y][t]:>(λ^n),y[t]:>1}
sol=Solve[poly,λ]
Plot[Evaluate[Re[λ]/.sol],{c,-10,10},PlotStyle->{Red,Dashed}]

Quiet@Remove["Global`*"];
body={{1,2},{-3,5},{0,1},{4,-3}};
fit=Fit[body,{1,x,(x^2),(x^3)},x];
Show[ListPlot[body,PlotStyle->{Red,PointSize[0.015]}],Plot[fit,{x,-4,5}]];
Print["fit[x=2]= ",fit/.x->2]

Quiet@Remove["Global`*"];
points={a,b,c,d}={{{-1,-1.5},8.9},{{3,1.},4.5},{{1.,-2},8.1},{{-1.5,-1.5},9.2}};
err[{{xb_,yb_},d_}]:=((((Sqrt[(((xb-x))^2)+(((yb-y))^2)])-d))^2);
errCelk=Total[err/@points];
sol=NMinimize[errCelk,{x,y}]

errCelk=Total[points/.{{xb_,yb_},d_}:>((((Sqrt[(((xb-x))^2)+(((yb-y))^2)])-d))^2)];
sol=NMinimize[errCelk,{x,y}]

pl1=ListPlot[First/@points,PlotRange->All];
pl2=ListPlot[{{x,y}/.sol[[2]]},PlotStyle->{Red,PointSize[0.015]}];
Show[pl2,pl1,PlotRange->All];

Quiet@Remove["Global`*"];
zv1=1+3I;
zv2=0.5*zv1;
ω=314.;
zz=((100*I*ω*0.5)/(100+I*ω*0.5));
zv2c=zv2+(1/(I*ω*c));
U=230;
rce={((U-Uz)/zv1)==(Uz/zz)+(Uz/zv2c)};
sol=Quiet@Solve[rce][[1]];
i1=((U-Uz)/zv1)/.sol;
i2=(Uz/zv2c)/.sol;
formin1=Re[zv1]*((Abs[i1])^2)+Re[zv2]*((Abs[i2])^2);
formin2=Abs[Uz/.sol];

NMinimize[formin1,{c}]

NMaximize[formin2,{c}]

Quiet@Remove["Global`*"];
zv1=1+3I;
zv2=0.5*zv1;
ω=314.;
R=100;
L=0.5;
zz=((R*I*ω*L)/(R+I*ω*L));
zv2c=zv2+(1/(I*ω*c));
U=230;
rce={((U-Uz)/zv1)==(Uz/zz)+(Uz/zv2c)};
sol=Quiet@Solve[rce][[1]];
i1=((U-Uz)/zv1)/.sol;
i2=(Uz/zv2c)/.sol;
formin=Re[zv1]*((Abs[i1])^2)+Re[zv2]*((Abs[i2])^2);
formax=Abs[Uz/.sol];

NMinimize[formin,{c}]

NMaximize[formax,{c}]

LogLogPlot[formax,{c,(10^(-4)),(10^(-2))},AxesLabel->{"c[F]","Abs[Uz]"},PlotStyle->{Red,Thickness[0.006]},GridLines->Full]

Quiet@Remove["Global`*"];
kW=1000.;
dataK2={{500kW,0.943},{1900kW,0.921}};
dataK3={{300kW,0.93},{1040kW,0.899}};
ClearAll[η2,η3,P];
η2[P_]=Fit[dataK2,{1,P},P];
η3[P_]=Fit[dataK3,{1,P},P];
PoutMin=800kW;
PoutMax=2940kW;
vydej[Pcelk_]:=Module[{Pin,arg,min,max},
Pin=(P2/(η2[P2]))+(P3/(η2[P3]));
arg={Pin,P2+P3==Pcelk,500kW≤P2≤1900kW,300kW≤P3≤1040kW};
min=NMinimize[arg,{P2,P3},Method->"DifferentialEvolution"];
max=NMaximize[arg,{P2,P3},Method->"DifferentialEvolution"];
{Pcelk,(Pcelk/(min[[1]])),(Pcelk/(max[[1]]))}
];
data=vydej/@Range[PoutMin,PoutMax,20kW]
data>>"data";

data=<<"data";
pl1=ListPlot[data/.{P_,min_,max_}:>{(P/1000),min},AxesLabel->{"P[kW]","η[-]"},Joined->True,PlotStyle->{Red,Thickness[0.006]},GridLines->Full];
pl2=ListPlot[data/.{P_,min_,max_}:>{(P/1000),max},AxesLabel->{"P[kW]","η[-]"},Joined->True,PlotStyle->{Black,Thickness[0.006]},GridLines->Full];
Show[pl1,pl2]

dataK2={{500kW,0.943},{1900kW,0.921}};
dataK3={{300kW,0.93},{1040kW,0.899}};

vydej[Pcelk_]:=Module[{Pin,arg,min,max},
Pin=(P2/(η2[P2]))+(P3/(η2[P3]));
arg={Pin,P2+P3==Pcelk,500kW≤P2≤1900kW,300kW≤P3≤1040kW};
min=NMinimize[arg,{P2,P3},Method->"DifferentialEvolution"];
max=NMaximize[arg,{P2,P3},Method->"DifferentialEvolution"];
{Pcelk,(Pcelk/(min[[1]])),(Pcelk/(max[[1]]))}
];
data=Table[vydej[P],{P,PoutMin,PoutMax,20kW}];
data>>"data";

data=<<"data";
pl1=ListPlot[data/.{P_,min_,max_}:>{(P/1000),min},AxesLabel->{"P[kW]","η[-]"},Joined->True,PlotStyle->{Red,Thickness[0.006]},GridLines->Full];
pl2=ListPlot[data/.{P_,min_,max_}:>{(P/1000),max},AxesLabel->{"P[kW]","η[-]"},Joined->True,PlotStyle->{Black,Thickness[0.006]},GridLines->Full];
Show[pl1,pl2]

Quiet@Remove["Global`*"];
fZlom=1000.;
pIdeal[f_]:=0.8/;f≤fZlom;
pIdeal[f_]:=0.6/;f>fZlom;
ser=Total;
par:=((Total[((#)^(-1))])^(-1))&;
z2=par[{R2,ser[{R3,(1/(I*2*Pi*f*c))}]}];
prenos[f_]=(z2/(R1+z2));
fmax=10000;
fmin=10.;
n=100;
q=((fmax/fmin)^(1/100));
frekvence=fmin*(q^(#))&/@Range[n];
err[f_]:=(((Abs[prenos[f]]-pIdeal[f]))^2);
celkErr=Total[err/@frekvence];
R1=1000;
min=NMinimize[{celkErr,R2>0,R3>0,c>0},{R2,R3,c},Method->"DifferentialEvolution"]

Quiet@Remove["Global`*"];
$HistoryLength=2;
SetDirectory[NotebookDirectory[]];
file=FileNames["*.csv"][[1]];
dataUI=Prepend[Import[file],{0,0}];
pl1=ListPlot[dataUI,AxesLabel->{"u[V]","i[A]"},PlotStyle->{Red,PointSize[0.015]},GridLines->Full];
dataIU=Reverse/@dataUI;
pl2=ListPlot[dataIU,AxesLabel->Reverse@{"u[V]","i[A]"},PlotStyle->{Red,PointSize[0.015]},GridLines->Full];
{iMin,iMax}=Interpolation[dataIU][[1,1]];
nMocnin=4;
baze=(i^(#))&/@Range[nMocnin];
u[i_]=Fit[dataIU,baze,i];
pl3=Plot[u[i],{i,iMin,iMax},PlotStyle->{Black,Thickness[0.006]}];
Show[pl2,pl3];
R[i_]=((u[i])/i)//Simplify;
dataUR=Table[{u[i],R[i]},{i,iMin,iMax,0.01}];
Plot[R[i],{i,iMin,iMax},PlotStyle->{Black,Thickness[0.006]},AxesLabel->{"i[A]","R[Ω]"},PlotStyle->{Red,PointSize[0.015]},GridLines->Full];
intR=Interpolation[dataUR];
{uMin,uMax}=intR[[1,1]];
Plot[intR[u],{u,uMin,uMax},PlotStyle->{Black,Thickness[0.006]},AxesLabel->{"u[V]","R[Ω]"},PlotStyle->{Red,PointSize[0.015]},GridLines->Full];

kR[T_]:=1+4.8297*(10^(-3))*T+1.663*(10^(-6))*(T^2);
dosR0=Solve[R0*kR[2450]==intR[24]][[1]];
RT[T_]:=R0*kR[T]/.dosR0;
vydejT[R_]:=Quiet[T/.FindRoot[RT[T]==R,{T,500}]];
dataUT=Table[{U,vydejT[intR[U]]},{U,uMin+0.1,uMax,0.2}];
ListPlot[dataUT,Joined->True,PlotStyle->{Red,Thickness[0.006]},AxesLabel->{"u[V]","T[°C]"},GridLines->Full];


kR[T_]:=1+4.8297*(10^(-3))*T+1.663*(10^(-6))*(T^2);

Show[Plot[Interpolation[dataIU,InterpolationOrder->4][x],{x,0,2.8}],pl2];
pl2;

listNapeti=Range[10]
listProudu=(listNapeti/R)
Thread[{listNapeti,listProudu}]

Quiet@Remove["Global`*"];
$HistoryLength=2;
SetDirectory[NotebookDirectory[]];
file=FileNames["*.csv"][[1]];
dataUI=Prepend[Import[file],{0,0}];
pl1=ListPlot[dataUI,AxesLabel->{"u[V]","i[A]"},PlotStyle->{Red,PointSize[0.015]},GridLines->Full];
dataIU=Reverse/@dataUI;
pl2=ListPlot[dataIU,AxesLabel->Reverse@{"u[V]","i[A]"},PlotStyle->{Red,PointSize[0.015]},GridLines->Full];
{iMin,iMax}=Interpolation[dataIU][[1,1]];
nMocnin=4;
baze=(i^(#))&/@Range[nMocnin];
u[i_]=Fit[dataIU,baze,i];
pl3=Plot[u[i],{i,iMin,iMax},PlotStyle->{Black,Thickness[0.006]}];
Show[pl2,pl3];
R[i_]=((u[i])/i)//Simplify;
dataUR=Table[{u[i],R[i]},{i,iMin,iMax,0.01}];
intR=Interpolation[dataUR];
{uMin,uMax}=intR[[1,1]];
Plot[intR[u],{u,uMin,uMax},PlotStyle->{Black,Thickness[0.006]},AxesLabel->{"u[V]","R[Ω]"},PlotStyle->{Red,PointSize[0.015]},GridLines->Full];
kR[T_]:=1+4.8297*(10^(-3))*T+1.663*(10^(-6))*(T^2);
dosR0=Solve[R0*kR[2450]==intR[24]][[1]];
RT[T_]:=R0*kR[T]/.dosR0;
vydejT[R_]:=Quiet[T/.FindRoot[RT[T]==R,{T,500}]];
dataUT=Table[{U,vydejT[intR[U]]},{U,uMin+0.1,uMax,0.2}];
ListPlot[dataUT,Joined->True,PlotStyle->{Red,Thickness[0.006]},AxesLabel->{"u[V]","T[°C]"},GridLines->Full]