Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -21,9 +21,14 @@ def parse_equation(equation):
|
|
21 |
a1, b1, c1 = parse_equation(equation1)
|
22 |
a2, b2, c2 = parse_equation(equation2)
|
23 |
|
24 |
-
intersection =
|
|
|
|
|
|
|
|
|
25 |
|
26 |
-
|
|
|
27 |
|
28 |
x = np.linspace(-10, 10, 400)
|
29 |
y1 = (c1 - a1*x) / b1
|
@@ -32,8 +37,9 @@ y2 = (c2 - a2*x) / b2
|
|
32 |
plt.figure()
|
33 |
plt.plot(x, y1, label='Equation 1')
|
34 |
plt.plot(x, y2, label='Equation 2')
|
35 |
-
|
|
|
36 |
plt.xlabel('x')
|
37 |
plt.ylabel('y')
|
38 |
plt.legend()
|
39 |
-
st.pyplot()
|
|
|
21 |
a1, b1, c1 = parse_equation(equation1)
|
22 |
a2, b2, c2 = parse_equation(equation2)
|
23 |
|
24 |
+
intersection = None
|
25 |
+
if np.linalg.det([[a1, b1], [a2, b2]]) != 0:
|
26 |
+
intersection = np.linalg.solve([[a1, b1], [a2, b2]], [c1, c2])
|
27 |
+
else:
|
28 |
+
st.write('Система уравнений вырожденная, решений бесконечно много или их нет')
|
29 |
|
30 |
+
if intersection is not None:
|
31 |
+
st.write(f'Координаты точки пересечения прямых: ({intersection[0]}, {intersection[1]})')
|
32 |
|
33 |
x = np.linspace(-10, 10, 400)
|
34 |
y1 = (c1 - a1*x) / b1
|
|
|
37 |
plt.figure()
|
38 |
plt.plot(x, y1, label='Equation 1')
|
39 |
plt.plot(x, y2, label='Equation 2')
|
40 |
+
if intersection is not None:
|
41 |
+
plt.scatter(intersection[0], intersection[1], color='red', label='Intersection')
|
42 |
plt.xlabel('x')
|
43 |
plt.ylabel('y')
|
44 |
plt.legend()
|
45 |
+
st.pyplot()
|