For If: %solusi Persamaan
For If: %solusi Persamaan
For If: %solusi Persamaan
fx = 2000*log(140000/(140000-2100*x))-9.8*x;
a = 8;
b = 30;
h=(b-a)/4;
n=100;
fa= subs(fx,x,a); Hasil :
fb= subs(fx,x,b);
fd= 0; Ik =
ff= 0;
for i=1:(n-1) 1.4386e+004 +1.5205e+004i
if rem (1,2)==0
fc = subs(fx,x,i);
fd = fd+fc;
else Ih =
fe= subs(fx,x,i);
ff= fe+ff; 1.1061e+004
end
end
Ik= (fa+4*ff+2*fd+fb)*h/(3*n)
e=
t = int(fx);
t1= subs (t,x,a); 1.4071
t2= subs(t,x,b);
Ih= t2-t1
e= abs ((Ih-Ik)/Ih)
syms x y
fx = 4*exp(0.8*x)-0.5*y; Hasil :
x0 = -7;
y0 = 2; N=
xn = 3;
n = 10;
h = (xn-x0)/n;
N = [];
1.0000 -6.0000 1.2320 1.4206
%solusi persamaan
t = 3; 2.0000 -5.0000 0.7886 1.2692
p = -0.22067*((10^-3)*t)-2.9282;
3.0000 -4.0000 0.5698 1.1946
for i = 1:n
k1 = subs(fx,{x,y},{x0,y0}); 4.0000 -3.0000 0.5491 1.1875
k2 = subs(fx, {x,y}, {x0+0.5*h,y0+0.5*k1*h});
k3 = subs(fx, {x,y}, {x0+0.5*h,y0+0.5*k2*h}); 5.0000 -2.0000 0.7856 1.2682
k4 = subs(fx, {x,y}, {x0+h,y0+k3*h});
y1 = y0+1/6*(k1+2*k2+2*k3+k4)*h;
x1 = x0+h; 6.0000 -1.0000 1.4836 1.5066
es = abs ((y1-p)/p);
N = [N; i x1 y1 es]; 7.0000 0 3.1413 2.0725
y0 = y1;
x0 =x1; 8.0000 1.0000 6.8935 3.3537
end
N 9.0000 2.0000 15.2827 6.2180
for i=1:n
y1 = y0 + subs(f,{x,y},{x0,y0})*h; 0.0010 0.0010 0.0055
x1 = x0 + h;
N = [N; i x1 y1]; 0.0020 0.0020 0.0117
x0 = x1;
y0 = y1; 0.0030 0.0030 0.0256
end
0.0040 0.0040 0.0569
N
0.0050 0.0050 0.1266