Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import sympy as sp
|
3 |
+
|
4 |
+
# Function for algebraic simplification
|
5 |
+
def algebra_simplification(expression):
|
6 |
+
try:
|
7 |
+
expr = sp.sympify(expression) # Convert the input to a sympy expression
|
8 |
+
simplified_expr = sp.simplify(expr) # Simplify the expression
|
9 |
+
return str(simplified_expr)
|
10 |
+
except Exception as e:
|
11 |
+
return f"Error: {str(e)}"
|
12 |
+
|
13 |
+
# Gradio interface
|
14 |
+
with gr.Blocks() as demo:
|
15 |
+
gr.Markdown("# Algebra Simplification Tool")
|
16 |
+
|
17 |
+
input_expression = gr.Textbox(label="Enter a Math Expression", placeholder="e.g., (x^2 - 4)/(x - 2)")
|
18 |
+
|
19 |
+
output_solution = gr.Textbox(label="Simplified Expression")
|
20 |
+
|
21 |
+
solve_button = gr.Button("Simplify")
|
22 |
+
|
23 |
+
# When button is clicked, call the algebra_simplification function
|
24 |
+
solve_button.click(fn=algebra_simplification, inputs=input_expression, outputs=output_solution)
|
25 |
+
|
26 |
+
# Launch the Gradio interface
|
27 |
+
demo.launch()
|