이 번역 페이지는 최신 내용을 담고 있지 않습니다. 최신 내용을 영문으로 보려면 여기를 클릭하십시오.
Symbolic Math Toolbox를 사용하여 미적분 배우기
Symbolic Math Toolbox™를 사용하여 미적분과 응용 수학을 배웁니다. 이 예제에서는 기본 함수인 fplot
, diff
및 int
를 보여줍니다.
변수를 조작하기 위해 syms
유형의 객체를 만듭니다.
disp('Create a symbolic variable for x') disp('>> syms x') syms x
Create a symbolic variable for x >> syms x
기호 변수를 정의하고 나면 함수를 작성하고 fplot
을 사용하여 시각화할 수 있습니다.
disp('Build the function f(x) and plot it') disp('>> f(x) = 1/(5+4*cos(x))') disp('>> fplot(f)') f(x) = 1/(5+4*cos(x)) figure; fplot(f) title('Plot of f(x)')
Build the function f(x) and plot it >> f(x) = 1/(5+4*cos(x)) >> fplot(f) f(x) = 1/(4*cos(x) + 5)
수학 표기법을 사용하여 x = pi/2에 대해 함수를 실행합니다.
disp('Evaluate f(x) at x = pi/2') disp('>> f(pi/2)') f(pi/2)
Evaluate f(x) at x = pi/2 >> f(pi/2) ans = 1/5
대부분의 함수에 기호 변수를 사용할 수 있습니다. 예를 들어, 함수 diff
는 함수를 미분합니다.
disp('Differentiate f(x) and plot the result') disp('>> f1 = diff(f)') disp('>> fplot(f1)') f1 = diff(f) figure; fplot(f1) title("Plot of the derivative of f")
Differentiate f(x) and plot the result >> f1 = diff(f) >> fplot(f1) f1(x) = (4*sin(x))/(4*cos(x) + 5)^2
diff
함수는 N계 도함수를 구할 수도 있습니다. 다음 예제에서는 2계 도함수를 보여줍니다.
disp('Compute the second derivative of f(x) and plot it') disp('>> f2 = diff(f,2)') disp('>> fplot(f2)') f2 = diff(f,2) figure; fplot(f2) title("Plot of the 2nd derivative of f(x)")
Compute the second derivative of f(x) and plot it >> f2 = diff(f,2) >> fplot(f2) f2(x) = (4*cos(x))/(4*cos(x) + 5)^2 + (32*sin(x)^2)/(4*cos(x) + 5)^3
int
함수는 기호 변수로 구성된 함수를 적분합니다. 다음 예제에서는 2계 도함수를 두 번 적분하여 원래 함수를 가져오려는 시도를 보여줍니다.
disp('Retrieve the original function by integrating the second derivative twice. Plot the result.') disp('>> g = int(int(f2))') disp('>> fplot(g)') g = int(int(f2)) figure; fplot(g) title("Plot of int(int(f2))")
Retrieve the original function by integrating the second derivative twice. Plot the result. >> g = int(int(f2)) >> fplot(g) g(x) = -8/(tan(x/2)^2 + 9)
처음에는 f
및 g
에 대한 플롯이 똑같아 보입니다. 하지만, 식과 y축 범위가 서로 다릅니다.
disp('Observe the formulas and ranges on the y-axis when comparing f and g') disp('>> subplot(1,2,1)') disp('>> fplot(f)') disp('>> subplot(1,2,2)') disp('>> fplot(g)') disp(' ') figure; subplot(1,2,1) fplot(f) title("Plot of f") subplot(1,2,2) fplot(g) title("Plot of g")
Observe the formulas and ranges on the y-axis when comparing f and g >> subplot(1,2,1) >> fplot(f) >> subplot(1,2,2) >> fplot(g)
값 e
는 f
와 g
간의 차입니다. 식은 복잡하지만 그래프는 상수로 그려집니다.
disp('Compute the difference between f and g') disp('>> e = f - g') e = f - g
Compute the difference between f and g >> e = f - g e(x) = 8/(tan(x/2)^2 + 9) + 1/(4*cos(x) + 5)
차가 상수임을 보이기 위해 방정식을 단순화합니다.
disp('Simplify the equation to show that the difference between f and g is constant') disp('>> simplify(e)') e = simplify(e)
Simplify the equation to show that the difference between f and g is constant >> simplify(e) e(x) = 1