Matlab Plynomial Fitting

Download as pdf or txt
Download as pdf or txt
You are on page 1of 12

Chapter 8

Polynomials, Curve Fitting &


Interpolation
8. Introduction
8.1 Polynomials
8.1.1 Value of a Polynomial
8.1.2 Roots of a Polynomial
8.1.3 Addition, Multiplication, and Division of Polynomials
8.1.4 Derivatives of Polynomials
8.2 Curve Fitting
8.2.1 Curve Fitting with Polynomials; the polyfit Function
8.2.2 Curve Fitting with Functions Other than Polynomials
8.3 Interpolation
8.4 The Basic Fitting Interface
8.5 Examples of MATLAB Applications
‫‪CH-8‬‬ ‫‪Dr. Elham Jasim Mohammad‬‬

‫‪8.1 Polynomials‬‬
‫ﯾﺘﻢ اﻟﺘﻌﺎﻣﻞ ﻣﻊ ﻣﺘﻌﺪد اﻟﺤﺪود ﻓﻲ ‪ MATLAB‬ﻣﻦ ﺧﻼل ﺗﻮاﺑﻊ ﺧﺎﺻﺔ أﻋﺪت ﻟﺤﻞ ﻣﺘﻌﺪد اﻟﺤﺪود ﺿﻤﻦ ھﺬا‬
‫اﻟﺒﺮﻧﺎﻣﺞ‪ .‬ﺣﯿﺚ ﯾﺘﻢ ﺗﺤﻮﯾﻞ ﻣﺘﻌﺪد اﻟﺤﺪود إﻟﻰ ﻣﺘﺠﮫ ﺳﻄﺮي وﺗﻤﺜﻞ اﻷﻋﺪاد ﺿﻤﻦ ھﺬا اﻟﻨﺴﻖ ﻣﻌﺎﻣﻼت ﻣﺘﻌﺪد‬
‫اﻟﺤﺪود‪ .‬وﺗﺮﺗﺐ ﺿﻤﻦ اﻟﻨﺴﻖ ﺑﺸﻜﻞ ﺗﻨﺎزﻟﻲ ﯾﻮاﻓﻖ ﻗﻮى اﻟﻤﺘﺤﻮل ﻓﻲ ﻣﺘﻌﺪد اﻟﺤﺪود ﺑﺪءا ً ﻣﻦ اﻟﻘﻮة )‪ (n‬وﺣﺘﻰ‬
‫اﻟﻘﻮة )‪ (0‬ﺑﻤﺎ ﻓﻲ ذﻟﻚ اﻟﻤﻌﺎﻣﻼت اﻟﻤﻌﺪوﻣﺔ ﻟﻠﻤﺘﺤﻮل ﺣﯿﺚ ) ‪ (n‬أﻋﻠﻰ رﺗﺒﺔ ﻟﻠﻤﺘﺤﻮل ﻓﻲ ﻣﺘﻌﺪد اﻟﺤﺪود وذﻟﻚ‬
‫ﻟﻠﺘﻮاﻓﻖ ﻣﻊ اﻷﺳﻠﻮب اﻟﺬي ﯾﺘﻌﺎﻣﻞ ﻣﻌﮫ ﺑﺮﻧﺎﻣﺞ ‪ MATLAB‬ﻓﻲ ﺣﻞ ﻣﺘﻌﺪد اﻟﺤﺪود ﻓﻤﺜﻼ ﻟﺪﯾﻨﺎ اﻟﺪاﻟﺔ اﻟﺘﺎﻟﯿﺔ‪:‬‬
‫;‪f(t)= 7t^4 +6t^3+3t^2+t+5‬‬
‫ﯾﺘﻢ ﺗﻤﺜﯿﻞ ﻣﺘﻌﺪد اﻟﺤﺪود ھﺬا ﺑﺎﻟﻤﺼﻔﻮﻓﺔ‪:‬‬
‫‪A= [7‬‬ ‫‪6‬‬ ‫‪3‬‬ ‫‪1‬‬ ‫]‪5‬‬

‫‪8.1.1 Value of a Polynomial‬‬


‫ﺗﺘﻢ ھﺬه اﻟﻌﻤﻠﯿﺔ ﻓﻲ ‪ MATLAB‬ﺑﺎﺳﺘﺨﺪام اﻟﺘﺎﺑﻊ اﻟﺨﺎص )‪ polyval(p,x‬واﻟﺼﯿﻐﺔ اﻟﻌﺎﻣﺔ ھﻲ‪:‬‬

‫ﺣﯿﺚ ﺗﻤﺜﻞ ‪ p‬اﻟﻤﺘﺠﮫ أو اﻟﻤﺼﻔﻮﻓﺔ اﻟﻤﻤﺜﻠﺔ ﻟﻤﺘﻌﺪد اﻟﺤﺪود واﻟﺮﻣﺰ ‪ x‬ﯾﻌﺒﺮ ﻋﻦ ﻗﯿﻤﺔ ﻋﺪد أو اﻟﻤﺘﻐﯿﺮ اﻟﻤﺮاد‬
‫ﺣﺴﺎب ﻣﺘﻌﺪد اﻟﺤﺪود ﻟﮫ‪.‬‬

‫‪8.1.2 Roots of a Polynomial‬‬


‫إن اﻟﺘﺎﺑﻊ ‪ roots‬ھﻮ اﻟﺘﺎﺑﻊ اﻟﺨﺎص ﻓﻲ ‪ MATLAB‬اﻟﺬي ﯾﻤﻜﻦ ﻋﻦ طﺮﯾﻘﮫ إﯾﺠﺎد ﺟﺬور ﻣﺘﻌﺪد اﻟﺤﺪود ﺣﯿﺚ‬
‫ﯾﻌﻄﻲ ھﺬا اﻟﺘﺎﺑﻊ ﺟﺬور ﻣﺘﻌﺪد اﻟﺤﺪود ﻋﻠﻰ ﺷﻜﻞ ﻣﺘﺠﮫ ﻋﻤﻮد وﻋﻨﺎﺻﺮ ھﺬه اﻟﻤﺘﺠﮭﺎت ھﻲ ﺟﺬور ﻣﺘﻌﺪد اﻟﺤﺪود‬
‫واﻟﺼﯿﻐﺔ اﻟﻌﺎﻣﺔ ھﻲ‪:‬‬

‫ﺣﯿﺚ ‪ r‬ﯾﻤﺜﻞ ﻣﺘﺠﮫ ﻋﻤﻮد و ‪ p‬ﯾﻤﺜﻞ ﻣﺘﺠﮫ ﺳﻄﺮ ﻟﻤﻌﺎﻣﻼت ﻣﺘﻌﺪد اﻟﺤﺪود‪.‬‬
‫وﻋﻨﺪﻣﺎ ﯾﻜﻮن ﺟﺬر اﻟﺪاﻟﺔ ﻣﻌﺮوف ﻧﺴﺘﺨﺪم اﻟﺘﺎﺑﻊ ‪ poly‬ﻟﺤﺴﺎب ﻣﻌﺎﻣﻼت ﻣﺘﻌﺪد اﻟﺤﺪود واﻟﺼﯿﻐﺔ اﻟﻌﺎﻣﺔ ھﻲ‪:‬‬

‫‪8.1.3 Addition, Multiplication, Division and Integration of Polynomials‬‬


‫‪a. Addition‬‬
‫ﯾﻤﻜﻦ ﺟﻤﻊ ﻣﺘﻌﺪد اﻟﺤﺪود ﻣﻦ ﺧﻼل اﻟﺘﻌﺎﻣﻞ ﻣﻊ اﻟﻤﺼﻔﻮﻓﺎت اﻟﻤﻤﺜﻠﺔ ﻟﮭﺎ ﻣﻊ ﻣﻼﺣﻈﺔ أن ﺗﻜﻮن ﻛﻼ اﻟﻤﺼﻔﻮﻓﺘﯿﻦ‬
‫ﻣﻦ ﻧﻔﺲ اﻟﺪرﺟﺔ‪ .‬ﻓﻤﺜﻼ إذا ﻛﺎن ﻟﺪﯾﻨﺎ ﻣﺘﻌﺪد اﻟﺤﺪود اﻟﺘﺎﻟﻲ‪:‬‬

‫ﻓﻌﻨﺪ إﺟﺮاء ﻋﻤﻠﯿﺔ اﻟﺠﻤﻊ‪:‬‬

‫‪Mustansirayah University, Collage of Science, Physics Department 2020-2021‬‬ ‫‪Page 1‬‬


‫‪CH-8‬‬ ‫‪Dr. Elham Jasim Mohammad‬‬

‫;]‪>> p1=[3 15 0 -10 -3 15 -40‬‬


‫;]‪>> p2=[3 0 -2 -6‬‬
‫]‪>> p=p1+[0 0 0 p2‬‬
‫= ‪p‬‬
‫‪3 15 0 -7 -3 13 -46‬‬
‫ﺣﯿﺚ أﺿﻔﻨﺎ ﺛﻼﺛﺔ أﺻﻔﺎر ﻗﺒﻞ ‪ p2‬ﻻن ﻣﺮﺗﺒﺔ ‪ p1‬ﺗﺴﺎوي ‪ 6‬وﻣﺮﺗﺒﺔ ‪ p2‬ﺗﺴﺎوي ‪.3‬‬

‫‪b. Multiplication‬‬
‫أﻣﺎ ﻋﻤﻠﯿﺔ اﻟﻀﺮب ﻓﯿﻤﻜﻦ اﻟﻘﯿﺎم ﺑﮭﺎ ﻣﻦ ﺧﻼل اﻻﺳﺘﻌﺎﻧﺔ ﺑﺎﻟﺘﺎﺑﻊ ‪ conv‬ﻣﺨﺘﺼﺮ ﻛﻠﻤﺔ ‪convolution‬‬
‫وﺑﺎﺳﺘﺨﺪام ھﺬا اﻟﺘﺎﺑﻊ ﯾﺘﻢ اﻟﺤﺼﻮل ﻋﻠﻰ ﺿﺮب ﻣﺘﻌﺪد اﻟﺤﺪود ﺑﺸﺮط أن ﺗﻌﺮف ﻣﺘﻌﺪدات اﻟﺤﺪود ﺑﻤﺼﻔﻮﻓﺎت‬
‫ﻣﺘﻮاﻓﻘﺔ وﻣﻌﺒﺮة ﻋﻦ ﻣﻌﺎﻣﻼﺗﮭﺎ واﻟﺼﯿﻐﺔ اﻟﻌﺎﻣﺔ ھﻲ‪:‬‬

‫وﺑﺎﻟﺮﺟﻮع إﻟﻰ اﻟﻤﻌﺎدﻻت ﻓﻲ ﻓﻘﺮة ‪ a‬ﻣﻤﻜﻦ أن ﻧﺠﺮي ﻋﻤﻠﯿﺔ اﻟﻀﺮب ﻛﺎﻟﺘﺎﻟﻲ‪:‬‬


‫)‪>> pm= conv(p1,p2‬‬
‫= ‪pm‬‬
‫‪9 45 -6 -78 -99 65 -54 -12 -10 240‬‬
‫وھﺬا ﻣﻌﻨﺎه إن اﻟﺠﻮاب ﯾﻜﻮن‪:‬‬

‫‪c. Division‬‬
‫اﻟﺼﯿﻐﺔ اﻟﻌﺎﻣﺔ ﻟﻌﻤﻠﯿﺔ اﻟﻘﺴﻤﺔ ﺗﺄﺧﺬ اﻟﺸﻜﻞ اﻟﺘﺎﻟﻲ‪:‬‬

‫ﺣﯿﺚ‪ q :‬ﺗﻤﺜﻞ ﻣﺘﺠﮫ ﻣﻊ ﻣﻌﺎﻣﻼت ﺣﺎﺻﻞ ﻗﺴﻤﺔ ﻣﺘﻌﺪد اﻟﺤﺪود‪.‬‬


‫‪ r‬ﯾﻤﺜﻞ ﻣﺘﺠﮫ ﻣﻊ ﻣﻌﺎﻣﻼت ﺑﻮاﻗﻲ ﻣﺘﻌﺪد اﻟﺤﺪود‪.‬‬
‫‪ u‬ﯾﻤﺜﻞ ﻣﺘﺠﮫ ﻣﻊ ﻣﻌﺎﻣﻼت اﻟﺒﺴﻂ ﻟﻤﺘﻌﺪد اﻟﺤﺪود و ‪ v‬ﯾﻤﺜﻞ ﻣﺘﺠﮫ ﻣﻊ ﻣﻌﺎﻣﻼت اﻟﻤﻘﺎم ﻟﻤﺘﻌﺪد اﻟﺤﺪود‪.‬‬
‫ﯾﻜﻮن‪:‬‬ ‫ﻋﻠﻰ‬ ‫وﻋﻠﻰ ﺳﺒﯿﻞ اﻟﻤﺜﺎل ﻓﺄن ﻗﺴﻤﺔ اﻟﻤﻌﺎدﻟﺔ‪:‬‬

‫;]‪>> u= [2 9 7 -6‬‬
‫;]‪>> v= [1 3‬‬
‫;)‪>> [a b]= deconv(u,v‬‬

‫‪% The answer is:‬‬


‫‪a = 2 3 -2‬‬

‫‪% Remainder is zero‬‬


‫‪b = 0 0 0 0‬‬

‫‪Mustansirayah University, Collage of Science, Physics Department 2020-2021‬‬ ‫‪Page 2‬‬


‫‪CH-8‬‬ ‫‪Dr. Elham Jasim Mohammad‬‬

‫‪d. Integration‬‬
‫ﻣﻦ اﻟﻤﻌﺮوف أن اﻟﺘﻜﺎﻣﻞ ھﻮ ﻋﻤﻠﯿﺔ ﻣﻌﺎﻛﺴﺔ ﻟﻼﺷﺘﻘﺎق وﯾﻤﻜﻨﻨﺎ اﻟﺘﺎﺑﻊ ‪ polyint‬اﻟﻤﻮﺟﻮد داﺧﻞ اﻟﻤﻜﺘﺒﺔ‬
‫اﻟﺮﯾﺎﺿﯿﺔ ﻓﻲ ‪ MATLAB‬ﻣﻦ إﯾﺠﺎد ﺗﻜﺎﻣﻞ ﺗﺎﺑﻊ ﻣﻦ ﺧﻼل إدﺧﺎل ﻣﻌﺎﻣﻼت ﻣﺘﻌﺪد اﻟﺤﺪود ﺑﺸﻜﻞ ﻣﺼﻔﻮﻓﺔ‪.‬‬

‫‪8.1.4 Derivatives of Polynomials‬‬


‫ﯾﻤﻜﻦ إﯾﺠﺎد ﻣﺸﺘﻖ ﻣﺘﻌﺪد اﻟﺤﺪود ﺑﺎﺳﺘﺨﺪام اﻟﺘﺎﺑﻊ ‪ polyder‬وﺗﻜﻮن اﻟﻨﺘﯿﺠﺔ ﻋﺒﺎرة ﻋﻦ ﻣﺘﻌﺪد ﺣﺪود ﯾﻤﺜﻞ‬
‫ﻣﺸﺘﻖ ﻣﺘﻌﺪد اﻟﺤﺪود اﻷﺻﻠﻲ‪ .‬ﺣﯿﺚ ﯾﻤﻜﻦ اﺳﺘﺨﺪام اﻟﺪاﻟﺔ ‪ polyder‬ﻓﻲ ﺣﺴﺎب ﻣﺸﺘﻖ ﻣﻔﺮد ﻣﺘﻌﺪد اﻟﺤﺪود‪،‬‬
‫وھﻮ ﯾﻨﺘﺞ ﻣﻦ اﺛﻨﯿﻦ ﻣﻦ ﻣﺘﻌﺪد اﻟﺤﺪود‪ ،‬أو ﺣﺎﺻﻞ ﻗﺴﻤﺔ اﺛﻨﯿﻦ ﻣﻦ ﻣﺘﻌﺪد اﻟﺤﺪود‪ ،‬ﻛﻤﺎ ھﻮ ﻣﻮﺿﺢ ﻓﻲ اﻟﺤﺎﻻت‬
‫اﻟﺜﻼﺛﺔ اﻟﺘﺎﻟﯿﺔ‪:‬‬
‫‪ : k = polyder (p) .1‬ﻣﺸﺘﻘﺔ ﻣﺘﻌﺪد اﻟﺤﺪود ﻣﻔﺮد‪ .‬ﺣﯿﺚ ‪ p‬ﯾﻤﺜﻞ ﻣﺘﺠﮫ ﻣﻊ ﻣﻌﺎﻣﻼت ﻣﺘﻌﺪد اﻟﺤﺪود و ‪k‬‬
‫ﯾﻤﺜﻞ ﻣﺘﺠﮫ ﻣﻌﺎﻣﻼت ﻣﺘﻌﺪد اﻟﺤﺪود اﻟﺘﻲ ھﻲ اﻟﻤﺸﺘﻘﺔ‪.‬‬
‫‪ : k = polyder (a, b) .2‬ﻣﺸﺘﻘﺔ ﻧﺎﺗﺠﺔ ﻋﻦ ﺿﺮب اﺛﻨﯿﻦ ﻣﻦ ﻣﺘﻌﺪدات اﻟﺤﺪود‪ a .‬و ‪ b‬ﺗﻤﺜﻞ ﻣﺘﺠﮭﺎت ﻣﻊ‬
‫ﻣﻌﺎﻣﻼت ﻣﺘﻌﺪد اﻟﺤﺪود واﻟﺘﻲ ﺗﺘﻀﺎﻋﻒ‪ .‬و ‪ k‬ﯾﻤﺜﻞ ﻣﺘﺠﮫ ﻣﻌﺎﻣﻼت ﻣﺘﻌﺪد اﻟﺤﺪود اﻟﺘﻲ ھﻲ ﻣﺸﺘﻘﺔ اﻟﻨﺎﺗﺞ‪.‬‬
‫‪ : [n d] = polyder (u, v) .3‬ﯾﻤﺜﻞ ﻣﺸﺘﻘﺔ ﺣﺎﺻﻞ ﺿﺮب اﺛﻨﯿﻦ ﻣﻦ ﻣﺘﻌﺪد اﻟﺤﺪود‪ u .‬و ‪ v‬ھﻲ ﻣﺘﺠﮭﺎت ﻣﻊ‬
‫ﻣﻌﺎﻣﻼت اﻟﺒﺴﻂ واﻟﻤﻘﺎم ﻟﻤﺘﻌﺪد اﻟﺤﺪود‪ n .‬و ‪ d‬ھﻲ ﻣﺘﺠﮭﺎت ﻣﻊ ﻣﻌﺎﻣﻼت اﻟﺒﺴﻂ واﻟﻤﻘﺎم ﻟﻤﺘﻌﺪد اﻟﺤﺪود ﻓﻲ‬
‫ﺣﺎﺻﻞ اﻟﻘﺴﻤﺔ وﯾﻤﺜﻞ اﻟﻤﺸﺘﻘﺔ‪.‬‬
‫واﻻﺧﺘﻼف اﻟﻮﺣﯿﺪ ﺑﯿﻦ اﻷﻣﺮﯾﻦ اﻷﺧﯿﺮﯾﻦ ھﻮ ﻋﺪد اﻟﻤﺨﺮﺟﺎت‪ .‬ﺣﯿﺚ ﺑﺎﺳﺘﺨﺪام اﺛﻨﺎن ﻣﻦ وﺳﻄﺎء اﻟﻤﺨﺮﺟﺎت‪،‬‬
‫ﻓﺎن ‪ MATLAB‬ﯾﺤﺴﺐ ﻣﺸﺘﻘﺔ ﺣﺎﺻﻞ اﻟﻘﺴﻤﺔ ﻻﺛﻨﯿﻦ ﻣﻦ ﻣﺘﻌﺪدات اﻟﺤﺪود‪ .‬وﻓﻲ ﺣﺎﻟﺔ اﻟﺨﺮج اﻟﻮاﺣﺪ ﻓﺎن‬
‫ﻧﺎﺗﺞ اﻟﻤﺸﺘﻘﺔ ﯾﻜﻮن ﻣﻦ اﻟﻨﺎﺗﺞ‪ .‬واﻟﺠﺪول اﻟﺘﺎﻟﻲ ﯾﺒﯿﻦ أھﻢ اﻟﺘﻮاﺑﻊ اﻟﻤﺴﺘﺨﺪﻣﺔ ﻓﻲ ﻣﺘﻌﺪد اﻟﺤﺪود وﺣﺴﺐ اﻟﺘﺮﺗﯿﺐ‬
‫اﻷﺑﺠﺪي‪:‬‬
‫اﻟﺘﺎﺑﻊ‬ ‫وظﯿﻔﺔ اﻟﺘﺎﺑﻊ‬
‫‪conv‬‬ ‫ﺿﺮب ﻣﺘﻌﺪد اﻟﺤﺪود‬
‫‪deconv‬‬ ‫ﻗﺴﻤﺔ ﻣﺘﻌﺪد اﻟﺤﺪود‬
‫‪poly‬‬ ‫اﻛﺘﺸﺎف ﻣﻌﺎدﻟﺔ ﻣﺘﻌﺪد ﺣﺪود ﺟﺬورھﺎ ﻣﻌﻠﻮﻣﺔ‬
‫‪polyder‬‬ ‫ﻣﺸﺘﻖ ﻣﺘﻌﺪد ﺣﺪود‬
‫‪polyfit‬‬ ‫إﯾﺠﺎد ﻣﺘﻌﺪد اﻟﺤﺪود اﻟﻤﻼﺋﻢ‬
‫‪polyint‬‬ ‫ﺗﻜﺎﻣﻞ ﻣﺘﻌﺪد اﻟﺤﺪود‬
‫‪polyval‬‬ ‫ﺣﺴﺎب ﻗﯿﻤﺔ ﻣﺘﻌﺪد اﻟﺤﺪود ﻋﻨﺪ ﻗﯿﻤﺔ ﻣﻌﯿﻨﺔ‬
‫‪roots‬‬ ‫إﯾﺠﺎد ﺟﺬور ﻣﺘﻌﺪد اﻟﺤﺪود‬

‫‪8.2 Curve Fitting‬‬


‫‪8.2.1 Curve Fitting with Polynomials; the polyfit Function‬‬
‫إذا ﻛﺎن ﻟﺪﯾﻚ ﻣﺠﻤﻮﻋﺔ ﻧﻘﺎط ﻣﻦ ﻣﻨﺤﻨﻲ ﻻ ﺗﻌﺮف ﻣﻌﺎدﻟﺘﮫ وﺗﺮﯾﺪ أن ﺗﺸﻜﻞ ﻣﻌﺎدﻟﺔ ﻟﮭﺬا اﻟﻤﻨﺤﻨﻲ ﻓﯿﻤﻜﻦ‬
‫اﻻﺳﺘﻌﺎﻧﺔ ﺑﺎﻟﺘﺎﺑﻊ ‪ polyfit‬ﻟﻠﻘﯿﺎم ﺑﮭﺬه اﻟﻌﻤﻠﯿﺔ ﺣﯿﺚ أﻧﮫ ﯾﻌﻄﯿﻚ ﻣﻌﺎدﻟﺔ ﻣﺘﻌﺪد اﻟﺤﺪود اﻟﻤﻼﺋﻢ ﻟﻠﻤﻨﺤﻨﻲ ﺑﺤﯿﺚ‬
‫أﻧﻚ ﺗﺨﺘﺎر درﺟﺔ ﻣﺘﻌﺪد اﻟﺤﺪود اﻟﺬي ﺗﺮﯾﺪ اﻟﺤﺼﻮل ﻋﻠﯿﮫ‪ .‬وھﻨﺎﻟﻚ ﺣﺎﻟﺘﯿﻦ ﻟﻌﺮض اﻟﺮﺳﻢ‪:‬‬
‫‪a. Polynomials that pass through all the points‬‬
‫‪b. Polynomials that do not necessarily pass through any of the points‬‬
‫ﻟﻨﻔﺮض ﺑﺄﻧﻨﺎ ﻗﻤﻨﺎ ﺑﺄداء ﺗﺠﺮﺑﺔ ﻣﻌﯿﻨﺔ وﺣﺼﻠﻨﺎ ﻣﻨﮭﺎ ﻋﻠﻰ اﻟﺒﯿﺎﻧﺎت اﻟﺘﺎﻟﯿﺔ‪:‬‬
‫‪x= 0 0.349 0.698 1.047 1.396 1.745 2.094 2.443‬‬ ‫‪2.792‬‬ ‫‪3.141‬‬
‫‪y= 0.006 0.348 0.643 0.866 0.988 0.990 0.872 0.646‬‬ ‫‪0.350‬‬ ‫‪0.007‬‬

‫‪Mustansirayah University, Collage of Science, Physics Department 2020-2021‬‬ ‫‪Page 3‬‬


CH-8 Dr. Elham Jasim Mohammad

‫ ﺑﻌﺪ ذﻟﻚ اردﻧﺎ اﺳﺘﻨﺘﺎج اﻟﻨﻤﻮذج اﻟﺮﯾﺎﺿﻲ اﻟﺬي ﯾﺤﻜﻢ ھﺬا اﻟﻨﻈﺎم وﺑﻤﻌﻨﻰ اﺧﺮ‬y ‫ و‬x ‫وﻧﺮﯾﺪ رﺳﻢ اﻟﻌﻼﻗﺔ ﺑﯿﻦ‬
‫اﻧﺘﺎج اﻟﺪاﻟﺔ اﻟﺮﯾﺎﺿﯿﺔ اﻟﺘﻲ ﺗﻘﺪم ﻣﻨﺤﻨﻲ ﯾﻤﺮ ﺑﺠﻤﯿﻊ او ﻣﻌﻈﻢ اﻟﻨﻘﺎط اﻟﺘﻲ ﺣﺼﻠﻨﺎ وﺗﻌﺮف ھﺬه اﻟﻌﻤﻠﯿﺔ ب‬
:‫ واﻟﺼﯿﻐﺔ اﻟﻌﺎﻣﺔ ﻟﮭﺬا اﻻﻣﺮ ھﻲ‬polyfit ‫ وﯾﻤﻜﻦ ﺗﻄﺒﯿﻘﮭﺎ ﺑﺎﺳﺘﺨﺪام اﻻﻣﺮ‬fitting

:‫وﻟﻜﺘﺎﺑﺔ اﻟﺒﺮﻧﺎﻣﺞ ﻧﺘﺒﻊ اﻟﺘﺎﻟﻲ‬


:‫ ﺗﻜﻮن ﺻﯿﻐﺔ اﻟﺒﺮﻧﺎﻣﺞ ﻛﺎﻟﺘﺎﻟﻲ‬script file ‫ ﺑﺎﻟﺮﺟﻮع إﻟﻰ اﻟﻄﺮﯾﻘﺔ اﻟﻘﺪﯾﻤﺔ ﻓﻲ ﻛﺘﺎﺑﺔ اﻟﺒﺮﻧﺎﻣﺞ ﺑﺎﺳﺘﺨﺪام‬:‫أوﻻ‬
clear all; close;
% ND: Number of data points
ND= 50;
x= linspace(0,pi,ND);
f= sin(x)+0.01*rand(1,length(x));
p=polyfit(x,f,4);
g=polyval(p,x);
plot(x,g,'r-',x,f,'b--')

:‫ أﻣﺎ ﻓﻲ ﺣﺎﻟﺔ اﺳﺘﺨﺪام اﻟﺘﻮاﺑﻊ ﺗﻜﻮن ﺻﯿﻐﺔ اﻟﺒﺮﻧﺎﻣﺞ ﻛﺎﻟﺘﺎﻟﻲ‬:‫ﺛﺎﻧﯿﺎ‬


‫ طﺮﯾﻘﺔ ﺗﺎﺑﻊ واﺣﺪ‬.1
clear all; close;
% ND: Number of data points
ND= 50;
function
[x,RandData]=DataBuild(NumOfPoints)
[x,f]=DataBuild(ND); x= linspace(0,pi, NumOfPoints);
RandData=
sin(x)+0.01*rand(1,length(x));
p=polyfit(x,f,4);
g=polyval(p,x);
plot(x,g,'r-',x,f,'b--')

:‫ طﺮﯾﻘﺔ أﻛﺜﺮ ﻣﻦ ﺗﺎﺑﻊ واﺣﺪ ﺣﯿﺚ ﯾﻤﻜﻦ ﺟﻌﻞ اﻟﺒﺮﻧﺎﻣﺞ ﯾﺤﻮي أﻛﺜﺮ ﻣﻦ ﺗﺎﺑﻊ‬.2
clear all; close;
% ND: Number of data points
ND= 50;
function
[x,RandData]=DataBuild(NumOfPoints)
[x,f]=DataBuild(ND); x= linspace(0,pi, NumOfPoints);
RandData= sin(x)+0.01*rand(1,length(x));

function g= DataFitting(x,f)
g= DataFitting(x,f) p=polyfit(x,f,4);
g=polyval(p,x);

Mustansirayah University, Collage of Science, Physics Department 2020-2021 Page 4


‫‪CH-8‬‬ ‫‪Dr. Elham Jasim Mohammad‬‬

‫)'‪plot(x,g,'r-',x,f,'b--‬‬

