mirror of
https://github.com/DeaDvey/mathgenerator.git
synced 2025-11-28 14:35:23 +01:00
26 lines
773 B
Python
26 lines
773 B
Python
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)
|