I like the joke, but to play the devil's advocate it's slightly sexist to assume the mathematician and the engineer are both male.
If one were male and the other were female, the joke wouldn't work.
If both were female it wouldn't work, as (if you're male like me) you're aware of our inherent and unfortunate sexism (our rational brain shuts down upon viewing an attractive female).
The difference between sexism and acceptable behaviour is knowing this limitation of our selves and acting respectfully with the other sex.