Solution (source code)

= Solution

Stationarity gives $\operatorname{artanh}m=\beta(B+6Jm+6Km^2)$, or $m=\tanh Q(m)$ with $Q(m)=\beta(B+6Jm+6Km^2)$.