‫‪8.2.2 Curve Fitting with Functions Other than Polynomials‬‬


‫ﺗﺘﻄﻠﺐ اﻟﻌﺪﯾﺪ ﻣﻦ اﻟﺤﺴﺎﺑﺎت ﻓﻲ اﻟﻌﻠﻮم واﻟﮭﻨﺪﺳﺔ اﺧﺘﯿﺎر ﻷﻓﻀﻞ ﻣﻨﺤﻨﻲ أو رﺳﻢ ﺑﯿﺎﻧﻲ ﻛﻤﺎ ھﻮ اﻟﺤﺎل ﻓﻲ ﻣﺘﻌﺪد‬
‫اﻟﺤﺪود ﻟﻠﺒﯿﺎﻧﺎت اﻟﻤﻌﻄﺎة‪ .‬وﺗﻮﻓﺮ ﺑﻌﺾ اﻟﺪوال ﺻﯿﻎ أﻓﻀﻞ ﻣﻦ ﻏﯿﺮھﺎ وﺳﻮف ﻧﻌﺮض ﻓﻲ ھﺬه اﻟﻔﻘﺮة أﺷﻜﺎل‬
‫ھﺬه اﻟﺪوال وﻣﻨﮭﺎ اﻟﺪوال اﻟﻤﺮﻓﻮﻋﺔ إﻟﻰ ﻗﻮى واﻟﺪوال اﻟﻤﺮﻓﻮﻋﺔ إﻟﻰ أس واﻟﺪوال اﻟﻠﻮﻏﺎرﺗﻤﯿﺔ ودوال اﻟﻤﻘﻠﻮب‪:‬‬

