We present the use of the recently developed Square Gradient Minimization (SGM) algorithm for excited state orbital optimization, to obtain spin-pure Restricted Open-Shell Kohn-Sham (ROKS) energies for core excited states of molecules. The SGM algorithm is robust against variational collapse, and offers a reliable route to converging orbitals for target excited states at only 2-3 times the cost of ground state orbital optimization (per iteration). ROKS/SGM with the modern SCAN/ωB97X-V functionals is found to predict the K edge of C,N,O and F to a root mean squared error of ∼0.3 eV. ROKS/SGM is equally effective at predicting L edge spectra of third period elements, provided a perturbative spin-orbit correction is employed. This high accuracy can be contrasted with traditional TDDFT, which typically has greater than arXiv:1912.05249v2 [physics.chem-ph] 9 Jan 2020 10 eV error and requires translation of computed spectra to align with experiment.ROKS is computationally affordable (having the same scaling as ground state DFT, and a slightly larger prefactor) and can be applied to geometry optimizations/ab-initio molecular dynamics of core excited states, as well as condensed phase simulations. ROKS can also model doubly excited/ionized states with one broken electron pair, which are beyond the ability of linear response based methods.Spectroscopy of core electrons is an useful tool for characterizing local electronic structure in molecules and extended materials, and has consequently seen wide use for studying both static properties 1-3 and dynamics 4-6 of chemical systems. Theoretical modeling of core excited states is however a challenging task, as traditional quantum chemistry methods are typically geared towards understanding behavior of valence electrons. Indeed, it is common practice to 'shift' computed X-ray absorption spectra (XAS) by several eV to align with experiment. 7-12 Such uncontrolled translation of spectra for empirical mitigation of systematic error is quite unappealing, and creates considerable scope for incorrect assignments.Linear response (LR) methods like time dependent density functional theory (TDDFT) [13][14][15] and equation of motion coupled cluster (EOM-CC) 16,17 are widely used to model excitations.LR methods do not require prior knowledge about the nature of targeted states, as they permit simultaneous calculation of multiple states on an even footing. However, widely used LR methods only contain a limited description of orbital relaxation, leading to poor performance for cases where such effects are essential (such as double excitations, 18-20 as well as charge-transfer 15,21 and Rydberg states 18,22 in the case of TDDFT). Core excitations in particular are accompanied by substantial relaxation of the resulting core-hole (as well as relaxation of the valence density in response), leading to rather large errors with standard LR protocols. For instance, TDDFT spectra often need to be blue-shifted by > 10 eV to correspond to experiment 7-10 (unless short-range corrected functionals spec...