Implemented and tested the standalone function linearCombination(a, P, b, Q)