‫وﯾﻤﻜﻦ اﺳﺘﺨﺪام اﻻﻣﺮ ‪ polyfit‬ﻣﻊ ھﺬه اﻟﺪوال ﻋﻦ طﺮﯾﻖ اﻋﺎدة ﻛﺘﺎﺑﺔ اﻟﺪوال ﺑﺤﯿﺚ ﯾﻤﻜﻦ اﺟﺮاء ﺿﺒﻂ‬
‫ﺑﺼﯿﻐﺔ ﻣﺘﻌﺪد ﺣﺪود ﺧﻄﻲ‪:‬‬
‫‪y=mx+b‬‬

‫أي ﯾﻤﻜﻦ اﺳﺘﺨﺪام اﻟﺪاﻟﺔ )‪ polyfit(x,y,1‬ﻟﺘﺤﺪﯾﺪ اﻟﺜﻮاﺑﺖ اﻷﻓﻀﻞ ﻣﻼﺋﻤﺔ ﺣﯿﺚ ﺗﻜﻮن اﻟﺼﯿﻎ ﺑﺎﻟﺸﻜﻞ‪:‬‬

‫‪8.3 Interpolation‬‬
‫اﻻﺳﺘﯿﻔﺎء أو اﻻﺳﺘﻜﻤﺎل ھﻮ ﻋﻤﻠﯿﺔ إﯾﺠﺎد ﻗﯿﻤﺔ ‪ y‬ﻋﻨﺪ ﻗﯿﻤﺔ ﻣﻌﻠﻮﻣﺔ ‪ x‬ﻟﯿﺴﺖ ﻣﻮﺟﻮدة ﻓﻲ ﺟﺪول اﻟﻨﻘﺎط اﻟﻤﻌﻄﺎة‬
‫وﺗﺴﻤﻰ ھﺬه اﻟﻌﻤﻠﯿﺔ ﻗﻀﯿﺔ اﻻﺳﺘﻜﻤﺎل وﯾﺠﺐ اﻟﺘﻔﺮﻗﺔ ﺑﯿﻦ ﻧﻮﻋﯿﻦ ﻣﻦ اﻟﻘﻀﺎﯾﺎ‪:‬‬
‫اﻟﻘﻀﯿﺔ اﻷوﻟﻰ‪ :‬أن اﻟﻨﻘﻄﺔ اﻟﻤﻄﻠﻮﺑﺔ داﺧﻞ ﻧﻘﺎط اﻟﺠﺪول وﺑﺎﻟﺘﺎﻟﻲ ﺗﺴﻤﻰ اﻟﻌﻤﻠﯿﺔ ﻓﻲ ھﺬه اﻟﺤﺎﻟﺔ اﺳﺘﻜﻤﺎل داﺧﻠﻲ‬
‫‪.Interior Interpolation‬‬
‫اﻟﻘﻀﯿﺔ اﻟﺜﺎﻧﯿﺔ‪ :‬أن ﺗﻜﻮن اﻟﻨﻘﻄﺔ اﻟﻤﻄﻠﻮﺑﺔ ﺧﺎرج ﻧﻘﺎط اﻟﺠﺪول وﺑﺎﻟﺘﺎﻟﻲ ﺗﺴﻤﻰ اﻟﻌﻤﻠﯿﺔ ﻓﻲ ھﺬه اﻟﺤﺎﻟﺔ اﺳﺘﻜﻤﺎل‬
‫ﺧﺎرﺟﻲ ‪.Exterior Extrapolation‬‬

‫‪Mustansirayah University, Collage of Science, Physics Department 2020-2021‬‬ ‫‪Page 5‬‬


‫‪CH-8‬‬ ‫‪Dr. Elham Jasim Mohammad‬‬

‫وﻓﻲ اﻻﺳﺘﯿﻔﺎء أﺣﺎدي اﻟﺒﻌﺪ ﯾﻜﻮن ﻟﻜﻞ ﻧﻘﻄﺔ ﻣﺘﻐﯿﺮ واﺣﺪ ﻣﺴﺘﻘﻞ ‪ x‬وﻣﺘﻐﯿﺮ ﻣﻌﺘﻤﺪ واﺣﺪ ‪ .y‬أﻣﺎ ﻓﻲ اﻻﺳﺘﯿﻔﺎء‬
‫ﺛﻨﺎﺋﻲ اﻷﺑﻌﺎد ﻓﻠﻜﻞ ﻧﻘﻄﺔ ﻣﺘﻐﯿﺮﯾﻦ ﻣﺴﺘﻘﻠﯿﻦ ‪ x‬و ‪ y‬وﻣﺘﻐﯿﺮ ﻣﻌﺘﻤﺪ واﺣﺪ ‪.z‬‬

‫أﻧﻮاع اﻻﺳﺘﯿﻔﺎء أو اﻻﺳﺘﻜﻤﺎل‬


‫‪n‬‬
‫‪ .1‬اﻻﺳﺘﻜﻤﺎل اﻟﺨﻄﻲ ‪ :Linear Interpolation‬ﺗﺴﻤﻰ اﻟﺪاﻟﺔ ‪ p ( x)  a0  a1x  a2 x  ......  an x‬ﺑﺪاﻟﺔ‬
‫ﻣﺘﻌﺪدة اﻟﺤﺪود وﺗﺴﻤﻰ ‪ n‬ﺑﺪرﺟﺔ ھﺬه اﻟﺪاﻟﺔ‪ .‬وﻓﻲ ﺣﺎﻟﺔ ‪ n  1‬ﺗﻤﺜﻞ )‪ p (x‬ﺧﻄﺎ ً ﻣﺴﺘﻘﯿﻤﺎ ً وﻛﻤﺎ ھﻮ ﻣﻌﻠﻮم ﻓﺈﻧﮫ‬
‫ﯾﻜﻔﻲ ﻟﺘﺤﺪﯾﺪ اﻟﺨﻂ اﻟﻤﺴﺘﻘﯿﻢ ﻧﻘﻄﺘﺎن ﯾﻤﺮ ﺑﮭﻤﺎ وﯾﺴﻤﻰ ﻓﻲ ھﺬه اﻟﺤﺎﻟﺔ ﺑﺨﻂ اﻻﺳﺘﻜﻤﺎل ‪Line Interpolation‬‬
‫ﺣﯿﺚ ﯾﻤﻜﻦ اﺳﺘﻌﻤﺎﻟﮫ ﻟﺘﻘﺪﯾﺮ اﺳﺘﻜﻤﺎل ﻧﻘﻄﺔ ﺛﺎﻟﺜﺔ‪.‬‬
‫‪ .2‬اﻻﺳﺘﻜﻤﺎل أﻟﺘﺮﺑﯿﻌﻲ ‪ :Quadratic Interpolation‬ھﻮ ﻋﻤﻠﯿﺔ إﯾﺠﺎد ﻛﺜﯿﺮة اﻟﺤﺪود ﻣﻦ اﻟﺪرﺟﺔ اﻟﺜﺎﻧﯿﺔ‬
‫)اﻟﻘﻄﻊ اﻟﻤﻜﺎﻓﺊ( ‪ p ( x)  a0  a1 x  a2 x 2‬وھﻨﺎ ﯾﻜﻮن ﻟﺪﯾﻨﺎ ﺛﻼﺛﺔ ﻣﻌﺎﻣﻼت ‪ a0 , a1 , a2‬اﻟﻤﺎرة ﺑﺎﻟﻨﻘﺎط اﻟﺜﻼﺛﺔ‪:‬‬
‫) ‪. ( x1 , y1 ), ( x2 , y2 ) ( x0 , y0‬‬
‫‪ .3‬اﻻﺳﺘﻜﻤﺎل اﻟﺘﻜﻌﯿﺒﻲ ‪cubic Interpolation‬‬
‫‪ .4‬اﻻﺳﺘﻜﻤﺎل اﻟﻌﻜﺴﻲ ‪Inverse Matrix‬‬

‫اﻟﺼﯿﻐﺔ اﻟﻌﺎﻣﺔ‬
‫ﯾُﻄﻠﻖ ﻋﻠﻰ أﺑﺴﻂ طﺮﯾﻘﺔ ﻟﻼﺳﺘﯿﻔﺎء اﺳﻢ اﺳﺘﯿﻔﺎء اﻟﺸﺮﯾﺤﺔ اﻟﺨﻄﯿﺔ‪ ،‬وﻓﻲ ھﺬه اﻟﻄﺮﯾﻘﺔ واﻟﻤﻮﺿﺤﺔ ﻓﻲ اﻟﺸﻜﻞ‬
‫أدﻧﺎه‪ ،‬ﺗﺮﺗﺒﻂ ﻛﻞ ﻧﻘﻄﺘﯿﻦ ﻣﺘﺠﺎورﺗﯿﻦ ﺑﺨﻂ ﻣﺴﺘﻘﯿﻢ ﻣﺘﻌﺪد اﻟﺤﺪود ﻣﻦ اﻟﺪرﺟﺔ اﻷوﻟﻰ‪.‬‬

‫ﻣﻌﺎدﻟﺔ ﺧﻂ ﻣﺴﺘﻘﯿﻢ ﯾﻤﺮ ﻋﺒﺮ ﻧﻘﻄﺘﯿﻦ ﻣﺘﺠﺎورﺗﯿﻦ ﺗﻌﻄﻰ ﺑﺎﻟﻤﻌﺎدﻟﺔ‪:‬‬

‫ﺗﺘﻢ ﻋﻤﻠﯿﺔ اﻻﺳﺘﻜﻤﺎل اﻟﺪاﺧﻠﻲ أﺣﺎدي اﻟﺒﻌﺪ ﻓﻲ ‪ MATLAB‬ﺑﺎﺳﺘﺨﺪام اﻟﺪاﻟﺔ ‪ interp1‬واﻟﺘﻲ ﺗﺄﺧﺬ اﻟﺸﻜﻞ‬
‫اﻟﺘﺎﻟﻲ )ﺻﻔﺤﺔ ‪:(276‬‬

‫ﺣﯿﺚ‪:‬‬
‫ﯾﺠﺐ أن ﯾﻜﻮن ‪ x‬ﻣﺘﺠﮭًﺎ ﻣﻊ ﻋﻨﺎﺻﺮ ﺑﺘﺮﺗﯿﺐ ﺗﺼﺎﻋﺪي أو ﺗﻨﺎزﻟﻲ‪.‬‬
‫ﯾﻤﻜﻦ أن ﯾﻜﻮن ‪ xi‬ﻋﺪدا )اﻻﺳﺘﻜﻤﺎل ﻟﻨﻘﻄﺔ واﺣﺪة( أو ﻣﺘﺠﮫ )اﻻﺳﺘﻜﻤﺎل ﻟﻌﺪد ﻣﻦ اﻟﻨﻘﺎط( و ‪ yi‬ھﻮ ﻋﺪد أو ﻣﺘﺠﮫ‬
‫ﺑﻘﯿﻢ اﻻﺳﺘﻜﻤﺎل اﻟﻤﻘﺎﺑﻠﺔ‪.‬‬
‫ﯾﻤﻜﻨﻨﺎ ‪ MATLAB‬ﻣﻦ اﻟﻘﯿﺎم ﺑﺎﻻﺳﺘﯿﻔﺎء ﺑﺎﺳﺘﺨﺪام واﺣﺪ ﻣﻦ ﻋﺪة طﺮق ﯾﻤﻜﻦ ﺗﺤﺪﯾﺪھﺎ وﺗﺘﻀﻤﻦ ھﺬه اﻟﻄﺮق‪:‬‬

‫‪Mustansirayah University, Collage of Science, Physics Department 2020-2021‬‬ ‫‪Page 6‬‬


‫‪CH-8‬‬ ‫‪Dr. Elham Jasim Mohammad‬‬

‫‪ :’nearest’ .1‬اﻷﻗﺮب ﺗﻘﻮم ﺑﺈرﺟﺎع ﻗﯿﻤﺔ ﻧﻘﻄﺔ اﻟﺒﯿﺎﻧﺎت اﻷﻗﺮب إﻟﻰ اﻟﻨﻘﻄﺔ اﻟﻤﺤﻮﻟﺔ‪.‬‬
‫‪ :’linear’ .2‬ﯾﺴﺘﺨﺪم ﺷﺮﯾﺤﺔ اﻻﺳﺘﯿﻔﺎء اﻟﺨﻄﻲ‪.‬‬
‫‪ :’spline’ .3‬ﯾﺴﺘﺨﺪم اﻻﺳﺘﯿﻔﺎء اﻟﻤﻜﻌﺐ‪.‬‬
‫‪ :’pchip’ .4‬ﺗﺴﺘﺨﺪم اﻻﺳﺘﯿﻔﺎء اﻟﻤﻜﻌﺐ اﻟﮭﺮﻣﻲ وﯾﺴﻤﻰ أﯾﻀﺎ اﻟﻤﻜﻌﺐ‪.‬‬
‫ﻣﻼﺣﻈﺎت‪:‬‬
‫‪ .1‬ﻋﻨﺪ اﺳﺘﺨﺪام اﻟﻄﺮق ’‪ ’nearest‬و ’‪ ،’linear‬ﯾﺠﺐ أن ﺗﻜﻮن ﻗﯿﻤﺔ ‪ xi‬ﺿﻤﻦ ﻣﺠﺎل‬
‫‪x‬وإذا ﺗﻢ اﺳﺘﺨﺪام أﺳﺎﻟﯿﺐ’‪ ’spline‬أو ’‪ ’pchip‬ﯾﻤﻜﻦ أن ﺗﺤﺘﻮي ‪ xi‬ﻋﻠﻰ ﻗﯿﻢ ﺧﺎرج ﻧﻄﺎق‬
‫‪x‬وﺗﻘﻮم اﻟﺪاﻟﺔ ‪ interp1‬ﺑﺈﺟﺮاء ﻋﻤﻠﯿﺔ اﺳﺘﻘﺮاء ‪.Extrapolation‬‬
‫‪ .2‬ﯾﻤﻜﻦ أن ﺗﻌﻄﻲ طﺮﯾﻘﺔ ’‪ ’spline‬أﺧﻄﺎء ﻛﺒﯿﺮة إذا ﻛﺎﻧﺖ ﻧﻘﺎط ﺑﯿﺎﻧﺎت اﻹدﺧﺎل ﻏﯿﺮ ﻣﻨﺘﻈﻤﺔ‪،‬‬
‫ﺑﺤﯿﺚ ﺗﻜﻮن ﺑﻌﺾ اﻟﻨﻘﺎط أﻗﺮب ﻣﻦ ﺑﻌﻀﮭﺎ اﻟﺒﻌﺾ‪.‬‬
‫‪ .3‬ﻋﻠﻤﺎ إن ﻣﻮاﺻﻔﺎت اﻟﻄﺮﯾﻘﺔ اﺧﺘﯿﺎرﯾﺔ وإذا ﻟﻢ ﯾﺘﻢ ﺗﺤﺪﯾﺪ أي طﺮﯾﻘﺔ‪ ،‬ﻓﯿﻜﻮن اﻹﻋﺪاد اﻻﻓﺘﺮاﺿﻲ ھﻮ‬
‫ﺧﻄﻲ‪.‬‬
‫‪8.4 Examples of MATLAB Applications‬‬
‫ﻣﺜﺎل رﻗﻢ )‪ (1‬ﺻﻔﺤﺔ رﻗﻢ ) ‪(262‬‬
‫‪For the polynomial:‬‬ ‫‪.‬‬
‫‪(a) Calculate‬‬ ‫‪.‬‬
‫‪(b) Plot the polynomial for‬‬
‫‪(c) The roots of the polynomial.‬‬
‫‪(d) the coefficients of the polynomial.‬‬
‫اﻟﺒﺮﻧﺎﻣﺞ‪:‬‬
‫‪% a‬‬
‫;]‪>> p = [1 -12.1 40.59 -17.015 -71.95 35.88‬‬
‫)‪>> polyval(p,9‬‬

‫‪ans = 7.2611e+003‬‬

‫‪% b‬‬
‫;‪>> x=-1.5:0.1:6.7‬‬
‫;)‪>> y=polyval(p,x‬‬
‫)‪>> plot(x,y‬‬

‫‪% c‬‬
‫;]‪>> p= [1 -12.1 40.59 -17.015 -71.95 35.88‬‬
‫)‪>> r=roots(p‬‬
‫‪r = 6.5000‬‬
‫‪4.0000‬‬
‫‪2.3000‬‬
‫‪-1.2000‬‬
‫‪0.5000‬‬

‫)]‪>> roots([4 10 -8‬‬


‫‪ans = -3.1375‬‬
‫‪0.6375‬‬

‫;]‪>> r=6.5 4 2.3 -1.2 0.5‬‬


‫)‪>> p=poly(r‬‬
‫‪p = 1.0000 -12.1000 40.5900 -17.0150 -71.9500 35.8800‬‬

‫‪Mustansirayah University, Collage of Science, Physics Department 2020-2021‬‬ ‫‪Page 7‬‬


CH-8 Dr. Elham Jasim Mohammad

% d
>> r=6.5 4 2.3 -1.2 0.5];
>> p=poly(r)
p = 1.0000 -12.1000 40.5900 -17.0150 -71.9500 35.8800
(276 ) ‫( ﺻﻔﺤﺔ رﻗﻢ‬2) ‫ﻣﺜﺎل رﻗﻢ‬
The following data points, which are points of the function:
, are given. Use linear, spline, and pchip interpolation
methods to calculate the value of y between the points. Make a figure for each of
the interpolation methods. In the figure show the points, a plot of the function, and
a curve that corresponds to the interpolation method.
x 0 1 2 3 4 5
y 1 -0.6242 -1.4707 3.2406 -0.7366 -6.3717
‫ ﺑﯿﻦ اﻟﻨﻘﺎط ﻟﻠﻘﯿﻢ اﻟﻤﻮﺿﺤﺔ ﻓﻲ اﻟﺠﺪول وارﺳﻢ ﺷﻜﻞ ﺗﻄﺒﯿﻖ طﺮق‬y ‫ﺑﺎﺳﺘﺨﺪام ﺛﻼﺛﺔ طﺮق ﻟﻼﺳﺘﻜﻤﺎل اﺣﺴﺐ ﻗﯿﻢ‬
.‫ وﻓﻲ اﻟﺮﺳﻢ اﺷﺮ ﻟﻠﻨﻘﺎط وارﺳﻢ اﻟﺪاﻟﺔ وارﺳﻢ اﺿﺒﻂ ﻣﻨﺤﻨﻲ ﯾﻤﺮ ﺑﺎﻟﻨﻘﺎط‬.‫اﻻﺳﺘﻜﻤﺎل اﻟﺜﻼﺛﺔ اﻟﻤﺸﺎر ﻟﮭﺎ‬
:‫اﻟﺒﺮﻧﺎﻣﺞ‬
% ‫إﻧﺸﺎء اﻟﻤﺘﺠﮭﺎت‬
x=0:1.0:5;
y=[1.0 -0.6242 -1.4707 3.2406 -0.7366 -6.3717];
xi=0:0.1:5;
% ‫ ﻣﻦ ﺛﻼﺛﺔ اﻧﻮاع ﻟﻼﺳﺘﻜﻤﺎل‬y ‫ﺣﺴﺎب ﻧﻘﺎط‬
yilin=interp1(x,y,xi,'linear');
yispl=interp1(x,y,xi,'spline');
yipch=interp1(x,y,xi,'pchip');
% ‫ ﻣﻦ ﺗﻄﺒﯿﻖ اﻟﺪاﻟﺔ اﻟﻤﻌﻄﺎة ﻓﻲ اﻟﺴﺆال‬y ‫ﺣﺴﺎب‬
yfun=1.5.^xi.*cos(2*xi);
subplot(1,3,1)
plot(x,y,'o',xi,yfun,xi,yilin,'--');
subplot(1,3,2)
plot(x,y,'o',xi,yfun,xi,yispl,'--');
subplot(1,3,3)
plot(x,y,'o',xi,yfun,xi,yipch,'--');

