# Local density approximation: How do I get an expression for exchange and correlation for an atom?

I want to make a DFT program for an atom in the local density approximation. The user specifies the proton number and electron quantum numbers $$n,l$$, and the program returns the ground state energy by solving the radial equation iteratively. In Hartree units, I am solving the equation $$- \frac{1}{2} \frac{d ^2 u^\sigma_{ln}}{dr^2} + \left[ V_\text{eff}(r) + \frac{1}{2}\frac{l(l+1)}{r^2} \right] u^\sigma_{ln} = Eu^\sigma_{ln}$$ Using the potential $$V_\text{eff}^\sigma(r) = V_\text{Enuc}(r) + V_\text{Hartree}(r) + V_\text{x}^\sigma(r) + V_\text{c}(r).$$ And then assume that $$\psi_{lm}^\sigma = R_{nl}^\sigma Y^m_l$$ where $$R_{nl}^\sigma = u^\sigma_{ln}/r$$. My question: In this case, what are the correct expressions for exchange and correlation?

Here is my attempt. It would be good if you could correct me using the same kind of notation that I am using because I find it (very interesting) but already pretty difficult. For exchange, my reference said that \begin{align*} V_\text{x}^\sigma &= \frac{4}{3}\varepsilon_\text{x}^\sigma \qquad \text{and I believe for unif. elect. gas} \qquad \varepsilon_\text{x}^\sigma = -\frac{3}{4}\left( \frac{6}{\pi} n^\sigma \right). \end{align*} I am puzzled by this because my reference also says (for contradiction?) that $$V_\text{x}^\sigma = [\varepsilon_{x} + n(\partial \varepsilon_\text{x}/\partial n^\sigma)]$$, and I can only get the equation to the left if I in addition assume that $$n = n^\sigma$$. Anyway, I trust my reference and not myself and combine these and get $$V_\text{x}^\sigma = \frac{4}{3}(- \frac{3}{4})\left( \frac{6}{\pi} n(r; \sigma) \right)^{1/3} = - \left( \frac{6}{\pi}\sum_{i=1}^{N^\sigma}|\psi_i^\sigma|^2 \right)^{1/3}$$ for homogenous gas. My reference again postulates that for correlation $$V_\text{c}(r_s) = \varepsilon_\text{c}(r_s) - \frac{r_s}{3} \frac{d\varepsilon_\text{c}}{dr_s}(r_s)$$ In the VWN approximation we have: \begin{align*} \frac{2}{A}\varepsilon_\text{c}(r_s) = \log\left[ \frac{y^2}{Y(y)} \right] &+ \frac{2b}{Q} \arctan\left( \frac{Q}{2y + b} \right)\\ &- \frac{by_0}{Y(y_0)} \left( \log\left[ \frac{(y - y _0)^2}{Y(y)}\right] + \frac{2(b + 2y_0)}{Q} \arctan\Big( \frac{Q}{2y +b} \Big) \right) \end{align*} $$Y(y) = y^2 + by + c$$, $$Q = (4c -b^2)^{1/2}$$, $$y_0 = -0.10498$$, $$b = 3.72744$$, $$c = 12.93532$$, $$A = 0.0621814$$ and $$y = r_s^{1/2}$$. My reference says that the derivative is $$r_s \frac{ d\varepsilon_\text{c}}{dr_s}(r_s) = A \frac{1}{2} \frac{c(y-y_0) - by_0y}{(y-y_0)(y^2 + by + c)}$$ Using these I get a lengthy expression for $$V_\text{c}$$.

Where does this go wrong, and why?