Update app.py
Browse files
app.py
CHANGED
|
@@ -149,35 +149,10 @@ def inequality_solver():
|
|
| 149 |
# 不等式の解を求める
|
| 150 |
x = symbols('x')
|
| 151 |
inequality = eval(inequality_input)
|
| 152 |
-
|
| 153 |
-
|
| 154 |
-
inequalities = [ineq for ineq in inequality.args if ineq.is_Relational]
|
| 155 |
-
solutions = [solve(ineq, x) for ineq in inequalities]
|
| 156 |
-
|
| 157 |
st.subheader("不等式の解")
|
| 158 |
-
st.write(
|
| 159 |
|
| 160 |
-
# 不等式の解を一次元に描画
|
| 161 |
-
for sol in solutions:
|
| 162 |
-
plot_inequality(inequality, sol)
|
| 163 |
-
|
| 164 |
-
|
| 165 |
-
def plot_inequality(inequality, solution):
|
| 166 |
-
fig, ax = plt.subplots(figsize=(10, 1))
|
| 167 |
-
|
| 168 |
-
ax.spines['top'].set_visible(False)
|
| 169 |
-
ax.spines['right'].set_visible(False)
|
| 170 |
-
ax.spines['bottom'].set_visible(True)
|
| 171 |
-
ax.spines['left'].set_visible(False)
|
| 172 |
-
|
| 173 |
-
ax.plot([0, 1], [0, 0], color='black') # x軸
|
| 174 |
-
ax.scatter(solution, np.zeros_like(solution), color='blue', zorder=5)
|
| 175 |
-
ax.set_yticks([])
|
| 176 |
-
ax.set_xticks(np.arange(0, 1.1, 0.1))
|
| 177 |
-
ax.set_xlim(0, 1)
|
| 178 |
-
ax.grid(True, axis='x', linestyle='--', alpha=0.7)
|
| 179 |
-
ax.set_title("不等式の解のプロット")
|
| 180 |
-
|
| 181 |
-
st.pyplot(fig)
|
| 182 |
if __name__ == "__main__":
|
| 183 |
main()
|
|
|
|
| 149 |
# 不等式の解を求める
|
| 150 |
x = symbols('x')
|
| 151 |
inequality = eval(inequality_input)
|
| 152 |
+
solution = solve(inequality, x)
|
| 153 |
+
|
|
|
|
|
|
|
|
|
|
| 154 |
st.subheader("不等式の解")
|
| 155 |
+
st.write(solution)
|
| 156 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 157 |
if __name__ == "__main__":
|
| 158 |
main()
|