(281 ) ‫( ﺻﻔﺤﺔ رﻗﻢ‬3) ‫ﻣﺜﺎل رﻗﻢ‬


The outside dimensions of a rectangular box (bottom and four sides, no top), made
of aluminum, are 24 by 12 by 4 inches. The wall
thickness of the bottom and the sides is x. Derive an
expression that relates the weight of the box and the
wall thickness x. Determine the thickness x for a box

Mustansirayah University, Collage of Science, Physics Department 2020-2021 Page 8


CH-8 Dr. Elham Jasim Mohammad

that weighs 15 lb. The specific weight of aluminum is 0.101 lb/in3. The volume of
the aluminum VAl is calculated from: , where γ is the specific weight.
‫ ﻓﻲ‬24 ‫ ھﻲ‬،‫ ﻣﺼﻨﻮﻋﺔ ﻣﻦ اﻷﻟﻤﻨﯿﻮم‬،(‫ ﺑﺪون ﻗﻤﺔ‬،‫اﻷﺑﻌﺎد اﻟﺨﺎرﺟﯿﺔ ﻟﺼﻨﺪوق ﻣﺴﺘﻄﯿﻞ )أﺳﻔﻞ وأرﺑﻌﺔ ﺟﻮاﻧﺐ‬
x ‫ اﺷﺘﻖ ﺗﻌﺒﯿﺮ ًا ﯾﺮﺑﻂ وزن اﻟﺼﻨﺪوق وﺳﻤﻚ اﻟﺠﺪار‬.x ‫ ﺳﻤﻚ اﻟﺠﺪار ﻣﻦ اﻟﻘﺎع واﻟﺠﺎﻧﺒﯿﻦ ھﻮ‬.‫ أﻧﺞ‬4 ‫ ﻓﻲ‬12
‫ وﺣﺠﻢ‬.0.101 lb/in3 ‫ ﻋﻠﻤﺎ إن اﻟﻮزن اﻟﻤﺤﺪد ﻟﻸﻟﻤﻨﯿﻮم ھﻮ‬. ً ‫رطﻼ‬15 ‫ ﻟﻠﺼﻨﺪوق اﻟﺬي ﯾﺰن‬x ‫وﺣﺪد اﻟﺴﻤﻚ‬
.‫ ﺗﻤﺜﻞ اﻟﻮزن اﻟﻨﻮﻋﻲ‬γ ‫و‬ ‫اﻷﻟﻤﻨﯿﻮم ﯾﺤﺴﺐ ﻣﻦ اﻟﻌﻼﻗﺔ‬

