bang one’s head against a brick wall

(fig.) udariti glavom o zid; lupiti (udariti) glavom o zid razočarati se, snositi loše posljedice zbog zablude ili pogreške, prekasno shvatiti i kajati se zbog onog što je počinjeno;

I feel like I’ve been banging my head against a brick wall trying to understand this math equation. Some people are never going to agree with you on this, so it’s no use banging your head against a brick wall trying to convince everyone.