mirror of
https://github.com/DeaDvey/mathgenerator.git
synced 2025-11-28 14:35:23 +01:00
Add power rule differentiation.
This commit is contained in:
@@ -78,6 +78,20 @@ def squareRootFunction(minNo = 1, maxNo = 12):
|
|||||||
solution = str(b)
|
solution = str(b)
|
||||||
return problem, solution
|
return problem, solution
|
||||||
|
|
||||||
|
def powerRuleDifferentiationFunc(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 * exponent) + "x^" + str(exponent - 1)
|
||||||
|
return problem, solution
|
||||||
|
|
||||||
# || Class Instances
|
# || Class Instances
|
||||||
|
|
||||||
#Format is:
|
#Format is:
|
||||||
@@ -89,3 +103,4 @@ division = Generator("Division", 5, "a/b=", "c", divisionFunc)
|
|||||||
binaryComplement1s = Generator("binary_complement_1s", 6, "1010=", "0101", binaryComplement1sFunc)
|
binaryComplement1s = Generator("binary_complement_1s", 6, "1010=", "0101", binaryComplement1sFunc)
|
||||||
moduloDivision = Generator("Modulo_Division", 7, "a%b=", "c", moduloFunc)
|
moduloDivision = Generator("Modulo_Division", 7, "a%b=", "c", moduloFunc)
|
||||||
squareRoot = Generator("Square _Root", 8, "sqrt(a)=", "b", squareRootFunction)
|
squareRoot = Generator("Square _Root", 8, "sqrt(a)=", "b", squareRootFunction)
|
||||||
|
powerRuleDifferentiation = Generator("Power_Rule_Differentiation", 9, "nx^m=", "(n*m)x^(m-1)", powerRuleDifferentiationFunc)
|
||||||
Reference in New Issue
Block a user