Find the expression of M (a) when the minimum value of function f (x) = x ^ 2 + 2aX + 3 is m (a)

Find the expression of M (a) when the minimum value of function f (x) = x ^ 2 + 2aX + 3 is m (a)

Let X be {1,2} or x [1,2]
X [1,2] is as follows
f(x)=(x+a)^2+(3-a^2)
a[-1:-2] f(x)min=(3-a^2) ;m(a)=3-a^2
a>-1:f(x)min=f(1)=1+2a+3 ;m(a)=4+2a
a