A recent study has shown how mathematical Bach's music is, the study can be found here https://www.classicfm.com/.../mathematical-genius-revealed/
Now, those of you that have read my book The Modal Method will know that the Appendix contains an analysis of the Chaconne in D minor from the violin sonata. You will also know that the approach I use and explain in the book is based upon a simple mathematical operation that applies to scales, key changes and cadences.
I am sure Bach used the same approach, as I discovered the method while analysing the complete works of Bach for solo instruments. I'll leave you to read the article on the study and make your own opinion.
For those who are interested, my book can be found at https://www.bedwellmusic.co.uk/general-7
Glad to see this aspect of his genius recognized. A friend of mine and fellow music nerd use to call Bach 'The sound of mathematics'.