From f4aa55385863f58252a1a0bfc4f8b42d1eed2361 Mon Sep 17 00:00:00 2001 From: shyambhu Date: Sat, 17 Oct 2020 01:38:43 +0530 Subject: [PATCH] added power rule integration function. --- mathgenerator/mathgen.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/mathgenerator/mathgen.py b/mathgenerator/mathgen.py index 0b15947..5a141af 100644 --- a/mathgenerator/mathgen.py +++ b/mathgenerator/mathgen.py @@ -110,6 +110,21 @@ def powerRuleDifferentiationFunc(maxCoef = 10, maxExp = 10, maxTerms = 5): solution += str(coefficient * exponent) + "x^" + str(exponent - 1) return problem, solution +def powerRuleIntegrationFunc(maxCoef = 10, maxExp = 10, maxTerms = 5): + numTerms = random.randint(1, maxTerms) + problem = "" + solution = "" + for i in range(numTerms): + if i > 0: + problem += " + " + solution += " + " + coefficient = random.randint(1, maxCoef) + exponent = random.randint(1, maxExp) + problem += str(coefficient) + "x^" + str(exponent) + solution += "("+str(coefficient) +"/"+str(exponent) +")x^" + str(exponent +1) + solution = solution + " + c" + return problem, solution + def squareFunc(maxSquareNum = 20): a = random.randint(1, maxSquareNum) b = a * a