For each of the levels (u for upper, l for lower) in LS coupling holds:

$$g_\mathrm{LS} =\frac{3}{2}+\frac{S (S+1) - L (L+1)}{2J(J+1)}, $$

where $L$, $S$ and $J$ are the orbitatl, spin and total angular momentum quantum numbers of the atomic level (note that it is undefined for $J=0$). The effective Lande g-factor is then defined as:

$$\bar{g} = \frac{1}{2}(g_\mathrm{l} +g_\mathrm{u}) + \frac{1}{4}(g_\mathrm{l} - g_\mathrm{u})(J_\mathrm{l}(J_\mathrm{l}+1) - J_\mathrm{u}(J_\mathrm{u}+1)).$$

Here is my IDL code for computing the effective Lande g-factor of a spectral line in LS coupling. At the input the code takes the quantum number of the lower and the upper level of a transition. The numbers may be specified either as an array [L, S, J] or in spectroscopic notation.

Example:

```
IDL> PRINT, LANDE_FACTOR(lower = [3., 1, 2.], upper = '3p1.0')
Upper term: 3p1.0 => l = 1.00000s = 1.00000j = 1.00000
0.250000
IDL> PRINT, LANDE_FACTOR(lower = '5F1.0', upper = '5d0.0')
Lower term: 5f1.0 => l = 3.00000s = 2.00000j = 1.00000
Upper term: 5d0.0 => l = 2.00000s = 2.00000j = 0.00000
0.00000
```

Download: lande_factor.pro