I was accepted into a PhD in maths at a fairly highly ranked school in 2017. My supervisor was known for being quite demanding, but I wanted this because I wanted to push myself, and he is quite well known in the field I was interested in, which is algebraic geometry.
During the first year I was doing background work and developed my maths up to the point where I could start actually doing research. This involved going through textbooks and exercises and generally learning maths at a high level. Each week he was unhappy with my work, and would find holes in the proofs and logic, and holes in my understanding. After this happened over months, he began to suggest that maybe maths wasn't for me. Eventually he basically explicitly said this, and said that I wasn't understanding the material and wasn't able to think mathematically. He suggested that I drop out and "do something else with my life".
The other issue here is that I was suffering from depression, and was fairly burned out from my undergrad, and I blame that in large part for not being able to study efficiently and think clearly. I did end up leaving the program late 2018, and I got a medical certificate to document the depression.
The thing is, I am determined to succeed. I know for a fact that a PhD in maths is what I want to do, and I am not willing to give up on that. I am certain I have the ability, and am putting my failure down to the above mentioned issues. I am still doing maths every day to keep my skill level up and increase my understanding. At some point I want to reenter a PhD program. That is where my question comes in.
What is the best way to get back into a PhD? How much will my past dismissal (technically I left voluntarily) affect my chances? Given that my supervisor has said flat out that he doesn't think I am cut out for maths research, how would I go about getting an academic reference for any future application? Any other advice is appreciated.