Math/기초수학
기초수학 : 3. 거듭제곱과 제곱근
bright jazz music
2022. 7. 14. 08:12
1. 거듭제곱
- 거듭제곱은 같은 수 또는 문자를 여러 번 곱하는 것이다.
- 3 x 3 x 3 x 3 = 3⁴
- 이 때 우변을 3의 4제곱이라고 읽는다. (삼의 네제곱)
y=x^a를 코드로 구현
import numpy as np
import matplotlib.pyplot as plt
def my_func(x):
a = 3 #여기서는 a를 3으로 지정하였다. y = x³ 형태가 된다.
return x**a #x의 a제곱
x = np.linspace(0, 2)
y = my_func(x) # y = f(x)
plt.plot(x, y)
plt.xlabel("x", size=14)
plt.ylabel("y", size=14)
plt.grid()
plt.show()
plt.show()
2. 제곱근
- 2제곱해서 x가 되는 y를 x의 제곱근이라고 한다.
- 제곱근에는 양수와 음수가 있다. 9의 제곱근은 3과 -3이다.
- 이 중 양의 제곱근은 √ 기호를 이용하여 다음과 같이 기술할 수 있다.
y = √ x
제곱근을 코드로 구현
import numpy as np
import matplotlib.pyplot as plt
def my_func(x):
return np.sqrt(x) #x의 양의 제곱근을 반환. x**(1/2) 와도 같다.
x = np.linspace(0, 9)
y = my_func(x) # y = f(x)
plt.plot(x, y)
plt.xlabel("x", size=14)
plt.ylabel("y", size=14)
plt.grid()
plt.show()
plt.show()
3. 실습
아래의 수식을 그래프로 그려라.
y = √ x + 1
import numpy as np
import matplotlib.pyplot as plt
def my_func(x):
return np.sqrt(x) + 1 #y = √ x +1
x = np.linspace(0, 9)
y = my_func(x)
plt.plot(x, y)
plt.xlabel("x", size=14)
plt.ylabel("y", size=14)
plt.grid()
plt.show()