본문 바로가기

카테고리 없음

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

%main.m

bisect = bisection("func", 0, 2, 0.01);
newt = newton("func", "diff_func", 0, 0.01);
sec = secant("func", 0, 2, 0.01);

fprintf("이분법 : %f \n", bisect);
fprintf("newton : %f \n", newt);
fprintf("secant : %f \n", sec);

%func.m

function f = func(x)
f  = 2*x^3-3*x-4;
end

 

%diff_func.m

function f = diff_func(x)
f = 6*x^2-3;
end