Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -8,6 +8,9 @@ def solve_equation(equation):
|
|
| 8 |
if "=" not in equation:
|
| 9 |
return "Invalid input. Please enter an equation with '=' (e.g., 2*x + 3 = 5)."
|
| 10 |
|
|
|
|
|
|
|
|
|
|
| 11 |
lhs, rhs = equation.split("=")
|
| 12 |
lhs = sp.sympify(lhs)
|
| 13 |
rhs = sp.sympify(rhs)
|
|
@@ -19,6 +22,9 @@ def solve_equation(equation):
|
|
| 19 |
# Function to simplify expressions
|
| 20 |
def simplify_expression(expression):
|
| 21 |
try:
|
|
|
|
|
|
|
|
|
|
| 22 |
expr = sp.sympify(expression)
|
| 23 |
simplified_expr = sp.simplify(expr)
|
| 24 |
return f"Simplified Expression: {simplified_expr}"
|
|
@@ -28,6 +34,9 @@ def simplify_expression(expression):
|
|
| 28 |
# Function to factor expressions
|
| 29 |
def factor_expression(expression):
|
| 30 |
try:
|
|
|
|
|
|
|
|
|
|
| 31 |
expr = sp.sympify(expression)
|
| 32 |
factored_expr = sp.factor(expr)
|
| 33 |
return f"Factored Expression: {factored_expr}"
|
|
|
|
| 8 |
if "=" not in equation:
|
| 9 |
return "Invalid input. Please enter an equation with '=' (e.g., 2*x + 3 = 5)."
|
| 10 |
|
| 11 |
+
# Replace '^' with '**' for exponentiation
|
| 12 |
+
equation = equation.replace("^", "**")
|
| 13 |
+
|
| 14 |
lhs, rhs = equation.split("=")
|
| 15 |
lhs = sp.sympify(lhs)
|
| 16 |
rhs = sp.sympify(rhs)
|
|
|
|
| 22 |
# Function to simplify expressions
|
| 23 |
def simplify_expression(expression):
|
| 24 |
try:
|
| 25 |
+
# Replace '^' with '**' for exponentiation
|
| 26 |
+
expression = expression.replace("^", "**")
|
| 27 |
+
|
| 28 |
expr = sp.sympify(expression)
|
| 29 |
simplified_expr = sp.simplify(expr)
|
| 30 |
return f"Simplified Expression: {simplified_expr}"
|
|
|
|
| 34 |
# Function to factor expressions
|
| 35 |
def factor_expression(expression):
|
| 36 |
try:
|
| 37 |
+
# Replace '^' with '**' for exponentiation
|
| 38 |
+
expression = expression.replace("^", "**")
|
| 39 |
+
|
| 40 |
expr = sp.sympify(expression)
|
| 41 |
factored_expr = sp.factor(expr)
|
| 42 |
return f"Factored Expression: {factored_expr}"
|