OzoneAsai commited on
Commit
ea5b02a
·
1 Parent(s): dd8165e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -2
app.py CHANGED
@@ -92,8 +92,19 @@ elif selected_function == "関数の交点":
92
  x = symbols('x', real=True)
93
  func1 = simplify(parse_expr(func1_expression))
94
  func2 = simplify(parse_expr(func2_expression))
95
- intersection_points = solve(Eq(func1, func2), x)
96
- st.success(f"関数の交点の座標: {intersection_points}")
 
 
 
 
 
 
 
 
 
 
 
97
 
98
  # 三平方の定理(空欄補充)
99
  elif selected_function == "三平方の定理":
 
92
  x = symbols('x', real=True)
93
  func1 = simplify(parse_expr(func1_expression))
94
  func2 = simplify(parse_expr(func2_expression))
95
+
96
+ # 関数を数値的に解くためラムダ関数
97
+ equation_system = lambda x: [func1.subs('x', x[0]) - func2.subs('x', x[0]),
98
+ func1.subs('x', x[1]) - func2.subs('x', x[1])]
99
+
100
+ # 初期値の設定
101
+ initial_guess = [0, 0]
102
+
103
+ # fsolveを使用して交点を求める
104
+ intersection_points = fsolve(equation_system, initial_guess)
105
+
106
+ st.success(f"関数の交点の座標: {tuple(intersection_points)}")
107
+
108
 
109
  # 三平方の定理(空欄補充)
110
  elif selected_function == "三平方の定理":