:‫اﻟﺒﺮﻧﺎﻣﺞ‬
W=15; gamma=0.101;
% ‫ﻧﺤﺴﺐ ﺣﺠﻢ اﻻﻟﻤﻨﯿﻮم‬
VAlum=W/gamma;
% VAl = 24 . 12 . 4 – (24 – 2x) (12 – 2x) (4 – x)
a=[-2 24]; % 24 – 2x :a ‫ﻣﺘﻌﺪد اﻟﺤﺪود ل‬
b=[-2 12]; % 12 – 2x :b ‫ﻣﺘﻌﺪد اﻟﺤﺪود ل‬
c=[-1 4]; %4–x :c ‫ﻣﺘﻌﺪد اﻟﺤﺪود ل‬
% ‫ﻧﺠﺮي ﻋﻤﻠﯿﺔ اﻟﻀﺮب ﻟﻤﺘﻌﺪدات اﻟﺤﺪود اﻟﺜﻼﺛﺔ اﻋﻼه‬
Vin=conv(c, conv(a,b));
% Vin ‫( اﻟﻰ‬VAl – 24*12*4) :‫ﻧﻀﯿﻒ اﻟﻤﻘﺪار‬
polyeq=[0 0 0 (VAlum-24*12*4)]+Vin
% ‫ﻧﺤﺪد ﺟﺬر ﻣﺘﻌﺪد اﻟﺤﺪود‬
x=roots(polyeq)
:‫اﻟﻨﺎﺗﺞ‬
% – 4x3 + 88x2 – 576x + 148.515 :‫ﻣﺘﻌﺪد اﻟﺤﺪود ھﻮ‬
polyeq =
-4.0000 88.0000 -576.0000 148.5149
% ‫ واﻟﺬي ﯾﻤﺜﻞ ﺳﻤﻚ ﺟﺪار اﻻﻟﻤﻨﯿﻮم‬0.2687 ‫ﻣﺘﻌﺪد اﻟﺤﺪود ﯾﻤﺘﻠﻚ ﺟﺬر ﺣﻘﯿﻘﻲ واﺣﺪ ھﻮ‬
x =
10.8656 + 4.4831i
10.8656 - 4.4831i
0.2687
(282) ‫( ﺻﻔﺤﺔ رﻗﻢ‬4) ‫ﻣﺜﺎل رﻗﻢ‬
An aluminum thin-walled sphere is used as a marker buoy. The sphere has a radius
of 60 cm and a wall thickness of 12 mm. The density of aluminum is
kg/m3. The buoy is placed in the ocean, where the density of the water is 1030
kg/m3. According to Archimedes’ law, the weight of
the sphere is given by:
, where
is the volume of the aluminum; and are the
outside and inside radii of the sphere, respectively;
and is the gravitational acceleration.. The weight
of the water that is displaced by the spherical portion that is submerged is given
by: and setting the two
weights equal to each other gives the following equation:
Mustansirayah University, Collage of Science, Physics Department 2020-2021 Page 9
CH-8 Dr. Elham Jasim Mohammad

