Spaces:
Running
Running
Update solver.py
Browse files
solver.py
CHANGED
@@ -2,7 +2,7 @@ import sympy as sp
|
|
2 |
from sympy.parsing.sympy_parser import parse_expr, standard_transformations, implicit_multiplication_application
|
3 |
from sympy.solvers import solve
|
4 |
from sympy import integrate, diff, simplify, expand, log, exp, sin, cos, tan, asin, acos, atan, Symbol, factorial, laplace_transform
|
5 |
-
|
6 |
def format_expression(expr):
|
7 |
"""Format expression to make it more readable."""
|
8 |
# Convert string representation to a more readable format
|
@@ -34,6 +34,8 @@ def preprocess_equation(equation_str):
|
|
34 |
}
|
35 |
for old, new in replacements.items():
|
36 |
equation_str = equation_str.replace(old, new)
|
|
|
|
|
37 |
|
38 |
# Handle exponential expressions
|
39 |
if 'exp' in equation_str:
|
|
|
2 |
from sympy.parsing.sympy_parser import parse_expr, standard_transformations, implicit_multiplication_application
|
3 |
from sympy.solvers import solve
|
4 |
from sympy import integrate, diff, simplify, expand, log, exp, sin, cos, tan, asin, acos, atan, Symbol, factorial, laplace_transform
|
5 |
+
import re
|
6 |
def format_expression(expr):
|
7 |
"""Format expression to make it more readable."""
|
8 |
# Convert string representation to a more readable format
|
|
|
34 |
}
|
35 |
for old, new in replacements.items():
|
36 |
equation_str = equation_str.replace(old, new)
|
37 |
+
|
38 |
+
equation_str = re.sub(r'(\d+)!', r'factorial(\1)', equation_str)
|
39 |
|
40 |
# Handle exponential expressions
|
41 |
if 'exp' in equation_str:
|