Perform advanced mathematical operation using Python