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

file=FileNames["*.csv"][[1]];
data=Import[file];
pl1=ListPlot[data,PlotStyle->{Red,PointSize[0.01]}];

xmax=15;
Plot[{(2/Pi)ArcTan[3x],Tanh[x]},{x,-xmax,xmax},PlotStyle->{Red,Blue}];

model[x_]:=a*Tanh[b*(x-c)]+d;
err[{x_,y_}]:=(((y-model[x]))^2);
proMinimim=Plus@@(err/@data);
dos=FindMinimum[proMinimim,{c,2.5},{b,1},{a,1},{d,1}][[2]];
proklad=model[x]/.dos;
{xmin,xmax}={Min[First/@data],Max[First/@data]};
pl2=Plot[proklad,{x,xmin,xmax}];
Show[pl1,pl2];

ClearAll[model];
v[i_]:=(Subscript[α, i]);
model=v[1]*Tanh[v[2]*(x-v[3])]+v[4];
params=Union[Cases[model,(Subscript[α, _]),{0,∞}]]
fit=FindFit[data,model,params,x,MaxIterations->(10^3),Method->NMinimize];
proklad2=model/.fit;
pl3=Plot[proklad2,{x,xmin,xmax}];
Show[pl1,pl3]

Series[f[Δ],{Δ,0,3}];
Series[f[-Δ],{Δ,0,3}];
%-%%;

Δx=Mean[Union[Partition[First/@data,2]/.{x1_,x2_}:>x2-x1]];

derivace[{{x1_,y1_},{x2_,y2_},{x3_,y3_}}]:=((y3-y1)/(2*Δx));
proVysledek[arg:{{x1_,y1_},{x2_,y2_},{x3_,y3_}}]:={x2,derivace[arg]};
trojice=Partition[data,3,1];
dataDer=proVysledek/@trojice;
ListPlot[dataDer,PlotRange->All];
{xMaxDer,maxDer}=First[Sort[dataDer,#1[[2]]>#2[[2]]&]];

model3[x_]:=a*Tanh[b*(x-xMaxDer)]+c;
rce1=model3'[xMaxDer]==maxDer//Chop;
yMax=data[[-1,2]];
yMin=data[[1,2]];
rce2=-a+c==yMin;
rce3=a+c==yMax;
Solve[{rce1,rce2,rce3}]

podivnaFce[x_]:=Exp[-(0.5(x^2)+x+0.01(x^3))];
dataFce={#,podivnaFce[#]}&/@Range[0,5,0.1];
FindFit[dataFce,Exp[a*x+b*(x^2)+c*(x^3)],{a,b,c},x]

logData=DeleteCases[dataFce/.{x_,y_}:>{x,Log[x]},{_,Indeterminate}];
ListPlot[logData,PlotStyle->{Red,PointSize[0.01]}]
Fit[logData,{x,(x^2),(x^3)},x];