q[elist_,glist_,beta_]:=Sum[glist[[i]]*Exp[-beta elist[[i]]],{i,1,Length[elist]}]

e[elist_,glist_,beta_]:=Sum[elist[[i]]glist[[i]]*Exp[-beta elist[[i]]],{i,1,Length[elist]}]/q[elist,glist,beta]

e2[elist_,glist_,beta_]:=Sum[elist[[i]]^2glist[[i]]*Exp[-beta elist[[i]]],{i,1,Length[elist]}]/q[elist,glist,beta]

cv[elist_,glist_,beta_]:=beta^2  (e2[elist,glist,beta]-e[elist,glist,beta]^2)

GraphicsColumn[
{
Plot[e[{1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16},{1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},1/x],{x,0,10},PlotRange->All]

Plot[cv[Range[100],100/Range[100],1/x],{x,0,1},PlotRange->All]

mxn=20;
el=ConstantArray[0,mxn];
Manipulate[
ListPlot[Table[i,{i,1,n}]],
{n,2,mxn},
Sequence[Table[{el[[i]],0,100},{i,1,n}]]
]

q[elist_,beta_]:=Sum[Exp[-beta elist[[i]]],{i,1,Length[elist]}]

pop[elist_,beta_]:=Table[Exp[-beta elist[[i]]],{i,1,Length[elist]}]/q[elist,beta]

e[elist_,beta_]:=Sum[elist[[i]]Exp[-beta elist[[i]]],{i,1,Length[elist]}]/q[elist,beta]

e2[elist_,beta_]:=Sum[elist[[i]]^2Exp[-beta elist[[i]]],{i,1,Length[elist]}]/q[elist,beta]

cv[elist_,beta_]:=beta^2  (e2[elist,beta]-e[elist,beta]^2)

mxn=20;
mxtemp=50; mxene=100;
el=Table[i,{i,1,mxn}];
temp=5; uint=5;
DynamicModule[{n=5},Column[
{
Row[{"N. Levels",Slider[Dynamic[n],{2,mxn,1},Appearance->"Labeled"]}],
Row[{
Dynamic[Grid[Table[With[{i=i},{"Level "<>ToString[i],Slider[Dynamic[el[[i]]],{0.1,mxene} ,Appearance->"Labeled"]}],{i,n}] ]],(*Dynamic*)
Column[{Style["Energy levels",Bold],
Dynamic[
Show[Graphics[{Thick,
Red,
Table[Line[{{0,el[[i]]},{1,el[[i]]}}],{i,1,n}]
}],
Frame->True,FrameLabel->{"","energy"},PlotRange->{Min[el[[1]],0],Max[el[[Range[n]]]]*1.05},
FrameTicks->{None,Automatic,None,Automatic},AspectRatio->0.8,ImageSize->Medium
],UpdateInterval->uint
]}]}],
Style["Mean Energy",Bold],
Row[{
Dynamic[Plot[e[el[[Range[n]]],1/tt],{tt,0.1,mxtemp},Frame->True,FrameLabel->{"T","<E>"},PlotRange->All,ImageSize->Medium],UpdateInterval->uint,TrackedSymbols->{}],
Dynamic[LogLogPlot[e[el[[Range[n]]],1/tt],{tt,0.1,mxtemp},Frame->True,FrameLabel->{"T","<E>"},PlotRange->All,ImageSize->Medium],UpdateInterval->uint,TrackedSymbols->{}]
}],
Style["Heat capacity",Bold],
Row[{
Dynamic[Plot[cv[el[[Range[n]]],1/tt],{tt,0.1,mxtemp},Frame->True,FrameLabel->{"T","Cv"},PlotRange->All,ImageSize->Medium,PlotStyle->Red],UpdateInterval->uint,TrackedSymbols->{}],
Dynamic[LogLogPlot[cv[el[[Range[n]]],1/tt],{tt,0.1,mxtemp},Frame->True,FrameLabel->{"T","Cv"},PlotRange->All,ImageSize->Medium,PlotStyle->Red],UpdateInterval->uint,TrackedSymbols->{}]
}]
,Row[{"Temperature",Slider[Dynamic[temp],{0.1,mxtemp},Appearance->"Labeled"]}],
Style["Populations",Bold],
Dynamic[BarChart[pop[el[[Range[n]]],1/temp],ImageSize->Medium],UpdateInterval->uint,TrackedSymbols->{}]
},

Center,0,ItemSize->Automatic],
SaveDefinitions->True
]

Sum[i^-n,{i,1,Infinity}]

testq=Sum[Exp[-beta  Log[i] de ] ,{i,1,Infinity}]

teste=Sum[Log[i] de Exp[-beta  Log[i] de ] ,{i,1,Infinity}]

testcv=FullSimplify[-D[Log[testq],{beta,1}]]

Table[Log[i],{i,1,1000.}]

Plot[testcv/.{de->0.5,beta->1/T},{T,0.01,0.9},PlotRange->All]

testcv/.{de->1,beta->1.001}