. Determine the height h between the top


of the buoy and the surface of the water.
‫ ﻛﺜﺎﻓﺔ‬.‫ ﻣﻠﻢ‬12 ‫ ﺳﻢ وﯾﺒﻠﻎ ﺳﻤﻚ اﻟﺠﺪار‬60 ‫ ﯾﺒﻠﻎ ﻗﻄﺮ اﻟﻜﺮة‬.‫ﯾﺘﻢ اﺳﺘﺨﺪام ﻛﺮة أﻟﻤﻨﯿﻮم رﻗﯿﻘﺔ اﻟﺠﺪران ﻛﻌﻼﻣﺔ‬
‫ وطﺒﻘﺎ ﻟﻘﺎﻋﺪة‬.1030 kg/m3 ‫ ﺣﯿﺚ ﻛﺜﺎﻓﺔ اﻟﻤﺎء‬،‫ وﺗﻮﺿﻊ ھﺬه اﻟﻜﺮة ﻓﻲ اﻟﻤﺤﯿﻂ‬kg/m3 ‫اﻷﻟﻤﻨﯿﻮم ھﻲ‬
.‫ ﺑﯿﻦ ﻗﻤﺔ اﻟﻜﺮة وﺳﻄﺢ اﻟﻤﺎء‬h ‫ ﺣﺪد اﻻرﺗﻔﺎع‬.‫ارﺧﻤﯿﺪس ﻓﺄن وزن اﻟﻜﺮة ﯾﻌﻄﻰ ﺑﺎﻟﻌﻼﻗﺔ‬

