Example #1
0
def exponentiateExpression(exp,power):
	if _debug:
		legitEquation(exp)
	out=Equation()
	out.terms = {a:exp.terms[a]*power for a in exp.terms}
	out.coefficient = exp.coefficient**power
	return out
Example #2
0
def rearrange(expression, variable):
	if _debug:
		legitEquation(expression)
	if variable in expression.terms:
		coefficient = expression.terms[variable]
		out = Equation()
		out.terms= {x:expression.terms[x]/(-coefficient) for x in 
						without(expression.terms, variable)}
		out.coefficient = expression.coefficient**(1/coefficient)
		return out
	return None
Example #3
0
def multiplyExpressions(a,b,equivalencies):
	if _debug:
		legitEquation(a) and legitEquation(b)
	
	outdict = dict(a.terms)

	for term in b.terms:
		eqVar = findEqualVariable(term,equivalencies,a.terms)
		if eqVar:
			outdict[eqVar] += b.terms[term]
			if outdict[eqVar] == 0:
				outdict.pop(eqVar)
		else:
			outdict[term] = b.terms[term]
	out = Equation()
	out.terms = outdict
	out.coefficient = a.coefficient * b.coefficient
	return out