<jupyter_start><jupyter_text>원의 방정식Equation of a circle 원의 방정식을 `sympy`를 써서 나타내 보자.Let's represent a circle in `sympy`. 먼저 사용할 기호를 준비한다.First, let's prepare symbols to use as follows.<jupyter_code>x, y, r = sym.symbols("x y r", real=True)
x, y, r<jupyter_output><empty_output><jupyter_text>`sympy.Eq()`는 방정식의 두 변을 매개변수로 받아들인다.`sympy.Eq()` takes both sides of the equation as arguments.<jupyter_code>circle = sym.Eq((x * x) + (y * y), (r * r))
circle<jupyter_output><empty_output><jupyter_text>위 방정식을 $y$에 대해 풀어보자.Let's solve the equation above about $y$.<jupyter_code>sol = sym.solve(circle, y)


sol[0]


sol[1]<jupyter_output><empty_output><jupyter_text>닫힌 형태Closed form 위 두 닫힌 형태의 양함수를 그려보자.Let's plot two closed form functions.<jupyter_code>r = 10
num = 51
fig, ax = plt.subplots(figsize=(10, 10))
x_array = np.linspace(-r, r, num)
y1_array = np.sqrt(r**2 - x_array**2)
y2_array = - np.sqrt(r**2 - x_array**2)

plt.plot(x_array, y1_array)
plt.plot(x_array, y2_array)
plt.grid(True);<jupyter_output><empty_output><jupyter_text>열린 형태Open form<jupyter_code>circle<jupyter_output><empty_output><jupyter_text>$(x, y)$ 좌표 평면의 점들 가운데, 위 조건을 만족하는 점들을 모으면 원이 될 것이다.Among the points of $(x, y)$ coordinates, set of all points satisfying the equation above would be the circle. 유한개의 $(x, y)$ 점이 위 조건에 얼마나 가까운지 한번 표시해 보자.Let's plot a finite number of $(x, y)$ points; how close are these from satisfying the condition above?<jupyter_code>fig, ax = plt.subplots(figsize=(10, 10))

x = np.linspace(-15, 15, 61)
y = np.linspace(-15, 15, 61)

X, Y = np.meshgrid(x, y)

Z = -np.abs(10**2 - (X**2 + Y**2))

plt.pcolor(X, Y, Z, shading="auto")
plt.colorbar()
plt.axis("equal");

# plt.savefig("ㅇ.png", dpi=300)<jupyter_output><empty_output><jupyter_text>매개변수 형태Parametric form $\theta$를 독립 변수로 사용하여 $(x, y)$ 를 표시해 보자.Let's plot $(x, y)$ using $\theta$ as an independent variable. $$x(\theta) = r cos \theta \\y(\theta) = r sin \theta$$<jupyter_code>theta_deg = np.linspace(0, 360)
# num = 얼마가 좋겠습니까?
r = 10

x_array = 10 * np.cos(theta_deg)
y_array = 10 * np.sin(theta_deg)


len(theta_deg)


fig, ax = plt.subplots(figsize=(12, 12))
plt.plot(x_array, y_array, ".-")
plt.axis("equal")
plt.grid(True)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.16124661246612465, 'fraction_numerical': 0.025293586269196026, 'mean_word_length': 5.22191011235955, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 29, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '7', 'dir': 'jupyter-structured-clean-dedup', 'id': '203820', 'license': 'BSD-3-Clause', 'n_tokens_mistral': 1123, 'n_tokens_neox': 1177, 'n_words': 243, 'path': '00_introduction/40_how_to_draw_a_circle.ipynb', 'repo_name': 'kangwonlee/2109eca-nmisp-template', 'size': '2214'}