Taizun commited on
Commit
aaada7e
·
verified ·
1 Parent(s): 89b0f29

Update solver.py

Browse files
Files changed (1) hide show
  1. solver.py +4 -12
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
- positive_root = sp.sqrt(expr)
119
- negative_root = -positive_root
120
-
121
- # Check if the expression is a perfect square
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,)))