$HistoryLength=2;
ClearAll["Global`*"];

1+1;
a=8;

ClearAll[a]
a==8

Sin[(5/8)Pi]

N[(5/8)Pi,100];

Sin[(5./8)Pi]

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

list={1,{ja,ty},{0,{alfa,romeo}}}

list[[-1,-1,-1]]

Length[list]

list[[2]][[1]]
list[[2,1]]

list[[0]]

list={1,{ja,ty},{0,{alfa,romeo}}}

TreeForm[list]

TreeForm[a+b]

a+b=3

FullForm[list]

List[1,List[ja,ty],List[0,List[alfa,romeo]]]

List[1,List[ja,ty],List[0,List[alfa,romeo]]]

vyr=(((x+3))^2)*Sin[(1/(2+Log[4+x]))];
FullForm[vyr]

vyr[[0]]

TreeForm[f[vyr]]

ClearAll[f];

?_

(*f[x:_]:="kuzle"+x;*)

ClearAll[f];
f[5]:="osel";
f[x_]:="kuzle"+x;
f[x_Integer]:=x+13;
f[x_,1]:=(x/("osel"));
f[x_,y_]:=((x+"kuzle")/("osel"));
f[{x_,y_}]:=x-y;
f[{1,1}]

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

Trace[a[3]]

?:=

?=

x

ClearAll[g,x];

g[x_]=Integrate[x*Exp[-x],x]
g[5]
?g

ClearAll[g,x];
g[x_]:=Integrate[x*Exp[-x],x]
?g

ClearAll[g];
g[x_]:=Integrate[x*Exp[-x],x]

ClearAll[res];
res[x_]:=FindRoot[Cos[x*y]==0.1y+0.02,{y,0.1}];
res[0.3]

Off[FindRoot::"nlnum"]

ClearAll[res];
res[x_]=Quiet[FindRoot[Cos[x*y]==0.1y+0.02,{y,0.1}]];
Quiet[res[0.3]]

Plot[{Sin[x],Cos[x]},{x,0,2Pi}]

Options[Plot];

Plot[x*Sin[(x^2)],{x,0,2Pi},PlotStyle->{Thickness[0.006],RGBColor[0,0.5,0.5],Dashing[{0.01,0.02,0.03}]}]

Plot[{x*Sin[(x^2)],x*Cos[(x^2)]},{x,0,2Pi},PlotStyle->{{Thickness[0.006],RGBColor[0,0.5,0.5],Dashing[{0.01,0.02,0.03}]},{Thickness[0.006],Blue}}];

plotik=Plot[{x*Sin[Tanh[(x^2)]],x*Cos[Tanh[(x^2)]]},{x,0,2Pi},PlotStyle->{{Thickness[0.006],Red},{Thickness[0.006],Blue}}];

SetDirectory[NotebookDirectory[]];

Export["graf1.png",plotik,ImageResolution->300]

Head["f[x]"]
"f[x]"[[0]]

Plot[Tanh[5Sin[314t]],{t,0,0.04},PlotStyle->Thick,AxesLabel->{"x","f[x]"},PlotLabel->"nas graf",GridLines->Automatic]

Manipulate[
Plot[Tanh[ampl*Sin[314t]],{t,0,0.04},PlotStyle->Thick,AxesLabel->{"x","f[x]"},PlotLabel->"nas graf",GridLines->Automatic,PlotRange->{Automatic,{-1.1,1.1}}]
,{ampl,0,10},ControlPlacement->Top]

Solve[(x^2)==1]
%[[1,1,2]]

3x+5/.x->"osel"

3x+5y/.{x->"osel",y->"krava"}

(x^2)/.{{x->2},{x->3}}

Clear[a]

n=2;
rovnice=(∑_(i=0)^n)(Subscript[a, i])*(x^i)==0;
dosadZaKoreny=Solve[rovnice,x]
2(Subscript[a, 2])*x/.dosadZaKoreny

