Update app.py
Browse files
app.py
CHANGED
|
@@ -153,12 +153,13 @@ def solve_from_coeffs(degree, coeff_str):
|
|
| 153 |
return f"❌ You entered {len(coeffs)} coefficients, but degree {degree} needs {int(degree)+1}.", ""
|
| 154 |
x = sp.Symbol("x")
|
| 155 |
poly_expr = sum(coeffs[i] * x**(int(degree) - i) for i in range(len(coeffs)))
|
| 156 |
-
|
| 157 |
-
|
| 158 |
result = "## 🧮 Symbolic Roots:\n"
|
|
|
|
| 159 |
for i, r in enumerate(roots, 1):
|
| 160 |
result += f"- Root {i}: $${sp.latex(sp.N(r, 6))}$$\n"
|
| 161 |
-
return result,
|
| 162 |
except Exception as e:
|
| 163 |
return f"❌ Error: {str(e)}", ""
|
| 164 |
|
|
|
|
| 153 |
return f"❌ You entered {len(coeffs)} coefficients, but degree {degree} needs {int(degree)+1}.", ""
|
| 154 |
x = sp.Symbol("x")
|
| 155 |
poly_expr = sum(coeffs[i] * x**(int(degree) - i) for i in range(len(coeffs)))
|
| 156 |
+
equation = sp.Eq(poly_expr, 0)
|
| 157 |
+
latex_equation = sp.latex(equation)
|
| 158 |
result = "## 🧮 Symbolic Roots:\n"
|
| 159 |
+
roots = sp.solve(poly_expr, x)
|
| 160 |
for i, r in enumerate(roots, 1):
|
| 161 |
result += f"- Root {i}: $${sp.latex(sp.N(r, 6))}$$\n"
|
| 162 |
+
return result, latex_equation
|
| 163 |
except Exception as e:
|
| 164 |
return f"❌ Error: {str(e)}", ""
|
| 165 |
|