In the actual program, the second-order energy in Eq. ( ) is calculated using algebraic operations involving a large number of matrices. These matrices are constructed from one and two-electron integrals, as well as first-order to fourth-order density matrices calculated from CI coefficients obtained by CASCI calculations. (See Eq.( )-Eq.( ) in Ref 28 for example.) Within the diagonal approximation of CASPT2 28 introduced in our program, the generalized Fock operator containing only the diagonal elements is utilized. This effectively reduces the computational cost because the linear equation in Eq. ( ) can be separated into eight independent subspaces (generally called A-H) by classifying the excitation patterns for |𝑗⟩. In the CASCI-CASPT2 method, a major challenge arises as the size of the CAS increases, leading to an explosion in the number of electronic configurations, rendering the computation impractical. To overcome this limitation, the RASCI-RASPT2 method divides the CAS into three orbital spaces known as RAS1, RAS2, and RAS3, where specific restrictions on excitations are imposed. Figure illustrates a summary of each space and its corresponding restrictions. In the RASCI-RASPT2 method, 'secondary' orbitals in CASCI-CASPT2 are refered to 'external' orbitals.