Question: what are the mathematical rules?
Answer: Brackets (parts of a calculation inside brackets always come first).
Orders (numbers involving powers or square roots).
Division.
Multiplication.
Addition.
Subtraction.