  For families of Hamiltonians defined by parts that are local, the most
general definition of a symmetry algebra is the commutant algebra, i.e., the
algebra of operators that commute with each local part. Thinking about symmetry
algebras as commutant algebras allows for the treatment of conventional
symmetries and unconventional symmetries (e.g., those responsible for weak
ergodicity breaking phenomena) on equal algebraic footing. In this work, we
discuss two methods for numerically constructing this commutant algebra
starting from a family of Hamiltonians. First, we use the equivalence of this
problem to that of simultaneous block-diagonalization of a given set of local
operators, and discuss a probabilistic method that has been found to work with
probability 1 for both Abelian and non-Abelian symmetries or commutant
algebras. Second, we map this problem onto the problem of determining
frustration-free ground states of certain Hamiltonians, and we use ideas from
tensor network algorithms to efficiently solve this problem in one dimension.
These numerical methods are useful in detecting standard and non-standard
conserved quantities in families of Hamiltonians, which includes examples of
regular symmetries, Hilbert space fragmentation, and quantum many-body scars,
and we show many such examples. In addition, they are necessary for verifying
several conjectures on the structure of the commutant algebras in these cases,
which we have put forward in earlier works. Finally, we also discuss similar
methods for the inverse problem of determining local operators with a given
symmetry or commutant algebra, which connects to existing methods in the
literature. A special case of this construction reduces to well-known
``Eigenstate to Hamiltonian" methods for constructing Hermitian local operators
that have a given state as an eigenstate.
