I had that problem when I was a kid I was diagnosed with adhd when was in 9th grade. Y
But you have to get tested for it so I can't say for sure if it turns out you have that though you don't always need medications. They have allot of good programs and there are even books written in a way that makes it easier for adhd people to focus on them. There might be things like that out now for homework or ways the teacher can arrange how its worded on the paper so it will be easier for you to stick to it and get it done.
I had a very good dr who diagnosed me. He had allot of good ideas to help me focus on my work he added things into my iep like I was allowed to listen to music while doing school work so I could tune out distractions as well as if there was a book report due and they wanted you to write it out I was allowed to use the computer or typewriter because it made it easier and I wouldn't have such a hard time focusing on my writing for me it was the pencil and paper that was hard I have awful and writing and it would take me a very long time to get going.
I was awful at basic math and algebra but very good at geometry.
So that's cool your doing algebra ^_^