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] 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