@Florencia you are correct. The formula for the gradient is y2-y1/x2-x1. Implying that 3-(-1) / 3-1 which is 4/2=2. This makes the gradient of the perpendicular line -1/2, not -2.
For the last step, all you have to do is with the help of the midpoint and the gradient find the value of b. (y=ax+b). Insert the values of the midpoint along with the gradient which are (1,2) into the equation. Then you are left with 2= - 1/2 * 2 + b. Solving this you get b which is 3. Then you get the equation of the line: y= -1/2x + 3