:‫اﻟﺒﺮﻧﺎﻣﺞ‬
% ‫ادﺧﺎل ﻗﯿﻢ اﻟﻘﻄﺎر‬
rout=0.60; rin=0.588;
% ‫ادﺧﺎل ﻗﯿﻢ ﻛﺜﺎﻓﺔ اﻟﻤﺘﻐﯿﺮات‬
rhoalum=2690; rhowtr=1030;
% a0 ‫اﯾﺠﺎد اﻟﻤﻌﺎﻣﻞ‬
a0=4*rout^3-4*rhoalum*(rout^3-rin^3)/rhowtr;
% ‫اﯾﺠﺎد ﻣﻌﺎﻣﻼت ﻣﺘﻌﺪد اﻟﺤﺪود‬
p = [1 -3*rout 0 a0];
% ‫اﯾﺠﺎد ﺟﺬر ﻣﺘﻌﺪد اﻟﺤﺪود‬
h = roots(p)
:‫اﻟﻨﺎﺗﺞ‬
% 0.9029 ‫ﻣﺘﻌﺪد اﻟﺤﺪود ﯾﻤﺘﻠﻚ ﺛﻼﺛﺔ ﺟﺬور واﻟﺠﺬر اﻟﻤﺴﻤﻮح ﺑﮫ ﻓﯿﺰﯾﺎﺋﯿﺎ ھﻮ‬
h =
1.4542
0.9029
-0.5570

