input: Write a function to optimize an equation by combining identical terms. The function should take a string representing the equation as input and return a new string with combined terms in the format of "variable^count".
  assert optimize_equation("x + x + y + y + y") == "x^2 + y^3"
  assert optimize_equation("a + b + b + a") == "a^2 + b^2"
  assert optimize_equation("c + d + d + c + c") == "c^3 + d^2"
  assert optimize_equation("x") == "x^1"
  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
      result = []
      for term, count in term_count.items():
          if count > 1:
              result.append(f"{term}^{count}")
          else:
              result.append(f"{term}^1")
      return ' + '.join(result)