boolean resultIsProduct = isProduct(resultFracD);
boolean fIsProduct = isProduct(fD);
if (!(resultIsProduct || fIsProduct))
if (TTest.testParity(resultFracD, fD))
resultFrac = new Fraction(new Sum(resultFracN, fN), resultFracD);
else {
Tensor summond1 = new Product(resultFracN, fD);
Tensor summond2 = new Product(fN, resultFracD.clone());
Tensor newNumerator = new Sum(summond1, summond2);
Tensor newDenumerator = new Product(resultFracD.clone(), fD);
resultFrac = new Fraction(newNumerator, newDenumerator);
}
else if (resultIsProduct ^ fIsProduct)
if (resultIsProduct)
resultFrac = getSumWithProductAndSimpleDenominator(resultFrac, f);
else
resultFrac = getSumWithProductAndSimpleDenominator(f, resultFrac);
else
if (((Product) resultFracD).size() >= ((Product) fD).size())
resultFrac = getSumWithProductDenominator(resultFrac, f);
else
resultFrac = getSumWithProductDenominator(f, resultFrac);
}
if (!listTensor.isEmpty()) {
Tensor simpleSum = new Sum(listTensor);
Tensor summand1 = new Product(simpleSum, resultFrac.getDenominator().clone());
Tensor summand2 = resultFrac.getNumerator();
Tensor result = new Fraction(new Sum(summand1, summand2), resultFrac.getDenominator());
return result;
}
return resultFrac;
}