You can maybe split this up into chunks. They will be split into different chunks that can be independently run in SymPy Live, and it will make it easier to read.