Composition of solutions of quadratic Diophantine equations