```python
import numpy as np
import matplotlib.pyplot as plt
import sympy as sym


```

### 원의 방정식<br>Equation of a circle



원의 방정식을 `sympy`를 써서 나타내 보자.<br>Let's represent a circle in `sympy`.



먼저 사용할 기호를 준비한다.<br>First, let's prepare symbols to use as follows.




```python
x, y, r = sym.symbols("x y r", real=True)
x, y, r


```

`sympy.Eq()`는 방정식의 두 변을 매개변수로 받아들인다.<br>`sympy.Eq()` takes both sides of the equation as arguments.




```python
circle = sym.Eq((x * x) + (y * y), (r * r))
circle


```

위 방정식을 $y$에 대해 풀어보자.<br>Let's solve the equation above about $y$.




```python
sol = sym.solve(circle, y)


```


```python
sol[0]


```


```python
sol[1]


```

### 닫힌 형태<br>Closed form



위 두 닫힌 형태의 양함수를 그려보자.<br>
Let's plot two closed form functions.




```python
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);


```

### 열린 형태<br>Open form




```python
circle


```

$(x, y)$ 좌표 평면의 점들 가운데, 위 조건을 만족하는 점들을 모으면 원이 될 것이다.<br>
Among the points of $(x, y)$ coordinates, set of all points satisfying the equation above would be the circle.



유한개의 $(x, y)$ 점이 위 조건에 얼마나 가까운지 한번 표시해 보자.<br>Let's plot a finite number of $(x, y)$ points; how close are these from satisfying the condition above?




```python
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)

```

### 매개변수 형태<br>Parametric form



$\theta$를 독립 변수로 사용하여 $(x, y)$ 를 표시해 보자.<br>Let's plot $(x, y)$ using $\theta$ as an independent variable.



$$
x(\theta) = r cos \theta \\
y(\theta) = r sin \theta
$$


```python
theta_deg = np.linspace(0, 360)
# num = 얼마가 좋겠습니까?
r = 10

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


```


```python
len(theta_deg)


```


```python
fig, ax = plt.subplots(figsize=(12, 12))
plt.plot(x_array, y_array, ".-")
plt.axis("equal")
plt.grid(True)


```

위 그림을 고쳐 보시오<br>Fix the figure above.



각각 몇개의 점을 계산하였는가<br>
How many calculations each?




```python

```

ed67f5fac048fa45a83c5b269424bebeba3ce41c
ipynb
Jupyter Notebook
00_introduction/40_how_to_draw_a_circle.ipynb
kangwonlee/2109eca-nmisp-template
2e078870757fa06222df62d0ff8f4f4f288af51a
BSD-3-Clause
00_introduction/40_how_to_draw_a_circle.ipynb
kangwonlee/2109eca-nmisp-template
2e078870757fa06222df62d0ff8f4f4f288af51a
BSD-3-Clause
00_introduction/40_how_to_draw_a_circle.ipynb
kangwonlee/2109eca-nmisp-template
2e078870757fa06222df62d0ff8f4f4f288af51a
BSD-3-Clause
Qwen/Qwen-72B
1. YES
2. YES