def calc_perfect_auc_at_k(k,when_reaches_max,height):
  """
  Calculates the AUC of the best recall@k AUC possible.

  input: 

  k : the k value until which to calculate the AUC.
  when_reaches_max : the value of k in which the perfect recall@k graph should reach its max value (usually 1).
  height : the max value (usually 1) of the recall@k graph.

  output:

  the AUC of the best recall@k AUC possible
  """
  if(k<=when_reaches_max):
    # calc the area of the triagle
    return ((when_reaches_max*height)/2)*(k/when_reaches_max)**2
  # calc the area of the full triagle plus the rectangle
  return ((when_reaches_max*height)/2) + (k-when_reaches_max)*height