 			newMul = newMul.expandAndSimplify()
 			return newMul
 
+		substituteExpression: (sourceExpression, variable, equivalencies=null) ->
+			children = []
+			for child in @children
+				if child instanceof terminals.Variable and child.label == variable
+					children.push(sourceExpression.copy())
+				else if child.substituteExpression?
+					children.push(substituteExpression(sourcex, variable, equivalencies))
+				else
+					children.push(child.copy())
+
 		toMathML: (equationID, expression=false, equality="0", topLevel=false) ->
 			# Return a MathML string representing this node.
 			[mathClass, mathID, html] = generateInfo.getMathMLInfo(equationID, expression, equality)

			if @children.right instanceof terminals.Variable and @children.right.label of replacements
				@children.right.label = replacements[@children.right.label]

		toMathML: (equationID, expression=false, equality="0", topLevel=false) ->
			# Return a MathML string representing this node.
			# This code was partially lifted from the (delightfully uncommented) predecessor

			newAdd = newAdd.expandAndSimplify()
			return newAdd

		substituteExpression: (sourceExpression, variable, equivalencies=null) ->
			children = []
			for child in @children
				if child instanceof terminals.Variable and child.label == variable
					children.push(sourceExpression.copy())
				else if child.substituteExpression?
					children.push(substituteExpression(sourcex, variable, equivalencies))
				else
					children.push(child.copy())

		toMathML: (equationID, expression=false, equality="0", topLevel=false) ->
			# Return a MathML string representing this node.
			[mathClass, mathID, html] = generateInfo.getMathMLInfo(equationID, expression, equality)
