small stress testing
This commit is contained in:
@@ -31,7 +31,7 @@ def generate_linear_steps(problem):
|
||||
b = expr.subs(x, 0)
|
||||
|
||||
## First Step
|
||||
if b.is_zero == False:
|
||||
if b.is_nonzero:
|
||||
if b.is_negative:
|
||||
steps.append(algebraic_steps.add_both_sides(current, -b))
|
||||
elif b.is_positive:
|
||||
@@ -179,7 +179,7 @@ def generate_like_terms_steps (problem):
|
||||
current = problem["problem"]
|
||||
|
||||
## First Step
|
||||
steps.append(algebraic_steps.combine_like_terms(current))
|
||||
steps.extend(algebraic_steps.combine_like_terms(current))
|
||||
current = steps[-1]["after"]
|
||||
|
||||
## Second Step
|
||||
@@ -208,7 +208,6 @@ def generate_like_terms_steps (problem):
|
||||
|
||||
@register_steps_generator("quadratic")
|
||||
def generate_quadratic_steps (problem, skip_check=False):
|
||||
print(f"calling generate_quadratic_steps with: {problem["problem"]}")
|
||||
#ax² + bx + c = 0
|
||||
steps = []
|
||||
|
||||
@@ -221,11 +220,13 @@ def generate_quadratic_steps (problem, skip_check=False):
|
||||
b = left_expr.coeff(x)
|
||||
c = left_expr.subs(x, 0)
|
||||
div = gcd(a, b, c)
|
||||
if a.is_zero:
|
||||
return generate_linear_steps(problem)
|
||||
if a.is_negative:
|
||||
div = -div
|
||||
|
||||
## First Step
|
||||
if div != 1 and c.is_zero == False:
|
||||
if div != 1 and c.is_nonzero:
|
||||
steps.append(algebraic_steps.factor_out(current, div))
|
||||
current = steps[-1]["after"]
|
||||
elif c.is_zero:
|
||||
@@ -233,7 +234,7 @@ def generate_quadratic_steps (problem, skip_check=False):
|
||||
steps.append(algebraic_steps.factor_out(current, div*x))
|
||||
current = steps[-1]["after"]
|
||||
|
||||
if c.is_zero == False:
|
||||
if c.is_nonzero:
|
||||
## Second Steps
|
||||
left, right = current.split("=")
|
||||
left_expr = parse_expr(left, transformations=transformations)
|
||||
@@ -253,7 +254,7 @@ def generate_quadratic_steps (problem, skip_check=False):
|
||||
|
||||
@register_steps_generator("difference_squares")
|
||||
def generate_difference_squares_steps (problem, skip_check=False):
|
||||
#x² - a² = 0
|
||||
#x² - a² = 0 : a is not 0
|
||||
steps = []
|
||||
|
||||
x = symbols('x')
|
||||
@@ -302,15 +303,15 @@ def generate_radical_steps (problem, skip_check=False):
|
||||
current = problem["problem"]
|
||||
|
||||
|
||||
## First Step
|
||||
## Square both sides
|
||||
steps.append(algebraic_steps.square_both_sides(current))
|
||||
|
||||
## Second Step
|
||||
## Subtract constant
|
||||
current = steps[-1]["after"]
|
||||
left, right = current.split("=")
|
||||
left_expr = parse_expr(left, transformations=transformations)
|
||||
b = left_expr.subs(x, 0)
|
||||
if b.is_zero != False:
|
||||
if b.is_nonzero :
|
||||
if b.is_negative:
|
||||
steps.append(algebraic_steps.add_both_sides(current, -b))
|
||||
elif b.is_positive:
|
||||
@@ -340,7 +341,7 @@ def generate_fraction_steps (problem):
|
||||
left, right = current.split("=")
|
||||
left_expr = parse_expr(left, transformations=transformations)
|
||||
b = left_expr.subs(x, 0)
|
||||
if b.is_zero == False:
|
||||
if b.is_nonzero:
|
||||
if b.is_negative:
|
||||
steps.append(algebraic_steps.add_both_sides(current, -b))
|
||||
elif b.is_positive:
|
||||
@@ -386,7 +387,7 @@ def generate_binomial_steps (problem):
|
||||
|
||||
## Subtract constant
|
||||
b = left_expr.subs(x, 0)
|
||||
if b.is_zero == False:
|
||||
if b.is_nonzero:
|
||||
if b.is_negative:
|
||||
steps.append(algebraic_steps.add_both_sides(current, -b))
|
||||
elif b.is_positive:
|
||||
|
||||
Reference in New Issue
Block a user