I think that some strict teachers would be UNhappy with that sentence.
It sounds as if the rules are performing calculations.
So it should probably be changed to something like:
"When performing calculations, you / one / people should observe certain rules."
*****
For example,
"While walking down the street, an accident happened." Of course, the accident was not walking down the street.
So we need to say: While walking down the street, I saw an accident happen right before my eyes.