def perpendicular(x_val, y_val):
  """
  This function gives the intercepts and slope of the perpendicular bisector of a given line segment.

  Parameters
  ----------
  x_val, y_vals : coordinates of the two points of the line segments(x_val = [x1, x2], y_val = [y1, y2]).

  Return
  ----------
  cx, cy : intercepts of the perpendicular bisector.
  slope : slope of perpendicular bisector.
  """
  slope = (y_val[1] - y_val[0])/(x_val[1] - x_val[0])
  q = (y_val[1] + y_val[0])/2 
  p = (x_val[1] + x_val[0])/2
  slope = -1/slope
  cy = -slope * p + q
  cx = p - q/ slope 
  return cx, cy, slope