  The understanding of complex quantum many-body systems has been vastly
boosted by tensor network (TN) methods. Among others, excitation spectrum and
long-range interacting systems can be studied using TNs, where one however
confronts the intricate summation over an extensive number of tensor diagrams.
Here, we introduce a set of generating functions, which encode the diagrammatic
summations as leading order series expansion coefficients. Combined with
automatic differentiation, the generating function allows us to solve the
problem of TN diagrammatic summation. We illustrate this scheme by computing
variational excited states and dynamical structure factor of a quantum spin
chain, and further investigating entanglement properties of excited states.
Extensions to infinite size systems and higher dimension are outlined.

Strongly Correlated Electrons;Quantum Physics