input: Write a function to optimize an equation represented as a string by combining like terms. The function should return the optimized equation as a string. If the input equation is empty, the function should return an empty string.
  assert optimize_equation('x + x + y + y + y')=='x^2 + y^3'
  assert optimize_equation('a + a + a + b')=='a^3 + b'
  assert optimize_equation('c + c + c + c + c + d + d')=='c^5 + d^2'
  assert optimize_equation('')==''
output: def optimize_equation(equation):
      if not equation:
          return ''
      
      terms = equation.split(' + ')
      term_count = {}
      
      for term in terms:
          if term in term_count:
              term_count[term] += 1
          else:
              term_count[term] = 1
      
      optimized_terms = []
      for term, count in term_count.items():
          if count > 1:
              optimized_terms.append(f"{term}^{count}")
          else:
              optimized_terms.append(term)
      
      return ' + '.join(optimized_terms)