mirror of
https://github.com/DeaDvey/mathgenerator.git
synced 2025-11-28 14:35:23 +01:00
Merge pull request #321 from nella17/nella17-patch
Add Stationary Points
This commit is contained in:
@@ -114,3 +114,4 @@ from .signum_function import *
|
|||||||
from .conditional_probability import *
|
from .conditional_probability import *
|
||||||
from .arc_length import *
|
from .arc_length import *
|
||||||
from .binomial_distribution import *
|
from .binomial_distribution import *
|
||||||
|
from .stationary_points import *
|
||||||
|
|||||||
23
mathgenerator/funcs/stationary_points.py
Normal file
23
mathgenerator/funcs/stationary_points.py
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
from .__init__ import *
|
||||||
|
import sympy
|
||||||
|
|
||||||
|
|
||||||
|
def stationaryPointsFunc(maxExp=3, maxCoef=10):
|
||||||
|
while True:
|
||||||
|
x = sympy.symbols('x')
|
||||||
|
problem = 0
|
||||||
|
for exp in range(maxExp + 1):
|
||||||
|
coefficient = random.randint(0, maxCoef)
|
||||||
|
problem += coefficient * pow(x, exp)
|
||||||
|
solution = sympy.stationary_points(problem, x)
|
||||||
|
|
||||||
|
if len(solution) != 0:
|
||||||
|
solution = ','.join('({},{})'.format(
|
||||||
|
str(p),
|
||||||
|
sympy.sympify(problem.replace(x, p))
|
||||||
|
) for p in solution)
|
||||||
|
problem = 'f(x)=' + str(problem).replace('**', '^')
|
||||||
|
return problem, solution
|
||||||
|
|
||||||
|
|
||||||
|
stationary_points = Generator("Stationary Points", 106, "f(x)=x^3-3x", "(-1,2),(1,-2)", stationaryPointsFunc)
|
||||||
Reference in New Issue
Block a user