ଗସ-ସିଡ଼ାଲ ପଦ୍ଧତି ହୋଇଛି ଏକ iterative technique ଏବଂ ଏହା ଅଜଣା x ଥିବା n ଗୋଟି linear equation ବିଶିଷ୍ଟ ଗୋଟିଏ square systemକୁ ସମାଧାନ କରିବାରେ ବ୍ୟବହାର କରାଯାଏ:
iterationଦ୍ୱାରା ନିମ୍ନ ମତେ ଏହାର ସଂଜ୍ଞା ପ୍ରକରଣ କରାଯାଇପାରେ
ଏବଂ is the kth approximation or iteration of is the next or k + 1 iteration of , and the matrix A is decomposed into a lower triangular component , and a strictly upper triangular component U: .
Inputs: A, A Output: Choose an initial guess to the solution repeat until convergence for A from 1 until A do for A from 1 until A do if A ≠ A then end if end (A-loop) end (A-loop) check if convergence is reached end (repeat)
ଭାବେ ଗୋଟିଏ linear system ଦର୍ଶଯାଇଛି, ଯଥା:
ଆମେ ନିମ୍ନୋକ୍ତ ସମୀକରଣ
କୁ ନିମ୍ନୋକ୍ତ ରୂପେ ବ୍ୟବହାର କରିବାକୁ ଚାହୁଁ
ଯେଉଁଠାରେ କି:
The following numerical procedure simply iterates to produce the solution vector.
import numpy as np ITERATION_LIMIT = 1000 # initialize the matrix A = np.array([[10., -1., 2., 0.], [-1., 11., -1., 3.], [2., -1., 10., -1.], [0.0, 3., -1., 8.]]) # initialize the RHS vector b = np.array([6., 25., -11., 15.]) # prints the system print("System:") for i in range(A.shape[0]): row = ["{}*x{}".format(A[i, j], j + 1) for j in range(A.shape[1])] print(" + ".join(row), "=", b[i]) print() x = np.zeros_like(b) for it_count in range(ITERATION_LIMIT): print("Current solution:", x) x_new = np.zeros_like(x) for i in range(A.shape[0]): s1 = np.dot(A[i, :i], x_new[:i]) s2 = np.dot(A[i, i + 1:], x[i + 1:]) x_new[i] = (b[i] - s1 - s2) / A[i, i] if np.allclose(x, x_new, rtol=1e-8): break x = x_new print("Solution:") print(x) error = np.dot(A, x) - b print("Error:") print(error)
ଏହାର output ଆସିବ:
System: 10.0*x1 + -1.0*x2 + 2.0*x3 + 0.0*x4 = 6.0 -1.0*x1 + 11.0*x2 + -1.0*x3 + 3.0*x4 = 25.0 2.0*x1 + -1.0*x2 + 10.0*x3 + -1.0*x4 = -11.0 0.0*x1 + 3.0*x2 + -1.0*x3 + 8.0*x4 = 15.0 Current solution: [ 0. 0. 0. 0.] Current solution: [ 0.6 2.32727273 -0.98727273 0.87886364] Current solution: [ 1.03018182 2.03693802 -1.0144562 0.98434122] Current solution: [ 1.00658504 2.00355502 -1.00252738 0.99835095] Current solution: [ 1.00086098 2.00029825 -1.00030728 0.99984975] Current solution: [ 1.00009128 2.00002134 -1.00003115 0.9999881 ] Current solution: [ 1.00000836 2.00000117 -1.00000275 0.99999922] Current solution: [ 1.00000067 2.00000002 -1.00000021 0.99999996] Current solution: [ 1.00000004 1.99999999 -1.00000001 1. ] Current solution: [ 1. 2. -1. 1.] Solution: [ 1. 2. -1. 1.] Error: [ 2.06480930e-08 -1.25551054e-08 3.61417563e-11 0.00000000e+00]
The following code uses the formula
function [x] = gauss_seidel(A, b, x0, iters) n = length(A); x = x0; for k = 1:iters for i = 1:n x(i) = (1/A(i, i))*(b(i) - A(i, 1:n)*x + A(i, i)*x(i)); end end end
{{citation}}
: CS1 maint: unrecognized language (link).{{citation}}
: CS1 maint: unrecognized language (link).{{citation}}
: CS1 maint: unrecognized language (link)This article uses material from the Wikipedia ଓଡ଼ିଆ article ଗସ୍ - ସିଡ଼ାଲ୍ ପଦ୍ଧତି, which is released under the Creative Commons Attribution-ShareAlike 3.0 license ("CC BY-SA 3.0"); additional terms may apply (view authors). ଦର୍ଶାଯାଇନଥିଲେ ସମସ୍ତ ବିଷୟବସ୍ତୁ CC BY-SA 4.0 ରେ ଉପଲବ୍ଧ । Images, videos and audio are available under their respective licenses.
®Wikipedia is a registered trademark of the Wiki Foundation, Inc. Wiki ଓଡ଼ିଆ (DUHOCTRUNGQUOC.VN) is an independent company and has no affiliation with Wiki Foundation.