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

Příliš žluťoučký kůň úpěl ďábelské ódy.

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

(*Drop[pom=data2\[Transpose],-1]\[Transpose]*)

{c,d,u}=={k,d,h}
Thread[{c,d,u}=={k,dd,h}]

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

Quiet@Remove["Global`*"];
FileNames["*.xls"];
data1=Import["koeficientyReal.xls"][[1]];
data2=Drop[data1,1];
A=Drop[#,-1]&/@data2;
b=(Take[#,-1]&/@data2)//Flatten;
b=(Take[#,-1]&/@data2)/.{v_Real}:>v;
LinearSolve[A,b]

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

A=data1[[2;;-1,1;;-2]];
A//MatrixForm;
b=data1[[2;;-1,-1]];
LinearSolve[A,b]

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

pom=Range[20]
Partition[pom,2]

Quiet@Remove["Global`*"];
FileNames["*.xls"];
data1=Import["koeficientyKomplex.xls"][[1]];
Are=data1[[3;;-1,1;;-3;;2]];
Aim=data1[[3;;-1,2;;-3;;2]];
A=Are+I*Aim;
Bre=data1[[3;;-1,-2]];
Bim=data1[[3;;-1,-1]];
b=Bre+I*Bim;
LinearSolve[A,b]-(<<"vys1");

Dimensions[Are]
Dimensions[Aim]

?y

ClearAll[y]
rce={5,11,2}.{y''[t],y'[t],y[t]}==((Sin[t])/(t+1));
tmax=50;
sol=NDSolve[{rce,y[0]==1,y'[0]==5},y,{t,0,tmax}][[1]]

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

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

(x^3)//TreeForm

Attributes[Sin]

Sin[{a,b,c,d}]

Sin/@{a,b,c,d}

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

matM*matM*matM*matM*matM

NMinimize[{x+2y,(x^2)+(y^2)==1},{x,y},Method->"DifferentialEvolution"]
pom=NMaximize[{x+2y,(x^2)+(y^2)==1},{x,y}]

y/.pom[[2]]

?/.

pom={#,NMaximize[{x+2y,(x^2)+(y^2)==#},{x,y}]}&/@Range[10]

Cases[pom,{4,_}]

Quiet@Remove["Global`*"];
$HistoryLength=2;
SetDirectory[NotebookDirectory[]];(*koment*)
FileNames["*.xls"];
teploty=Import["teploty.xls"][[1]];
Take[teploty,5];
Flatten[teploty];
First/@teploty;
teploty/.{T_}:>T;
teploty[[;;,1]];
Transpose[teploty][[1]]>>"teploty";

teploty=<<"teploty";
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
]
]
]
]
]
]
];

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
];

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[#[T],{T,-20,20}]&/@{P,P1};

P3[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[#[T],{T,-20,20}]&/@{P,P1,P3};

ListPlot[teploty,PlotRange->All];

f/@{1,2,3}

Head[5.]

N[Pi,100]

N[Sin[5],50]

Sin[5.]

-0.9589242746631385`

hodinoveEnergie=P/@teploty;
n=Length[teploty];
hodinoveEnergie=Table[P[teploty[[i]]],{i,1,n}];
energieCelkem=Total[hodinoveEnergie];
Print["energie= ",((energieCelkem*3600.)/(10^6))," GJ"]

Options[NIntegrate]

dataProInterpolaci=Table[{(i-1)*3600.,teploty[[i]]},{i,1,n}];
intTeplota=Interpolation[dataProInterpolaci,InterpolationOrder->0];
{tmin,tmax}=intTeplota[[1,1]];
energiInt=Quiet@NIntegrate[P[intTeplota[t]],{t,tmin,tmax}]

Options[NDSolve]

sol=NDSolve[{e'[t]==P[intTeplota[t]],e[tmin]==0},e,{t,tmin,tmax},MaxStepSize->50][[1]]
e[tmax]/.sol

Quiet@Remove["Global`*"];
$HistoryLength=2;
SetDirectory[NotebookDirectory[]];(*koment*)
FileNames["*.xls"];
mereni=First/@(Import["DataStatistika.xls"][[1]]);

{a,b,c}-2

(({a,b,c})^2)

((Total[(((mereni-Mean[mereni]))^2)])/(Length[mereni]-1))

Mean[mereni]
Variance[mereni]
StandardDeviation[mereni]
(Sqrt[Variance[mereni]])

z=1+2*I;

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=1+Tanh[0.5x];
rhs=x;
Plot[{lhs,rhs},{x,-10,10}];
FindRoot[lhs==rhs,{x,2}]
NMinimize[(((lhs-rhs))^2),{x}]

Quiet@Remove["Global`*"];
b1={0,(1/2),0};
b2={2,0,0};
b3={0,0,1};
v={1,2,3};
rce=v==λ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=2y''[t]+c*y'[t]+5*y[t]==0;
charrce=rce/.{Derivative[n_][y][t]:>(λ^n),y[t]->1};
sol=Solve[charrce,λ];
Plot[Evaluate[Re[λ]/.sol],{c,-10,10},PlotStyle->{Red,{Black,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]},PlotLabel->"fit[x=2] = "<>ToString[fit/.x->2]],Plot[fit,{x,-4,6}]]

Quiet@Remove["Global`*"];
body=Table[{Prime[i],Prime[i+2]},{i,1,20}];
err[{xb_,yb_}]:=(Sqrt[(((x-xb))^2)+(((y-yb))^2)]);
Total[err/@body];

Quiet@Remove["Global`*"];
body=Table[{Prime[i],Prime[i+2]},{i,1,20}];
Total[body/.{xb_,yb_}:>(Sqrt[(((x-xb))^2)+(((y-yb))^2)])];

err[{xb_,yb_}]:=(Sqrt[(((x-xb))^2)+(((y-yb))^2)]);
totalError=Total[err/@body];
min=NMinimize[totalError,{x,y}]

min[[2]]

ListPlot[{{5,6}}]

ListPlot[{{x,y}}/.min[[2]]]

pl1=ListPlot[body,PlotStyle->{Black,PointSize[0.01]}];

pl2=ListPlot[{{x,y}/.min[[2]]},PlotStyle->{Red,PointSize[0.02]}];



body=Table[{Prime[i],Prime[i+2]},{i,1,20}];
Show[pl1,pl2]
min

Quiet@Remove["Global`*"];
Zv1=1+5I;
Zv2=1+I;
Lz=1;
Rz=100;
ω=314.;
Zz=((Rz*I*ω*Lz)/(Rz+I*ω*Lz));
U=230.;
rce={((U-Ub)/Zv1)==((Ub-Ua)/Zv2)+(Ub/(1/(I*ω*c))),((Ub-Ua)/Zv2)==(Ua/Zz)};
sol=Solve[rce,{Ua,Ub}][[1]];
ztraty=Re[Zv1]*((Abs[((U-Ub)/Zv1)])^2)+Re[Zv2]*((Abs[((Ub-Ua)/Zv1)])^2)/.sol;
absUa=Abs[Ua/.sol];

NMinimize[ztraty,{c}]

LogLogPlot[ztraty,{c,(10^(-8)),1.7*(10^(-5))},AxesLabel->{"c[F]","ztraty[W]"},PlotStyle->{Red,Thickness[0.006]},GridLines->Full]

LogLogPlot[absUa,{c,(10^(-5)),(10^(-2))},AxesLabel->{"c[F]","Abs[Ua][V]"},PlotStyle->{Red,Thickness[0.006]},GridLines->Full]

(*https://clintel.org/*)