Update app.py
Browse files
app.py
CHANGED
|
@@ -85,8 +85,13 @@ def solve_polynomial(image, llm_url):
|
|
| 85 |
|
| 86 |
try:
|
| 87 |
expr = parse_latex(cleaned_latex)
|
| 88 |
-
|
| 89 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 90 |
|
| 91 |
if not isinstance(expr, sp.Equality):
|
| 92 |
raise ValueError("Expression is not an equation.")
|
|
@@ -104,8 +109,13 @@ def solve_polynomial(image, llm_url):
|
|
| 104 |
cleaned_latex = clean_latex(fixed_latex)
|
| 105 |
try:
|
| 106 |
expr = parse_latex(cleaned_latex)
|
| 107 |
-
|
| 108 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 109 |
|
| 110 |
if not isinstance(expr, sp.Equality):
|
| 111 |
raise ValueError("Expression is not an equation.")
|
|
|
|
| 85 |
|
| 86 |
try:
|
| 87 |
expr = parse_latex(cleaned_latex)
|
| 88 |
+
|
| 89 |
+
# ✅ Replace pi and e by name
|
| 90 |
+
for symbol in expr.free_symbols:
|
| 91 |
+
if str(symbol) == 'pi':
|
| 92 |
+
expr = expr.subs(symbol, sp.Float(3.1416))
|
| 93 |
+
elif str(symbol) == 'e':
|
| 94 |
+
expr = expr.subs(symbol, sp.Float(2.7183))
|
| 95 |
|
| 96 |
if not isinstance(expr, sp.Equality):
|
| 97 |
raise ValueError("Expression is not an equation.")
|
|
|
|
| 109 |
cleaned_latex = clean_latex(fixed_latex)
|
| 110 |
try:
|
| 111 |
expr = parse_latex(cleaned_latex)
|
| 112 |
+
|
| 113 |
+
# ✅ Repeat fix in fallback too
|
| 114 |
+
for symbol in expr.free_symbols:
|
| 115 |
+
if str(symbol) == 'pi':
|
| 116 |
+
expr = expr.subs(symbol, sp.Float(3.1416))
|
| 117 |
+
elif str(symbol) == 'e':
|
| 118 |
+
expr = expr.subs(symbol, sp.Float(2.7183))
|
| 119 |
|
| 120 |
if not isinstance(expr, sp.Equality):
|
| 121 |
raise ValueError("Expression is not an equation.")
|