NPM : 1917031062
1. selesaikan persamaan nonlinier pada domain dengan menggunakan metode seperti perintah
pada soal
Data={{1,0.05},{1.1,0.092},{1.2,0.138},{1.3,0.188},
{1.4,0.242},{1.5,0.3},{1.6,0.362}};
Lagrange[anydata_]:=Sum[anydata[[i,2]]*LP[anydata,i],
{i,1,Length[anydata]}]
LP[anydata_,i_]:=(newdata=Drop[anydata,{i}];
Product[(x-newdata[[j,1]])/(anydata[[i,1]]-newdata[[j,1]]),
{j,1,Length[newdata]}])
(Using the Lagrange polynomial function)
y=Expand[Lagrange[Data]]
(Using the interpolating polynomial built-in function)
y2=Expand[InterpolatingPolynomial[Data,x]]
Plot[y,
{x,0,2.2},Epilog{PointSize[Large],Point[Data]},PlotLeg
ends{"model"},AxesLabel{"x","y"},AxesOrigin{0,0}]
Output :
function Lagrange polynomial the Using
-0.15-1.45519×10-11 x+0.2 x2-5.82077×10-11 x3+4.36557×10-11 x4-
7.27596×10-12 x5+1.81899×10-12 x6
-function in+built interpolating polynomial the Using
-0.15-7.50268×10-11 x+0.2 x2-1.52658×10-10 x3+8.87318×10-11 x4-
2.73614×10-11 x5+3.4972×10-12 x6
y
0 .8
0 .6
0 .4
0 .2
x
0 .5 1 .0 1 .5 2 .0
m od el
,
b. . Terkait nilai fungsi dalam Tabel 1, tentukan turunan pertama fungsi di xi = 1,15.
Clear[x,f,x0]
f[x_]:=-0.14999999999417923`-1.4551915228366852`*^-11
x+0.20000000005529728` x2-5.820766091346741`*^-11
x3+4.3655745685100555`*^-11 x4-7.275957614183426`*^-12
x5+1.8189894035458565`*^-12 x6;
xstart=1.15;
xstop=1.16;
Deltax=xstart-xstop;
Manipulate[kchangesides=xstart/2+xstop/2;
koffsetleft=0.2 Deltax;
koffsetright=0.15 Deltax;
ystop=Maximize[{f[x],xstartxxstop},x][[1]];
ystart=Minimize[{f[x],xstartxxstop},x][[1]];
Deltay=(ystop-ystart)*0.5;
ystop=ystop+Deltay;
ystart=ystart-Deltay;
dx=(xstop-xstart)/10;
funccolor=RGBColor[0.378912,0.742199,0.570321];
Plot[{f[x]},{x,xstart,xstop},PlotRange{{xstart,xstop},
{ystart,ystop}},ImageSize600,AxesLabel{Style["x",14,Italic],
Style["f[x]="
f[x],15]},BackgroundRGBColor[0.972549,0.937255,0.694118],Plot
Style{{funccolor,Thickness[.005]}},Epilog{Black,PointSize[.0
15],Arrowheads[.025],Arrow[{{xstop-.02,0},
{xstop,0}}],Arrow[{{0,ystop-.02},{0,ystop}}],Line[{{x0,f[x0]},
{x0+1,f[x0]}}],Thickness[.005],Blue,Line[{{x0-dx,f[x0]-dx
f'[x0]},{x0+dx,f[x0]+dx
f'[x0]}}],Red,Point[{x0,f[x0]}],Line[{{x0+1,f[x0]},
{x0+1,f'[x0]+f[x0]}}],Black,Point[{x0+1,f'[x0]+f[x0]}],Point[{
x0+1,f[x0]}],Red,Style[Inset[Row[{"f'[",x0,"] =
",ToString[NumberForm[N@f'[x0],{4,3}]]}],If[x0<kchangesides,
{x0-koffsetleft,f[x0]},{x0+koffsetright,f[x0]}]],14]}],
{x0,xstart,xstop}]
x0
f x 1 .8 1 8 9 9 1 0 1 2 x 6 7 .2 7 5 9 6 1 0 1 2 x 5 4 .3 6 5 5 7 1 0 1 1 x 4 5 .8 2 0 7 7 1 0 1 1 x 3 0 .2 x 2 1 .4 5 5 1 9 1 0 1 1 x 0 .1 5
0 .1 2 0
0 .1 1 8
0 .1 1 6
0 .1 1 4
f ' 1 .1 5 0 .4 6 0
x
1 .1 5 2 1 .1 5 4 1 .1 5 6 1 .1 5 8 1 .1 6 0
1. Tentukan solusi masalah nilai awal tersebut di atas hingga x(0.6) dengan
menggunakan metode Eksplisit Runge-Kutta Orde 2 dan metode implisit Heun orde
dua untuk ukuran partisi h = 0.1
RK4Method[fp_,x0_,h_,t0_,tmax_]:=(n=(tmax-t0)/h+1;
xtable=Table[0,{i,1,n}];
xtable[[1]]=x0;
Do[k1=fp[xtable[[i-1]],t0+(i-2) h];
k2=fp[xtable[[i-1]]+h/2*k1,t0+(i-0.6) h];
k3=fp[xtable[[i-1]]+h/2*k2,t0+(i-0.6) h];
k4=fp[xtable[[i-1]]+h*k3,t0+(i-1) h];
xtable[[i]]=xtable[[i-1]]+h (k1+2 k2+2 k3+k4)/6,{i,2,n}];
Data2=Table[{t0+(i-1)*h,xtable[[i]]},{i,1,n}];
Data2)
Clear[x,xtable]
a=DSolve[{x'[t]Sin[t]-x[t],x[0]0},x,t];
x=x[t]/.a[[1]]
fp[x_,t_]:=Sin[t]-x;
Data4=RK4Method[fp,0,0.1,0.4,1];
p3=ListPlot[Data2,AxesLabel{"t","x"},PlotStyle{RGBColor[0,
1,1], PointSize[Large]}]
Title={"t_i","x_i"};
Data4=Prepend[Data2,Title];
Data4//MatrixForm