Nie obrażaj więc mojej inteligencji poprzez czynione na pokaz zaniżanie własnej.
>
restart: Metoda Jacobiego + −= −+ + = 20 4 3 19 3 0 2 3 xxx 1 2 3 x 1 x x 2 3 4 xx x 1 + + = 3 2 20 3 70 > n:=3; := n 3 > A:=Array([[20,4,-3],[-3,40,2],[4,3,20]]); 20 4 -3 -3 40 2 43 0 A := > b:=Array([19,83,70]); := b [ 19 83 70 , , ] > x:=Array(1..n): > x[1],x[2],x[3]:=0.,0.,0.; x 1 , , x 2 x 3 := 0. 0. 0. 1 n ∑ x ( ) k + = − b a x () k , i = 1, 2,..., , n k = 0,1, 2,... i i i j j a j = ≠ 1 ii ji > for k to 15 do x:=[seq(1/A[i,i]*(b[i]-add(A[i,j]*x[j],j=1..n)+A[i,i]*x[i]),i=1. .n)]: end do; 0.9500000000 2.075000000 3.500000000 := x [ , , ] 1.060000000 1.971250000 2.998750000 , , ] := x [ 1.005562500 2.004562500 2.992312500 , , ] := x [ 0.9979343750 2.000801562 2.998203125 , , ] 0.9995701560 1.999934922 3.000292890 := x [ , , ] 1.000056949 1.999953117 3.000095730 , , ] := x [ 1.000023736 1.999999485 2.999995642 , , ] := x [ 0.9999994495 2.000001998 2.999995330 , , ] := x [ 0.9999989000 2.000000192 2.999999810 , , ] := x [ 0.9999999330 1.999999927 3.000000191 , , ] ,, := x [ := x [ := x [ 1.000000043 1.999999986 3.000000024 , , ] := x [ 1.000000006 2.000000002 2.999999994 , , ] := x [ 0.9999999985 2.000000001 2.999999998 , , ] := x [ 0.9999999995 2.000000000 3.000000000 := x [ , , ] 1.000000000 2.000000000 3.000000000 , , ] > x:='x': Inny sposób - bez znajomości wzorów +−= −+ + = 20 4 3 19 3 0 2 3 x x x 1 2 3 x 1 x x 2 3 43 0 0 1 ++ = 2 3 1 n ∑ x = − b a x i , = 1, 2,..., n i i i j j a j = ≠ 1 ii ji > for i to n do r||i:=x[i]=1/A[i,i]*(b[i]-add(A[i,j]*x[j],j=1..n)+A[i,i]*x[i]); end do; r1 = := x 1 19 20 − + 1 5 x 2 3 20 x 3 r2 = := x 2 83 40 + − 3 40 x 1 1 20 x 3 r3 = := x 3 7 2 − − 1 5 x 1 3 20 x 2 > x[1],x[2],x[3]:=0.,0.,0.; x 1 , , x 3 := 0. 0. 0. 0.9500000000 2.075000000 3.500000000 > x[1],x[2],x[3]:=0.,0.,0.; , , ] x 1 , , x 3 := 0. 0. 0. > for k to 15 do x:=[seq(rhs(r||i),i=1..n)]; end do; := x [ 0.9500000000 2.075000000 3.500000000 := x [ , , ] 1.060000000 1.971250000 2.998750000 , , ] := x [ 1.005562500 2.004562500 2.992312500 , , ] := x [ 0.9979343750 2.000801563 2.998203125 , , ] := x [ 0.9995701562 1.999934922 3.000292891 := x [ , , ] 1.000056949 1.999953117 3.000095731 , , ] xx x x 2 ,, > x:=[seq(rhs(r||i),i=1..n)]; := x [ x 2 ,, x [ := 1.000023736 1.999999484 2.999995642 , , ] x [ 0.9999994495 2.000001998 2.999995330 , , ] x [ 0.9999988999 2.000000192 2.999999810 , , ] x [ 0.9999999331 1.999999926 3.000000191 , , ] x [ := 1.000000043 1.999999985 3.000000024 , , ] x [ := 1.000000007 2.000000002 2.999999993 , , ] x [ 0.9999999986 2.000000001 2.999999999 , , ] x [ 0.9999999996 2.000000000 3.000000000 , , ] x [ := 1.000000000 2.000000000 3.000000000 , , ] > x:='x': Metoda Gaussa-Seidla > x[1],x[2],x[3]:=0.,0.,0.; x 1 , , x 2 x 3 := 0. 0. 0. 1 ∑∑ − 1 n x () k + = − b a x () k + − a x () k , i = 1, 2,..., , n k = 0,1, 2,... i a i i j j i j j ii j = 1 j i = + 1 > for k to 8 do for i to n do x[i]:=1/A[i,i]*(b[i]-add(A[i,j]*x[j],j=1..i-1)-add(A[i,j]*x[j],j =i+1..n)); end do; [seq(x[j],j=1..n)]; end do; [ 0.9500000000 2.146250000 2.988062500 , , ] [ 0.9689593750 1.998268828 3.006467801 [ , , ] 1.001316404 1.999775340 2.999770418 , , ] [ 1.000010494 2.000012266 2.999996062 , , ] [ 0.9999969560 1.999999969 3.000000614 [ , , ] 1.000000098 1.999999976 2.999999984 , , ] [ 1.000000002 2.000000001 3.000000000 , , ] [ 1.000000000 2.000000000 3.000000000 , , ] > x:='x': Inny sposób - bez znajomości wzorów 1 ∑ n x = − b a x i , = 1, 2,..., n i i i j j a ii j = ≠ 1 ji > for i to n do r||i end do; := := := := := ,, i x 1 = 19 20 − + 1 5 x 2 3 20 x 3 x 2 = 83 40 + − 3 40 x 1 1 20 x 3 x 3 = 7 2 − − 1 5 x 1 3 20 x 2 > x[1],x[2],x[3]:=0.,0.,0.; x 1 , , x 2 x 3 := 0. 0. 0. ,, > x[1]:=rhs(r1); x 1 := 0.9500000000 > x[2]:=rhs(r2); x 2 := 2.146250000 > x[3]:=rhs(r3); x 3 := 2.988062500 > x[1],x[2],x[3]:=0.,0.,0.; x 1 , , x 2 x 3 := 0. 0. 0. ,, > for k to 9 do for i to n do x[i]:=rhs(r||i); end do; [seq(x[j],j=1..n)]; end do; [ 0.9500000000 2.146250000 2.988062500 , , ] [ 0.9689593750 1.998268828 3.006467801 [ , , ] 1.001316405 1.999775340 2.999770418 , , ] [ 1.000010495 2.000012266 2.999996061 , , ] [ 0.9999969560 1.999999969 3.000000614 [ , , ] 1.000000098 1.999999976 2.999999984 , , ] [ 1.000000002 2.000000001 3.000000000 , , ] [ 0.9999999998 2.000000000 3.000000000 [ , , ] 1.000000000 2.000000000 3.000000000 , , ] > > |
Menu
|