From fbd88492599055e17fdd1601ee099fcd86cc68cc Mon Sep 17 00:00:00 2001 From: helplessThor <66440538+helplessThor@users.noreply.github.com> Date: Tue, 20 Oct 2020 12:07:00 +0530 Subject: [PATCH 1/6] Create definiteIntegralFunc.py Created Definite Integral function within limits 0 to 1. --- mathgenerator/funcs/definiteIntegralFunc.py | 22 +++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 mathgenerator/funcs/definiteIntegralFunc.py diff --git a/mathgenerator/funcs/definiteIntegralFunc.py b/mathgenerator/funcs/definiteIntegralFunc.py new file mode 100644 index 0000000..73d81d6 --- /dev/null +++ b/mathgenerator/funcs/definiteIntegralFunc.py @@ -0,0 +1,22 @@ +from .__init__ import * +from ..__init__ import Generator +from scipy.integrate import quad + + +def definiteIntegralFunc(max_coeff=100): + + def integrand(x, a, b, c): + return a*x**2 + b*x + c + + a = random.randint(0, max_coeff) + b = random.randint(0, max_coeff) + c = random.randint(0, max_coeff) + + I = quad(integrand, 0, 1, args=(a, b, c))[0] + I = round(I, 4) + + problem = "The definite integral within limits 0 to 1 of the equation "+ str(a) +"x^2 + "+ str(b) +"x + "+ str(c) +" is = " + + solution = str(I) + + return problem, solution From 8407ba145856c8b253d4094ec052101fcfbdcc88 Mon Sep 17 00:00:00 2001 From: helplessThor <66440538+helplessThor@users.noreply.github.com> Date: Tue, 20 Oct 2020 12:08:15 +0530 Subject: [PATCH 2/6] Update __init__.py updated init.py with definite integral module --- mathgenerator/funcs/__init__.py | 1 + 1 file changed, 1 insertion(+) diff --git a/mathgenerator/funcs/__init__.py b/mathgenerator/funcs/__init__.py index 12bf15e..7f2f7d4 100644 --- a/mathgenerator/funcs/__init__.py +++ b/mathgenerator/funcs/__init__.py @@ -90,3 +90,4 @@ from .decimalToOctalFunc import * from .decimalToRomanNumeralsFunc import * from .degreeToRadFunc import * from .radianToDegFunc import * +from .definiteIntegralFunc import * From 8f6fb56c15fb867acb0fbba5c4aabf50aeacbe0d Mon Sep 17 00:00:00 2001 From: helplessThor <66440538+helplessThor@users.noreply.github.com> Date: Tue, 20 Oct 2020 12:11:53 +0530 Subject: [PATCH 3/6] Update definiteIntegralFunc.py Added generator class --- mathgenerator/funcs/definiteIntegralFunc.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mathgenerator/funcs/definiteIntegralFunc.py b/mathgenerator/funcs/definiteIntegralFunc.py index 73d81d6..e5631c0 100644 --- a/mathgenerator/funcs/definiteIntegralFunc.py +++ b/mathgenerator/funcs/definiteIntegralFunc.py @@ -20,3 +20,6 @@ def definiteIntegralFunc(max_coeff=100): solution = str(I) return problem, solution + + +definiteIntegral = Generator("Definite Integral of Quadratic Equation", 110, "The definite integral within limits 0 to 1 of quadratic equation ax^2+bx+c is = ", "I", definiteIntegralFunc) From 2f6c9b0eb70e0055a109f3c6200935ece6507545 Mon Sep 17 00:00:00 2001 From: helplessThor <66440538+helplessThor@users.noreply.github.com> Date: Tue, 20 Oct 2020 12:24:17 +0530 Subject: [PATCH 4/6] Update definiteIntegralFunc.py fixed presentation errors --- mathgenerator/funcs/definiteIntegralFunc.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/mathgenerator/funcs/definiteIntegralFunc.py b/mathgenerator/funcs/definiteIntegralFunc.py index e5631c0..b029ccb 100644 --- a/mathgenerator/funcs/definiteIntegralFunc.py +++ b/mathgenerator/funcs/definiteIntegralFunc.py @@ -6,18 +6,18 @@ from scipy.integrate import quad def definiteIntegralFunc(max_coeff=100): def integrand(x, a, b, c): - return a*x**2 + b*x + c + return a * x ** 2 + b * x + c a = random.randint(0, max_coeff) b = random.randint(0, max_coeff) c = random.randint(0, max_coeff) I = quad(integrand, 0, 1, args=(a, b, c))[0] - I = round(I, 4) + S = round(I, 4) - problem = "The definite integral within limits 0 to 1 of the equation "+ str(a) +"x^2 + "+ str(b) +"x + "+ str(c) +" is = " + problem = "The definite integral within limits 0 to 1 of the equation " + str(a) + "x^2 + "+ str(b) +"x + " + str(c) + " is = " - solution = str(I) + solution = str(S) return problem, solution From 1d1a6f274056d851ba56a221e3edf42bc96ae31d Mon Sep 17 00:00:00 2001 From: helplessThor <66440538+helplessThor@users.noreply.github.com> Date: Tue, 20 Oct 2020 12:30:04 +0530 Subject: [PATCH 5/6] Update definiteIntegralFunc.py fixed presentation error --- mathgenerator/funcs/definiteIntegralFunc.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/mathgenerator/funcs/definiteIntegralFunc.py b/mathgenerator/funcs/definiteIntegralFunc.py index b029ccb..b0e502c 100644 --- a/mathgenerator/funcs/definiteIntegralFunc.py +++ b/mathgenerator/funcs/definiteIntegralFunc.py @@ -12,14 +12,14 @@ def definiteIntegralFunc(max_coeff=100): b = random.randint(0, max_coeff) c = random.randint(0, max_coeff) - I = quad(integrand, 0, 1, args=(a, b, c))[0] - S = round(I, 4) + result = quad(integrand, 0, 1, args=(a, b, c))[0] + S = round(result, 4) - problem = "The definite integral within limits 0 to 1 of the equation " + str(a) + "x^2 + "+ str(b) +"x + " + str(c) + " is = " + problem = "The definite integral within limits 0 to 1 of the equation " + str(a) + "x^2 + " + str(b) + "x + " + str(c) + " is = " solution = str(S) return problem, solution -definiteIntegral = Generator("Definite Integral of Quadratic Equation", 110, "The definite integral within limits 0 to 1 of quadratic equation ax^2+bx+c is = ", "I", definiteIntegralFunc) +definiteIntegral = Generator("Definite Integral of Quadratic Equation", 110, "The definite integral within limits 0 to 1 of quadratic equation ax^2+bx+c is = ", "S", definiteIntegralFunc) From 19a9d4981a2a6cba97717bd1131260b7334638e2 Mon Sep 17 00:00:00 2001 From: helplessThor <66440538+helplessThor@users.noreply.github.com> Date: Tue, 20 Oct 2020 12:36:23 +0530 Subject: [PATCH 6/6] Update mathgen.py importing scipy --- mathgenerator/mathgen.py | 1 + 1 file changed, 1 insertion(+) diff --git a/mathgenerator/mathgen.py b/mathgenerator/mathgen.py index 959093b..d2eee73 100644 --- a/mathgenerator/mathgen.py +++ b/mathgenerator/mathgen.py @@ -3,6 +3,7 @@ import math import fractions from .funcs import * from .__init__ import getGenList +import scipy genList = getGenList()