Anda di halaman 1dari 1

Fungsigtitik_tetap

%%
% My Input
clear all; close all; clc;
syms x
fun = (-exp(-x)*sin(x))/3 ; x0 = 1;
root = titik_tetap(fun,x0)

titik tetap

function[root] = titik_tetap(fun,x0)
% Method Fixed Point
format short;
title = ' Iterasi roots errors';
line = '----------------------------------';
fprintf('%s\n',title);
fprintf('%s\n',line); n = 0;
while(1)
n = n + 1;
x1 = double(subs(fun,x0));
error = abs((x1-x0)/x1);
disp([n,x1,error])
if error > 1e-4
x0 = x1;
else
root = x1; break;
end
end
fprintf('%s\n',line);
end

Anda mungkin juga menyukai