input: from typing import Union
  
  
  def evaluate_expression(expr: str) -> Union[int, float, complex]:
      """
      Takes a string containing a numerical expression and returns the result.
  
      >>> evaluate_expression('1 + 1')
      2
      >>> evaluate_expression('2 * 3')
      6
      >>> evaluate_expression('4 / 2')
      2.0
      >>> evaluate_expression('3 ** 2')
      9
      """
      return eval(expr)
output:     try:
          result = eval(expr)
          if isinstance(result, (int, float, complex)):
              return result
          else:
              raise ValueError("Expression does not evaluate to a number")
      except Exception as e:
          raise ValueError(f"Invalid expression: {e}")