mirror of
https://github.com/DeaDvey/mathgenerator.git
synced 2025-11-28 06:25:23 +01:00
Merge pull request #285 from helplessThor/helplessThor-definite-integral
Added Definite Integral for Simple Quadratic Equation
This commit is contained in:
@@ -93,3 +93,4 @@ from .decimal_to_roman_numerals import *
|
|||||||
from .degree_to_rad import *
|
from .degree_to_rad import *
|
||||||
from .radian_to_deg import *
|
from .radian_to_deg import *
|
||||||
from .differentiation import *
|
from .differentiation import *
|
||||||
|
from .definiteIntegralFunc import *
|
||||||
|
|||||||
25
mathgenerator/funcs/definiteIntegralFunc.py
Normal file
25
mathgenerator/funcs/definiteIntegralFunc.py
Normal 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)
|
||||||
@@ -3,6 +3,7 @@ import math
|
|||||||
import fractions
|
import fractions
|
||||||
from .funcs import *
|
from .funcs import *
|
||||||
from .__init__ import getGenList
|
from .__init__ import getGenList
|
||||||
|
import scipy
|
||||||
|
|
||||||
genList = getGenList()
|
genList = getGenList()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user