Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

آموزش محاسبات عددی - بخش دوم

1,103 views

Published on

محاسبات عددی علم و هنر محاسبه است. محاسبات عددی (یا آنالیز عددی) به مطالعه ی روش ها و الگوریتم هایی گفته می شود که تقریب های عددی (در مقابل جواب های تحلیلی) را برای مسائل ریاضی بکار می برند. محاسبات عددی با اعمال شیوه های تقریبی محاسباتی به حل مسائلی از ریاضیات پیوسته می پردازد که به روش تحلیلی قابل حل نبوده و یا به سختی قابل حل تحلیلی هستند.

سرفصل هایی که در این آموزش به آن پرداخته شده است:

درس اول: خطاها و اشتباهات
درس دوم: حل دستگاه های معادلات خطی
درس سوم: درون یابی و برازش
درس چهارم: مشتق گیری و انتگرال گیری عددی
درس پنجم: حل عددی معادلات دیفرانسیل معمولی
...

برای توضیحات بیشتر و تهیه این آموزش لطفا به لینک زیر مراجعه بفرمائید:
http://faradars.org/courses/fvmth102

Published in: Education
  • Be the first to comment

آموزش محاسبات عددی - بخش دوم

  1. 1. ‫افزار‬ ‫نرم‬ ‫کمک‬ ‫به‬ ‫عددی‬ ‫محاسبات‬MATLAB «‫خطی‬ ‫معادالت‬ ‫های‬ ‫دستگاه‬ ‫حل‬ ‫های‬ ‫روش‬» ‫مدرس‬: ‫تاشک‬ ‫اشکان‬ ‫تحصیلی‬ ‫رشته‬ ‫و‬ ‫درجه‬ ‫برق‬ ‫مهندسی‬ ‫دکترای‬-‫دانشگاه‬ ‫مدرس‬ ‫و‬ ‫سیستم‬ ‫گرایش‬ ‫مخابرات‬ ‫عددی‬ ‫محاسبات‬ ‫کمک‬ ‫به‬MATLAB faradars.org/fvmth102 ‫س‬‫ر‬‫د‬‫ا‬‫ﺮ‬‫ﻓ‬ FaraDars.org
  2. 2. ‫ﻓﺼﻞ‬ ‫ﻋﻨﺎوﻳﻦ‬‫دوم‬ ‫ﻓﺼﻞ‬‫دوم‬:‫ﺣﻞ‬‫دﺳﺘﮕﺎه‬‫ﻫﺎي‬‫ﻣﻌﺎدﻻت‬‫ﺧﻄﻲ‬ -‫ﻣﻘﺪﻣﻪ‬ 1-‫رﻫﻴﺎﻓﺖ‬‫ﻫﺎي‬‫ﻏﻴﺮ‬‫ﺗﻜﺮاري‬)‫ﺑﻪ‬‫ﻫﻤﺮاه‬‫ﺑﺮﻧﺎﻣﻪ‬MATLAB( -‫روش‬‫ﮔﻮس‬‫ﻧﺎﻗﺺ‬ -‫ﮔﻮس‬‫ﺑﺎ‬‫ﻣﺤﻮرﻳﺖ‬‫ﻧﺴﺒﻲ‬‫ﻗﻴﺎﺳﻲ‬‫ﻳﺎ‬‫ﭘﻴﻮوﺗﻴﻨﮓ‬ -‫روش‬‫ﺗﺠﺰﻳﻪ‬LU 2-‫رﻫﻴﺎﻓﺖ‬‫ﻫﺎي‬‫ﺗﻜﺮاري‬)‫ﺑﻪ‬‫ﻫﻤﺮاه‬‫ﺑﺮﻧﺎﻣﻪ‬MATLAB( -‫روش‬‫ژاﻛﻮﺑﻲ‬ -‫روش‬‫ﮔﻮس‬-‫ﺳﻴﺪال‬ 2 ‫ﻋﺪدي‬ ‫ﻣﺤﺎﺳﺒﺎت‬ ‫ﻛﻤﻚ‬ ‫ﺑﻪ‬MATLAB faradars.org/fvmth102 ‫س‬‫ر‬‫د‬‫ا‬‫ﺮ‬‫ﻓ‬ FaraDars.org
  3. 3. ‫ﻣﻘﺪﻣﻪ‬ •‫ﺣﻞ‬‫ﻣﺴﺎﺋﻞ‬‫ﺑﺴﻴﺎري‬‫در‬‫ﻣﻬﻨﺪﺳﻲ‬‫ﺑﻪ‬‫دﺳﺘﮕﺎه‬‫ﻣﻌﺎدﻻت‬‫ﺟﺒﺮي‬‫ﻣﻨ‬‫ﺠﺮ‬ ‫ﻣﻲ‬‫ﺷﻮد‬. •‫ﺑﻪ‬‫ﻋﻨﻮان‬‫ﻣﺜﺎل‬‫ﺑﺮاي‬‫ﺳﻴﺴﺘﻢ‬‫ﺟﺮم‬-‫ﻓﻨﺮ‬‫ﻧﺸﺎن‬‫داده‬‫ﺷﺪه‬‫در‬‫ﺣﺎل‬ ‫ﺗﻌﺎدل‬‫ﺑﺎ‬‫ﺣﺬف‬،‫ﻧﻴﺮوﻫﺎ‬‫ﺳﻴﺴﺘﻢ‬‫در‬‫وﺿﻌﻴﺖ‬‫ﺗﻌﺎدﻟﻲ‬‫ﺟﺪﻳﺪ‬‫ﻗﺮار‬‫ﺧ‬‫ﻮاﻫﺪ‬ ‫ﮔﺮﻓﺖ‬. •‫ﻣﻮﻗﻌﻴﺖ‬‫ﺟﺪﻳﺪ‬‫ﺟﺮم‬‫ﻫﺎ‬‫ﺑﺎ‬‫ﺣﻞ‬‫دﺳﺘﮕﺎه‬‫ﻣﻌﺎدﻻت‬‫ﺟﺒﺮي‬‫ﺧﻄﻲ‬‫ﻗﺎﺑﻞ‬ ‫ﻣﺤﺎﺳﺒﻪ‬‫ﻫﺴﺘﻨﺪ‬. •‫ﺑﺮاي‬‫ﻳﻚ‬‫ﺳﻴﺴﺘﻢ‬‫ﺟﺮم‬‫و‬،‫ﻓﻨﺮ‬‫ﻃﺒﻖ‬‫ﻗﺎﻧﻮن‬‫دوم‬ ‫ﻧﻴﻮﺗﻦ‬‫دارﻳﻢ‬: •،‫ﺣﺎل‬‫ﻣﺴﺌﻠﻪ‬‫ﺣﻞ‬‫اﻳﻦ‬‫دﺳﺘﮕﺎه‬‫اﺳﺖ‬: 3 (K1+K2+(K3/2))x1-(K2+(K3/2))x2=W1 -(K2 +(K3/2))x1+(K2+(K3/2)+K4)x2-(K4+(K3/2))x3=W2 -(K4+(K3/2))x2+((K3/2)+K4+K5)x3=W3 K1=40N/cm,K2=K3=K4=20N/cm K5=90N/cm ,W1=W2=W3=20N 20=3x0+2x30-1x07 20=3x30-2x50+1x30- 20=3x120+2x30-1x0+ Ma dt yd MMgyKF s  2 2 ‫ﻋﺪدي‬ ‫ﻣﺤﺎﺳﺒﺎت‬ ‫ﻛﻤﻚ‬ ‫ﺑﻪ‬MATLAB faradars.org/fvmth102 ‫س‬‫ر‬‫د‬‫ا‬‫ﺮ‬‫ﻓ‬ FaraDars.org
  4. 4. ‫ﻣﺤﺎﺳﺒﺎﺗﻲ‬ ‫ﻫﺎي‬ ‫رﻫﻴﺎﻓﺖ‬ ‫اداﻣﻪ‬ •‫ﻓﺮم‬‫ﻛﻠﻲ‬)‫اﻟﺒﺘﻪ‬‫ﺑﺮاي‬‫دﺳﺘﮕﺎه‬‫ﻫﺎي‬‫ﺑﺎ‬‫ﺗﻌﺪاد‬‫ﻣﻌﺎدﻻت‬‫و‬‫ﻣﺠﻬﻮﻻت‬‫ﺑﺮاﺑﺮ‬‫ﻳﺎ‬m=n( 4 Ax b m =n ‫ﻋﺪدي‬ ‫ﻣﺤﺎﺳﺒﺎت‬ ‫ﻛﻤﻚ‬ ‫ﺑﻪ‬MATLAB faradars.org/fvmth102 ‫س‬‫ر‬‫د‬‫ا‬‫ﺮ‬‫ﻓ‬ FaraDars.org
  5. 5. ‫ﺧﻄﻲ‬ ‫ﻣﻌﺎدﻻت‬ ‫دﺳﺘﮕﺎه‬ ‫ﭘﺎراﻣﺘﺮﻫﺎي‬ ‫اﺳﺎﻣﻲ‬ •‫ﻣﺎﺗﺮﻳﺲ‬‫ﺿﺮاﻳﺐ‬)m=n( •‫ﺑﺮدار‬‫ﻣﺠﻬﻮﻻت‬ •‫ﺑﺮدار‬‫ﻣﻌﻠﻮﻣﺎت‬ 5 ‫ﻋﺪدي‬ ‫ﻣﺤﺎﺳﺒﺎت‬ ‫ﻛﻤﻚ‬ ‫ﺑﻪ‬MATLAB faradars.org/fvmth102 ‫س‬‫ر‬‫د‬‫ا‬‫ﺮ‬‫ﻓ‬ FaraDars.org
  6. 6. ‫ﻣﺤﺎﺳﺒﺎﺗﻲ‬ ‫ﻫﺎي‬ ‫رﻫﻴﺎﻓﺖ‬ •‫رﻫﻴﺎﻓﺖ‬‫ﻫﺎي‬‫ﻣﺴﺘﻘﻴﻢ‬:‫در‬‫روش‬‫ﻫﺎي‬،‫ﻣﺴﺘﻘﻴﻢ‬‫ﭘﺎﺳﺦ‬‫اﻋﺪاد‬‫ﺛﺎﺑﺘﻲ‬‫ﻫﺴﺘﻨﺪ‬‫ﻛﻪ‬‫از‬‫ﻣﺮاﺣﻠﻲ‬‫ﺑﺪﺳ‬‫ﺖ‬‫ﻣﻲ‬ ‫آﻳﻨﺪ‬‫ﻛﻪ‬‫اﻳﻦ‬‫ﻋﺪد‬‫ﺣﺎﺻﻞ‬‫ﺧﻄﺎﻫﺎي‬‫ﮔﺮدﻛﺮدن‬‫ﻣﻲ‬‫ﺑﺎﺷﻨﺪ‬. •‫رﻫﻴﺎﻓﺖ‬‫ﻫﺎي‬‫ﻏﻴﺮ‬‫ﻣﺴﺘﻘﻴﻢ‬‫ﻳﺎ‬‫ﺗﻜﺮاري‬:‫روش‬‫ﻫﺎي‬‫ﮔﺎم‬‫ﺑﻪ‬‫ﮔﺎم‬‫ﺑﺮ‬‫ﻣﺒﻨﺎي‬‫اﻃﻼﻋﺎت‬‫ﭘﻲ‬‫در‬‫ﭘﻲ‬‫ﺳ‬‫ﺣﺪ‬‫ﻬﺎي‬ ‫اوﻟﻴﻪ‬‫ﺑﺮاي‬‫ﭘﺎﺳﺦ‬،‫ﻣﺴﺌﻠﻪ‬‫ﭘﺎﻳﻪ‬‫ﮔﺬاري‬‫ﺷﺪه‬‫اﻧﺪ‬. 6 ‫ﻋﺪدي‬ ‫ﻣﺤﺎﺳﺒﺎت‬ ‫ﻛﻤﻚ‬ ‫ﺑﻪ‬MATLAB faradars.org/fvmth102 ‫س‬‫ر‬‫د‬‫ا‬‫ﺮ‬‫ﻓ‬ FaraDars.org
  7. 7. ‫ﻣﺤﺎﺳﺒﺎﺗﻲ‬ ‫ﻫﺎي‬ ‫رﻫﻴﺎﻓﺖ‬ ‫اداﻣﻪ‬ •‫رﻫﻴﺎﻓﺖ‬‫ﻫﺎي‬‫ﻣﺴﺘﻘﻴﻢ‬‫ﻳﺎ‬‫ﻏﻴﺮ‬‫ﺗﻜﺮاري‬ –‫ﺷﺮط‬‫ﺟﻮاب‬‫داﺷﺘﻦ‬:‫ﻣﺎﺗﺮﻳﺲ‬‫ﺿﺮاﻳﺐ‬‫ﻧﺎوﻳﮋه‬‫ﻳﻌﻨﻲ‬‫دﺗﺮﻣﻴﻨﺎن‬‫ﻣﺎﺗﺮﻳﺲ‬‫ﺿﺮاﻳﺐ‬‫ﻏﻴﺮ‬‫ﺻﻔﺮ‬‫ﺑﺎﺷﺪ‬. –‫روش‬‫ﻫﺎي‬‫ﻣﺘﺪاول‬: 1.‫ﻣﻌﻜﻮس‬‫ﻣﺎﺗﺮﻳﺲ‬‫ﺿﺮاﻳﺐ‬ 2.‫روش‬‫ﻛﺮاﻣﺮ‬ 3.‫روش‬‫ﻫﺎي‬‫ﺣﺬﻓﻲ‬ *‫روش‬‫ﺳﺎده‬)‫ﻧﺎﻗﺺ‬(‫ﮔﻮس‬)Naive Gaussian Elimination( *‫روش‬‫ﺣﺬف‬‫ﮔﻮس‬‫ﺑﺎ‬‫ﻣﺤﻮرﻳﺖ‬‫ﻧﺴﺒﻲ‬‫ﻗﻴﺎﺳﻲ‬)Pivoting Gaussian Elimination( 4.‫روش‬‫ﺗﺠﺰﻳﻪ‬LU 7 bAx  bAAxA 11   1  A IAA 1 bAx 1  ‫ﻋﺪدي‬ ‫ﻣﺤﺎﺳﺒﺎت‬ ‫ﻛﻤﻚ‬ ‫ﺑﻪ‬MATLAB faradars.org/fvmth102 ‫س‬‫ر‬‫د‬‫ا‬‫ﺮ‬‫ﻓ‬ FaraDars.org
  8. 8. ‫ﻣﺤﺎﺳﺒﺎﺗﻲ‬ ‫ﻫﺎي‬ ‫رﻫﻴﺎﻓﺖ‬ ‫اداﻣﻪ‬ •‫رﻫﻴﺎﻓﺖ‬‫ﻫﺎي‬‫ﻏﻴﺮ‬‫ﻣﺴﺘﻘﻴﻢ‬‫ﻳﺎ‬‫ﺗﻜﺮاري‬)Iterative Methods( –‫ﺷﺮط‬‫داﺷﺘﻦ‬‫ﺟﻮاب‬:‫ﻣﺎﺗﺮﻳﺲ‬‫ﺿﺮاﻳﺐ‬ً‫ﺎ‬‫ﺣﺘﻤ‬‫ﺑﺎﻳﺪ‬‫ﻳﺎ‬positive definite‫و‬‫ﻳﺎ‬diagonally dominant‫ﺑﺎﺷﺪ‬)‫ﺷﺮاﻳﻂ‬ ‫ﻻزم‬‫و‬‫ﻛﺎﻓﻲ‬‫ﻫﻤﮕﺮاﻳﻲ‬‫روش‬‫ﻫﺎي‬‫ﺗﻜﺮاري‬(. –‫روش‬‫ﻫﺎي‬‫ﻣﺘﺪاول‬: 1.‫ژاﻛﻮﺑﻲ‬ 2.‫ﮔﻮس‬-‫ﺳﻴﺪال‬ 8 ‫ﻋﺪدي‬ ‫ﻣﺤﺎﺳﺒﺎت‬ ‫ﻛﻤﻚ‬ ‫ﺑﻪ‬MATLAB faradars.org/fvmth102 ‫س‬‫ر‬‫د‬‫ا‬‫ﺮ‬‫ﻓ‬ FaraDars.org
  9. 9. ‫رﻫﻴﺎﻓﺖ‬‫ﻫﺎي‬ ‫ﻏﻴﺮﺗﻜﺮاري‬ ‫ﻳﺎ‬ ‫ﻣﺴﺘﻘﻴﻢ‬ 9 ‫ﻋﺪدي‬ ‫ﻣﺤﺎﺳﺒﺎت‬ ‫ﻛﻤﻚ‬ ‫ﺑﻪ‬MATLAB faradars.org/fvmth102 ‫س‬‫ر‬‫د‬‫ا‬‫ﺮ‬‫ﻓ‬ FaraDars.org
  10. 10. ‫ﺧﻄﻲ‬ ‫ﻣﻌﺎدﻻت‬ ‫ﻫﺎي‬ ‫دﺳﺘﮕﺎه‬ ‫ﺣﻞ‬ ‫ﺑﺮاي‬ ‫ﻛﺮاﻣﺮ‬ ‫روش‬ •‫ﺑﺎﺷ‬ ‫ﻣﻲ‬ ‫زﻳﺮ‬ ‫ﻗﺮار‬ ‫از‬ ‫ﻛﺮاﻣﺮ‬ ‫روش‬ ‫ﺑﻪ‬ ‫ﺧﻄﻲ‬ ‫ﻣﻌﺎدﻻت‬ ‫دﺳﺘﮕﺎه‬ ‫ﻳﻚ‬ ‫ﺑﻮدن‬ ‫ﺣﻞ‬ ‫ﻗﺎﺑﻞ‬ ‫ﺑﺮاي‬ ‫ﻻزم‬ ‫ﺷﺮاﻳﻂ‬‫ﺪ‬: ‫اﻟﻒ‬(‫ﺿﺮاﻳﺐ‬ ‫ﻣﺎﺗﺮﻳﺲ‬A‫ﺑﺎﺷﺪ‬ ‫ﻣﺮﺗﺒﻪ‬ ‫ﻛﺎﻣﻞ‬ ‫ﻳﺎ‬ ‫و‬ ‫ﻧﺎوﻳﮋه‬ ‫ﺑﺎﻳﺴﺘﻲ‬. •‫ﺗﺬﻛﺮ‬1:‫ﺗﻌﺮﻳﻒ‬‫ﻧﺎوﻳﮋه‬‫ﻳﺎ‬‫ﻛﺎﻣﻞ‬‫ﻣﺮﺗﺒﻪ‬‫ﺑﻮدن‬‫ﻳﻚ‬‫ﻣﺎﺗﺮﻳﺲ‬‫ﻣﺮﺑﻌﻲ‬:‫ﻳﻌﻨﻲ‬‫آن‬‫ﻣﺎﺗﺮﻳﺲ‬‫ﻣﻌﻜﻮس‬‫ﭘﺬﻳﺮ‬‫ﺑﻮده‬‫ﻛ‬‫ﻪ‬‫ﻻزﻣﻪ‬‫آن‬ ‫داﺷﺘﻦ‬‫دﺗﺮﻣﻴﻨﺎن‬‫ﻣﺎﺗﺮﻳﺲ‬‫ﻣﺨﺎﻟﻒ‬‫ﺻﻔﺮ‬‫اﺳﺖ‬. •‫ﺗﺬﻛﺮ‬2:‫در‬‫ﺻﻮرﺗﻲ‬‫ﻛﻪ‬‫ﺳﻄﺮ‬)‫ﻫﺎ‬(‫ﻳﺎ‬‫ﺳﺘﻮن‬)‫ﻫﺎ‬(‫اي‬‫از‬‫ﻣﺎﺗﺮﻳﺲ‬‫ﻣﻮرد‬‫ﻧﻈﺮ‬‫ﺿﺮﻳﺒﻲ‬‫از‬‫ﺳﻄﺮ‬)‫ﻫﺎ‬(‫ﻳﺎ‬‫ﺳﺘﻮن‬)‫ﻫﺎ‬(‫ي‬ ‫دﻳﮕﺮي‬‫از‬‫آن‬‫ﻣﺎﺗﺮﻳﺲ‬،‫ﺑﺎﺷﻨﺪ‬‫آﻧﮕﺎه‬‫دﺗﺮﻣﻴﻨﺎن‬‫آن‬‫ﻣﺎﺗﺮﻳﺲ‬‫ﺑﺮاﺑﺮ‬‫ﺻﻔﺮ‬‫ﺧﻮاﻫﺪ‬‫ﺷﺪ‬.‫ﺑﺪﻳﻦ‬،‫ﺗﺮﺗﻴﺐ‬‫آن‬‫ﻣﺎﺗﺮ‬‫ﻳﺲ‬‫وﻳﮋه‬ ‫اﺳﺖ‬.‫ﺑﻪ‬‫ﻋﺒﺎرت‬‫دﻳﮕﺮ‬‫ﻣﻌﺎدﻻت‬‫ﻣﻮﺟﻮد‬‫در‬‫دﺳﺘﮕﺎه‬‫ﻣﻌﺎدﻻت‬‫ﺧﻄﻲ‬‫ﻣﺮﺑﻮط‬‫ﺑﻪ‬‫ﭼﻨﻴﻦ‬‫ﻣﺎﺗﺮﻳﺲ‬‫ﺿﺮاﻳﺒﻲ‬‫واﺑﺴﺘ‬‫ﮕﻲ‬‫ﺧﻄﻲ‬ ‫ﺑﻪ‬‫ﻫﻢ‬‫دارﻧﺪ‬. 10 ‫ﻋﺪدي‬ ‫ﻣﺤﺎﺳﺒﺎت‬ ‫ﻛﻤﻚ‬ ‫ﺑﻪ‬MATLAB faradars.org/fvmth102 ‫س‬‫ر‬‫د‬‫ا‬‫ﺮ‬‫ﻓ‬ FaraDars.org
  11. 11. ‫ﺧﻄﻲ‬ ‫ﻣﻌﺎدﻻت‬ ‫ﻫﺎي‬ ‫دﺳﺘﮕﺎه‬ ‫ﺣﻞ‬ ‫ﺑﺮاي‬ ‫ﻛﺮاﻣﺮ‬ ‫روش‬ •‫دارﻳﻢ‬ ‫ﻛﺮاﻣﺮ‬ ‫روش‬ ‫ﺑﻪ‬ ‫ﺧﻄﻲ‬ ‫ﻣﻌﺎدﻻت‬ ‫دﺳﺘﮕﺎه‬ ‫ﺣﻞ‬ ‫ﺑﺮاي‬: 1( 2(‫ﻣﺎﺗﺮﻳﺲ‬jA‫ﺗﻌﻮﻳﺾ‬ ‫از‬j‫ﻣﺎﺗﺮﻳﺲ‬ ‫ﺳﺘﻮن‬ ‫اﻣﻴﻦ‬A‫ﺑﺮدار‬ ‫ﺑﺎ‬b‫آﻳﺪ‬ ‫ﻣﻲ‬ ‫ﺑﺪﺳﺖ‬. ==================================================================================== ‫ﻣﺜﺎل‬:‫روش‬ ‫ﺑﻪ‬ ‫را‬ ‫روﺑﺮو‬ ‫ﺧﻄﻲ‬ ‫ﻣﻌﺎدﻻت‬ ‫دﺳﺘﮕﺎه‬ ‫ﻧﻤﺎﻳﻴﺪ‬ ‫ﺣﻞ‬ ‫ﻛﺮاﻣﺮ‬. ‫ﺣﻞ‬-‫ﺑﻌﺪ‬ ‫ﺻﻔﺤﻪ‬ ‫در‬ 11 ),...,2,1( )det( )det( nj A A x j j  201302020 20204020 20202080 321 321 321    xxx xxx xxx ‫ﻋﺪدي‬ ‫ﻣﺤﺎﺳﺒﺎت‬ ‫ﻛﻤﻚ‬ ‫ﺑﻪ‬MATLAB faradars.org/fvmth102 ‫س‬‫ر‬‫د‬‫ا‬‫ﺮ‬‫ﻓ‬ FaraDars.org
  12. 12. ‫ﺧﻄﻲ‬ ‫ﻣﻌﺎدﻻت‬ ‫ﻫﺎي‬ ‫دﺳﺘﮕﺎه‬ ‫ﺣﻞ‬ ‫ﺑﺮاي‬ ‫ﻛﺮاﻣﺮ‬ ‫روش‬ ‫ﻛﺮاﻣﺮ‬ ‫روش‬ ‫ﺑﻪ‬ ‫ﻣﺜﺎل‬ ‫ﺣﻞ‬ ‫اداﻣﻪ‬- 12 4.0 )det( )det( 120000 202020 204020 202080 )det( 3 3 3      A A xA 0.1 )det( )det( 300000 1302020 202020 202080 )det( 2 2 2      A A xA 300000 1302020 204020 202080 )det(     A 6.0 )det( )det( 180000 1302020 204020 202020 )det( 1 1 1      A A xA ‫ﻋﺪدي‬ ‫ﻣﺤﺎﺳﺒﺎت‬ ‫ﻛﻤﻚ‬ ‫ﺑﻪ‬MATLAB faradars.org/fvmth102 ‫س‬‫ر‬‫د‬‫ا‬‫ﺮ‬‫ﻓ‬ FaraDars.org
  13. 13. ‫ﮔﻮس‬ ‫ﺳﺎده‬ ‫ﺣﺬف‬ ‫روش‬ )Naive Gauss Elimination( •‫ﻣﺰاﻳﺎ‬:‫ﺳﺎده‬ ‫رﻳﺎﺿﻴﺎﺗﻲ‬ ‫ﺑﻴﺎن‬ •‫روش‬ ‫ﻫﺎي‬ ‫ﻣﺤﺪودﻳﺖ‬:‫ﺿ‬ ‫ﻣﺎﺗﺮﻳﺲ‬ ‫ﻣﺜﻠﺜﻲ‬ ‫ﭘﺎﻳﻴﻦ‬ ‫ﻳﺎ‬ ‫و‬ ‫ﺑﺎﻻ‬ ‫ﺿﺮاﻳﺐ‬ ‫ﺑﻮدن‬ ‫ﺻﻔﺮ‬ ‫ﻏﻴﺮ‬ ‫ﺻﻮرت‬ ‫در‬ ‫ﺗﻨﻬﺎ‬،‫ﺮاﻳﺐ‬ ‫دارد‬ ‫ﺟﻮاب‬. •‫ﺗﺸﻜﻴﻞ‬‫ﻣﺎﺗﺮﻳﺲ‬‫اﻓﺰوده‬)augmented Matrix(‫ﺣﺎﺻﻞ‬‫ﺑﻪ‬‫ﻫﻢ‬‫ﭘﻴﻮﺳﺘﻦ‬‫ﻣﺎﺗﺮﻳﺲ‬‫ﺿﺮاﻳﺐ‬‫و‬‫ﺑﺮدار‬ ‫ﻣﻌﻠﻮﻣﺎت‬: 13 ‫ﻋﺪدي‬ ‫ﻣﺤﺎﺳﺒﺎت‬ ‫ﻛﻤﻚ‬ ‫ﺑﻪ‬MATLAB faradars.org/fvmth102 ‫س‬‫ر‬‫د‬‫ا‬‫ﺮ‬‫ﻓ‬ FaraDars.org
  14. 14. ‫دﺳﺘﻮراﻟﻌﻤﻞ‬‫ﺳﺎده‬ ‫ﺣﺬف‬ ‫روش‬ ‫اﻟﮕﻮرﻳﺘﻤﻲ‬‫ﮔﻮس‬ )Naive Gauss Elimination( •‫اول‬ ‫ﻣﺮﺣﻠﻪ‬:‫اﮔﺮ‬ •‫ﻣﺮﺣﻠﻪ‬‫دوم‬:‫ﺿﺮب‬‫دراﻳﻪ‬‫ﻫﺎي‬‫اوﻟﻴﻦ‬‫ﺳﻄﺮ‬‫از‬‫ﻣﺎﺗﺮﻳﺲ‬‫اﻓﺰوده‬‫در‬‫و‬‫اﻧﺠﺎم‬‫ﻋﻤﻠﻴﺎت‬‫ﺗﻔﺮﻳﻖ‬‫روﺑﺮو‬: •‫ﻣﺮﺣﻠﻪ‬‫ﺳﻮم‬:‫ﺑﺪﻳﻦ‬‫ﺗﺮﺗﻴﺐ‬،‫در‬‫اﻳﻦ‬‫ﻣﺮﺣﻠﻪ‬،‫ّﻟﻴﻦ‬‫و‬‫ا‬‫ﺳﻄﺮ‬‫ﻫﺎ‬‫از‬‫ﻣﺎﺗﺮﻳﺲ‬‫ﻫﺎي‬A‫و‬b،‫ﺑﺪون‬‫ﺗﻐﻴﻴﺮ‬‫ﺑﺎﻗﻲ‬‫ﻣﻲ‬،‫ﻣﺎﻧﻨﺪ‬‫و‬‫درآﻳﻪ‬‫ﻫﺎي‬‫ّﻟﻴﻦ‬‫و‬‫ا‬ ‫ﺳﺘﻮن‬‫از‬‫ﻣﺎﺗﺮﻳﺲ‬A‫در‬‫زﻳﺮ‬‫ﺗﺒﺪﻳﻞ‬‫ﺑﻪ‬‫ﺻﻔﺮ‬‫ﻣﻲ‬‫ﮔﺮدﻧﺪ‬.‫ﺑﻨﺎﺑﺮاﻳﻦ‬،‫ﻧﺘﻴﺠﻪ‬‫ﺣﺎﺻﻞ‬‫از‬‫اﻧﺠﺎم‬‫ﻋﻤﻠﻴﺖ‬‫ﻓﻮق‬،‫دﺳﺘﮕﺎه‬‫ﺗﻐﻴﻴﺮ‬‫ﻓ‬‫ﺮم‬‫ﻳﺎﻓﺘﻪ‬‫زﻳﺮ‬ ‫اﺳﺖ‬: (1) 11 0a  (1) 1 1 (1) 11 i i a m a  1im (2) (1) (1) 1 1 (2) (1) (1) 1 1 , 2,3,...,ij ij i j i i i j na a m a b b m b      (1) 11a (1) (1) (1) (1) 111 12 1 1 (2) (2) (2) 222 2 2 (2) (2) (2) 2 . . . 0 . . . .. . . . . .. . . . . .. . . . . 0 . . . n n nn nn n xa a a b xa a b xa a b                                                  14 ‫ﻋﺪدي‬ ‫ﻣﺤﺎﺳﺒﺎت‬ ‫ﻛﻤﻚ‬ ‫ﺑﻪ‬MATLAB faradars.org/fvmth102 ‫س‬‫ر‬‫د‬‫ا‬‫ﺮ‬‫ﻓ‬ FaraDars.org
  15. 15. ‫دﺳﺘﻮراﻟﻌﻤﻞ‬ ‫اداﻣﻪ‬‫ﺳﺎده‬ ‫ﺣﺬف‬ ‫روش‬ ‫اﻟﮕﻮرﻳﺘﻤﻲ‬‫ﮔﻮس‬ )Naive Gauss Elimination( •‫ﻫﻤﻴﻦ‬‫روش‬‫را‬‫ﺑﺮاي‬‫ﺳﺎﻳﺮ‬‫ﺳﻄﺮﻫﺎ‬‫ﻧﻴﺰ‬‫اداﻣﻪ‬‫ﻣﻲ‬‫دﻫﻴﻢ‬،‫ﻛﻪ‬‫ﺑﺪﻳﻦ‬‫ﺗﺮﺗﻴﺐ‬‫در‬‫ﺣﺎﻟﺖ‬ ‫ﻛﻠﻲ‬‫در‬k‫اﻣﻴﻦ‬‫ﮔﺎم‬‫ﺧﻮاﻫﻴﻢ‬‫داﺷﺖ‬)‫اﻟﺒﺘﻪ‬‫ﺑﺎ‬‫ﻓﺮض‬( ( ) 0k kka  ( ) ( ) 1 k ik ik k k a m a  k‫اﻓﺰوده‬ ‫ﻣﺎﺗﺮﻳﺲ‬ ‫از‬ ‫ﺳﻄﺮ‬ ‫اﻣﻴﻦ‬ ( 1) ( ) ( ) ( 1) ( ) ( ) , 2,3,...,k k k ij ij ik kj k k k i i ik k j na a m a b b m b        (1) (1) (1) (1) (1) 111 12 1, 1, 1 1 (2) (2) (2) (2) 222 1, 1, 1 1 ( ) ( ) ( ) , 1 ( 1) ( 1) 11, 1 1, ( 1) ( 1) , 1 0 0 0 0 0 0 0 0 0 k k n k k n k k k kkk k k kn k k kk k k n k k nn k nn xa a a a a xa a a a xa a a xa a xa a                                                              (1) 1 (2) 2 ( ) ( 1) 1 ( 1) k k k k k n b b b b b                             15 ‫ﻋﺪدي‬ ‫ﻣﺤﺎﺳﺒﺎت‬ ‫ﻛﻤﻚ‬ ‫ﺑﻪ‬MATLAB faradars.org/fvmth102 ‫س‬‫ر‬‫د‬‫ا‬‫ﺮ‬‫ﻓ‬ FaraDars.org
  16. 16. ‫دﺳﺘﻮراﻟﻌﻤﻞ‬ ‫اداﻣﻪ‬‫ﺳﺎده‬ ‫ﺣﺬف‬ ‫روش‬ ‫اﻟﮕﻮرﻳﺘﻤﻲ‬‫ﮔﻮس‬ )Naive Gauss Elimination( •‫در‬،‫ﻧﻬﺎﻳﺖ‬‫از‬‫روي‬‫ﻣﺎﺗﺮﻳﺲ‬‫اﻓﺰوده‬،‫ﻧﻬﺎﻳﻲ‬‫ﻣﺎﺗﺮﻳﺴﻬﺎي‬‫زﻳﺮ‬‫ﻗﺎﺑﻞ‬‫اﺳﺘﺨﺮاج‬‫ﻫﺴﺘﻨﺪ‬: 1(‫ﻳﻚ‬‫ﻣﺎﺗﺮﻳﺲ‬‫ﺿﺮاﻳﺐ‬‫ﺑﺎﻻ‬‫ﻣﺜﻠﺜﻲ‬‫ﺑﻪ‬‫ﻓﺮم‬‫زﻳﺮ‬‫ﺣﺎﺻﻞ‬‫ﻣﻲ‬‫آﻳﺪ‬: 2(‫ﻫﻤﭽﻨﻴﻦ‬‫ﺑﺮدار‬‫ﻣﻌﻠﻮﻣﺎت‬‫ارﺗﻘﺎء‬‫ﻳﺎﻓﺘﻪ‬‫ﺑﻪ‬‫ﻗﺮار‬‫روﺑﺮو‬‫ﻣﻲ‬‫ﺑﺎﺷﺪ‬: •‫ﺳﭙﺲ‬‫ﺑﺮﻃﺒﻖ‬‫دﺳﺘﮕﺎه‬‫ﺣﺎﺿﺮ‬‫از‬‫آﺧﺮ‬‫ﺑﻪ‬‫اول‬‫ﻣﺠﻬﻮﻻت‬‫ﻣﺤﺎﺳﺒﻪ‬‫ﻣﻲ‬‫ﺷﻮﻧﺪ‬. 16 ‫ﻋﺪدي‬ ‫ﻣﺤﺎﺳﺒﺎت‬ ‫ﻛﻤﻚ‬ ‫ﺑﻪ‬MATLAB faradars.org/fvmth102 ‫س‬‫ر‬‫د‬‫ا‬‫ﺮ‬‫ﻓ‬ FaraDars.org
  17. 17. ‫ﺑﺮﻧﺎﻣﻪ‬Matlab‫روش‬‫ﮔﻮس‬ ‫ﺳﺎده‬ ‫ﺣﺬف‬ function ngaussel(A,b) n=length(b); x=zeros(n,1); fprintf('n'); disp(' The augmented matrix is') augm =[A b] for k=1:n-1 for i=k+1:n m=A(i,k)/A(k,k); for j=k+1:n A(i,j)=A(i,j)-m*A(k,j); end A(i,k)=m; b(i)=b(i)-m*b(k); end end x(n)=b(n)/A(n,n); for i=n-1:-1:1 S=b(i); for j=i+1:n S=S-A(i,j)*x(j); end x(i)=S/A(i,i); end % Print the results fprintf('n'); disp(' The transformed upper triangular augmented matrix C is =') fprintf('n'); for i=1:n for j=1:n if (j<i) A(i,j)=0; end end end C=[A b] fprintf('n'); disp(' Back substitution gives the vector solution') x 17 ‫ﻋﺪدي‬ ‫ﻣﺤﺎﺳﺒﺎت‬ ‫ﻛﻤﻚ‬ ‫ﺑﻪ‬MATLAB faradars.org/fvmth102 ‫س‬‫ر‬‫د‬‫ا‬‫ﺮ‬‫ﻓ‬ FaraDars.org
  18. 18. ‫ﮔﻮس‬ ‫ﺳﺎده‬ ‫ﺣﺬف‬ ‫ﺷﻴﻮه‬ ‫ﺑﻪ‬ ‫ﺧﻄﻲ‬ ‫ﻣﻌﺎدﻻت‬ ‫دﺳﺘﮕﺎه‬ ‫ﺣﻞ‬ ‫ﻣﺜﺎل‬ m32=2/1= 2 m42=-2/1= -2 18 ‫ﻣﺜﺎل‬:‫دﺳﺘﮕﺎه‬‫ﻣﻌﺎدﻻت‬‫زﻳﺮ‬‫را‬‫ﺑﻪ‬‫روش‬‫ﮔﻮس‬‫ﺳﺎده‬‫ﺣﻞ‬‫ﻛﻨﻴﺪ‬: ‫ﻣﺎﺗﺮﻳﺲ‬‫اﻓﺰوده‬‫ﺷﺪه‬‫در‬‫ﻃﻮل‬‫ﺑﺎ‬‫ﺿﺮاﻳﺐ‬1im،‫ﻋﺒﺎرت‬‫اﺳﺖ‬‫از‬: ‫ﺑﺎ‬‫ﺗﻔﺮﻳﻖ‬‫ﺣﺎﺻﻞ‬‫ﺿﺮب‬‫ﻫﺎي‬‫ﺑﺪﺳﺖ‬‫آﻣﺪه‬‫ي‬‫اوﻟﻴﻦ‬‫ﻣﻌﺎدﻟﻪ‬‫از‬‫ﺳﻪ‬‫ﻣﻌﺎدﻟﻪ‬،‫دﻳﮕﺮ‬‫دارﻳﻢ‬: ‫ﺑﺎ‬‫ﺗﻔﺮﻳﻖ‬‫ﺣﺎﺻﻞ‬‫ﺿﺮب‬‫ﻫﺎي‬‫ﻣﻌﺪﻟﻪ‬‫ﺳﻮم‬‫از‬‫ﻣﻌﺎدﻟﻪ‬‫ي‬‫آﺧﺮ‬‫ﻫﻢ‬‫ﺧﻮاﻫﻴﻢ‬‫داﺷﺖ‬: ‫اول‬ ‫ﺳﻄﺮ‬ ‫ﻣﺤﻮري‬ ‫درآﻳﻪ‬ m21=2/1= 2 m31=-1/1=-1 m41=3/1= 3 ‫دوم‬ ‫ﺳﻄﺮ‬ ‫ﻣﺤﻮري‬ ‫درآﻳﻪ‬ m43=2/-2 = -1 ‫ﺳﻮم‬ ‫ﺳﻄﺮ‬ ‫ﻣﺤﻮري‬ ‫درآﻳﻪ‬ ‫ﻋﺪدي‬ ‫ﻣﺤﺎﺳﺒﺎت‬ ‫ﻛﻤﻚ‬ ‫ﺑﻪ‬MATLAB faradars.org/fvmth102 ‫س‬‫ر‬‫د‬‫ا‬‫ﺮ‬‫ﻓ‬ FaraDars.org
  19. 19. •‫ﺑﺎ‬‫ﻛﻢ‬‫ﻛﺮدن‬‫ﺣﺎﺻﻞ‬‫ﺿﺮب‬‫ﻫﺎي‬‫ﻣﻌﺎدﻟﻪ‬‫ﺳﻮم‬‫از‬‫ﻣﻌﺎدﻟﻪ‬،‫آﺧﺮ‬‫دﺳﺘﮕﺎه‬‫ﺑﺎﻻ‬‫ﻣﺜﻠﺜﻲ‬‫زﻳﺮ‬‫ﺣﺎﺻﻞ‬‫ﻣ‬‫ﻲ‬‫آﻳﺪ‬: •‫ﻋﻤﻠﻴﺎت‬‫ﻣﺮﺑﻮط‬‫ﺑﻪ‬‫دﺳﺘﻮراﻟﻌﻤﻞ‬‫ﺟﺎﻳﮕﺬاري‬‫ﺑﺮﮔﺸﺘﻲ‬‫ﺑﺎ‬‫ﻣﻌﻜﻮس‬‫اﻋﻤﺎل‬‫ﺷﺪه‬‫ﺑﻪ‬‫دﺳﺘﮕﺎه‬‫ﺑ‬‫ﺎﻻ‬‫ﻣﺜﻠﺜﻲ‬ ،‫ﺣﺎﺻﻞ‬‫ﻧﺘﺎﻳﺞ‬‫زﻳﺮ‬‫را‬‫ﺑﺪﺳﺖ‬‫ﻣﻲ‬‫دﻫﺪ‬: ‫ﮔﻮس‬ ‫ﺳﺎده‬ ‫ﺣﺬف‬ ‫ﺷﻴﻮه‬ ‫ﺑﻪ‬ ‫ﺧﻄﻲ‬ ‫ﻣﻌﺎدﻻت‬ ‫دﺳﺘﮕﺎه‬ ‫ﺣﻞ‬ ‫ﻣﺜﺎل‬ ‫اداﻣﻪ‬ 19 x1+x2+x3+x4 = 10 x2-x3+3x4= 11 -2x3- 2x4= -14 -x4= -4 ‫ﻋﺪدي‬ ‫ﻣﺤﺎﺳﺒﺎت‬ ‫ﻛﻤﻚ‬ ‫ﺑﻪ‬MATLAB faradars.org/fvmth102 ‫س‬‫ر‬‫د‬‫ا‬‫ﺮ‬‫ﻓ‬ FaraDars.org
  20. 20. ‫ﮔﻮس‬ ‫ﺳﺎده‬ ‫ﺣﺬف‬ ‫روش‬ ‫ﻧﻜﺎت‬ 20 ‫ﻣﺰاﻳﺎ‬: *‫ﺳﺎدﮔﻲ‬‫روش‬ ‫ﻣﻌﺎﻳﺐ‬: *‫ﻋﺪم‬‫ﻛﺎرآﻳﻲ‬‫ﺑﺮاي‬‫ﻣﺎﺗﺮﻳﺲ‬‫ﺿﺮاﻳﺐ‬‫ﺑﺎ‬‫وﺟﻮد‬‫ﻳﻚ‬‫در‬‫ا‬‫ي‬‫ﻳﻪ‬‫ي‬‫ﭘﺎﻳﻪ‬‫ﺻ‬‫ﻔﺮ‬. *‫ﺑﺴﻴﺎر‬‫ﻛﻮﭼﻚ‬‫ﺑﻮدن‬‫ي‬‫دراﻳﻪ‬‫ﭘﺎﻳﻪ‬)‫ﻋﻤﻮدي‬(‫از‬‫ﻧﻈﺮاﻧﺪازه‬‫درﻣﻘﺎﻳﺴﻪ‬‫ﺑﺎ‬ ‫ﺳﺎﻳﺮ‬‫دراﻳﻪ‬‫ﻫﺎي‬‫ﺳﻄﺮ‬‫ﻣﺤﻮري‬. ‫ﻧﺘﻴﺠﻪ‬:‫اﻓﺰاﻳﺶ‬‫ﺧﻄﺎي‬‫ﮔﺮد‬‫ﻛﺮدن‬)(Round-Off‫ﻛﻪ‬‫در‬‫اﻳﻦ‬‫ﺻﻮرت‬ ‫ﺧﻄﺎ‬‫ﺗﻮاﻧﺪ‬‫ﻣﻲ‬‫ﻣﻨﺠﺮ‬‫ﺑﻪ‬‫ﻳﻚ‬‫ﺑﺮدار‬‫ﺟﻮاب‬‫ﻏﻴﺮ‬‫دﻗﻴﻖ‬‫ﺷﻮد‬. ‫ﻋﺪدي‬ ‫ﻣﺤﺎﺳﺒﺎت‬ ‫ﻛﻤﻚ‬ ‫ﺑﻪ‬MATLAB faradars.org/fvmth102 ‫س‬‫ر‬‫د‬‫ا‬‫ﺮ‬‫ﻓ‬ FaraDars.org
  21. 21. ‫ﻗﻴﺎﺳﻲ‬ ‫ﻧﺴﺒﻲ‬ ‫ﻣﺤﻮرﻳﺖ‬ ‫ﺑﺎ‬ ‫ﮔﻮس‬ ‫ﺣﺬف‬ ‫روش‬ )Pivoting Gaussian Elimination( 21 ‫ﺗﺬﻛﺮ‬:‫ﻣﻨﻈﻮر‬‫از‬‫درآﻳﻪ‬‫ﺑﺎ‬‫ﻣﺤﻮر‬‫ﻫﻤﺎن‬‫درآﻳﻪ‬‫ي‬‫ﻫﺎ‬‫ﺻﻔﺮ‬‫ﺑﺮ‬‫روي‬‫ﻗﻄﺮ‬‫اﺻﻠﻲ‬‫ﻣﻲ‬‫ﺑﺎﺷﻨﺪ‬. ‫اﺗﻜﺎ‬ ‫اﻟﻤﺎن‬ ‫از‬ ‫ﭼﻨﺪ‬ ‫ﻧﻜﺎﺗﻲ‬)Pivoting:( 1(‫اﻟﻤﺎن‬‫روي‬‫ﻗﻄﺮ‬‫اﺻﻠﻲ‬. 2(‫ﻓﺮآﻳﻨﺪ‬‫روش‬‫ﺣﺬف‬‫ﺳﺎده‬‫ﮔﻮس‬‫در‬‫ﺻﻮرت‬‫ﺻﻔﺮ‬‫ﺑﻮدن‬‫ﻫﺮ‬‫ﻳﻚ‬‫از‬‫اﻟﻤﺎن‬‫ﻫﺎي‬‫ﻗﻄﺮ‬‫اﺻﻠﻲ‬‫ﻣﺘﻮﻗﻒ‬ ‫ﺧﻮاﻫﺪ‬‫ﺷﺪ‬. 3(‫روش‬‫ﺣﺬف‬‫ﺳﺎده‬‫ﮔﻮس‬‫ﺑﺮاي‬‫اﺟﺘﻨﺎب‬‫از‬‫اﻳﻦ‬‫ﻣﺸﻜﻞ‬‫ﺑﺎﻳﺪ‬‫اﺻﻼح‬‫ﺷﻮد‬. ‫ﻋﺪدي‬ ‫ﻣﺤﺎﺳﺒﺎت‬ ‫ﻛﻤﻚ‬ ‫ﺑﻪ‬MATLAB faradars.org/fvmth102 ‫س‬‫ر‬‫د‬‫ا‬‫ﺮ‬‫ﻓ‬ FaraDars.org
  22. 22. ‫روش‬ ‫اداﻣﻪ‬‫ﻗﻴﺎﺳﻲ‬ ‫ﻧﺴﺒﻲ‬ ‫ﻣﺤﻮرﻳﺖ‬ ‫ﺑﺎ‬ ‫ﮔﻮس‬ ‫ﺣﺬف‬ )Pivoting Gaussian Elimination( 22 *‫روش‬‫ﭘﻴﺸﻨﻬﺎدي‬‫ﺗﻌﻮﻳﺾ‬‫ﻣﻌﺎدﻻت‬)‫ﺳﻄﺮﻫﺎ‬(‫ﻳﺎ‬‫ﻣﺘﻐﻴﺮﻫﺎ‬)‫ﺳﺘﻮن‬‫ﻫﺎ‬(‫ﺑﻪ‬‫ﻣﻨﻈﻮر‬‫ﻣﻨﺘﻘﻞ‬‫ﻧﻤﻮدن‬‫ﺑﺰرﮔ‬‫ﺘﺮﻳﻦ‬ ‫اﻟﻤﺎن‬‫ﺑﻪ‬‫روي‬‫ﻗﻄﺮ‬‫اﺻﻠﻲ‬‫ﻗﺒﻞ‬‫از‬‫اﻧﺠﺎم‬‫ﻋﻤﻞ‬‫ﺣﺬف‬‫اﺳﺖ‬. *‫اﻳﻦ‬‫روش‬pivoting‫ﻧﺎﻣﻴﺪه‬‫ﻣﻲ‬‫ﺷﻮد‬.‫ﺗﻌﻮﻳﺾ‬‫ﻫﺮدو‬‫ﺳﻄﺮﻫﺎ‬‫و‬‫ﺳﺘﻮن‬‫ﻫﺎ‬full pivoting‫ﻧﺎﻣﻴﺪه‬‫ﻣﻲ‬ ‫ﺷﻮد‬. *Full pivoting‫ﺑﻪ‬‫ﻋﻠﺖ‬‫ﭘﻴﭽﻴﺪﮔﻲ‬‫اﺳﺘﻔﺎده‬‫ﻧﻤﻲ‬‫ﺷﻮد‬.‫روش‬‫ﭘﻴﺸﻨﻬﺎدي‬partial pivoting‫اﺳﺖ‬. *‫در‬‫روش‬partial pivoting‫از‬‫ﺟﺎﺑﺠﺎﻳﻲ‬‫ﺳﻄﺮﻫﺎ‬‫اﺳﺘﻔﺎده‬‫ﻣﻲ‬‫ﺷﻮد‬. ‫ﻋﺪدي‬ ‫ﻣﺤﺎﺳﺒﺎت‬ ‫ﻛﻤﻚ‬ ‫ﺑﻪ‬MATLAB faradars.org/fvmth102 ‫س‬‫ر‬‫د‬‫ا‬‫ﺮ‬‫ﻓ‬ FaraDars.org
  23. 23. ‫از‬ ‫ﻣﺜﺎﻟﻲ‬Partial Pivoting 23 *‫ﻣﺜﺎل‬:‫ﭼﻮن‬1,1a=0‫ﭘﺲ‬‫ﻻزم‬‫اﺳﺖ‬‫ﻋﻤﻠﻴﺎت‬pivoting‫اﻧﺠﺎم‬‫ﺷﻮد‬: Pivoting                  )1( 3 )1( 2 )1( 1 : : : 1111 2110 0112 r r r   1 1 1 )4( 11 3 2 )4( 1 )4( 11 )4( 223 )4( 23 )4( 22 )4( 33 )4( 33           axabx axabx abx n nn                           )4( 3 )4( 2 )4( 1 )3( 2 )3( 22 )3( 32 )3( 3 )3( 2 )3( 1 : : : 3/43/400 2110 0112 r r r raar r r                              )2( 3 )2( 2 )2( 1 )1( 1 )1( 11 )1( 31 )1( 3 )1( 1 )1( 11 )1( 21 )1( 2 )1( 1 : : : 12/12/30 2110 0112 r r r raar raar r                  )3( 3 )3( 2 )3( 1 : : : 2110 12/12/30 0112 r r r             1111 0112 2110 ]|[ bA              1111 2110 0112 ]|[ bA ‫ﻋﺪدي‬ ‫ﻣﺤﺎﺳﺒﺎت‬ ‫ﻛﻤﻚ‬ ‫ﺑﻪ‬MATLAB faradars.org/fvmth102 ‫س‬‫ر‬‫د‬‫ا‬‫ﺮ‬‫ﻓ‬ FaraDars.org
  24. 24. ‫ﺳﺎزي‬ ‫ﻣﺘﻨﺎﺳﺐ‬)scaling( •‫ﻳﺎﺑﺪ‬ ‫ﻣﻲ‬ ‫اﻫﻤﻴﺖ‬ ‫ﻛﺮدن‬ ‫ﮔﺮد‬ ‫از‬ ‫ﻧﺎﺷﻲ‬ ‫ﺧﻄﺎي‬ ،‫ﺳﻄﺮ‬ ‫ﻫﺎي‬ ‫اﻟﻤﺎن‬ ‫ﺳﺎﻳﺮ‬ ‫از‬ ‫اﺗﻜﺎ‬ ‫اﻟﻤﺎن‬ ‫ﺑﻮدن‬ ‫ﻛﻮﭼﻚ‬ ‫ﺻﻮرت‬ ‫در‬. •‫ﺳﺎزي‬ ‫ﻣﺘﻨﺎﺳﺐ‬ ‫روش‬ ‫از‬ ‫اﺳﺘﻔﺎده‬ ‫ﺣﺎﻟﺘﻲ‬ ‫ﭼﻨﻴﻦ‬ ‫در‬)Scaling(‫ﺷﻮد‬ ‫ﻣﻲ‬ ‫ﭘﻴﺸﻨﻬﺎد‬ ‫اﺗﻜﺎ‬ ‫اﻟﻤﺎن‬ ‫اﻧﺘﺨﺎب‬ ‫ﺑﺮاي‬. •‫ﺳﺎزي‬ ‫ﻣﺘﻨﺎﺳﺐ‬ ‫روش‬)Scaling(: –‫ﺑﺰرﮔﺘﺮﻳ‬ ‫ﺑﻪ‬ ‫ﻳﻌﻨﻲ‬ ‫ﺷﻮﻧﺪ‬ ‫ﻣﻲ‬ ‫ﻧﺮﻣﺎﻟﻴﺰه‬ ‫اول‬ ‫ﺳﺘﻮن‬ ‫ﻫﺎي‬ ‫اﻟﻤﺎن‬ ‫ﻛﻠﻴﻪ‬ ،‫اول‬ ‫ﺳﺘﻮن‬ ‫روي‬ ‫ﺑﺮ‬ ،‫ﮔﻮس‬ ‫ﺣﺬف‬ ‫روش‬ ‫اﻋﻤﺎل‬ ‫از‬ ‫ﻗﺒﻞ‬‫اﻟﻤﺎن‬ ‫ﻦ‬ ‫ﺷﻮﻧﺪ‬ ‫ﻣﻲ‬ ‫ﺗﻘﺴﻴﻢ‬ ‫ﻣﺮﺑﻮﻃﻪ‬ ‫ﺳﻄﺮ‬ ‫در‬ ‫ﻣﻮﺟﻮد‬.( –‫ﺷﻮد‬ ‫ﻣﻲ‬ ‫اﻧﺠﺎم‬ ‫اﺗﻜﺎ‬ ‫اﻟﻤﺎن‬ ‫اﻧﺘﺨﺎب‬ ‫ﺳﭙﺲ‬. –‫ﺷﻮد‬ ‫ﻣﻲ‬ ‫ﺑﻜﺎرﮔﺮﻓﺘﻪ‬ ‫ﮔﻮس‬ ‫ﺳﺎده‬ ‫ﺣﺬف‬ ‫روش‬. –‫ﻫﺎي‬ ‫اﻟﻤﺎن‬ ،‫ﺣﺬﻓﻲ‬ ‫روش‬ ‫ﺑﻜﺎرﮔﻴﺮي‬ ‫از‬ ‫ﻗﺒﻞ‬ ‫دوم‬ ‫ﺳﺘﻮن‬ ‫ﺑﺮاي‬2‫ﺗﺎ‬n‫ﺳﺘﻮن‬ ‫در‬2‫ﻋﻤﻞ‬ ،‫ﺷﺪه‬ ‫ﻧﺮﻣﺎﻟﻴﺰه‬pivotingً‫ﺎ‬‫ﻣﺘﻌﺎﻗﺒ‬ ‫و‬ ‫اﻧﺠﺎم‬ ‫ﺷﻮد‬ ‫ﻣﻲ‬ ‫اﺳﺘﻔﺎده‬ ‫ﺣﺬﻓﻲ‬ ‫روش‬ ‫از‬. ‫ﻋﺪدي‬ ‫ﻣﺤﺎﺳﺒﺎت‬ ‫ﻛﻤﻚ‬ ‫ﺑﻪ‬MATLAB faradars.org/fvmth102 ‫س‬‫ر‬‫د‬‫ا‬‫ﺮ‬‫ﻓ‬ FaraDars.org
  25. 25. ‫ﺳﺎزي‬ ‫ﻣﺘﻨﺎﺳﺐ‬ ‫ﺑﺎ‬ ‫ﮔﻮس‬ ‫ﺣﺬف‬ ‫روش‬‫و‬pivoting 25 -‫ﺑﺎ‬ ‫ﻫﻤﺮاه‬ ‫ﺣﺬﻓﻲ‬ ‫روش‬ ‫ﺑﺮاي‬ ‫ﻣﺜﺎل‬Scaling: ‫اول‬ ‫ﺳﺘﻮن‬ ‫ﻛﺮدن‬ ‫ﻧﺮﻣﺎﻟﻴﺰه‬: ‫ﺳﻄﺮ‬ ‫ﺟﺎﺑﺠﺎﻳﻲ‬1‫ﺑﺎ‬3)Pivoting( ‫دوم‬ ‫ﺳﺘﻮن‬ ‫ﻛﺮدن‬ ‫ﻧﺮﻣﺎﻟﻴﺰه‬: ‫ﺣﺬف‬ ‫اﻋﻤﺎل‬:            3311 9810332 10410523 ]|[ bA                       333.0 0194.0 0286.0 3/1 103/2 105/3 1a            10410523 9810332 3311 13 12 )1/3( )1/2( RR RR               959610 929750 3311                             0104.0 0516.0 96/1 97/52a             959610 929750 3311 23 )5/1( RR             6.766.760.00.0 0.920.970.50.0 0.30.30.10.1            10410523 9810332 3311 ‫س‬‫ر‬‫د‬‫ا‬‫ﺮ‬‫ﻓ‬ FaraDars.org
  26. 26. ‫ﺑﺮﻧﺎﻣﻪ‬Matlab‫روش‬pivoting gauss elimination function gaussel(A,b) % Solve the system Ax=b using naive Gaussian elimination n=length(b); x=zeros(n,1); fprintf('n'); disp(' The augmented matrix is =') augm =[A b] for i=1:n d(i)=i; smax=0; for j=1:n smax=max(smax,abs(A(i,j))); end c(i)=smax; end for k=1:n-1 rmax=0; for i=k:n R=abs(A(d(i),k))/c(d(i)); if (R>rmax) 26 j=I; rmax=R; end end dk=d(j); d(j)=d(k); d(k)=dk; for i=k+1:n m=A(d(i),k)/A(dk,k); for j=k+1:n A(d(i),j)=A(d(i),j)-m*A(dk,j); end A(d(i),k)=m; end end % Perform the back substitution. for k=1:n-1 for i=k+1:n b(d(i))=b(d(i))-b(d(k))*A(d(i),k); end end x(n)=b(d(n))/A(d(n),n); for i=n-1:-1:1 S=b(d(i)); for j=i+1:n S=S-A(d(i),j)*x(j); end x(i)=S/A(d(i),i); end % Print the results disp('The scale vector =‘) c disp('The index vector at the end of the elimination process is =') d fprintf('n'); disp(' The transformed upper triangular augmented matrix C is =') fprintf('n'); for i=1:n M(i,:)=A(d(i),:); end for i=1:n for j=1:n if (j<i) M(i,j)=0; end end end C=[M b] fprintf('n'); disp(' Back substitution gives the vector solution') x ‫ﻋﺪدي‬ ‫ﻣﺤﺎﺳﺒﺎت‬ ‫ﻛﻤﻚ‬ ‫ﺑﻪ‬MATLAB faradars.org/fvmth102 ‫س‬‫ر‬‫د‬‫ا‬‫ﺮ‬‫ﻓ‬ FaraDars.org
  27. 27. ‫ي‬ ‫ﺗﺠﺰﻳﻪ‬ ‫روش‬LU 27 ‫روش‬‫ﺗﺠﺰﻳﻪ‬‫ي‬LU،‫ﺷﺎﻣﻞ‬‫ﺗﺒﺪﻳﻞ‬‫ﻣﺎﺗﺮﻳﺲ‬‫ﺿﺮاﻳﺐ‬‫ﺑﻪ‬‫ﺣﺎﺻﻞ‬‫ﺿﺮب‬‫دو‬‫ﻣﺎﺗﺮﻳﺲ‬L‫و‬U‫ﻣﻲ‬‫ﺑﺎﺷﺪ‬‫ﻛﻪ‬‫در‬‫اﻳﻨﺠﺎ‬L،‫ﻳﻚ‬ ‫ﻣﺎﺗﺮﻳﺲ‬‫ﭘﺎﻳﻴﻦ‬‫ﻣﺜﻠﺜﻲ‬‫و‬U،‫ﻳﻚ‬‫ﻣﺎﺗﺮﻳﺲ‬‫ﺑﺎﻻ‬‫ﻣﺜﻠﺜﻲ‬‫ﺑﺎ‬‫درآﻳﻪ‬‫ﻫﺎي‬‫واﺣﺪ‬‫در‬‫ﻃﻮل‬‫ﻗﻄﺮ‬‫اﺻﻠﻲ‬‫ﺧﻮد‬‫ﻣﻲ‬‫ﺑﺎﺷﻨﺪ‬.‫زﻣﺎﻧﻲ‬‫ﻛﻪ‬ ‫ﻣﺎﺗﺮﻳﺲ‬‫ﻫﺎي‬L‫و‬U‫ﭘﻴﺪا‬،‫ﺷﻮﻧﺪ‬‫آﻧﮕﺎه‬‫ﺣﻞ‬‫دﺳﺘﮕﺎه‬‫ﻣﻲ‬‫ﺗﻮاﻧﺪ‬‫ﺑﻪ‬‫ﻃﺮﻳﻖ‬‫زﻳﺮ‬‫اﻧﺠﺎم‬‫ﺷﻮد‬: Ax b LUx b Ux y Ly bAx b ‫ﻋﺪدي‬ ‫ﻣﺤﺎﺳﺒﺎت‬ ‫ﻛﻤﻚ‬ ‫ﺑﻪ‬MATLAB faradars.org/fvmth102 ‫س‬‫ر‬‫د‬‫ا‬‫ﺮ‬‫ﻓ‬ FaraDars.org
  28. 28. ‫ﻣﺜﻠﺜﻲ‬ ‫ﭘﺎﻳﻴﻦ‬ ‫و‬ ‫ﺑﺎﻻ‬ ‫ﻣﺎﺗﺮﻳﺲ‬ ‫ﻳﺎﻓﺘﻦ‬ ‫ﻫﺎي‬ ‫روش‬ ‫اﻧﻮاع‬L‫و‬U 28 1(‫روش‬‫ﻫﺎي‬Choleski‫و‬Crout‫و‬2(‫روش‬‫ﺣﺬف‬‫ﮔﻮس‬ *‫در‬‫اﻳﻨﺠﺎ‬‫ﺗﻨﻬﺎ‬‫ﺑﻪ‬‫روش‬‫اول‬‫ﭘﺮداﺧﺘﻪ‬‫ﻣﻲ‬‫ﺷﻮد‬. *‫ﻣﺎﺗﺮﻳﺲ‬L‫را‬‫ﺑﺎ‬‫ﻋﻨﺎﺻﺮ‬‫ﻏﻴﺮ‬‫ﺻﻔﺮ‬‫در‬‫ﻃﻮل‬‫ﻗﻄﺮ‬‫اﺻﻠﻲ‬‫آن‬‫ﺑﺪﺳﺖ‬‫ﻣﻲ‬‫آورﻳﻢ‬‫و‬‫در‬‫ﺿﻤﻦ‬‫ﻣﺎﺗﺮﻳﺲ‬U‫را‬‫ﺑﻪ‬‫ﮔﻮﻧﻪ‬‫اي‬‫ﺑﺪﺳﺖ‬ ‫ﻣﻲ‬‫آورﻳﻢ‬‫ﻛﻪ‬‫ﺗﺴﺎوي‬‫ﻣﺎﺗﺮﻳﺴﻲ‬‫زﻳﺮ‬‫ﺑﺮﻗﺮار‬‫ﺑﺎﺷﺪ‬)‫اﻟﺒﺘﻪ‬‫ﺑﺮاي‬‫ﻳﻚ‬‫ﻣﺎﺗﺮﻳﺲ‬4x4‫ﻧﻤﻮﻧﻪ‬(: *‫ﺑﺮاي‬‫ﻣﺤﺎﺳﺒﻪ‬‫ﻣﺎﺗﺮﻳﺲ‬‫ﭘﺎﻳﻴﻦ‬‫ﻣﺜﻠﺜﻲ‬L،‫از‬‫روش‬‫ﺣﺬف‬‫ﮔﻮس‬‫ﺳﺎده‬‫اﺳﺘﻔﺎده‬‫ﻣﻲ‬‫ﻛﻨﻴﻢ‬‫اﻟﺒﺘﻪ‬‫در‬‫راﺳﺘﺎي‬‫ﺳﺘﻮن‬‫ﻫﺎ‬‫و‬‫ﺑﺮاي‬ ‫ﻣﺤﺎﺳﺒﻪ‬‫ﻋﻨﺎﺻﺮ‬‫ﻣﺎﺗﺮﻳﺲ‬‫ﺑﺎﻻ‬‫ﻣﺜﻠﺜﻲ‬U‫از‬‫ﻣﻌﺎدﻟﻪ‬‫و‬‫ﺗﺴﺎوي‬‫ﻓﻮق‬‫اﺳﺘﻔﺎده‬‫ﻣﻲ‬‫ﺷﻮد‬. 11 11 12 13 1412 13 14 21 22 21 22 23 2423 24 31 32 33 31 32 33 3434 41 42 43 44 41 42 43 44 0 0 0 1 0 0 0 1 0 0 0 1 0 0 0 1 l a a a au u u l l a a a au u l l l a a a au l l l l a a a a                                ‫ﻋﺪدي‬ ‫ﻣﺤﺎﺳﺒﺎت‬ ‫ﻛﻤﻚ‬ ‫ﺑﻪ‬MATLAB faradars.org/fvmth102 ‫س‬‫ر‬‫د‬‫ا‬‫ﺮ‬‫ﻓ‬ FaraDars.org
  29. 29. ‫ﺑﺮﻳﺪ‬ ‫ﺑﻜﺎر‬ ‫زﻳﺮ‬ ‫دﺳﺘﮕﺎه‬ ‫ﺣﻞ‬ ‫ﺑﺮاي‬ ‫را‬ ‫ﻛﺮوت‬ ‫روش‬ ‫ﻣﺜﺎل‬: ‫ﻣﺴﺘﻘﻴﻢ‬ ‫ﻓﺎﻛﺘﻮرﮔﻴﺮي‬ ‫ﻳﻚ‬ ، ‫ﻣﺎﺗﺮﻳﺲ‬ ‫اﮔﺮ‬LU‫آﻧﮕﺎه‬ ،‫ﺑﺎﺷﺪ‬ ‫داﺷﺘﻪ‬: ‫ﺑﻮﺳﻴﻠﻪ‬‫ي‬‫ﺿﺮب‬‫ﻛﺮدن‬L‫در‬U،‫و‬‫ﻣﻘﺎﻳﺴﻪ‬‫ي‬‫در‬‫آﻳﻪ‬‫ﻫﺎي‬‫ﻣﺎﺗﺮﻳﺲ‬‫ﻫﺎي‬‫ﺣﺎﺻﻞ‬‫ﺿﺮب‬‫ﺑﺎ‬‫درآﻳﻪ‬‫ﻫﺎي‬‫ﻣﺎﺗﺮﻳﺲ‬A،‫ﺑﺪﺳﺖ‬ ‫ﻣﻲ‬‫آورﻳﻢ‬: )i(‫از‬‫ﺿﺮب‬‫اوﻟﻴﻦ‬‫ﺳﻄﺮ‬‫از‬‫ﻣﺎﺗﺮﻳﺲ‬L،‫در‬‫ﺳﺘﻮن‬‫ﻫﺎي‬‫ﻣﺎﺗﺮﻳﺲ‬U‫،ﺑﺪﺳﺖ‬‫ﻣﻲ‬‫آورﻳﻢ‬‫ﻛﻪ‬: ‫از‬ ‫ﻣﺜﺎﻟﻲ‬‫ﺗﺠﺰﻳﻪ‬ ‫روش‬LU 29 1 2 3 4 1 1 1 1 10 2 3 1 5 31 1 1 5 3 2 3 1 7 2 18 x x x x                                 11 12 13 14 21 22 23 24 31 32 33 34 41 42 43 44 0 0 01 1 1 1 1 0 02 3 1 5 0 1 01 1 5 3 0 0 1 3 1 7 2 0 0 0 1 l u u u l l u u A l l l u l l l l                                 ‫ﻋﺪدي‬ ‫ﻣﺤﺎﺳﺒﺎت‬ ‫ﻛﻤﻚ‬ ‫ﺑﻪ‬MATLAB faradars.org/fvmth102 ‫س‬‫ر‬‫د‬‫ا‬‫ﺮ‬‫ﻓ‬ FaraDars.org
  30. 30. ‫ﺗﺠﺰﻳﻪ‬ ‫روش‬ ‫از‬ ‫ﻣﺜﺎﻟﻲ‬ ‫اداﻣﻪ‬LU 30 (i)‫از‬‫ﺿﺮب‬‫اوﻟﻴﻦ‬‫ﺳﻄﺮ‬‫از‬‫ﻣﺎﺗﺮﻳﺲ‬L،‫در‬‫ﺳﺘﻮن‬‫ﻫﺎي‬‫ﻣﺎﺗﺮﻳﺲ‬U،‫ﺑﺪﺳﺖ‬‫ﻣﻲ‬‫آورﻳﻢ‬‫ﻛﻪ‬: (ii)‫از‬‫ﺿﺮب‬‫دوﻣﻴﻦ‬‫ﺳﻄﺮ‬‫از‬‫ﻣﺎﺗﺮﻳﺲ‬L،‫در‬‫ﺳﺘﻮن‬‫ﻫﺎي‬‫ﻣﺎﺗﺮﻳﺲ‬U،‫دارﻳﻢ‬: (iii)‫از‬‫ﺿﺮب‬‫ﺳﻮﻣﻴﻦ‬‫ﺳﻄﺮ‬‫از‬‫ﻣﺎﺗﺮﻳﺲ‬L،‫در‬‫ﺳﺘﻮن‬‫ﻫﺎي‬‫ﻣﺎﺗﺮﻳﺲ‬U،‫دارﻳﻢ‬: 11 11 12 12 11 13 13 11 14 14 1, 1 1, 1 1, 1 1. l l u u l u u l u u           21 21 12 22 22 21 12 21 13 22 23 23 21 13 22 21 14 22 24 24 21 14 22 2, 3 3 1, 1 (1 ) / 1, 5 (5 )/ 3. l l u l l l u l u l u u l u l l u l u u l u l                     31 31 12 32 32 31 12 31 13 32 23 33 33 31 13 32 23 31 14 32 24 33 34 34 31 14 32 24 33 1, 1 1 2, 5 5 2, 3 (3 )/ 1 l l u l l l u l u l u l l l u l u l u l u l u u l u l u l                            ‫ﻋﺪدي‬ ‫ﻣﺤﺎﺳﺒﺎت‬ ‫ﻛﻤﻚ‬ ‫ﺑﻪ‬MATLAB faradars.org/fvmth102 ‫س‬‫ر‬‫د‬‫ا‬‫ﺮ‬‫ﻓ‬ FaraDars.org
  31. 31. ‫ﺗﺠﺰﻳﻪ‬ ‫روش‬ ‫از‬ ‫ﻣﺜﺎﻟﻲ‬ ‫اداﻣﻪ‬LU 31 (iv)‫از‬‫ﺿﺮب‬‫ﭼﻬﺎرﻣﻴﻦ‬‫ﺳﻄﺮ‬‫از‬‫ﻣﺎﺗﺮﻳﺲ‬L،‫در‬‫ﺳﺘﻮن‬‫ﻫﺎي‬‫ﻣﺎﺗﺮﻳﺲ‬U،‫دارﻳﻢ‬: ‫ﺑﻨﺎﺑﺮاﻳﻦ‬‫ﻣﺎﺗﺮﻳﺲ‬‫ﻫﺎي‬L‫و‬U‫ﺑﺮاﺑﺮﻧﺪ‬‫ﺑﺎ‬: ‫و‬ ‫ﺑﺎ‬‫اﻋﻤﺎل‬‫ﺟﺎﻳﮕﺬاري‬‫ﭘﻴﺸﺮوﻧﺪه‬‫در‬‫دﺳﺘﮕﺎه‬‫ﭘﺎﻳﻴﻦ‬‫ﻣﺜﻠﺜﻲ‬Ly=b،‫ﻧﺘﺎﻳﺞ‬‫زﻳﺮ‬‫را‬‫ﺑﺪﺳﺖ‬‫ﻣﻲ‬‫آورﻳﻢ‬: 1 2 3 4 10, 31 2(10) 11, [ 2 10 2(11)]/( 2) 7, [18 3(10) 2(11) 2(7)] 4 y y y y                 1 1 1 1 0 1 1 3 U= 0 0 1 1 0 0 0 1            1 0 0 0 2 1 0 0 L= 1 2 2 0 3 2 2 1               122 ,277 3443244214414444344324421441 23421341434323421341   ulululllululul ululllulul 41 41 12 42 42 41 12 3, 1 1 2, l l u l l l u         ‫ﻋﺪدي‬ ‫ﻣﺤﺎﺳﺒﺎت‬ ‫ﻛﻤﻚ‬ ‫ﺑﻪ‬MATLAB faradars.org/fvmth102 ‫س‬‫ر‬‫د‬‫ا‬‫ﺮ‬‫ﻓ‬ FaraDars.org
  32. 32. ‫ﺗﺠﺰﻳﻪ‬ ‫روش‬ ‫از‬ ‫ﻣﺜﺎﻟﻲ‬ ‫اداﻣﻪ‬LU 32 ‫در‬،‫ﻧﻬﺎﻳﺖ‬‫ﺑﺎ‬‫ﺟﺎﻳﮕﺬاري‬‫ﭘﺴﺮو‬‫در‬‫دﺳﺘﮕﺎه‬‫ﺑﺎﻻ‬‫ﻣﺜﻠﺜﻲ‬Ux=y،‫ﻣﻘﺎدﻳﺮ‬‫زﻳﺮ‬‫را‬‫ﺑﺮاي‬x‫ﻫﺎ‬‫ﺑﺪﺳﺖ‬‫ﻣﻲ‬‫آورﻳﻢ‬: 1 2 3 4 10 4 3 2 1, [11 4 3(3)] 2, 7 4 3, 4 x x x x               ‫ﻋﺪدي‬ ‫ﻣﺤﺎﺳﺒﺎت‬ ‫ﻛﻤﻚ‬ ‫ﺑﻪ‬MATLAB faradars.org/fvmth102 ‫س‬‫ر‬‫د‬‫ا‬‫ﺮ‬‫ﻓ‬ FaraDars.org
  33. 33. ‫ﺑﺮﻧﺎﻣﻪ‬Matlab‫ﺗﺠﺰﻳﻪ‬ ‫روش‬LU function lufact(A,b) % Solve the system Ax=b using the LU decomposition. n=length(b); y=zeros(n,1); x=zeros(n,1); fprintf('n'); for i=1:n U(i,i)=1; end L(1,1)=A(1,1)/U(1,1); for j=2:n L(j,1)=A(j,1)/U(1,1); U(1,j)=A(1,j)/L(1,1); end for i=2:n-1 S=0; for k=1:i-1 S=S+U(k,i)*L(i,k); end L(i,i)=(A(i,i)-S)/U(i,i); 33 for j=i+1:n S=0; for k=1:i-1 S=S+U(k,i)*L(j,k); end L(j,i)=(A(j,i)-S)/U(i,i); S=0; for k=1:i-1 S=S+U(k,j)*L(i,k); end U(i,j)=(A(i,j)-S)/L(i,i); end end S=0; for k=1:n-1 S=S+U(k,n)*L(n,k); end L(n,n)=(A(n,n)-S)/U(n,n); % Perform the forward substitution. y(1)=b(1)/L(1,1); for i=2:n S=b(i); for j=1:i-1 S=S-L(i,j)*y(j); end y(i)=S/L(i,i); end % Perform the back substitution. x(n)=y(n)/U(n,n); for i=n-1:-1:1 S=y(i); for j=i+1:n S=S-U(i,j)*x(j); end x(i)=S/U(i,i); end % Print the results L disp(' The forward substitution gives') y U disp('The vector solution is =') X ‫س‬‫ر‬‫د‬‫ا‬‫ﺮ‬‫ﻓ‬ FaraDars.org
  34. 34. ‫رﻫﻴﺎﻓﺖ‬‫ﻫﺎي‬‫ﻏﻴﺮ‬‫ﻳﺎ‬ ‫ﻣﺴﺘﻘﻴﻢ‬ ‫ﺗﻜﺮاري‬ )Iterative Methods( 34 ‫ﻋﺪدي‬ ‫ﻣﺤﺎﺳﺒﺎت‬ ‫ﻛﻤﻚ‬ ‫ﺑﻪ‬MATLAB faradars.org/fvmth102 ‫س‬‫ر‬‫د‬‫ا‬‫ﺮ‬‫ﻓ‬ FaraDars.org
  35. 35. ‫ﺗﻜﺮاري‬ ‫ﻫﺎي‬ ‫روش‬ ‫ﻣﻬﻢ‬ ‫ﻧﻜﺎت‬ 35 1(‫ﺑﺨﺎﻃﺮ‬‫وﺟﻮد‬‫ﺧﻄﺎﻫﺎي‬‫ﺣﺎﺻﻞ‬‫از‬‫ﮔﺮد‬،‫ﻛﺮدن‬‫روش‬‫ﻫﺎي‬‫ﻣﺴﺘﻘﻴﻢ‬‫ﻣﺤﺎﺳﺒﻪ‬‫ي‬‫دﺳﺘﮕﺎه‬،‫ﻫﺎ‬‫از‬‫ﻛﺎرآﻳﻲ‬‫و‬‫ﺑﺎزده‬‫ﻛﻤﺘﺮي‬‫ﻧﺴﺒ‬‫ﺖ‬‫ﺑﻪ‬ ‫روش‬‫ﻫﺎي‬‫ﺗﻜﺮار‬‫ﻣﺘﻮاﻟﻲ‬‫ﺑﺮﺧﻮردارﻧﺪ‬. 2(‫ﻋﻼوه‬‫ﺑﺮ‬‫ﺧﻄﺎﻫﺎي‬‫ﺣﺎﺻﻞ‬‫از‬‫ﮔﺮد‬،‫ﻛﺮدن‬‫ﻣﻘﺪار‬‫ﻓﻀﺎي‬‫ذﺧﻴﺮه‬‫ﺳﺎزي‬‫ﻣﻮرد‬‫ﻧﻴﺎز‬‫ﺑﺮاي‬‫ﺣﻞ‬‫ﻣﻌﺎدﻻت‬‫ﺑﻪ‬‫روش‬‫ﻫﺎي‬‫ﺗﻜﺮار‬‫ﻣﺘﻮاﻟ‬‫ﻲ‬ ‫ﺑﺴﻴﺎر‬‫ﻛﻤﺘﺮ‬‫از‬‫ﻣﻘﺪار‬‫ﻣﻮرد‬‫ﻧﻴﺎز‬‫در‬‫روش‬‫ﻫﺎي‬‫ﻣﺴﺘﻘﻴﻢ‬‫ﻣﻲ‬،‫ﺑﺎﺷﺪ‬‫ﺑﺨﺼﻮص‬‫زﻣﺎﻧﻲ‬‫ﻛﻪ‬‫ﻣﺎﺗﺮﻳﺲ‬‫ﺿﺮاﻳﺐ‬‫ﻣﺘﻔﺮق‬‫و‬‫ﭘﺮاﻛ‬‫ﻨﺪه‬،‫اﺳﺖ‬ ‫ﻳﻌﻨﻲ‬‫آراﻳﻪ‬‫ﻫﺎ‬‫و‬‫ﻣﺎﺗﺮﻳﺲ‬‫ﻫﺎ‬‫ﺷﺎﻣﻞ‬‫ﺗﻌﺪاد‬‫زﻳﺎدي‬‫درآﻳﻪ‬‫ﻫﺎي‬‫ﺻﻔﺮ‬‫ﻣﻲ‬‫ﺑﺎﺷﻨﺪ‬)Sparse(. 3(‫ﺷﺮاﻳﻂ‬‫وﺟﻮد‬‫ﺟﻮاب‬‫و‬‫ﻳﺎ‬‫ﻫﻤﮕﺮاﻳﻲ‬‫ﭘﺎﺳﺦ‬‫ﻫﺎ‬‫در‬‫روش‬‫ﻫﺎي‬‫ﺗﻜﺮاري‬‫ﺣﻞ‬‫دﺳﺘﮕﺎه‬‫ﻫﺎي‬‫ﻣﻌﺎدﻻت‬‫ﺧﻄﻲ‬‫ﻋﺒﺎرﺗﻨﺪ‬‫از‬: )‫اﻟﻒ‬(‫ﻣﺎﺗﺮﻳﺲ‬‫ﺿﺮاﻳﺐ‬ً‫ﺎ‬‫ﺣﺘﻤ‬‫ﺑﺎﻳﺪ‬‫ﻳﺎ‬positive definite‫و‬‫ﻳﺎ‬diagonally dominant‫ﺑﺎﺷﺪ‬)‫ﺷﺮاﻳﻂ‬‫ﻻزم‬‫و‬‫ﻛﺎﻓﻲ‬ ‫ﻫﻤﮕﺮاﻳﻲ‬‫روش‬‫ﻫﺎي‬‫ﺗﻜﺮاري‬(. )‫ب‬(‫ﻣﻨﻈﻮر‬‫از‬diagonally dominant‫ﺑﻮدن‬‫آن‬‫اﺳﺖ‬‫ﻛﻪ‬:     n ij j ijii aantoifor 1 :1     n ij j ijii aaAofrowaforleastatand 1 : ‫ﻋﺪدي‬ ‫ﻣﺤﺎﺳﺒﺎت‬ ‫ﻛﻤﻚ‬ ‫ﺑﻪ‬MATLAB faradars.org/fvmth102 ‫س‬‫ر‬‫د‬‫ا‬‫ﺮ‬‫ﻓ‬ FaraDars.org
  36. 36. ‫از‬ ‫ﻣﺜﺎﻟﻲ‬diagonally dominant‫ﺑﻮدن‬ 36 ‫ﺑﺎ‬‫ﺗﻮﺟﻪ‬‫ﺑﻪ‬‫ﺷﺮاﻳﻂ‬‫ذﻛﺮ‬،‫ﺷﺪه‬‫ﻛﺪام‬‫ﻳﻚ‬‫از‬‫ﻣﺎﺗﺮﻳﺲ‬‫ﺿﺮاﻳﺐ‬‫زﻳﺮ‬‫ﺑﻪ‬‫ﻃﻮر‬،‫ﻗﻄﺮي‬‫ﻏﺎﻟﺐ‬‫ﻫﺴﺘﻨﺪ؟‬  A               3481.52 14335 116123 1293496 55323 5634124 ][             B |81.5||2||34| |1||35||43| |1||16||123|    *‫ﻃﺒﻖ‬‫ﺷﺮاﻳﻂ‬‫ذﻛﺮ‬،‫ﺷﺪه‬‫ﻣﺎﺗﺮﻳﺲ‬A،diagonally dominant‫ﻫﺴﺖ‬‫زﻳﺮا‬‫ﻫﻢ‬‫ﻗﺪر‬‫ﻣﻄﻠﻖ‬ ‫ﺿﺮاﻳﺐ‬‫روي‬‫ﻗﻄﺮ‬‫اﺻﻠﻲ‬‫از‬‫ﻣﺠﻤﻮع‬‫ﺳﺎﻳﺮ‬‫ﺿﺮاﻳﺐ‬‫ﻫﺮ‬‫ﺳﻄﺮ‬‫ﺑﺰرﮔﺘﺮ‬‫ﻣﺴﺎوي‬‫ﻫﺴﺘﻨﺪ‬.‫ﻫﻤﭽﻨ‬‫ﻴﻦ‬ ‫ﺣﺪاﻗﻞ‬‫ﻳﻜﻲ‬‫از‬‫دراﻳﻪ‬‫ﻫﺎي‬‫روي‬‫ﻗﻄﺮ‬‫اﺻﻠﻲ‬‫ﺑﺰرﮔﺘﺮ‬‫از‬‫ﻣﺠﻤﻮع‬‫دراﻳﻪ‬‫ﻫﺎي‬‫ﻫﻤﺎن‬‫ﺳﻄﺮ‬‫اﺳﺖ‬. *‫ﻃﺒﻖ‬‫ﺷﺮاﻳﻂ‬‫ذﻛﺮ‬،‫ﺷﺪه‬‫ﻣﺎﺗﺮﻳﺲ‬B،diagonally dominant‫ﻧﻴﺴﺖ‬‫زﻳﺮا‬‫ﻗﺪر‬ ‫ﻣﻄﻠﻖ‬‫ﺿﺮﻳﺐ‬‫روي‬‫ﻗﻄﺮ‬‫اﺻﻠﻲ‬‫ﺳﻄﺮ‬‫ﺳﻮم‬‫از‬‫ﻣﺠﻤﻮع‬‫ﺳﺎﻳﺮ‬‫ﺿﺮاﻳﺐ‬‫ﻫﻤﺎن‬‫ﺳﻄﺮ‬ ‫ﻛﻮﭼﻜﺘﺮ‬‫اﺳﺖ‬.|34||96||129| |5||23||53| |56||34||124|    ‫ﻋﺪدي‬ ‫ﻣﺤﺎﺳﺒﺎت‬ ‫ﻛﻤﻚ‬ ‫ﺑﻪ‬MATLAB faradars.org/fvmth102 ‫س‬‫ر‬‫د‬‫ا‬‫ﺮ‬‫ﻓ‬ FaraDars.org
  37. 37. ‫ﻣﺘﻮاﻟﻲ‬ ‫ﺗﻜﺮار‬ ‫ﻫﺎي‬ ‫روش‬ ‫ﻛﻠﻲ‬ ‫ﻓﺮم‬ )Iterative Methods( •‫اول‬ ‫ﮔﺎم‬:‫روﺑﺮو‬ ‫ﻓﺮم‬ ‫ﺑﻪ‬ ‫ﺧﻄﻲ‬ ‫ﻣﻌﺎدﻻت‬ ‫دﺳﺘﮕﺎه‬ ‫ﻓﺮم‬ ‫ﺗﻐﻴﻴﺮ‬ •‫دوم‬ ‫ﮔﺎم‬:‫اوﻟﻴﻪ‬ ‫ﺣﺪس‬ ‫ﻳﻚ‬ ‫اﻧﺘﺨﺎب‬ –‫ﺳﻮم‬ ‫ﮔﺎم‬:‫زﻳﺮ‬ ‫ﻓﺮﻣﻮل‬ ‫ﻃﺮﻳﻖ‬ ‫از‬ ‫ﺗﻘﺮﻳﺒﻲ‬ ‫ﭘﺎﺳﺦ‬ ‫ﺑﺮدارﻫﺎي‬ ‫ﻣﺎﺗﺮﻳﺲ‬ ‫ي‬ ‫دﻧﺒﺎﻟﻪ‬ ‫ﻣﺤﺎﺳﺒﻪ‬ 37 ' x b Bx  (0) x ( ) ' ( 1)k k x b Bx    k=1,2,3,…‫ازاي‬ ‫ﺑﻪ‬ bAx  ‫ﻋﺪدي‬ ‫ﻣﺤﺎﺳﺒﺎت‬ ‫ﻛﻤﻚ‬ ‫ﺑﻪ‬MATLAB faradars.org/fvmth102 ‫س‬‫ر‬‫د‬‫ا‬‫ﺮ‬‫ﻓ‬ FaraDars.org
  38. 38. ‫ژاﻛﻮﺑﻲ‬ ‫روش‬ )Jacobi Iterative Method( •‫زﻳﺮ‬ ‫ﻓﺮم‬ ‫ﺑﻪ‬ ‫ﺧﻄﻲ‬ ‫ﻣﻌﺎدﻻت‬ ‫دﺳﺘﮕﺎه‬ ‫ﻓﺮم‬ ‫ﺗﻐﻴﻴﺮ‬ ‫ﺑﺎ‬ ‫ﻣﺘﻐﻴﺮﻫﺎ‬ ‫از‬ ‫ﻳﻚ‬ ‫ﻫﺮ‬ ‫ﻣﺤﺎﺳﺒﻪ‬ •‫زﻳﺮ‬ ‫ﻓﺮﻣﻮل‬ ‫ﺑﺎ‬ ‫ﺑﺮاي‬ ‫آوردن‬ ‫ﺑﺪﺳﺖ‬ •‫زﻳﺮ‬ ‫ﺷﺮاﻳﻂ‬ ‫ﺷﺪن‬ ‫ﺑﺮآورده‬ ‫ﺗﺎ‬ ‫ﻗﺒﻞ‬ ‫ﻣﺮاﺣﻞ‬ ‫ﺗﻜﺮار‬: 38 1 ( ) , 1,2, , n ij j i i j ii ii j i a x b x i n a a       ( )k ix1k  ],...,[ || )()( 1 )( )( )1()( k n kk k kk k xxxwhere x xx e      ni a bxa x ii i n ij j k jij k i ,...,2,1, 1 )1( )(        ‫ﻋﺪدي‬ ‫ﻣﺤﺎﺳﺒﺎت‬ ‫ﻛﻤﻚ‬ ‫ﺑﻪ‬MATLAB faradars.org/fvmth102 ‫س‬‫ر‬‫د‬‫ا‬‫ﺮ‬‫ﻓ‬ FaraDars.org
  39. 39. ‫ﻣﺜﺎل‬:‫ﻛﻨﻴﺪ‬ ‫ﺣﻞ‬ ‫ژاﻛﻮﺑﻲ‬ ‫ﻣﺘﻮاﻟﻲ‬ ‫ﺗﻜﺮار‬ ‫روش‬ ‫از‬ ‫اﺳﺘﻔﺎده‬ ‫ﺑﺎ‬ ‫زﻳﺮ‬ ‫ﻣﻌﺎدﻻت‬ ‫دﺳﺘﮕﺎه‬.‫ﺑ‬ ‫ﻣﺎﺗﺮﻳﺲ‬ ‫ﻋﻨﻮان‬ ‫ﺑﻪ‬ ‫را‬ ‫زﻳﺮ‬ ‫ﻣﻘﺎدﻳﺮ‬‫آﻏﺎزﻳﻦ‬ ‫ﺮدار‬ ‫ﺑﮕﻴﺮﻳﺪ‬ ‫ﻧﻈﺮ‬ ‫در‬:0=)0(x,30=ITMAX,3-10=EPS ‫ﻛﻨﻴﻢ‬ ‫ﻣﺮﺗﺐ‬ ‫و‬ ‫ﺑﺎزﻧﻮﻳﺴﻲ‬ ‫زﻳﺮ‬ ‫ﺻﻮرت‬ ‫ﺑﻪ‬ ‫ﺗﻮان‬ ‫ﻣﻲ‬ ‫را‬ ‫اﺧﻴﺮ‬ ‫ﻣﻌﺎدﻻت‬: ‫آﻳﺪ‬ ‫ﻣﻲ‬ ‫در‬ ‫زﻳﺮ‬ ‫ﺷﻜﻞ‬ ‫ﺑﻪ‬ ‫ژاﻛﻮﺑﻲ‬ ‫ﻣﺘﻮاﻟﻲ‬ ‫ﺗﻜﺮار‬ ‫ﻋﻤﻠﻴﺎت‬ ‫ﻓﺮم‬ ‫ﺗﺮﺗﻴﺐ‬ ‫ﺑﻪ‬ ‫ﻛﻪ‬: ‫ژاﻛﻮﺑﻲ‬ ‫روش‬ ‫ﺑﻪ‬ ‫ﺧﻄﻲ‬ ‫ﻣﻌﺎدﻻت‬ ‫دﺳﺘﮕﺎه‬ ‫ﺣﻞ‬ ‫ﻣﺜﺎل‬ 39 ‫ﻋﺪدي‬ ‫ﻣﺤﺎﺳﺒﺎت‬ ‫ﻛﻤﻚ‬ ‫ﺑﻪ‬MATLAB faradars.org/fvmth102 ‫س‬‫ر‬‫د‬‫ا‬‫ﺮ‬‫ﻓ‬ FaraDars.org
  40. 40. x(0)=(0,0,0,0)‫ﻛﻨﻴﺪ‬ ‫ﺟﺎﻳﮕﺰﻳﻦ‬ ،‫زﻳﺮ‬ ‫ﻣﻘﺎدﻳﺮ‬ ‫آوردن‬ ‫ﺑﺪﺳﺖ‬ ‫ﺑﺮاي‬ ،‫ﻗﺒﻞ‬ ‫ﻣﻌﺎدﻻت‬ ‫از‬ ‫ﻳﻚ‬ ‫ﻫﺮ‬ ‫راﺳﺖ‬ ‫ﺳﻤﺖ‬ ‫در‬ ‫را‬: ‫ﻛﻪ‬ ‫اﺳﺖ‬ ‫ﺗﺮﺗﻴﺐ‬ ‫ﺑﺪﻳﻦ‬ ‫و‬T)1.444444444,1.5,1.666666666-,2.428571429)=(1(x‫ﻋﻤﻠﻴﺎت‬ ‫ﻣﺸﺎﺑﻪ‬ ‫ﻋﻤﻠﻴﺎﺗﻲ‬ ‫ﺷﻮد‬ ‫ﻣﻲ‬ ‫ﺑﺎﺷﻨﺪ‬ ‫ﻣﻲ‬ ‫زﻳﺮ‬ ‫ﻣﻘﺎدﻳﺮ‬ ‫ﺑﻪ‬ ‫ﻫﻤﮕﺮا‬ ‫ﻛﻪ‬ ‫دﻫﻨﺪ‬ ‫ﻣﻲ‬ ‫ﺑﺪﺳﺖ‬ ‫را‬ ‫ﻣﻘﺎدﻳﺮ‬ ‫از‬ ‫اي‬ ‫دﻧﺒﺎﻟﻪ‬ ،‫ﻗﺒﻞ‬: ‫ژاﻛﻮﺑﻲ‬ ‫روش‬ ‫ﺑﻪ‬ ‫ﺧﻄﻲ‬ ‫ﻣﻌﺎدﻻت‬ ‫دﺳﺘﮕﺎه‬ ‫ﺣﻞ‬ ‫ﻣﺜﺎل‬ ‫اداﻣﻪ‬ 40 ‫ﻋﺪدي‬ ‫ﻣﺤﺎﺳﺒﺎت‬ ‫ﻛﻤﻚ‬ ‫ﺑﻪ‬MATLAB faradars.org/fvmth102 ‫س‬‫ر‬‫د‬‫ا‬‫ﺮ‬‫ﻓ‬ FaraDars.org
  41. 41. ‫ﺧﻄﻲ‬ ‫ﻣﻌﺎدﻻت‬ ‫دﺳﺘﮕﺎه‬ ‫ﺣﻞ‬ ‫روش‬ ‫ﺑﺮاي‬ ‫دﻳﮕﺮ‬ ‫ﻣﺜﺎل‬ ‫ژاﻛﻮﺑﻲ‬ ‫ﺗﻜﺮاري‬ ‫روش‬ ‫ﺑﻪ‬ •‫اول‬ ‫ﮔﺎم‬:‫ﺿﺮاﻳﺐ‬ ‫ﻣﺎﺗﺮﻳﺲ‬ ‫ﺑﺮاي‬ ‫ﻻزم‬ ‫ﺷﺮاﻳﻂ‬ ‫ﻛﺮدن‬ ‫ﭼﻚ‬)‫ﺑﻮدن‬ ‫ﻣﻌﻴﻦ‬ ‫ﻣﺜﺒﺖ‬ ‫و‬ ‫ﻏﺎﻟﺐ‬( •‫دوم‬ ‫ﮔﺎم‬:‫ﺑﻪ‬ ‫از‬ ‫ﻣﻌﺎدﻟﻪ‬ ‫دادن‬ ‫ﻓﺮﻣﺖ‬ ‫ﺗﻐﻴﻴﺮ‬ •‫ﺳﻮم‬ ‫ﮔﺎم‬:‫ﻧﺘﺎﻳﺞ‬ ‫ﻣﺤﺎﺳﺒﻪ‬ ‫و‬ ‫اوﻟﻴﻪ‬ ‫ﺣﺪس‬ ‫ﻳﻚ‬ ‫از‬ ‫اﺳﺘﻔﺎده‬ •‫ﭼﻬﺎرم‬ ‫ﮔﺎم‬:‫ﻣﻄﻠﻮب‬ ‫دﻗﺖ‬ ‫ﺑﻪ‬ ‫رﺳﻴﺪن‬ ‫ﺗﺎ‬ ‫ژاﻛﻮﺑﻲ‬ ‫روش‬ ‫ﺑﻪ‬ ‫ﻣﺮﺑﻮط‬ ‫ﻣﺤﺎﺳﺒﺎت‬ ‫اﻧﺠﺎم‬ 41                          3 12 14 11 2 1 x x bAx 3x4x 12x-x 21 21 Ax b' x b Bx  1 ( 1) ( ) ( ) , 1,2, , (4 11) n j ij j i j i i ii k k a x b x i n a           ],...,[ || )()( 1 )( )( )1()( k n kk k kk k xxxwhere x xx e      ‫ﻋﺪدي‬ ‫ﻣﺤﺎﺳﺒﺎت‬ ‫ﻛﻤﻚ‬ ‫ﺑﻪ‬MATLAB faradars.org/fvmth102 ‫س‬‫ر‬‫د‬‫ا‬‫ﺮ‬‫ﻓ‬ FaraDars.org
  42. 42. ‫ﺑﺮﻧﺎﻣﻪ‬Matlab‫ژاﻛﻮﺑﻲ‬ ‫روش‬ function jacobi(A,b,x0,tol,itmax) % Solve the system Ax=b using Jacobi iteration method. n=length(b); x=zeros(n,1); fprintf('n'); disp(' The augmented matrix is =') Augm=[A b] Y=zeros(n,1); Y=x0; for k=1:itmax+1 for i=1:n S=0; for j=1:n if (j~=i) S=S+A(i,j)*x0(j); end end if(A(i,i)==0) break end x(i)=(-S+b(i))/A(i,i); end err=abs(norm(x-x0)); 42 rerr=err/(norm(x)+eps); x0=x; Y=[Y x]; if(rerr<tol) break end end % Print the results if(A(i,i)==0) disp(' division by zero') elseif (k==itmax+1) disp(' No convergence') else fprintf('n'); disp(' The solution vectors are:') fprintf('n'); disp('iter # 0 1 2 3 4 ...') fprintf('n'); for i=1:n fprintf('x%1.0f = ',i) fprintf('%10.6f',Y(i,[1:k+1])) fprintf('n'); end fprintf('n'); disp(['The method converges after ',num2str(k),' iterations to']); x end ‫س‬‫ر‬‫د‬‫ا‬‫ﺮ‬‫ﻓ‬ FaraDars.org
  43. 43. ‫ﮔﻮس‬ ‫روش‬-‫ﺳﻴﺪال‬ )Gauss-Seidal Iterative Method( •‫روش‬ ‫دﺳﺘﻮراﻟﻌﻤﻞ‬‫ﮔﻮس‬-‫ﺳﻴﺪال‬‫ﻣﺘﻐ‬ ‫از‬ ‫ﻳﻚ‬ ‫ﻫﺮ‬ ‫ﻣﻘﺪار‬ ‫اﻳﻨﻜﻪ‬ ‫ﺟﺰ‬ ‫ﺑﻪ‬ ‫ﺑﺎﺷﺪ‬ ‫ﻣﻲ‬ ‫ژاﻛﻮﺑﻲ‬ ‫روش‬ ‫ﺑﻪ‬ ‫ﻣﺸﺎﺑﻪ‬ ً‫ﺎ‬‫ﺗﻘﺮﻳﺒ‬ ‫ﻧﻴﺰ‬‫ﺑﺎ‬ ‫ﻴﺮﻫﺎ‬ ‫ﺷﻮد‬ ‫ﻣﻲ‬ ‫ﻣﺤﺎﺳﺒﻪ‬ ، ‫ﻣﺮﺣﻠﻪ‬ ‫ﻫﺮ‬ ‫در‬ ‫ﻣﺘﻐﻴﺮﻫﺎ‬ ‫ﺳﺎﻳﺮ‬ ‫ﺑﺮاي‬ ‫آﻣﺪه‬ ‫ﺑﺪﺳﺖ‬ ‫ﺗﻘﺎرﻳﺐ‬ ‫ﺟﺪﻳﺪﺗﺮﻳﻦ‬ ‫از‬ ‫اﺳﺘﻔﺎده‬. •‫زﻳﺮ‬ ‫ﻓﺮم‬ ‫ﺑﻪ‬ ‫ﺧﻄﻲ‬ ‫ﻣﻌﺎدﻻت‬ ‫دﺳﺘﮕﺎه‬ ‫ﻓﺮم‬ ‫ﺗﻐﻴﻴﺮ‬ ‫ﺑﺎ‬ ‫ﻫﺎ‬ ‫ﻣﺘﻐﻴﺮ‬ ‫از‬ ‫ﻳﻚ‬ ‫ﻫﺮ‬ ‫ﻣﺤﺎﺳﺒﻪ‬ –‫زﻳﺮ‬ ‫ﺷﺮاﻳﻂ‬ ‫ﺷﺪن‬ ‫ﺑﺮآورده‬ ‫ﺗﺎ‬ ‫ﻗﺒﻞ‬ ‫ﻣﺮﺣﻠﻪ‬ ‫ﺗﻜﺮار‬: 43 ],...,[ || )()( 1 )( )( )1()( k n kk k kk k xxxwhere x xx e      111 1k  1 ( ) ( 1) 1 1( ) ( ) ( ) 1,2, , . i nk k ij j ij j ij j ik i ii a x a x b x a i n              ‫ﻋﺪدي‬ ‫ﻣﺤﺎﺳﺒﺎت‬ ‫ﻛﻤﻚ‬ ‫ﺑﻪ‬MATLAB faradars.org/fvmth102 ‫س‬‫ر‬‫د‬‫ا‬‫ﺮ‬‫ﻓ‬ FaraDars.org
  44. 44. ‫ﻣﺜﺎل‬:‫ﮔﻮس‬ ‫ﻣﺘﻮاﻟﻲ‬ ‫ﺗﻜﺮار‬ ‫روش‬ ‫ﺑﻪ‬ ‫را‬ ‫زﻳﺮ‬ ‫ﻣﻌﺎدﻻت‬ ‫دﺳﺘﮕﺎه‬-‫ﻛﻨﻴﺪ‬ ‫ﺣﻞ‬ ‫ﺳﻴﺪال‬.‫آﻏﺎزﻳ‬ ‫ﺑﺮدار‬ ‫ﻫﺎي‬ ‫درآﻳﻪ‬ ‫ﺑﺮاي‬ ‫را‬ ‫زﻳﺮ‬ ‫ﻣﻘﺎدﻳﺮ‬‫ﻧﻈﺮ‬ ‫در‬ ‫ﻦ‬ ‫ﺑﮕﻴﺮﻳﺪ‬:0=)0(x,30=ITMAX,3-10=EPS ‫ﻛﻪ‬ ‫آوردﻳﻢ‬ ‫ﺑﺪﺳﺖ‬ ‫ﻗﺒﻞ‬ ‫ﻣﺜﺎل‬ ‫از‬: ‫ﮔﻮس‬ ‫ﻣﺘﻮاﻟﻲ‬ ‫ﺗﻜﺮار‬ ‫ﻋﻤﻠﻴﺎت‬ ‫ﺟﻤﻼت‬ ،‫ﺑﺎﻻ‬ ‫ﻣﻌﺎدﻻت‬-‫آورﻧﺪ‬ ‫ﻣﻲ‬ ‫ﻓﺮاﻫﻢ‬ ‫را‬ ‫زﻳﺮ‬ ‫ﺳﻴﺪال‬: ‫ﮔﻮس‬ ‫روش‬ ‫ﺑﻪ‬ ‫ﺧﻄﻲ‬ ‫ﻣﻌﺎدﻻت‬ ‫دﺳﺘﮕﺎه‬ ‫ﺣﻞ‬ ‫ﻣﺜﺎل‬-‫ﺳﻴﺪال‬ 44 6/)15( 10/)215( 9/)313( 7/)217( )1( 3 )1( 2 )1( 1 )1( 4 )( 4 )1( 1 )1( 3 )( 4 )( 3 )1( 1 )1( 2 )( 3 )( 2 )1( 1         kkkk kkk kkkk kkk xxxx xxx xxxx xxx ‫ﻋﺪدي‬ ‫ﻣﺤﺎﺳﺒﺎت‬ ‫ﻛﻤﻚ‬ ‫ﺑﻪ‬MATLAB faradars.org/fvmth102 ‫س‬‫ر‬‫د‬‫ا‬‫ﺮ‬‫ﻓ‬ FaraDars.org
  45. 45. ‫ﺑﺮدار‬ ‫ﻣﻘﺎدﻳﺮ‬ ‫ﺣﺎل‬x(0)=(0,0,0,0)‫را‬ ‫زﻳﺮ‬ ‫اﻋﺪاد‬ ‫ﺗﺎ‬ ‫ﻛﻨﻴﻢ‬ ‫ﻣﻲ‬ ‫ﺟﺎﻳﮕﺰﻳﻦ‬ ‫اﺧﻴﺮ‬ ‫ﻣﻌﺎدﻻت‬ ‫از‬ ‫ﻳﻚ‬ ‫ﻫﺮ‬ ‫راﺳﺖ‬ ‫ﺳﻤﺖ‬ ‫در‬ ‫را‬ ‫آورﻳﻢ‬ ‫ﺑﺪﺳﺖ‬ ‫دارﻳﻢ‬ ‫ﺑﻨﺎﺑﺮاﻳﻦ‬: ‫داﺷﺖ‬ ‫ﺧﻮاﻫﻴﻢ‬ ‫را‬ ‫زﻳﺮ‬ ‫ﻣﻘﺎدﻳﺮ‬ ‫ﺑﻪ‬ ‫ﻫﻤﮕﺮا‬ ‫دﻧﺒﺎﻟﻪ‬ ،‫ﻗﺒﻞ‬ ‫ﻣﺸﺎﺑﻪ‬ ‫ﻫﺎﻳﻲ‬ ‫ﻋﻤﻠﻴﺎت‬ ‫اﻧﺠﺎم‬ ‫ﺑﺎ‬ ‫اداﻣﻪ‬ ‫در‬: ‫ﮔﻮس‬ ‫روش‬ ‫ﺑﻪ‬ ‫ﺧﻄﻲ‬ ‫ﻣﻌﺎدﻻت‬ ‫دﺳﺘﮕﺎه‬ ‫ﺣﻞ‬ ‫ﻣﺜﺎل‬-‫ﺳﻴﺪال‬ 45 ‫ﻋﺪدي‬ ‫ﻣﺤﺎﺳﺒﺎت‬ ‫ﻛﻤﻚ‬ ‫ﺑﻪ‬MATLAB faradars.org/fvmth102 ‫س‬‫ر‬‫د‬‫ا‬‫ﺮ‬‫ﻓ‬ FaraDars.org
  46. 46. ‫ﺑﺮﻧﺎﻣﻪ‬Matlab‫ﮔﻮس‬ ‫روش‬-‫ﺳﻴﺪال‬ 46 function seidel(A,b,x0,tol,itmax) % Solve the system Ax=b using Gauss-Seidel iteration method. n=length(b); x=zeros(n,1); fprintf('n'); disp(' The augmented matrix is =') Augm=[A b] Y=zeros(n,1); Y=x0; for k=1:itmax+1 for i=1:n S=0; for j=1:i-1 S=S+A(i,j)*x(j); end for j=i+1:n S=S+A(i,j)*x0(j); end if(A(i,i)==0) break end x(i)=(-S+b(i))/A(i,i); end err=abs(norm(x-x0)); rerr=err/(norm(x)+eps); x0=x; Y=[Y x]; if(rerr<tol) break end end % Print the results if(A(i,i)==0) disp(' division by zero') elseif (k==itmax+1) disp(' No convergence') else fprintf('n'); disp(' The solution vectors are:') fprintf('n'); disp('iter # 0 1 2 3 4 ...') fprintf('n'); for i=1:n fprintf('x%1.0f = ',i) fprintf('%10.6f',Y(i,[1:k+1])) fprintf('n'); end fprintf('n'); disp(['The method converges after ',num2str(k),' iterations to']); x end ‫س‬‫ر‬‫د‬‫ا‬‫ﺮ‬‫ﻓ‬ FaraDars.org
  47. 47. >> A = [7 -2 +1 0;1 -9 3 -1;2 0 10 1;2 -1 1 6]; >> b = [17;13;15;10] ; >> x1 = lufact(A,b); >> x0 = zeros(size(b)); >> ITMAX = 5; >> tol = 1e-5; >> X = zeros(length(b),ITMAX,2); >> for ii = 1 : ITMAX X(:,ii,1)=jacobi(A,b,x0,tol,ii); X(:,ii,2)=seidel(A,b,x0,tol,ii); end >> figure; >> for ii=1:length(b) subplot (length(b),1,ii);plot(1:ITMAX+1,x1(ii)*ones(1,ITMAX+1),'*-',1:ITMAX+1,[0,X(ii,:,1)],'s- ',1:ITMAX+1,[0,X(ii,:,2)],'d-','linewidth',2.5,'markersize',7); xlabel(' No. of Iterations ');ylabel(' X values ');title([' Comparison of Convergence Speed and Accuracy between Jacobi & Gauss-seidel Iterative Methods for Variable No. ', num2str(ii)]); legend('Real Value for Var. x','Jacobi Values for Var. x ','Seidel Values for Var. x'); end 47 ‫ﮔﻮس‬ ‫و‬ ‫ژاﻛﻮﺑﻲ‬ ‫روﺷﻬﺎي‬ ‫ﻫﻤﮕﺮاﻳﻲ‬ ‫ﺳﺮﻋﺖ‬ ‫ﻣﻴﺎن‬ ‫ﻣﻘﺎﻳﺴﻪ‬-‫ﺳﻴﺪال‬ ‫ﻋﺪدي‬ ‫ﻣﺤﺎﺳﺒﺎت‬ ‫ﻛﻤﻚ‬ ‫ﺑﻪ‬MATLAB faradars.org/fvmth102 ‫س‬‫ر‬‫د‬‫ا‬‫ﺮ‬‫ﻓ‬ FaraDars.org
  48. 48. 48 ‫ﮔﻮس‬ ‫و‬ ‫ژاﻛﻮﺑﻲ‬ ‫روﺷﻬﺎي‬ ‫ﻫﻤﮕﺮاﻳﻲ‬ ‫ﺳﺮﻋﺖ‬ ‫ﻣﻴﺎن‬ ‫ﻣﻘﺎﻳﺴﻪ‬ ‫اداﻣﻪ‬-‫ﺳﻴ‬‫ﺪال‬ 1 1.5 2 2.5 3 3.5 4 4.5 5 5.5 6 0 2 4 No. of Iterations Xvalues Comparison of Convergence Speed and Accuracy between Jacobi & Gauss-seidel Iterative Methods for Variable No. 1 Real Value for Var. x Jacobi Values for Var. x Seidel Values for Var. x 1 1.5 2 2.5 3 3.5 4 4.5 5 5.5 6 -2 -1 0 No. of Iterations Xvalues Comparison of Convergence Speed and Accuracy between Jacobi & Gauss-seidel Iterative Methods for Variable No. 2 Real Value for Var. x Jacobi Values for Var. x Seidel Values for Var. x 1 1.5 2 2.5 3 3.5 4 4.5 5 5.5 6 0 1 2 No. of Iterations Xvalues Comparison of Convergence Speed and Accuracy between Jacobi & Gauss-seidel Iterative Methods for Variable No. 3 Real Value for Var. x Jacobi Values for Var. x Seidel Values for Var. x 1 1.5 2 2.5 3 3.5 4 4.5 5 5.5 6 0 0.5 1 No. of Iterations Xvalues Comparison of Convergence Speed and Accuracy between Jacobi & Gauss-seidel Iterative Methods for Variable No. 4 Real Value for Var. x Jacobi Values for Var. x Seidel Values for Var. x ‫س‬‫ر‬‫د‬‫ا‬‫ﺮ‬‫ﻓ‬ FaraDars.org
  49. 49. 49 ‫ﻣﻌﻴﻦ‬ ‫ﻣﺜﺒﺖ‬ ‫ﻣﺎﺗﺮﻳﺲ‬ ‫ﺗﻌﺮﻳﻒ‬ )Positive Definite Matrix( ‫ﺗﻌﺮﻳﻒ‬:‫ﻣﺘﻘﺎرن‬ ‫ﻣﺎﺗﺮﻳﺲ‬ ‫ﻳﻚ‬‫ﻣﻌﻴﻦ‬ ‫ﻣﺜﺒﺖ‬(positive definite) ‫ﺷﻮد‬ ‫ﻣﻲ‬ ‫ﻧﺎﻣﻴﺪه‬(M>0)‫ﻫﺮ‬ ‫ﺑﺮاي‬ ‫اﮔﺮ‬ ‫ﺑﺎﺷﻴﻢ‬ ‫داﺷﺘﻪ‬: nn RM   n Rx   RxMxT ‫ﻗﻀﻴﻪ‬:‫ﻣﺎﺗﺮﻳﺲ‬‫ﻣﺘﻘﺎرن‬ ‫ﺣﻘﻴﻘﻲ‬M‫ﻣﻌﻴﻦ‬ ‫ﻣﺜﺒﺖ‬ ،)‫ﻣﻌﻴﻦ‬ ‫ﻧﻴﻤﻪ‬ ‫ﻣﺜﺒﺖ‬(‫از‬ ‫ﻛﺪام‬ ‫ﻫﺮ‬ ‫اﮔﺮ‬ ‫ﻓﻘﻂ‬ ‫و‬ ‫اﮔﺮ‬ ‫اﺳﺖ‬‫ﺷﺮاﻳﻂ‬‫ﺑﺮﻗﺮار‬ ‫زﻳﺮ‬‫ﺑﺎﺷﺪ‬: 1-‫ﻣﺎﺗﺮﻳﺲ‬ ‫وﻳﮋه‬ ‫ﻣﻘﺎدﻳﺮ‬ ‫ﺗﻤﺎم‬M‫ﻣﺜﺒﺖ‬ ،)‫ﺻﻔﺮ‬ ‫ﻳﺎ‬ ‫ﻣﺜﺒﺖ‬(‫ﺑﺎﺷﺪ‬. 2-‫ﺗﻤﺎم‬‫ﻛﻬﺎدﻫﺎ‬‫ﻣﺎﺗﺮﻳﺲ‬ ‫ﻣﻘﺪم‬ ‫اﺻﻠﻲ‬ ‫ﻣﺎﻳﻨﻮرﻫﺎي‬ ‫ﻳﺎ‬M‫ﻣﺜﺒﺖ‬ ،)‫ﺻﻔﺮ‬ ‫ﻳﺎ‬ ‫ﻣﺜﺒﺖ‬(‫ﺑﺎﺷﺪ‬. 3-‫ﻣﻨﻔﺮد‬ ‫ﻏﻴﺮ‬ ‫ﻣﺎﺗﺮﻳﺲ‬N‫اﺑﻌﺎد‬ ‫ﺑﺎ‬nn‫ﻛﻪ‬ ‫ﺑﺎﺷﺪ‬ ‫داﺷﺘﻪ‬ ‫وﺟﻮد‬NTNM=)‫ﻣﻨﻔﺮد‬ ‫ﻏﻴﺮ‬ ‫ﻣﺎﺗﺮﻳﺲ‬N‫اﺑﻌﺎد‬ ‫ﺑﺎ‬nn‫ﻣﺎﺗﺮﻳﺲ‬ ‫ﻳﺎ‬ ‫و‬N‫ﺑﺎ‬ ‫اﺑﻌﺎد‬nm‫ﺑﺎ‬nm<‫ﻛﻪ‬ ‫ﺑﺎﺷﺪ‬ ‫داﺷﺘﻪ‬ ‫وﺟﻮد‬NTNM=( ‫ﻋﺪدي‬ ‫ﻣﺤﺎﺳﺒﺎت‬ ‫ﻛﻤﻚ‬ ‫ﺑﻪ‬MATLAB faradars.org/fvmth102 ‫س‬‫ر‬‫د‬‫ا‬‫ﺮ‬‫ﻓ‬ FaraDars.org
  50. 50. 50 ‫ﻋﺪدي‬ ‫ﻣﺤﺎﺳﺒﺎت‬ ‫ﻛﻤﻚ‬ ‫ﺑﻪ‬MATLAB faradars.org/fvmth102 ‫س‬‫ر‬‫د‬‫ا‬‫ﺮ‬‫ﻓ‬ FaraDars.org
  51. 51. 51 ‫ﻓﺮادرس‬ ‫در‬ ‫ﺷﺪه‬ ‫ﻣﻄﺮح‬ ‫ﻧﻜﺎت‬ ‫ﻣﺒﻨﺎي‬ ‫ﺑﺮ‬ ‫ﻫﺎ‬ ‫اﺳﻼﻳﺪ‬ ‫اﻳﻦ‬ »‫اﻓﺰار‬ ‫ﻧﺮم‬ ‫ﻛﻤﻚ‬ ‫ﺑﻪ‬ ‫ﭘﻴﺸﺮﻓﺘﻪ‬ ‫ﻋﺪدي‬ ‫ﻣﺤﺎﺳﺒﺎت‬ ‫آﻣﻮزش‬MATLAB« ‫اﺳﺖ‬ ‫ﺷﺪه‬ ‫ﺗﻬﻴﻪ‬. ‫ﻧﻤﺎﻳﻴﺪ‬ ‫ﻣﺮاﺟﻌﻪ‬ ‫زﻳﺮ‬ ‫ﻟﻴﻨﻚ‬ ‫ﺑﻪ‬ ‫آﻣﻮزش‬ ‫اﻳﻦ‬ ‫ﻣﻮرد‬ ‫در‬ ‫ﺑﻴﺸﺘﺮ‬ ‫اﻃﻼﻋﺎت‬ ‫ﻛﺴﺐ‬ ‫ﺑﺮاي‬. faradars.org/fvmth102 ‫ﻋﺪدي‬ ‫ﻣﺤﺎﺳﺒﺎت‬ ‫ﻛﻤﻚ‬ ‫ﺑﻪ‬MATLAB faradars.org/fvmth102 ‫س‬‫ر‬‫د‬‫ا‬‫ﺮ‬‫ﻓ‬ FaraDars.org

×