Find the maximum of a solution expression of a quadratic equation

Question:
Given: x1 and x2 are two solutions of the quadratic equation x2 - (k - 1)x + k2 + 2k + 1 = 0. Find the maximum of x12 + x22
Solution:
If the quadratic equation has two solutions, then b2 - 4ac >= 0
For this quadratic equation: a = 1, b = - (k - 1), c = k2 + 2k + 1
b2 - 4ac = [-(k - 1)]2 - 4(1)(k2 + 2k + 1)
= (-1)2 (k - 1)2 - 4(k2 + 2k + 1)
= k2 - 2k + 1 - 4k2 - 8k - 4
= -3k2 - 10k - 3
= -(3k2 + 10k + 3)
Since the quadratic equation has two solutions, so b2 - 4ac >= 0
then -(3k2 + 10k + 3) >= 0
Both side of the inequality multiply (-1) and the inequality change its direction
3k2 + 10k + 3 <= 0
k1 <= [-10 + square root of (102 - 4 × 3 × 3)]/(2 × 3)
= [-10 + square root of (100 - 36)]/6
= [-10 + square root of 64]/6
= [-10 + 8]/6
= -2/6
= -1/3
k2 <= [-10 - square root of (102 - 4 × 3 × 3)]/(2 × 3)
= [-10 - square root of (100 - 36)]/6
= [-10 - square root of 64]/6
= [-10 - 8]/6
= -18/6
= -3
so the k is in the range of -3 <= k <= -1/3
 x12 + x22
= (x1 + x2)2 - 2x1x2
= (k - 1)2 - 2(k2 + 2k + 1)
= k2 - 2k + 1 - 2k2 - 4k -2
= - k2 - 6k - 1
= - (k2 + 6k + 1)
= - (k2 + 6k + 32 - 32 + 1)
= - (k2 + 6k + 32) + 9 - 1
= - (k + 3)2 + 8
When k = -3, x12 + x22 = 8
k = -3 is in the range of k. So when k = -3, x12 + x22 reach the maximum 8.

Rule used: If quadratic equation x2 + px + q has two solution x1 and x2, then the sum of these two solution is -p. That is, x1 + x2 = -p. The product of these two solutions is q. That is, x1 x2 = q.