(283 ) ‫( ﺻﻔﺤﺔ رﻗﻢ‬5) ‫ﻣﺜﺎل رﻗﻢ‬


An electrical capacitor has an unknown capacitance. In order to determine its
capacitance it is connected to the circuit shown. The switch is first connected to B
and the capacitor is charged. Then, the switch is connected to A and the capacitor
discharges through the resistor. As the capacitor is discharging, the voltage across
the capacitor is measured for 10 s in intervals of 1 s. When a capacitor discharges
through a resistor, the voltage of the capacitor as a function of time is given by:
, where is the initial voltage, R the resistance of the resistor, and
C the capacitance of the capacitor. The recorded measurements are given in the
table below. Plot the voltage as a function of time and determine the capacitance of
the capacitor by fitting an exponential curve to the data points.

t (s) 1 2 3 4 5 6 7 8 9 10
V (V) 9.4 7.31 5.15 3.55 2.81 2.04 1.26 0.97 0.74 0.58

‫ وﻣﻦ أﺟﻞ ﺗﺤﺪﯾﺪ اﻟﺴﻌﺔ اﻟﺨﺎﺻﺔ ﺑﮫ‬.‫ﻣﻜﺜﻒ ﻛﮭﺮﺑﺎﺋﻲ ﻟﺪﯾﮫ ﺳﻌﺔ ﻣﺠﮭﻮﻟﺔ‬
B ‫ ﻓﻲ اﻟﺒﺪاﯾﺔ ﺗﻢ ﺗﻮﺻﯿﻞ اﻟﻤﻔﺘﺎح ﺑـ‬.‫ﺗﻢ ﺗﻮﺻﯿﻠﮫ ﺑﺎﻟﺪاﺋﺮة اﻟﻤﻌﺮوﺿﺔ‬
‫ وﺗﻢ ﺗﻔﺮﯾﻎ اﻟﻤﻜﺜﻒ ﻋﺒﺮ‬A ‫ ﺛﻢ ﺗﻢ ﺗﻮﺻﯿﻞ اﻟﻤﻔﺘﺎح إﻟﻰ‬.‫وﺷﺤﻦ اﻟﻤﻜﺜﻒ‬
1 ‫ ﺛﺎﻧﯿﺔ ﺧﻼل ﻓﺘﺮة‬10 ‫ وﺗﻢ ﻗﯿﺎس اﻟﺠﮭﺪ ﻋﺒﺮ اﻟﻤﻜﺜﻒ ﻟﻤﺪة‬.‫اﻟﻤﻘﺎوم‬
‫ ﯾﺘﻢ إﻋﻄﺎء ﺟﮭﺪ اﻟﻤﻜﺜﻒ‬،‫ وﻋﻨﺪﻣﺎ ﯾﺘﻢ ﺗﻔﺮﯾﻎ ﻣﻜﺜﻒ ﻋﺒﺮ اﻟﻤﻘﺎوم‬. ‫ﺛﺎﻧﯿﺔ‬
‫ واﻟﻘﯿﺎﺳﺎت اﻟﻤﺴﺠﻠﺔ ﻣﻌﺮوﺿﺔ ﻓﻲ‬.‫ﻛﺪاﻟﺔ ﻟﻠﻮﻗﺖ ﺑﻮاﺳﻄﺔ اﻟﻌﻼﻗﺔ‬

Mustansirayah University, Collage of Science, Physics Department 2020-2021 Page 10


CH-8 Dr. Elham Jasim Mohammad

.‫ ارﺳﻢ اﻟﺠﮭﺪ ﻛﺪاﻟﺔ ﻟﻠﻮﻗﺖ وﺣﺪد ﺳﻌﺔ اﻟﻤﻜﺜﻒ ﻣﻦ ﺧﻼل ﺿﺒﻂ ﻣﻨﺤﻨﻲ أﺳﻲ ﻟﻨﻘﺎط اﻟﺒﯿﺎﻧﺎت‬.‫اﻟﺠﺪول أدﻧﺎه‬
:‫اﻟﺒﺮﻧﺎﻣﺞ‬
R=2000;
t=1:10;
v=[9.4 7.31 5.15 3.55 2.81 2.04 1.26 0.97 0.74 0.58];
% polyfit ‫اﺳﺘﺨﺪام داﻟﺔ‬
p=polyfit(t,log(v),1);
% y= mx +b :‫ ﻓﻲ اﻟﻤﻌﺎدﻟﺔ‬b‫ و‬m ‫ واﻟﺘﻲ ﺗﻘﺎﺑﻞ ﻗﯿﻢ‬V0‫ و‬C ‫ﺣﺴﺎب ﻗﯿﻢ‬
C=-1/(R*p(1))
V0=exp(p(2))
% ‫اﻧﺸﺎء ﻣﺘﺠﮭﺎت ﻟﺮﺳﻢ اﻟﺪاﻟﺔ‬
tplot=0:0.1:10;
vplot=V0*exp(-tplot./(R*C));
plot(t,v,'o',tplot,vplot)

:‫اﻟﻨﺎﺗﺞ‬
C =
0.0016
V0 =
13.2796

Mustansirayah University, Collage of Science, Physics Department 2020-2021 Page 11

You might also like