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

vyr[x_]:=a*(x^2)+b*x+c;
rce={vyr[x0]==f0,vyr[x0+dx]==fplus1,vyr[x0-dx]==fminus1};
res=Solve[rce,{a,b,c}][[1]];
integrand=vyr[x]/.res;
intNormal=Integrate[integrand,{x,x0-dx,x0+dx}]

intNewVlevo=Integrate[integrand,{x,x0-(3/2)dx,x0+dx}]

intNewVlevo-intNormal

plusVahyVlevo={(17/24),((-7)/24),(1/12)}

intNewVpravo=Integrate[integrand,{x,x0-dx,x0+(3/2)dx}]

intNewVpravo-intNormal

plusVahyVpravo=Reverse[{(17/24),((-7)/24),(1/12)}];
plusVahyVpravo==Reverse[plusVahyVlevo]
plusVahyVpravo

vahyOld[n_Integer]:=(1/3)Prepend[Append[((((-1))^(#+1))+3)&/@Range[2n+1],1],1];
vahyOld[5]
deltaVahy[n_Integer]:=Module[{oldVahy,nVah},
oldVahy=vahyOld[n];
nVah=Length[oldVahy];
Join[plusVahyVlevo,(0&/@Range[nVah-6]),plusVahyVpravo]
];
deltaVahy[5]
vahy[n_Integer]:=vahyOld[n]+deltaVahy[n];
vahy[5]

(*ukazkove pouziti pro zjisteni amplitudy*)
sr=1000;(*kolik samplu ODPOVIDA jedne sekunde, jsou to ale vnitrni samply*)
(*a ted to chosi nufozne i pro male sr*)
dt=(1/sr);
f=(sr/171)(*jmenovatel liche cislo musi byt*);
T=(1/f);
sampluNaPeriodu=(T/dt);

signalfce[t_]:=1*Sin[2.*Pi*f*t+0.642];
tabSin=Sin[2.Pi*f*#]&/@Range[0,T-dt,dt];
tabCos=Cos[2.Pi*f*#]&/@Range[0,T-dt,dt];
nPeriod=10;
signal=signalfce/@Range[0,nPeriod*T,dt];
%//ListPlot;
vydejAmplitdu[k_Integer]:=Module[{dats,vazky,nProVahy,intSin,intCos},
dats=Take[signal,{k,k+sampluNaPeriodu-1}];
nProVahy[i_Integer]:=(1/2) (-3+i);
vazky=vahy@nProVahy[sampluNaPeriodu]//N;
intSin=dt*((tabSin*dats).vazky);
intCos=dt*((tabCos*dats).vazky);
(2/T)(I*intCos+intSin)

];
vydejAmplitdu[1]
%//Abs