Spaces:
Running
Running
Update solver.py
Browse files
solver.py
CHANGED
@@ -115,18 +115,10 @@ def process_expression(expr_str):
|
|
115 |
|
116 |
elif 'sqrt' in processed_expr: # Handle square roots
|
117 |
expr = parse_expr(processed_expr, transformations=(standard_transformations + (implicit_multiplication_application,)))
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
if expr.is_positive and positive_root.is_real:
|
123 |
-
# Check if the expression is a perfect square
|
124 |
-
if positive_root.is_integer:
|
125 |
-
return f"√{format_expression(expr)} = {format_expression(positive_root)}"
|
126 |
-
else:
|
127 |
-
return f"√{format_expression(expr)} = ±√{format_expression(expr)}"
|
128 |
-
else:
|
129 |
-
return f"√{format_expression(expr)} = ±√{format_expression(expr)}"
|
130 |
|
131 |
elif 'factorial' in processed_expr: # Factorial case
|
132 |
expr = parse_expr(processed_expr, transformations=(standard_transformations + (implicit_multiplication_application,)))
|
|
|
115 |
|
116 |
elif 'sqrt' in processed_expr: # Handle square roots
|
117 |
expr = parse_expr(processed_expr, transformations=(standard_transformations + (implicit_multiplication_application,)))
|
118 |
+
result = sp.sqrt(expr)
|
119 |
+
positive_root = result
|
120 |
+
negative_root = -result
|
121 |
+
return f"√{format_expression(expr)} = ±{format_expression(positive_root)}"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
122 |
|
123 |
elif 'factorial' in processed_expr: # Factorial case
|
124 |
expr = parse_expr(processed_expr, transformations=(standard_transformations + (implicit_multiplication_application,)))
|