Merge pull request #285 from helplessThor/helplessThor-definite-integral

Added Definite Integral for Simple Quadratic Equation
This commit is contained in:
Luke Weiler
2020-10-20 13:09:05 -04:00
committed by GitHub
3 changed files with 27 additions and 0 deletions

View File

@@ -93,3 +93,4 @@ from .decimal_to_roman_numerals import *
from .degree_to_rad import *
from .radian_to_deg import *
from .differentiation import *
from .definiteIntegralFunc import *

View File

@@ -0,0 +1,25 @@
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)
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 = "
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 = ", "S", definiteIntegralFunc)

View File

@@ -3,6 +3,7 @@ import math
import fractions
from .funcs import *
from .__init__ import getGenList
import scipy
genList = getGenList()