Shu yechimni Nyuton usuli yordamida Maple dasturida taqribiy hisoblaymiz:
Avvalo Yakob matritsasini
linalg
paketining
jacobian
funksiyasi yordamida
hisoblaymiz, keyin esa uning teskarisini
linalg
paketining
inverse
funksiyasidan foy-
140
dalanib hisoblaymiz.
eval
funksiyasi ifodaning son qiymatini beradi.
evalm
funksiyasi esa matritsa va vektorlar ustida amal bajarib, son natija beradi. Bosh-
lang‘ich vektorni
xx:=[0.5;1.5]
va
eps:=0.001
aniqlik darajasi deb, Nyuton usuli
bo‘yicha taqribiy hisoblashlarni bajaramiz:
> with(linalg):
F:=(x,y)->[x*y-y^3-1,x^2*y^2+y^3-5];
FP:=jacobian(F(x,y),[x,y]); FPINV:=inverse(FP);
xx:=[0.5,1.5]; eps:=0.001; Err:=1000; v:=xx; v1:=[1e10,1e10]; j:=0;
for i while Err>eps do
v1:=eval(v); M:=eval(eval(FPINV),[x=v[1],y=v[2]]):
v:=evalm(v-M&*F(v[1],v[2])); Err:=max(abs(v1[1]-v[1]),abs(v1[2]-v[2]));
j:=j+1;
end do;
Natijalar quyidagicha:
:=
F
(
)
,
x y
[
]
,
x y
y
3
1
x
2
y
2
y
3
5
:=
FP
y
x
3
y
2
2
x y
2
2
x
2
y
3
y
2
:=
FPINV
2
x
2
3
y
3
y
2
(
)
1
2
x y
x
3
y
2
3
y
3
(
)
1
2
x y
2
x
3
y
(
)
1
2
x y
1
3
y
2
(
)
1
2
x y
:=
xx
[
]
,
0.5 1.5
:=
eps
0.001
:=
Err
1000
:=
v
[
]
,
0.5 1.5
:=
v1
[
]
,
0.1 10
11
0.1 10
11
:=
j
0
:=
v1
[
]
,
0.5 1.5
:=
M
0.2962962963
0.2469135803
-0.08888888887 0.05925925927
:=
v
[
]
,
1.836419753 1.240740741
:=
Err
1.336419753
:=
j
1
:=
v1
[
]
,
1.836419753 1.240740741
:=
M
0.4078488757
0.08736397583
-0.1775644435
0.03896485017
:=
v
[
]
,
1.910372475 1.046712441
:=
Err
0.194028300
:=
j
2
:=
v1
[
]
,
1.910372475 1.046712441
:=
M
0.6353135777
0.08003024373
-0.2433868149
0.06085855173
:=
v
[
]
,
1.992251965 1.002053670
:=
Err
0.081879490
:=
j
3
:=
v1
[
]
,
1.992251965 1.002053670
:=
M
0.7276965560
0.06768724860
-0.2654774883
0.06649093770
:=
v
[
]
,
1.999976663 1.000005095
:=
Err
0.007724698
:=
j
4
:=
v1
[
]
,
1.999976663 1.000005095
:=
M
0.7333182897
0.06666959200
-0.2666635987
0.06666633793
:=
v
[
]
,
2.000000000 1.000000000
:=
Err
0.000023337
:=
j
5
Iteratsion jarayonning 5-qadamida berilgan aniqlikdagi yechimga erishildi.
4-Misol.
Quyidagi uch noma’lumli uchta nochiziqli tenglamalar sustemasini
Nyuton usuli bilan yeching:
141
.
0
2
3
.
0
,
,
0
3
2
.
0
,
;
0
2
1
.
0
,
2
3
2
2
2
1
z
xy
z
y
x
f
y
xz
y
y
x
f
x
yz
x
y
x
f
Yechish.
Misolni Maple dasturida yechamiz. Yakob matritsasini tuzamiz:
>restart; with(LinearAlgebra):
f1:=0.1-x0^2+2*y0*z0-x0;
:=
f1
0.1
x0
2
2
y0 z0
x0
f2:=-0.2+y0^2-3*x0*z0-y0;
:=
f2
0.2
y0
2
3
x0 z0
y0
f3:=0.3-z0^2-2*x0*y0-z0;
:=
f3
0.3
z0
2
2
x0 y0
z0
f1x:=diff(f1,x0); f1y:=diff(f1,y0);
f1z:=diff(f1,z0); f2x:=diff(f2,x0);
f2y:=diff(f2,y0); f2z:=diff(f2,z0);
f3x:=diff(f3,x0); f3y:=diff(f3,y0);
f3z:=diff(f3,z0);
A:=<,
, >;
:=
A
2
x0
1
2
z0
2
y0
3
z0
2
y0
1
3
x0
2
y0
2
x0
2
z0
1
# Ildizga yaqin bo‘lgan
boshlang‘ich yaqinlashishni
tanlaymiz:
x0:=0: y0:=0: z0:=0:
A:=A;
:=
A
-1
0
0
0
-1
0
0
0
-1
A1:=A^(-1);
:=
A1
-1
0
0
0
-1
0
0
0
-1
f:=;
:=
f
0.1
-0.2
0.3
X0:=:
X:=Add(X0,(Multiply(A1,f)),1,-1);
:=
X
0.100000000000000004
-0.200000000000000010
0.299999999999999988
X0:=X; x0:=X[1];y0:=X[2];z0:=X[3];
A:=<,,>;
:=
A
-1.200000000
0.6000000000 -0.4000000000
-0.9000000000
-1.400000000
-0.3000000000
0.4000000000 -0.2000000000
-1.600000000
A1:=A^(-1); f:=;
:=
f
-0.1300000000
-0.0500000000
-0.0500000000
X:=Add(X0,(Multiply(A1,f)),1,-1);
:=
X
0.0224532224532224546
-0.174324324324324320
0.246153846153846140
i:=2: while (Norm(f))>0.0001 do
X0:=X; x0:=X[1];y0:=X[2];z0:=X[3];
A:=<,,>;
A1:=A^(-1); f:=;
X:=Add(X0,(Multiply(A1,f)),1,-1);
i:=i+1; end do: X:=X;
# Natija:
:=
X
0.0128241509376391898
-0.177800663726073254
0.244688047122264718
Sistemaning barcha haqiqiy yechimlarini topaylik:
>
solve
({0.1-
x
2
+2
x
y
-
x
=0,-0.2+
y
2
-3
x
z
-
y
=0,0,3-
z
2
-2
x
y
-
z
=0});
142
5-Misol.
Quyidagi nochiziqli tenglamalar sistemasini yechishning iteratsion ja-
rayonini quring:
.
0
1
)
,
(
,
0
1
)
1
(
)
,
(
2
2
y
x
y
x
g
x
y
y
x
f
Yechish.
Dastlab berilgan nochiqli tenglamalar sistemasining yechimi mavjud-
ligini Maple dasturi yordamida grafik usulda aniqlaylik (3.15-rasm):
> plots[implicitplot]({y*(x-1)-1=0,x^2-y^2-1=0},x=-3..3,y=-3..3);
3.15-rasm. 5-misolda berilgan tenglamalar sistemasi ildizining boshlang‘ich yaqin-
lashishini grafik usul bilan Maple dasturi yordamida aniqlash.
3.14-rasmdagi grafikdan ko‘rinadiki, bu tenglamalar sistemasi 2 ta haqiqiy
yechimga ega.
Berilgan nochiziqli tenglamalar sistemasining 1-chorakdagi aniq yechimi anali-
tik usulda Maple dasturi yordamida quyidagicha topiladi:
> evalf(solve({y*(x-1)-1=0,x^2-y^2-1=0},{x,y}));
{
}
,
x
1.716672747
y
1.395336994
Birinchi chorakda yotgan yechimni taqribiy usul bilan topish uchun quyidagi it-
eratsion jarayondan foydalaniladi:
n
n
y
x
1
1
1
,
1
2
1
1
n
n
x
y
,
n
=0,1,2,…
Natijalar esa quyidagi jadvalda keltirilgan:
n
=
0
1
…
17
18
n
n
y
x
2.0000
1.7321
1.5773
1.2198
…
1.7166
1.3952
1.7167
1.3954
Buning uchun quyidagi baholash o‘rinli:
4
18
18
10
*
8
y
y
x
x
.
143
Hisoblashlarning Maple dasturi quyidagicha bo‘lib, yuqoridagi jadval natijalarini
tasdiqlaydi:
> with(linalg): G:=(x,y)->[1+1/y,sqrt(x^2-1)]; v:=evalf(G(v[1],v[2]));
eps:=0.0001; Err:=1000; v:=[2,1.7]; j:=0;
for i while Err>eps do
v1:=evalf(v): v:=evalf(G(v[1],v[2]));
Err:=max(abs(v1[1]-v[1]),abs(v1[2]-v[2])): j:=j+1; end do;
Uchinchi chorakda yotgan yechimni taqribiy usul bilan topish uchun quyidagi
iteratsion jarayondan foydalaniladi:
1
2
1
n
n
y
x
,
1
1
1
1
n
n
x
y
.
Natijalar esa quyidagi jadvalda keltirilgan:
n
=
0
1
2
3
4
n
n
y
x
-1.1
-0.5
-1.1076
-0.4721
-1.1059
-0.4745
-1.1069
-0.4749
-1.1070
-0.4746
Buning uchun quyidagi baholash o‘rinli:
3
3
y
y
x
x
4
10
*
2
.
Hisoblashlarning Maple dasturi quyidagicha bo‘lib, jadval natijalarini
tasdiqlaydi:
> with(linalg): G:=(x,y)->[-sqrt(y^2+1),1/(x-1)]; v:=evalf(G(v[1],v[2]));
eps:=0.0001; Err:=1000; v:=[-1.1,-0.5]; j:=0;
for i while Err>eps do v1:=evalf(v): v:=evalf(G(v1[1],v[2]));
Err:=max(abs(v1[1]-v[1]),abs(v1[2]-v[2])): j:=j+1; end do;
Dostları ilə paylaş: |