First one
The function max = 5
The function min = -1
The equation of the midline is
y = [ function max + function min ] / 2 = [ 5 + - 1 ] / 2 = 4 / 2 = 2
So.... y = 2 = equation of midline
Second one
Here you go : https://www.desmos.com/calculator/xxf1s9z0my