public function multiplyBy($otherTerm) { $coef = $this->getCoefficient() * $otherTerm->getCoefficient(); $newTerm = new self($coef, $this->getExponent() + $otherTerm->getExponent(), $this->term ? $this->term : $otherTerm->getTerm()); if ($this->isNegative() != $otherTerm->isNegative()) { $newTerm->invert(); } return $newTerm; }