楼主: ReneeBK
3158 19

A First Course in Numerical Methods [推广有奖]

  • 1关注
  • 62粉丝

VIP

已卖:4897份资源

学术权威

14%

还不是VIP/贵宾

-

TA的文库  其他...

R资源总汇

Panel Data Analysis

Experimental Design

威望
1
论坛币
49635 个
通用积分
55.7537
学术水平
370 点
热心指数
273 点
信用等级
335 点
经验
57805 点
帖子
4005
精华
21
在线时间
582 小时
注册时间
2005-5-8
最后登录
2023-11-26

楼主
ReneeBK 发表于 2016-1-29 11:38:23 |AI写论文
1论坛币

Written for undergraduate and beginning graduate students, this book provides comprehensive coverage of modern techniques in scientific computing. The book provides an in-depth treatment of fundamental issues and methods, as well as the reasons behind the success and failure of numerical software. Topics include numerical algorithms, round-off errors, nonlinear equations in one variable, and linear algebra.

MATLAB is used to solve numerous examples in the book. In addition, a supplemental set of MATLAB code files is available for download.

Product Details
  • Series: Computational Science and Engineering (Book 7)
  • Paperback: 574 pages
  • Publisher: Society for Industrial & Applied Mathematics (June 22, 2011)
  • Language: English
  • ISBN-10: 0898719976
  • ISBN-13: 978-0898719970
  • Product Dimensions: 6.8 x 1.2 x 9.7 inches
  • Shipping Weight: 2.2 pounds


关键词:Numerical numeric Methods Method Course scientific techniques computing beginning software

本帖被以下文库推荐

沙发
ReneeBK 发表于 2016-1-29 11:40:43
  1. function [p,n] = bisect(func,a,b,fa,fb,atol)
  2. %
  3. % function [p,n] = bisect(func,a,b,fa,fb,atol)
  4. %
  5. % Assuming fa = func(a), fb = func(b), and fa*fb < 0,
  6. % there is a value root in (a,b) such that func(root) = 0.
  7. % This function returns in p a value such that
  8. %      | p - root | < atol
  9. % and in n the number of iterations required.
  10. %

  11. % check input
  12. if (a >= b) || (fa*fb >= 0) || (atol <= 0)
  13.   disp(' something wrong with the input: quitting');
  14.   p = NaN; n=NaN;
  15.   return
  16. end

  17. n = ceil ( log2 (b-a) - log2 (2*atol));
  18. for k=1:n
  19.   p = (a+b)/2;
  20.   fp = feval(func,p);
  21.   if abs(fp) < eps, n = k; return, end
  22.   if fa * fp < 0
  23.     b = p;
  24.   else
  25.     a = p;
  26.     fa = fp;
  27.   end
  28. end
  29. p = (a+b)/2;
复制代码

藤椅
ReneeBK 发表于 2016-1-29 11:43:28
  1. function [p] = bisect_recursive (func,a,b,fa,fb,atol)
  2. %
  3. % function [p] = bisect_recursive (func,a,b,fa,fb,atol)
  4. %
  5. % Assuming fa = func(a), fb = func(b), and fa*fb < 0,
  6. % there is a value root in (a,b) such that func(root) = 0.
  7. % This function returns in p a value such that
  8. %      | p - root | < atol

  9. p = (a+b)/2;
  10. if b-a < atol
  11.   return
  12. else  
  13.   fp = feval(func,p);
  14.   if fa * fp < 0
  15.     b = p;
  16.     fb = fp;
  17.   else
  18.     a = p;
  19.     fa = fp;
  20.   end
  21.   p = bisect_recursive (func,a,b,fa,fb,atol);
  22. end
复制代码

板凳
ReneeBK 发表于 2016-1-29 11:44:33
  1. function x = ainvb(A,b)
  2. %
  3. % function x = ainvb(A,b)
  4. %
  5. % solve Ax = b

  6. [p,LU] = plu (A);
  7. y = forsub (LU,b,p);
  8. x = backsub (LU,y);
复制代码

报纸
ReneeBK 发表于 2016-1-29 11:45:51
  1. function x = backsub (A,b)
  2. %
  3. % function x = backsub (A,b)
  4. %
  5. % Given an upper triangular, nonsingular n by n matrix A and
  6. % an n-vector b, return vector x which solves Ax = b

  7. n = length(b); x = b;
  8. x(n) = b(n) / A(n,n);
  9. for k = n-1:-1:1
  10.   x(k) = ( b(k) - A(k,k+1:n)*x(k+1:n) ) / A(k,k);
  11. end
复制代码

