For the past month I have been trying to understand the math behind the autocorrelation function and partial autocorrelation function for time-series project I have been working on. However, I am only able to find loads of articles which answer questions like How you can generate ACF & PACF plot in Python or in R, How to understand ACF and PACF plot? or How to obtain p and q values from ACF or PACF plot? Nowhere I am able to find something which tells me the exact math behind them!
I am looking for something that derives this comprehensively enough, in hopes of trying to replicate derivation myself(am a computer science graduate). Can anyone help me out with the same? Any resource would do! Or maybe list down all the steps so that I can try researching in pieces.