MATLAB: Enter in matlab a program to use the method gauss-seidel of solving the linear algebraic systems
gauss-seidel
Related Solutions
clcclearclose allA=[5 -2 3 0 6; -3 9 1 -2 7.4; 2 -1 -7 1 6.7; 4 3 -5 7 9; 2 3.5 6.1 -4 -8.1];b=[-1 2 3 0.5 3.1]';x=linspace(0,0,length(A))';n=size(x,1);normVal=Inf;nmax=1000; %number of maximum iterations which can be reached%tol=1e-3; % Tolerence for method%iter=0;while normVal>tol && iter<nmax x_old=x; for i=1:n guess=0; for j=1:i-1 guess=guess+A(i,j)*x(j); end for j=i+1:n guess=guess+A(i,j)*x_old(j); end x(i)=(1/A(i,i))*(b(i)-guess); end iter=iter+1; normVal=norm(x_old-x); endfprintf('Solution of the system is : \n%f\n%f\n%f\n%f\n%f in %d iterations',x,iter);
- A is symmetric positive-definite
- A is strictly or irreducibly diagonally dominant
MATLAB has multiple integration routines:
https://www.mathworks.com/help/matlab/ref/integral.html#References
References:
[1] L.F. Shampine “Vectorized Adaptive Quadrature in MATLAB®,” Journal of Computational and Applied Mathematics, 211, 2008, pp.131–140.
https://www.mathworks.com/help/matlab/ref/quad.html
Algorithms
quad implements a low order method using an adaptive recursive Simpson's rule. References
[1] Gander, W. and W. Gautschi, “Adaptive Quadrature – Revisited,” BIT, Vol. 40, 2000, pp. 84-101. This document is also available at http://www.inf.ethz.ch/personal/gander.
https://www.mathworks.com/help/matlab/ref/quadgk.html#f94-1004038
Algorithms
quadgk implements adaptive quadrature based on a Gauss-Kronrod pair (15th and 7th order formulas). References
[1] L.F. Shampine “Vectorized Adaptive Quadrature in MATLAB®,” Journal of Computational and Applied Mathematics, 211, 2008, pp.131–140.
https://www.mathworks.com/help/matlab/ref/quadl.html#f94-998971
Algorithms
quadl implements a high order method using an adaptive Gauss/Lobatto quadrature rule. References
[1] Gander, W. and W. Gautschi, “Adaptive Quadrature – Revisited,” BIT, Vol. 40, 2000, pp. 84-101. This document is also available at http://www.inf.ethz.ch/personal/gander.
Best Answer