mirror of
https://github.com/DeaDvey/mathgenerator.git
synced 2026-06-02 05:18:11 +02:00
Fixed incorrectly formatted output & incorrectly formatted documentation for the following generators: (#424)
-Complex Quadratic -Absolute Difference -Stationary Points -Volume of a Cube -Quotient of Powers with Same Base -Union, Intersection, Difference of Two Sets -Probability of a certain sum appearing on faces of dice
This commit is contained in:
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+160
-77
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+282
-268
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+1
-1
File diff suppressed because one or more lines are too long
@@ -65,7 +65,7 @@ def complex_quadratic(prob_type=0, max_range=10):
|
||||
|
||||
| Ex. Problem | Ex. Solution |
|
||||
| --- | --- |
|
||||
| Find the roots of given Quadratic Equation $x^2 + 8x + 8 = 0$ | $((-1.172, -6.828)) = (\frac{-8 + \sqrt{32}}{2*1}, (\frac{-8 - \sqrt{32}}{2*1})$ |
|
||||
| Find the roots of given Quadratic Equation $x^2 + 8x + 8 = 0$ | $((-1.172, -6.828)) = (\frac{-8 + \sqrt{32}}{2}, (\frac{-8 - \sqrt{32}}{2})$ |
|
||||
"""
|
||||
if prob_type < 0 or prob_type > 1:
|
||||
print("prob_type not supported")
|
||||
@@ -110,9 +110,9 @@ def complex_quadratic(prob_type=0, max_range=10):
|
||||
|
||||
if sqrt_d - int(sqrt_d) == 0:
|
||||
sqrt_d = int(sqrt_d)
|
||||
solution = rf'(\frac{{{-b} + {sqrt_d}i}}{{2*{a}}}, \frac{{{-b} - {sqrt_d}i}}{{2*{a}}})'
|
||||
solution = rf'(\frac{{{-b} + {sqrt_d}i}}{{{2*a}}}, \frac{{{-b} - {sqrt_d}i}}{{{2*a}}})'
|
||||
else:
|
||||
solution = rf'(\frac{{{-b} + \sqrt{{{-d}}}i}}{{2*{a}}}, \frac{{{-b} - \sqrt{{{-d}}}i}}{{2*{a}}})'
|
||||
solution = rf'(\frac{{{-b} + \sqrt{{{-d}}}i}}{{{2*a}}}, \frac{{{-b} - \sqrt{{{-d}}}i}}{{{2*a}}})'
|
||||
|
||||
return problem, solution
|
||||
|
||||
@@ -124,9 +124,9 @@ def complex_quadratic(prob_type=0, max_range=10):
|
||||
|
||||
if sqrt_d - int(sqrt_d) == 0:
|
||||
sqrt_d = int(sqrt_d)
|
||||
g_sol = rf'(\frac{{{-b} + {sqrt_d}}}{{2*{a}}}, \frac{{{-b} - {sqrt_d}}}{{2*{a}}})'
|
||||
g_sol = rf'(\frac{{{-b} + {sqrt_d}}}{{{2*a}}}, \frac{{{-b} - {sqrt_d}}}{{{2*a}}})'
|
||||
else:
|
||||
g_sol = rf'(\frac{{{-b} + \sqrt{{{d}}}}}{{2*{a}}}, (\frac{{{-b} - \sqrt{{{d}}}}}{{2*{a}}})'
|
||||
g_sol = rf'(\frac{{{-b} + \sqrt{{{d}}}}}{{{2*a}}}, (\frac{{{-b} - \sqrt{{{d}}}}}{{{2*a}}})'
|
||||
|
||||
solution = f'$({s_root1, s_root2}) = {g_sol}$'
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ def absolute_difference(max_a=100, max_b=100):
|
||||
|
||||
| Ex. Problem | Ex. Solution |
|
||||
| --- | --- |
|
||||
| $|22-34|=$ | $12$ |
|
||||
| $\|22-34\|=$ | $12$ |
|
||||
"""
|
||||
a = random.randint(-1 * max_a, max_a)
|
||||
b = random.randint(-1 * max_b, max_b)
|
||||
|
||||
@@ -83,7 +83,7 @@ def stationary_points(max_exp=3, max_coef=10):
|
||||
|
||||
| Ex. Problem | Ex. Solution |
|
||||
| --- | --- |
|
||||
| $f(x)=6*x^3 + 6*x^2 + x + 8$ | ${- \frac{1}{3} - \frac{\sqrt{2}}{6}, - \frac{1}{3} + \frac{\sqrt{2}}{6}}$ |
|
||||
| $f(x)=6x^3 + 6x^2 + x + 8$ | ${- \frac{1}{3} - \frac{\sqrt{2}}{6}, - \frac{1}{3} + \frac{\sqrt{2}}{6}}$ |
|
||||
"""
|
||||
solution = ''
|
||||
while len(solution) == 0:
|
||||
@@ -94,7 +94,7 @@ def stationary_points(max_exp=3, max_coef=10):
|
||||
problem += coefficient * pow(x, exp)
|
||||
solution = sympy.stationary_points(problem, x)
|
||||
|
||||
problem = 'f(x)=' + str(problem).replace('**', '^')
|
||||
problem = 'f(x)=' + str(problem).replace('**', '^').replace('*','')
|
||||
return f'${problem}$', f'${sympy.latex(solution)[6:-8]}}}$'
|
||||
|
||||
|
||||
|
||||
@@ -554,6 +554,7 @@ def volume_cone(max_radius=20, max_height=50, unit='m'):
|
||||
|
||||
def volume_cube(max_side=20, unit='m'):
|
||||
"""Volume of a cube
|
||||
|
||||
| Ex. Problem | Ex. Solution |
|
||||
| --- | --- |
|
||||
| Volume of a cube with a side length of $19m$ is | $6859 m^3$ |
|
||||
|
||||
@@ -476,7 +476,7 @@ def quotient_of_power_same_base(max_base=50, max_power=10):
|
||||
|
||||
| Ex. Problem | Ex. Solution |
|
||||
| --- | --- |
|
||||
| The Quotient of $5^{6}$ and $5^{8} = $5^{6-8} = 5^{-2}$ | $0.04$ |
|
||||
| The Quotient of $5^{6}$ and $5^{8} = 5^{6-8} = 5^{-2}$ | $0.04$ |
|
||||
"""
|
||||
base = random.randint(1, max_base)
|
||||
power1 = random.randint(1, max_power)
|
||||
@@ -485,7 +485,7 @@ def quotient_of_power_same_base(max_base=50, max_power=10):
|
||||
solution = base ** step
|
||||
|
||||
problem = f"The Quotient of ${base}^{{{power1}}}$ and ${base}^{{{power2}}} = " \
|
||||
f"${base}^{{{power1}-{power2}}} = {base}^{{{step}}}$"
|
||||
f"{base}^{{{power1}-{power2}}} = {base}^{{{step}}}$"
|
||||
return problem, f'${solution}$'
|
||||
|
||||
|
||||
@@ -512,7 +512,7 @@ def set_operation(min_size=3, max_size=7):
|
||||
|
||||
| Ex. Problem | Ex. Solution |
|
||||
| --- | --- |
|
||||
| Given the two sets $a={1, 2, 4, 5}$, $b={8, 1, 2}. Find the Union, intersection, a-b, b-a, and symmetric difference | Union is ${1, 2, 4, 5, 8}$. Intersection is ${1, 2}$, a-b is ${4, 5}$, b-a is ${8}$. Symmetric difference is ${4, 5, 8}$. |
|
||||
| Given the two sets $a={1, 2, 4, 5}$, $b={8, 1, 2}$. Find the Union, intersection, $a-b$, $b-a$, and symmetric difference | Union is ${1, 2, 4, 5, 8}$. Intersection is ${1, 2}$, $a-b$ is ${4, 5}$, $b-a$ is ${8}$. Symmetric difference is ${4, 5, 8}$. |
|
||||
"""
|
||||
number_variables_a = random.randint(min_size, max_size)
|
||||
number_variables_b = random.randint(min_size, max_size)
|
||||
@@ -525,10 +525,10 @@ def set_operation(min_size=3, max_size=7):
|
||||
a = set(a)
|
||||
b = set(b)
|
||||
|
||||
problem = f"Given the two sets $a={a}$, $b={b}. " + \
|
||||
"Find the Union, intersection, a-b, b-a, and symmetric difference"
|
||||
problem = f"Given the two sets $a={a}$, $b={b}$. " + \
|
||||
"Find the Union, intersection, $a-b$, $b-a$, and symmetric difference"
|
||||
solution = f"Union is ${a.union(b)}$. Intersection is ${a.intersection(b)}$" + \
|
||||
f", a-b is ${a.difference(b)}$, b-a is ${b.difference(a)}$." + \
|
||||
f", $a-b$ is ${a.difference(b)}$, $b-a$ is ${b.difference(a)}$." + \
|
||||
f" Symmetric difference is ${a.symmetric_difference(b)}$."
|
||||
return problem, solution
|
||||
|
||||
|
||||
@@ -116,7 +116,7 @@ def data_summary(number_values=15, min_val=5, max_val=50):
|
||||
|
||||
|
||||
def dice_sum_probability(max_dice=3):
|
||||
"""Probability of a certain sum appearing on faces of dice
|
||||
r"""Probability of a certain sum appearing on faces of dice
|
||||
|
||||
| Ex. Problem | Ex. Solution |
|
||||
| --- | --- |
|
||||
|
||||
Reference in New Issue
Block a user