ClearAll["Global`*"];
SetDirectory[NotebookDirectory[]];
$HistoryLength=3;

coefficients[n_Integer?(#>1&)]:=Module[{vyr,x,eqns,decka,dosd,integrand,integral,koefky,d,x1,f,Δx,t},
vyr=Sum[(Subscript[d, i])*((#)^(i-1)),{i,n}]&;
x[i_]:=x1+Δx*(i-1);
eqns=f[#]==vyr[x[#]]&/@Range[n];
decka=(Subscript[d, #])&/@Range[n];
dosd=Solve[eqns,decka][[1]];
integrand=vyr[t]/.dosd;
integral=Integrate[integrand,{t,x1,x[n]}];
koefky=Coefficient[Simplify[(integral/(Δx))],f[#]]&/@Range[n]
];
coefficients[1]:={1};