Typhoons01 main (#415)

* Create simplify_square_roots_generator

* Adopt simplify_square_root to standards

* lint fixes

* lint fix

* standardize line_equation_from_2_points

* Fix some lint issues

* Fix formatting/lint errors

* update docs

Co-authored-by: Hardik Gupta <96004638+typhoons01@users.noreply.github.com>
This commit is contained in:
Luke Weiler
2023-01-04 21:02:06 -05:00
committed by GitHub
parent a672709062
commit afad67f757
6 changed files with 616 additions and 453 deletions

View File

@@ -201,7 +201,8 @@
</span><span id="L-126"><a href="#L-126"><span class="linenos">126</span></a> <span class="p">(</span><span class="s2">&quot;is_composite&quot;</span><span class="p">,</span> <span class="s2">&quot;basic_math&quot;</span><span class="p">),</span>
</span><span id="L-127"><a href="#L-127"><span class="linenos">127</span></a> <span class="p">(</span><span class="s2">&quot;complementary_and_supplementary_angle&quot;</span><span class="p">,</span> <span class="s2">&quot;geometry&quot;</span><span class="p">),</span>
</span><span id="L-128"><a href="#L-128"><span class="linenos">128</span></a> <span class="p">(</span><span class="s2">&quot;simplify_square_root&quot;</span><span class="p">,</span> <span class="s2">&quot;basic_math&quot;</span><span class="p">),</span>
</span><span id="L-129"><a href="#L-129"><span class="linenos">129</span></a><span class="p">]</span>
</span><span id="L-129"><a href="#L-129"><span class="linenos">129</span></a> <span class="p">(</span><span class="s2">&quot;line_equation_from_2_points&quot;</span><span class="p">,</span> <span class="s2">&quot;algebra&quot;</span><span class="p">),</span>
</span><span id="L-130"><a href="#L-130"><span class="linenos">130</span></a><span class="p">]</span>
</span></pre></div>

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@@ -126,4 +126,5 @@ gen_list = [
("is_composite", "basic_math"),
("complementary_and_supplementary_angle", "geometry"),
("simplify_square_root", "basic_math"),
("line_equation_from_2_points", "algebra"),
]

View File

@@ -487,6 +487,48 @@ def linear_equations(n=2, var_range=20, coeff_range=20):
return f'Given the equations ${problem}$, solve for $x$ and $y$', f'${solution}$'
def line_equation_from_2_points(max_val=20):
r"""Equation of Line from Two Points
| Ex. Problem | Ex. Solution |
| --- | --- |
| Find the equation of the line passing through the points $(-19,-8)$ and $(-2,0)$. | $y=\frac{8}{17}x+\frac{16}{17}$ |
"""
x1 = random.randint(-max_val, max_val)
x2 = random.randint(-max_val, max_val)
if x1 == x2:
return line_equation_from_2_points(max_val=max_val)
y1 = random.randint(-max_val, max_val)
y2 = random.randint(-max_val, max_val)
m1 = (y2 - y1) // math.gcd(y2 - y1, x2 - x1)
m2 = (x2 - x1) // math.gcd(y2 - y1, x2 - x1)
c1 = (y1 * (x2 - x1) - (y2 - y1) * x1) // math.gcd(y1 * (x2 - x1) - (y2 - y1) * x1, (x2 - x1))
c2 = (x2 - x1) // math.gcd(y1 * (x2 - x1) - (y2 - y1) * x1, (x2 - x1))
c = rf"{'+' if c1 >= 0 else '-'}\frac{{{abs(c1)}}}{{{c2}}}" if c1 != 0 else ""
if c2 < 0:
c2 = -c2
c1 = -c1
c = rf"{'+' if c1 >= 0 else '-'}\frac{{{abs(c1)}}}{{{c2}}}"
if c2 == 1:
c = f"{c1:+}"
problem = f'Find the equation of the line passing through the points $({x1},{y1})$ and $({x2},{y2})$.'
if m1 == 0:
return problem, f"$y={c}$"
if m2 < 0:
m1 = -m1
m2 = -m2
if m2 == 1:
if m1 == 1:
return problem, f"$y=x{c}$"
if m1 == -1:
return problem, f"$y=-x{c}$"
return problem, f"y={m1}x{c}"
return problem, rf"$y=\frac{{{m1}}}{{{m2}}}x{c}$"
def log(max_base=3, max_val=8):
r"""Logarithm