Ok, so this is the moment I show how little physics I know... Anyway, what about something like replacing the variables with their dimensions, e.g.
Then decide if the degree of L is correct?
No, your second example gives a division by zero. Sorry, we can't do this robustly currently I think. An interesting project for a physics person: dimensional analysis in Maxima.
Yet, it might be worth a second try, once our moodle and stack are updated.