DSolve[(1+(x^2))*y''[x]+y'[x]*x+x*y[x]==1,y[x],x]

(*zde druhy prednes pocina se*)
ClearAll["Global`*"];

ClearAll[f];
f:=Random[];
{f,f,f,f,f,f,f}

ClearAll[f];
f=Random[]
{f,f,f,f,f,f,f}

Table["opice",{12}]

Table[(opice^i),{i,12}]
Plot[%,{opice,0,1}];

Table[(opice^i),{i,2,4,0.3}];

vys=Table[(Pi^i)*(E^j),{i,3},{j,3}]
MatrixForm[vys];
Grid[vys,Frame->All]

ClearAll[a];
a[0]:=1;
a[n_]:=n*a[n-1];
$RecursionLimit=2000;
Timing[Table[a[i],{i,1450}]][[1]]

ClearAll[a];
a[0]:=1;
a[n_]:=a[n]=n*a[n-1];
$RecursionLimit=2000;
Timing[Table[a[i],{i,1450}]][[1]]

?/;

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,-4,4}];
Trace[f[6.52]];

ClearAll[f];
f[x_]:=Module[{a,b,c},
a=Sin[x];
b=Cos[a];
c+a+b

];
f[5.]

ClearAll[f];
f[x_]:=Module[{a,b,c=1},
a=Sin[x];
Print["a= ",a];
b=Cos[a];
c+a+b

];
f[5.]

lide={ja,ty,on,ona,ono};
Map[ostrihej,lide]
ostrihej/@lide

Apply[natocPecko,lide]
natocPecko@@lide

{TreeForm[lide],TreeForm[natocPecko@@lide]}

Plus@@Range[100]

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

test[3]

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

