n=150;U[Nup_]:=n-2Nup;M[Nup_]:=((-U[Nup])/n);MA[x_]:=Tanh[(1/x)];OmegaN[Nup_]:=Binomial[n,Nup];S[Nup_]:=Log[OmegaN[Nup]];
OmegaA1[Nup_]:=((h!)/(k!b!))/.h_!->(h^h)Exp[-h]/.h->n/.k->Nup/.b->(n-Nup)//FullSimplify;OmegaA2[Nup_]:=((h!)/(k!b!))/.h_!->(h^h)Exp[-h](Sqrt[2π h])/.h->n/.k->Nup/.b->(n-Nup)//FullSimplify;SA1[Nup_]:=Log[OmegaA1[Nup]];SA2[Nup_]:=Log[OmegaA2[Nup]];T[Nup_]:=((U[Nup+1]-U[Nup-1])/(S[Nup+1]-S[Nup-1]));TA[x_]:=(2/(Log[(n-x)/(n+x)]));Cv[Nup_]:=(((S[Nup+1]-S[Nup-1])/(T[Nup+1]-T[Nup-1]))/n)*T[Nup];CvA[x_]:=(((((1/x)))^2)/((Cosh[(1/x)])^2))

p1=ListPlot[{Reverse@Table[{U[i],S[i]},{i,0,n,1}],Reverse@Table[{U[i],SA1[i]},{i,0,n,1}],Reverse@Table[{U[i],SA2[i]},{i,0,n,1}]},PlotTheme->"Scientific",FrameLabel->{"U/μB","S/k"},PlotStyle->{{Black,PointSize[0.00625]},{Red,Thick},{Blue,Thick}},Joined->{False,True,True},PlotRange->All,PlotLegends->{"Numerical",TraditionalForm[N!≈(N^N)Exp[-N]],TraditionalForm[N!≈(N^N)Exp[-N]((Sqrt[2π N])//HoldForm)]},ImageSize->Large]//Quiet

p2=Show[ListPlot[{Reverse@Table[{U[i],T[i]},{i,0,n,1}]},PlotTheme->"Scientific",FrameLabel->{"U/μB","kT/μB"},PlotStyle->{{Black,PointSize[0.00625]},{Blue,Thick}},Joined->{False,True,True},PlotLegends->{"Numerical",TraditionalForm[N!≈(N^N)Exp[-N]],TraditionalForm[N!≈(N^N)Exp[-N]((Sqrt[2π N])//HoldForm)]},ImageSize->Large]//Quiet,Plot[TA[x],{x,-150,150},PlotTheme->"Scientific",FrameLabel->{"U/μB","kT/μB"},PlotStyle->{{Red,PointSize[0.00525]},{Blue,Thick}},PlotRange->All,PlotLegends->{TraditionalForm[N!≈(N^N)Exp[-N]],TraditionalForm[N!≈(N^N)Exp[-N]((Sqrt[2π N])//HoldForm)]},ImageSize->Large],PlotRange->{All,{-30,30}}]

p3=Show[ListPlot[Reverse@Table[{T[i],M[i]},{i,0,n,1}],PlotTheme->"Scientific",FrameLabel->{"kT/μB","M/Nμ"},PlotStyle->{{Black,PointSize[0.00625]},{Red,Thick}},Joined->{False,True,True},PlotRange->All,PlotLegends->{"Numerical",TraditionalForm[N!≈(N^N)Exp[-N]],TraditionalForm[N!≈(N^N)Exp[-N]((Sqrt[2π N])//HoldForm)]},ImageSize->Large]//Quiet,Plot[MA[x],{x,-150,150},PlotRange->All,PlotTheme->"Scientific",FrameLabel->{"kT/μB","M/Nμ"},PlotStyle->{{Red,PointSize[0.00625]},{Blue,Thick}},PlotLegends->{TraditionalForm[N!≈(N^N)Exp[-N]],TraditionalForm[N!≈(N^N)Exp[-N]((Sqrt[2π N])//HoldForm)]},ImageSize->Large]]

p4=Show[ListPlot[{Reverse@Table[{T[i],Cv[i]},{i,0,n,1}]},PlotTheme->"Scientific",FrameLabel->{"kT/μB","C/Nk"},PlotStyle->{{Black,PointSize[0.00625]},{Blue,Thick}},PlotRange->{{0,10},All},Joined->{False,True,True},PlotRange->All,PlotLegends->{"Numerical",TraditionalForm[N!≈(N^N)Exp[-N]],TraditionalForm[N!≈(N^N)Exp[-N]((Sqrt[2π N])//HoldForm)]},ImageSize->Large]//Quiet,Plot[CvA[x],{x,0,150},PlotRange->All,PlotTheme->"Scientific",FrameLabel->{"U/μB","kT/μB"},PlotStyle->{{Red,PointSize[0.00625]},{Blue,Thick}},PlotLegends->{TraditionalForm[N!≈(N^N)Exp[-N]],TraditionalForm[N!≈(N^N)Exp[-N]((Sqrt[2π N])//HoldForm)]},ImageSize->Large],PlotRange->{{0,10},All}]//Quiet

SetAttributes[QExport,HoldFirst]
QExport[x_]:=Export["C:\\Users\\Administrator\\Downloads\\430HW5\\"<>ToString[SymbolName[Unevaluated@x]]<>".pdf",x]