class_docstr: A simple implementation
  of a polynomial class that
  records the details about two polynomials
  that are potentially comprised of multiple
  variables.
class_docstr_tok: ["A","simple","implementation","of","a","polynomial","class","that","records","the","details","about","two","polynomials","that","are","potentially","comprised","of","multiple","variables","."]
docstr: Add a given poylnomial to a copy of self.
docstr_tok: ["Add","a","given","poylnomial","to","a","copy","of","self","."]
code: def __add__(self, other: Union[int, float, Fraction, Monomial]):
      """
      Add a given poylnomial to a copy of self.
  
      """
      if (
          isinstance(other, int)
          or isinstance(other, float)
          or isinstance(other, Fraction)
      ):
          return self.__add__(
              Monomial({}, Polynomial._rationalize_if_possible(other))
          )
      elif isinstance(other, Monomial):
          monos = {m.clone() for m in self.monomials}
  
          for _own_monos in monos:
              if _own_monos.equal_upto_scalar(other):
                  scalar = _own_monos.coeff
                  monos -= {_own_monos}
                  temp_variables = {
                      i: other.variables[i] for i in other.variables
                  }
                  monos |= {
                      Monomial(
                          temp_variables,
                          Polynomial._rationalize_if_possible(
                              scalar + other.coeff
                          ),
                      )
                  }
                  return Polynomial([z for z in monos])
  
          monos |= {other.clone()}
          return Polynomial([z for z in monos])
      elif isinstance(other, Polynomial):
          temp = list(
              z for z in {m.clone() for m in self.all_monomials()}
          )
  
          p = Polynomial(temp)
          for o in other.all_monomials():
              p = p.__add__(o.clone())
          return p
      else:
          raise ValueError(
              "Can only add int, float, Fraction, Monomials, or Polynomials to Polynomials."
          )
  
imports: from fractions import Fraction
  from typing import Dict, Union, Set, Iterable
  from numbers import Rational
  from functools import reduce
label_desc: Use image node_id 3 for calling the Polynomial obj's underlying member method code with example usage: obj.__add__(other) and returns: self, Polynomial, p, Polynomial