地板
ReneeBK 发表于 2016-1-29 11:46:30
  1. function y = forsub (A,b,p)
  2. %
  3. % function y = forsub (A,b,p)
  4. %
  5. % Given a unit lower triangular, nonsingular n by n matrix A,
  6. % an n-vector b, and a permutation p,
  7. % return vector y which solves Ay = Pb

  8. n = length(b);

  9. % permute b according to p
  10. b = b(p);

  11. %forward substitution
  12. y = b;
  13. for k = 2:n
  14.   y(k) = b(k) - A(k,1:k-1) * y(1:k-1);
  15. end
复制代码

7
ReneeBK 发表于 2016-1-29 11:47:04
  1. function [p,A] = plu (A)
  2. %
  3. % function [p,A] = plu (A)
  4. %
  5. % Perform LU decomposition with partial pivoting.
  6. % Upon return the coefficients of L and U replace those
  7. % of the input n-by-n nonsingular matrix A. The row interchanges
  8. % performed are recorded in the 1D array p.

  9. n = size(A,1);

  10. % initialize permutation vector p
  11. p = 1:n;

  12. % LU decomposition with partial pivoting
  13. for k = 1:n-1

  14.   % find row index of relative maximum in column k
  15.   [val,q] = max(abs(A(k:n,k)));
  16.   q = q + k-1;

  17.   % interchange rows k and q and record this in p
  18.   A([k,q],:)=A([q,k],:);
  19.   p([k,q])=p([q,k]);

  20.   % compute the corresponding column of L
  21.   J=k+1:n;
  22.   A(J,k) = A(J,k) / A(k,k);
  23.   
  24.   % update submatrix by outer product
  25.   A(J,J) =  A(J,J) - A(J,k) * A(k,J);
  26.   
  27. end
复制代码

8
ReneeBK 发表于 2016-1-29 11:47:48
  1. function [p,A] = plu_scaled (A)
  2. %
  3. % function [p,A] = plu_scaled (A)
  4. %
  5. % Perform LU decomposition with scaled partial pivoting.
  6. % Upon return the coefficients of L and U replace those
  7. % of the input n-by-n nonsingular matrix A. The row interchanges
  8. % performed are recorded in the 1D array p.

  9. n = size(A,1);

  10. % find scales, initialize permutation vector p
  11. s = max(abs(A'))';
  12. p = 1:n;

  13. % LU decomposition with partial pivoting
  14. for k = 1:n-1

  15.   % find row index of relative maximum in column k
  16.   [val,q] = max ( abs(A(k:n,k)) ./ s(k:n) );
  17.   q = q + k-1;

  18.   % interchange rows k and q and record this in p
  19.   A([k,q],:)=A([q,k],:);
  20.   p([k,q])=p([q,k]);

  21.   % compute the corresponding column of L
  22.   J=k+1:n;
  23.   A(J,k) = A(J,k) / A(k,k);
  24.   
  25.   % update submatrix by outer product
  26.   A(J,J) =  A(J,J) - A(J,k) * A(k,J);
  27.   
  28. end
复制代码

9
ReneeBK 发表于 2016-1-29 11:48:19
  1. % Example 5.11 : comparing scaled and unscaled GEPP for a special example

  2. n = 100; h = 1/(n-1); K = 100;
  3. A = zeros(n,n);
  4. for i = 2:n-1
  5.   A(i,i) = -2/h^2 - K;
  6.   A(i,i-1) = -1/h^2; A(i,i+1) = -1/h^2;
  7. end
  8. A(1,1) = 1; A(n,n) = 1;  % end definition of A

  9. xe = ones(n,1);          % exact solution of 1's  
  10. b = A*xe;                % corresponding right hand side

  11. %solve using ainvb
  12. xu = ainvb(A,b);
  13. err_ainvb = norm(xu-xe)

  14. %solve using scaled GEPP version ainvb_scaled
  15. xs = ainvb_scaled(A,b);
  16. err_ainvb_scaled = norm(xs-xe)
复制代码

10
ReneeBK 发表于 2016-1-29 11:51:11
  1. % Example 5.13 : Cholesky for random matrices

  2. n = 500;
  3. C = randn(n,n); A = C'*C;
  4. xe = randn(n,1); % the exact solution
  5. b = A*xe;        % generate right hand side data

  6. R = chol(A);     % Cholesky factor
  7. % the following line is for compatibility with forsub
  8. D = diag(diag(R)); L = D \ R'; bb = D \ b; p = 1:n;
  9. y = forsub(L,bb,p);            % forward substitution R'y = b
  10. x = backsub(R,y);              % backward substitution Rx = y
  11. rerx = norm(x-xe)/norm(xe)     % error by Cholesky

  12. xd = ainvb(A,b);               % ignore spd and use partial pivoting
  13. rerxd = norm(xd-xe)/norm(xe)   % error by general routine
复制代码

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注jltj
拉您入交流群
GMT+8, 2026-1-1 05:16