beat (one's) head against a stone wall
To attempt, continuously and fruitlessly, to accomplish some task or achieve some goal that is or seems ultimately hopeless. I feel like I've been beating my head against a stone wall trying to understand this math equation. Some people are never going to agree with you on this, so it's no use beating your head against a stone wall to try and convince everyone.