본문 바로가기

컴퓨터/MATLAB을 이용한 알기 쉬운 수치해석

MATLAB을 이용한 알기 쉬운 수치해석) 2장 6번

x = pi/6;
first = x;
second = x;
third = x - x^3/6;
first_error = abs((sin(x) - first)/sin(x)) * 100;
second_error = abs((sin(x)-second)/sin(x)) * 100;
third_error = abs((sin(x)-third)/sin(x)) * 100;

fprintf("1차 근사값 : %f \n", first_error);
fprintf("2차 근사값 : %f \n", second_error);
fprintf("3차 근사값 : %f \n", third_error);