((#)^2)&[3]

Plot3D[((#1)^2)*Sin[#2]&[x,y],{x,-1,1},{y,-Pi,Pi}]

#=2

ClearAll[f];
f[x_Integer]:=5;
f[4.]

NumericQ[Pi]

?*Q;

ClearAll[f];
f[x_?NumericQ]:=5;
f[h]

(#>4&)[5]

ClearAll[f];
f[x_?(#>4&)]:=5;
f[6]

ClearAll[krok];
tmax=5.;
nKroku=100;
y0=1;
t0=0.;
Δt=(tmax/nKroku);
krok[{t_,y_}]:={t+Δt,y+(-y)*Δt};
NestList[krok,{t0,y0},nKroku];
ListPlot[%]

Nest[Cos,x,10]

Series[Cos[x],{x,0.,40}]//Chop;

NestList[Cos,0.,100]//ListPlot;

res

rce=y'[t]==-y[t];
poc=y[0]==1;
res=NDSolve[{rce,poc},y,{t,0,tmax}][[1]]
Plot[y[t]/.res,{t,0,tmax}]

FullForm[x->5]

x+3/.x->5

(y/.res)[2]

SetDirectory[NotebookDirectory[]]

(y/.res)>>"intfce"

res[[1,2]]

Plot[res[[1,2]][t],{t,0,tmax}]

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

R1=100;
R2=500;
R3=253;
c=6.8*(10^(-6));
L=0.05;
uz=15*Tanh[30*Sin[314t+0.23]];
iz=0.01*Sin[628t-0.5];
Plot[uz,{t,0,tmax},AxesLabel->{"t [s]","u4 [V]"}];

uzly={0==iL[t]+iz+iR3[t],
iL[t]+iuz[t]==iR1[t],
iR1[t]==iC[t],
iz==iuz[t]+iR2[t]
};
soucastky={u2[t]-u3[t]==R1*iR1[t],
u4[t]==R2*iR2[t],
u1[t]==R3*iR3[t],
u1[t]-u2[t]==L*iL'[t],
iC[t]==c*u3'[t],
uz==u2[t]-u4[t],
iL[0]==0,
u3[0]==0
};
rcedohr=Union[uzly,soucastky];
nezname=Union[Cases[rcedohr,_Symbol[t],{0,∞}]];
tmax=0.08;
res=NDSolve[rcedohr,nezname,{t,0,tmax},StartingStepSize->(10^(-9))][[1]];
Plot[u4[t]/.res,{t,0,tmax},AxesLabel->{"t [s]","u4 [V]"},PlotStyle->{Thick,Red}]

uzly={0==iL[t]+iz+iR3[t],
iL[t]+iuz[t]==iR1[t],
iR1[t]==iC[t],
iz==iuz[t]+iR2[t]
};
soucastky={u2[t]-u3[t]==R1*iR1[t],
u4[t]==R2*iR2[t],
u1[t]==R3*iR3[t],
u1[t]-u2[t]==L*iL'[t],
iC[t]==c*u3'[t],
uz==u2[t]-u4[t]
};
rcedohr=Union[uzly,soucastky];
nezname=Union[Cases[rcedohr,_Symbol[t],{0,∞}]];
pocs=Union[Cases[rcedohr,a_'[t]:>a[0]==0,{0,∞}]]

tmax=0.08;
res=NDSolve[Union[rcedohr,pocs],nezname,{t,0,tmax},StartingStepSize->(10^(-9))][[1]];
Plot[u4[t]/.res,{t,0,tmax},AxesLabel->{"t [s]","u4 [V]"},PlotStyle->{Thick,Yellow},GridLines->Automatic,Background->Black]

R1=100;
R2=500;
R3=253;
c=6.8*(10^(-6));
L=0.05;
uz=15;
iz=0.01;
uzly={0==iL[t]+iz+iR3[t],
iL[t]+iuz[t]==iR1[t],
iR1[t]==iC[t],
iz==iuz[t]+iR2[t]
};
soucastky={u2[t]-u3[t]==R1*iR1[t],
u4[t]==R2*iR2[t],
u1[t]==R3*iR3[t],
u1[t]-u2[t]==L*iL'[t],
iC[t]==c*u3'[t],
uz==u2[t]-u4[t]
};
rcedohr=Union[uzly,soucastky];
rceDC=rcedohr/.{a_Symbol[t]:>a,a_'[t]:>0}
Solve[rceDC]

R1=100;
R2=500;
R3=253;
uz=15;
iz=0.01;
uzly={iz+iuz==iR3,
0==iR2+iuz,
iR3+iR2==iR1+iout
};
soucastky={u3==R1*iR1,
u2-u3==R2*iR2,
u1-u3==R3*iR3,
uz==u2-u1
};
rcedohr=Union[uzly,soucastky];
Length[rcedohr]
pom=Union[Cases[rcedohr,_Symbol,{0,∞}]];
nezname=DeleteCases[pom,iout]
Solve[rcedohr,nezname]//Simplify

tryList={Ra,Rb,Rc};
par[list_]:=(((Plus@@(list^(-1))))^(-1));
par[tryList]
ser[list_]:=Plus@@list;
ser[tryList]

$HistoryLength=2;
ClearAll["Global`*"];

uz=100*Sin[314t];
R=50;
L=0.05;
c=47*(10^(-6));
rceUzly={iL[t]==iR[t],iL[t]==ic[t]};
rceSoucastky={uz-u1[t]==R*iR[t],
u1[t]-u2[t]==L*iL'[t],
ic[t]==c*u2'[t]
};
rceDohr=Union[rceSoucastky,rceUzly];
nezname=Union[Cases[rceDohr,_Symbol[t],{0,∞}]];
poc=Union[Cases[rceDohr,a_'[t]:>a[0]==0,{0,∞}]];
res=NDSolve[Union[rceDohr,poc],nezname,{t,0,0.08},StartingStepSize->(10^(-9))];
Plot[iR[t]/.res,{t,0,0.08},PlotStyle->Thick]

res//FullForm;

TrigReduce[((Cos[t])^2)]

Series[Exp[x],{x,0,5}];

z=3+4I;
{Re[z],Im[z],Abs[z],Abs[z]*(E^(I*Arg[z]))//ComplexExpand}

5*(E^(I*0.3))

tryList={Ra,Rb,Rc};
par[list_]:=(((Plus@@(list^(-1))))^(-1));
par[tryList];
ser[list_]:=Plus@@list;
ser[tryList];

z1=ser[{R1,(1/(I*ω*c1))}];
z2=par[{z1,I*ω*L1}];
z3=ser[{I*ω*L2,(1/(I*ω*c2))}];
z4=par[{z3,R2}];
u2=u1*(z4/(z4+z2))//Simplify;
uplot=u2/.{u1->1,R1->0.1,R2->10000,L1->0.1,L2->0.05,c1->(10^(-9)),c2->(10^(-6))};
LogLogPlot[Abs[uplot],{ω,0.01,(10^7)},PlotStyle->Thick,PlotRange->All,GridLines->Automatic]

par[list_]:=(((Plus@@(list^(-1))))^(-1));
ser[list_]:=Plus@@list;

za=par[{R1,I*ω*L1}];
zb=ser[{za,(1/(I*ω*C1))}];
z1=par[{zb,R2}];
zc=ser[{R3,I*ω*L2}];
z2=par[{zc,(1/(I*ω*C2))}];
prenos=(z2/(z1+z2))//Simplify;
k=1000;
μ=(10^(-6));
m=0.001;
dos={R1->100k,R2->100k,R3->0.1,C1->5μ,C2->0.1μ,L1->100m,L2->5m};
vysprenos=prenos/.dos;
LogLogPlot[Abs[vysprenos],{ω,0.1,(10^8)},PlotRange->All,PlotStyle->Thick,AxesLabel->{"ω [(s^(-1))]","Abs[P]"},GridLines->Automatic]

nn=16;
data=Table[{x,Sin[x]},{x,0,2Pi,(Pi/nn)}]//N;
pl1=ListPlot[data,PlotStyle->{PointSize[0.015],Red}];
int=Interpolation[data,InterpolationOrder->3];
pl2=Plot[int[x],{x,0,3Pi},PlotStyle->Thick];
Show[pl2,pl1]
Plot[int[x]-Sin[x],{x,0,3Pi},PlotStyle->Thick];

int

{xmin,xmax}=int[[1,1]]

f[x_]:=0.1x+0.001(x^3)+Tanh[1+0.1(x^2)];
Plot[f[x],{x,-10,10}];
ikx[y_]:=x/.FindRoot[f[x]==y,{x,0}]
ikx[1]

dat=Table[{f[x],x},{x,-10,10,0.1}];
intikx=Interpolation[dat];
{ikx[0],intikx[0]}

n=1000;
Timing[Table[ikx[x],{x,-0.5,0.5,(1/n)}]][[1]]

n=100000;
Timing[Table[intikx[x],{x,-0.5,0.5,(1/n)}]][[1]]

body;

vyrpresne[x_]:=(((x-1))^2)+3;
vyrhledam[x_]:=a*(x^2)+b*x+c;
body=Table[{x,vyrpresne[x]+RandomReal[{-0.5,0.5}]},{x,-1,3,0.2}];
pl1=ListPlot[body,PlotStyle->{PointSize[0.015],Red}];

err[{x_,y_}]:=(((y-vyrhledam[x]))^2);
celkeror=Plus@@(err/@body);
vyrhledam[x]/.Solve[0==D[celkeror,#]&/@{a,b,c}][[1]]
vysl=Fit[body,{1,x,(x^2)},x]//Simplify;
pl2=Plot[vysl,{x,-1,3},PlotStyle->Thick,GridLines->{Table[i,{i,-1,3,0.2}],Table[i,{i,3,7,0.2}]}];
Show[pl2,pl1]

ClearAll[uz]
uz[t_]:=100*Sin[314t+0.123]+5*Sin[3*314t+0.569];

c=16*(10^(-6));
R=50;
res=NDSolve[{uz[t]==R*i[t]+uc[t],i[t]==c*uc'[t],uc[0]==0},{uc,i},{t,0,0.1}][[1]];
proud[t_]:=i[t]/.res;
data=Table[{proud[t],proud'[t],uz'[t]},{t,0,0.1,0.0001}];
Fit[data,{pr,derpr},{pr,derpr}]

(1/c)

ClearAll["Global`*"];

Off[FindMinimum::"lstol"]

ClearAll["Global`*"];

n=3;
koeficientyNakladu={{100,0.1,0.01},{50,0.15,0.015},{150,0.08,0.006}};
minMaxVykony={{100,400},{50,200},{200,1000}};

fNaklady[vykon_,{a_,b_,c_}]:=a+b*vykon+c*(vykon^2);

vykony=(Subscript[P, #])&/@Range[n]
naklady=Plus@@MapThread[fNaklady,{vykony,koeficientyNakladu}]

fOmezeniVykonova[vykon_,{a_,b_}]:=a≤vykon≤b;
omezeniVykonova=MapThread[fOmezeniVykonova,{vykony,minMaxVykony}]

vykonCelkemZadany=500;
podminkaCelkovehoVykonu={vykonCelkemZadany==Plus@@vykony}

podminkyCelkem=Union[omezeniVykonova,podminkaCelkovehoVykonu]

NMinimize[Join[{naklady},podminkyCelkem],vykony]//Timing

strmost=3;
ClearAll[fPenale]
fPenale[x_,{a_,b_}]:=(2+(-Tanh[strmost*(x-a)]+Tanh[strmost*(x-b)]))*(((x-0.5*(a+b)))^2);

Plot[fPenale[x,{20,40}],{x,10,50},PlotRange->All,PlotStyle->Thick,AxesLabel->{"x","penale"}]

penaleCelkovyVykon=100*(((vykonCelkemZadany-Plus@@vykony))^2);
penaleVykonovaOmezeni=Plus@@MapThread[fPenale,{vykony,minMaxVykony}];

FminNeomezena=naklady+penaleCelkovyVykon+penaleVykonovaOmezeni

startHledani=minMaxVykony/.{a_,b_}:>((a+b)/2.)
zacatek=Thread[{vykony,startHledani}]
Quiet@FindMinimum[FminNeomezena,zacatek]//Timing

minMaxVykony

ClearAll[prenosIdeal];
prenosIdeal[ω_,k_]:=Module[{res,a,b,rce,ω0=1000},
rce={a-b==0.8,a+b==0.2};
res=Solve[rce][[1]];
a+b*Tanh[k*(ω-ω0)]/.res

];
pom=prenosIdeal[ω,.005]
ωmin=1;
ωmax=40000;
LogLogPlot[pom,{ω,ωmin,ωmax},PlotRange->All,PlotStyle->Thick,AxesLabel->{"ω [(s^(-1))]","Abs[P]"},GridLines->Automatic];

R1=1000;
par[list_]:=(((Plus@@(list^(-1))))^(-1));
ser[list_]:=Plus@@list;
z1=R1;
z2=par[{R3,ser[{R2,(1/(I*ω*c))}]}];
ClearAll[ω,absPrenos];
absPrenos[ω_]=Abs[(z2/(z1+z2))];
nBodu=100;
q=Select[qp/.Solve[ωmax==ωmin*(qp^(nBodu-1)),qp]//N,Im[#]==0&][[1]];
omega[i_]:=ωmin*(q^(i-1));

norm[x_]:=Abs[x];
err[ω_]:=norm[absPrenos[ω]-prenosIdeal[ω,.005]];
errcelkovy=Plus@@(err/@(omega/@Range[nBodu]));
rce={(R3/(R1+R3))==0.8,((par[{R2,R3}])/(R1+par[{R2,R3}]))==0.2};
respoc=Solve[rce][[1]];
proFindMin={{R2,R2/.respoc},{R3,R3/.respoc},{c,(10^(-6))}};
vys=Quiet@FindMinimum[errcelkovy,Evaluate[proFindMin],Method->"PrincipalAxis"][[2]];
vysprenos=absPrenos[ω]/.vys;
LogLogPlot[{pom,vysprenos},{ω,ωmin,ωmax},PlotRange->All,PlotStyle->Thick,AxesLabel->{"ω [(s^(-1))]","Abs[P]"},GridLines->Automatic]

lp[co_]:=LaplaceTransform[co,t,p];

rce=y''[t]+2y'[t]+3y[t]==u[t];
lp[rce]/.{LaplaceTransform[y[t],t,p]->Y[p],LaplaceTransform[u[t],t,p]->U[p]}
Solve[%,Y[p]]

(((1+p))^2)//Expand

mat=(({{0, 1}, {-4, -3}}));
v1={-2,7};
rce=Thread[{x1'[t],x2'[t]}==mat.{x1[t],x2[t]}+v1*u[t]]

laplasiRce=(lp/@rce)/.{LaplaceTransform[x1[t],t,p]->x1[p],LaplaceTransform[x2[t],t,p]->x2[p],x1[0]->0,x2[0]->0,LaplaceTransform[u[t],t,p]->u[p]}

Solve[laplasiRce,x1[p],x2[p]][[1]]
jmenovatel=%[[1,2]]//Denominator
Solve[jmenovatel==0]
Eigenvalues[mat]

DSolve[rce/.u[t]->0,{x1[t],x2[t]},t]

Plot[(E^(-0.1t))  Sin[(((Sqrt[7]) t)/2)],{t,0,50}]

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

Quiet@Remove["Global`*"];

R=0.1;
R1=0.5R;
R2=0.5R;
R3=1.5R;
R4=R;
u=230;
P1=1500;
P234=4000;
obvod={i1==((u-u1)/R1),i3==((u1-u2)/R2),i1==i2+i3,i4==((u-u3)/R3),i5==((u-u4)/R4)};
podminky={P1==u1*i2,P234==u2*i3+u3*i4+u4*i5};
ztraty=R1*(i1^2)+R2*(i3^2)+R3*(i4^2)+R4*(i5^2);
cons=Union[obvod,podminky];
proms=Union[Cases[cons,_Symbol,{0,∞}]];
Timing@FindMinimum[{ztraty,cons},proms]

Quiet@Remove["Global`*"];

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

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

myInt[f_,{x_,x1_,x2_}]:=y[x2]/.NDSolve[{y'[x]==f[x],y[x1]==0},y,{x,x1,x2}][[1]]
myInt[Sin,{x,0,Pi/2}]

ClearAll[myInt2];
myInt2[f_,{x_,x1_,x2_,n_Integer}]:=Module[{Δx,body},
Δx=((x2-x1)/n);
body=Range[x1+0.5Δx,x2,Δx];
Δx*Plus@@(f/@body)
];
myInt2[1+#&,{x,0,1,3}];
Integrate[1+x,{x,0,1}];
%-%%

Quiet@Remove["Global`*"];
vyr[x_]:=a*(x^2)+b*x+c;
rce={vyr[x0]==f0,vyr[x0-Δx]==fMinus,vyr[x0+Δx]==fPlus};
resabc=Solve[rce,{a,b,c}][[1]];
Integrate[vyr[x]/.resabc,{x,x0-Δx,x0+Δx}]

vahy[n_Integer]:=Append[Prepend[(((((-1))^(#+1))+1)&/@Range[n])+2,1],1];
vahy[10]//Length

ClearAll[myInt3];
myInt3[f_,{x1_,x2_,n_Integer}]:=Module[{vazky,body,Δx},
vazky=vahy[n-2];
Δx=((x2-x1)/(n-1));
body=Range[x1,x2,Δx];
((Δx)/3.)*(f/@body).vazky

];
f=1+#+((#)^2)+((#)^3)+((#)^4)&;
myInt3[f,{0.,1,5}]-Integrate[f[x],{x,0,1}]

Quiet@Remove["Global`*"];
n=10;
T=((2Pi)/ω);
vyr=(∑_(i=0)^n)((Subscript[a, i])*Cos[i*ω*t]+(Subscript[b, i])*Sin[i*ω*t])
(2/T)Integrate[vyr,{t,0,T}]