SlideShare una empresa de Scribd logo
1 de 4
Assignment (3)


Q1. Solve the integral                          using paper and pen or calculator, and
then compare the answer to the computational method using the Romberg method.

Solution



= [x6 /6 + x5 /5 + x4/ 4 + ex]

={ [1/6 (4)6 + 1/5 (4)5 + 1/4(4)4 + e4] –[1/6 (0.5)6 + 1/5 (0.5)5 + 1/4(0.5)4 + e5] }

= (1006.06) –(1.752865) = 1004.3071



function [q,ea,iter]=romberg(func,a,b,es,maxit,varargin)
% if nargin<3,error('at least 3arguments required'),end
if nargin<4||isempty(es),es=0.000001;end
if nargin<5||isempty(maxit),maxit=50;end
n=1;
r(1,1) = trap(func,a,b,n,varargin{:});
iter=0;
while iter<maxit
   iter=iter+1;
   n=2^iter;
   I(iter+1,1)=trap(func,a,b,n,varargin{:});
   for k=2:iter+1
      j=2+iter-k;
      I(j,k)=(4^(k-1)*I(j+1,k-1)-I(j,k-1))/(4^(k-1)-1);
   end
   ea=abs((I(1,iter+1)-I(2,iter))/I(1,iter+1))*100;
   if ea<=es, break; end
end
q=I(1,iter+1);



function I=trap(func,a,b,n,varargin)
if(nargin<3)
   error('at least 3 input arguments required');
end
if ~(b>a),error('upper bound must be greater than lower'),end
if nargin<4||isempty(n),n=100;end

  x=a; h=(b-a)/n;

    s=func(a,varargin{:});
      for i=1:n-1
        x=x+h;
     s=s+2*func(x,varargin{:});
   end
  s=s+func(b,varargin{:});
  I=(b-a)*s/(2*n);


>> f=@(x) x^5+x^4+x^3+exp(x);



>> romberg(f,0.5,4)



ans =



 1.0044e+003
Q2. Calculate the integral                    dt. The exact answer to this integral is
15.41260804810169. Solve the integral using the Romberg method



Solution


function [q,ea,iter]=romberg(func,a,b,es,maxit,varargin)
% if nargin<3,error('at least 3arguments required'),end
if nargin<4||isempty(es),es=0.000001;end
if nargin<5||isempty(maxit),maxit=50;end
n=1;
r(1,1) = trap(func,a,b,n,varargin{:});
iter=0;
while iter<maxit
   iter=iter+1;
   n=2^iter;
   I(iter+1,1)=trap(func,a,b,n,varargin{:});
   for k=2:iter+1



     j=2+iter-k;
     I(j,k)=(4^(k-1)*I(j+1,k-1)-I(j,k-1))/(4^(k-1)-1);
  end
  ea=abs((I(1,iter+1)-I(2,iter))/I(1,iter+1))*100;
  if ea<=es, break; end
end
q=I(1,iter+1);

function I=trap(func,a,b,n,varargin)
if(nargin<3)
   error('at least 3 input arguments required');
end
if ~(b>a),error('upper bound must be greater than lower'),end
if nargin<4||isempty(n),n=100;end
   x=a; h=(b-a)/n;
   s=func(a,varargin{:});
   for i=1:n-1
      x=x+h;
      s=s+2*func(x,varargin{:});
   end
   s=s+func(b,varargin{:});
   I=(b-a)*s/(2*n);
>> f=@(t) (10*exp(-t)*sin(2*pi*t))^2


>> romberg (f,0,0.5)


ans =


 15.4126

Más contenido relacionado

La actualidad más candente

Jan. 6 Inverse Functions
Jan. 6 Inverse FunctionsJan. 6 Inverse Functions
Jan. 6 Inverse FunctionsRyanWatt
 
Laplace periodic function
Laplace periodic functionLaplace periodic function
Laplace periodic functionKaushal Surti
 
The Moore-Spiegel Oscillator
The Moore-Spiegel OscillatorThe Moore-Spiegel Oscillator
The Moore-Spiegel OscillatorAbhranil Das
 
Application of derivatives
Application of derivativesApplication of derivatives
Application of derivativesindu thakur
 
Application of differentiation
Application of differentiationApplication of differentiation
Application of differentiationLily Maryati
 
APPLICATION OF PARTIAL DIFFERENTIATION
APPLICATION OF PARTIAL DIFFERENTIATIONAPPLICATION OF PARTIAL DIFFERENTIATION
APPLICATION OF PARTIAL DIFFERENTIATIONDhrupal Patel
 
Newton cotes integration method
Newton cotes integration  methodNewton cotes integration  method
Newton cotes integration methodshashikant pabari
 
application of partial differentiation
application of partial differentiationapplication of partial differentiation
application of partial differentiationeteaching
 
Math - Operations on Functions, Kinds of Functions
Math - Operations on Functions, Kinds of FunctionsMath - Operations on Functions, Kinds of Functions
Math - Operations on Functions, Kinds of FunctionsChuckie Balbuena
 
Lecture 18 antiderivatives - section 4.8
Lecture 18   antiderivatives - section 4.8Lecture 18   antiderivatives - section 4.8
Lecture 18 antiderivatives - section 4.8njit-ronbrown
 
5.7 rolle's thrm & mv theorem
5.7 rolle's thrm & mv theorem5.7 rolle's thrm & mv theorem
5.7 rolle's thrm & mv theoremdicosmo178
 
Inverse Functions
Inverse FunctionsInverse Functions
Inverse Functionsswartzje
 
Polynomial And Rational Funciotns 0921
Polynomial And Rational Funciotns 0921Polynomial And Rational Funciotns 0921
Polynomial And Rational Funciotns 0921ingroy
 

La actualidad más candente (20)

Jan. 6 Inverse Functions
Jan. 6 Inverse FunctionsJan. 6 Inverse Functions
Jan. 6 Inverse Functions
 
Laplace periodic function
Laplace periodic functionLaplace periodic function
Laplace periodic function
 
The Moore-Spiegel Oscillator
The Moore-Spiegel OscillatorThe Moore-Spiegel Oscillator
The Moore-Spiegel Oscillator
 
Application of derivatives
Application of derivativesApplication of derivatives
Application of derivatives
 
Application of differentiation
Application of differentiationApplication of differentiation
Application of differentiation
 
Es272 ch6
Es272 ch6Es272 ch6
Es272 ch6
 
APPLICATION OF PARTIAL DIFFERENTIATION
APPLICATION OF PARTIAL DIFFERENTIATIONAPPLICATION OF PARTIAL DIFFERENTIATION
APPLICATION OF PARTIAL DIFFERENTIATION
 
Newton cotes integration method
Newton cotes integration  methodNewton cotes integration  method
Newton cotes integration method
 
residue
residueresidue
residue
 
Taylor series
Taylor seriesTaylor series
Taylor series
 
application of partial differentiation
application of partial differentiationapplication of partial differentiation
application of partial differentiation
 
Math - Operations on Functions, Kinds of Functions
Math - Operations on Functions, Kinds of FunctionsMath - Operations on Functions, Kinds of Functions
Math - Operations on Functions, Kinds of Functions
 
Lecture 18 antiderivatives - section 4.8
Lecture 18   antiderivatives - section 4.8Lecture 18   antiderivatives - section 4.8
Lecture 18 antiderivatives - section 4.8
 
5.7 rolle's thrm & mv theorem
5.7 rolle's thrm & mv theorem5.7 rolle's thrm & mv theorem
5.7 rolle's thrm & mv theorem
 
Inverse Functions
Inverse FunctionsInverse Functions
Inverse Functions
 
Inverse functions
Inverse functionsInverse functions
Inverse functions
 
Polynomial And Rational Funciotns 0921
Polynomial And Rational Funciotns 0921Polynomial And Rational Funciotns 0921
Polynomial And Rational Funciotns 0921
 
Fourier series
Fourier series Fourier series
Fourier series
 
Lecture6
Lecture6Lecture6
Lecture6
 
Inverse Functions
Inverse FunctionsInverse Functions
Inverse Functions
 

Destacado

Are you paying attention presentation assignment #2-a crash course in creativ...
Are you paying attention presentation assignment #2-a crash course in creativ...Are you paying attention presentation assignment #2-a crash course in creativ...
Are you paying attention presentation assignment #2-a crash course in creativ...Seth Schalet
 
1.2. pruebas de hipótesis de una muestra parte 2
1.2. pruebas de hipótesis de una muestra parte 21.2. pruebas de hipótesis de una muestra parte 2
1.2. pruebas de hipótesis de una muestra parte 2alexis cañez
 
сетевые информационные технологии
сетевые информационные технологиисетевые информационные технологии
сетевые информационные технологииLazzerChel
 
Demmons creative 2011_small
Demmons creative 2011_smallDemmons creative 2011_small
Demmons creative 2011_smallMichael Demmons
 
De kiemtra 1 tiết lop 10
De kiemtra 1 tiết lop 10De kiemtra 1 tiết lop 10
De kiemtra 1 tiết lop 10nhom05vb2
 
Sponsorship opportunities at big boys toys 2012
Sponsorship opportunities at big boys toys 2012Sponsorship opportunities at big boys toys 2012
Sponsorship opportunities at big boys toys 2012Big Boys Toys UAE
 
Autism training-powerpoint
Autism training-powerpointAutism training-powerpoint
Autism training-powerpointdenisebur
 
Experimental Design
Experimental DesignExperimental Design
Experimental Designcoachsmb05
 
Roseland proposal
Roseland proposalRoseland proposal
Roseland proposalandymag1
 
Epic poetry battles of history!
Epic poetry battles of history!Epic poetry battles of history!
Epic poetry battles of history!Amanda Villalobos
 
The Yammer Way - Our Product Development Approach
The Yammer Way - Our Product Development ApproachThe Yammer Way - Our Product Development Approach
The Yammer Way - Our Product Development Approachyann ARMAND
 

Destacado (16)

Who said it
Who said itWho said it
Who said it
 
President powerpoint
President powerpointPresident powerpoint
President powerpoint
 
Bee
BeeBee
Bee
 
Are you paying attention presentation assignment #2-a crash course in creativ...
Are you paying attention presentation assignment #2-a crash course in creativ...Are you paying attention presentation assignment #2-a crash course in creativ...
Are you paying attention presentation assignment #2-a crash course in creativ...
 
Scars identify
Scars identifyScars identify
Scars identify
 
1.2. pruebas de hipótesis de una muestra parte 2
1.2. pruebas de hipótesis de una muestra parte 21.2. pruebas de hipótesis de una muestra parte 2
1.2. pruebas de hipótesis de una muestra parte 2
 
сетевые информационные технологии
сетевые информационные технологиисетевые информационные технологии
сетевые информационные технологии
 
Demmons creative 2011_small
Demmons creative 2011_smallDemmons creative 2011_small
Demmons creative 2011_small
 
De kiemtra 1 tiết lop 10
De kiemtra 1 tiết lop 10De kiemtra 1 tiết lop 10
De kiemtra 1 tiết lop 10
 
Sponsorship opportunities at big boys toys 2012
Sponsorship opportunities at big boys toys 2012Sponsorship opportunities at big boys toys 2012
Sponsorship opportunities at big boys toys 2012
 
Gg ppt
Gg pptGg ppt
Gg ppt
 
Autism training-powerpoint
Autism training-powerpointAutism training-powerpoint
Autism training-powerpoint
 
Experimental Design
Experimental DesignExperimental Design
Experimental Design
 
Roseland proposal
Roseland proposalRoseland proposal
Roseland proposal
 
Epic poetry battles of history!
Epic poetry battles of history!Epic poetry battles of history!
Epic poetry battles of history!
 
The Yammer Way - Our Product Development Approach
The Yammer Way - Our Product Development ApproachThe Yammer Way - Our Product Development Approach
The Yammer Way - Our Product Development Approach
 

Similar a Assignment 3

Intro to Functional Programming Workshop (code4lib)
Intro to Functional Programming Workshop (code4lib)Intro to Functional Programming Workshop (code4lib)
Intro to Functional Programming Workshop (code4lib)Will Kurt
 
Tarea De Scilab By Sebastian Vasquez
Tarea De Scilab By Sebastian VasquezTarea De Scilab By Sebastian Vasquez
Tarea De Scilab By Sebastian VasquezSebastian Vasquez
 
Ejercicios Scilab Completo
Ejercicios Scilab CompletoEjercicios Scilab Completo
Ejercicios Scilab CompletoRicardo Grandas
 
2. Fixed Point Iteration.pptx
2. Fixed Point Iteration.pptx2. Fixed Point Iteration.pptx
2. Fixed Point Iteration.pptxsaadhaq6
 
Introduction to MatLab programming
Introduction to MatLab programmingIntroduction to MatLab programming
Introduction to MatLab programmingDamian T. Gordon
 
MATLABAssignment 2Bracketing (Multiple Roots) (4)Bisection .docx
MATLABAssignment 2Bracketing (Multiple Roots) (4)Bisection .docxMATLABAssignment 2Bracketing (Multiple Roots) (4)Bisection .docx
MATLABAssignment 2Bracketing (Multiple Roots) (4)Bisection .docxandreecapon
 
Introduction to Functional Programming with Haskell and JavaScript
Introduction to Functional Programming with Haskell and JavaScriptIntroduction to Functional Programming with Haskell and JavaScript
Introduction to Functional Programming with Haskell and JavaScriptWill Kurt
 
Solucionario_de_Chapra_y_Canale_Quinta_E.pdf
Solucionario_de_Chapra_y_Canale_Quinta_E.pdfSolucionario_de_Chapra_y_Canale_Quinta_E.pdf
Solucionario_de_Chapra_y_Canale_Quinta_E.pdfJeancarlosPatalasanc
 
Performance Portability Through Descriptive Parallelism
Performance Portability Through Descriptive ParallelismPerformance Portability Through Descriptive Parallelism
Performance Portability Through Descriptive ParallelismJeff Larkin
 
Programación funcional con Haskell
Programación funcional con HaskellProgramación funcional con Haskell
Programación funcional con HaskellSoftware Guru
 
Gamma beta functions-1
Gamma   beta functions-1Gamma   beta functions-1
Gamma beta functions-1Selvaraj John
 
NUMERICAL METHODS WITH MATLAB : bisection,mueller's,newton-raphson,false poin...
NUMERICAL METHODS WITH MATLAB : bisection,mueller's,newton-raphson,false poin...NUMERICAL METHODS WITH MATLAB : bisection,mueller's,newton-raphson,false poin...
NUMERICAL METHODS WITH MATLAB : bisection,mueller's,newton-raphson,false poin...Parhamsagharchi
 
Csci101 lect04 advanced_selection
Csci101 lect04 advanced_selectionCsci101 lect04 advanced_selection
Csci101 lect04 advanced_selectionElsayed Hemayed
 

Similar a Assignment 3 (20)

Intro to Functional Programming Workshop (code4lib)
Intro to Functional Programming Workshop (code4lib)Intro to Functional Programming Workshop (code4lib)
Intro to Functional Programming Workshop (code4lib)
 
Tarea De Scilab By Sebastian Vasquez
Tarea De Scilab By Sebastian VasquezTarea De Scilab By Sebastian Vasquez
Tarea De Scilab By Sebastian Vasquez
 
Ejercicios Scilab Completo
Ejercicios Scilab CompletoEjercicios Scilab Completo
Ejercicios Scilab Completo
 
2. Fixed Point Iteration.pptx
2. Fixed Point Iteration.pptx2. Fixed Point Iteration.pptx
2. Fixed Point Iteration.pptx
 
Taller De Scilab
Taller De ScilabTaller De Scilab
Taller De Scilab
 
Introduction to MatLab programming
Introduction to MatLab programmingIntroduction to MatLab programming
Introduction to MatLab programming
 
MATLABAssignment 2Bracketing (Multiple Roots) (4)Bisection .docx
MATLABAssignment 2Bracketing (Multiple Roots) (4)Bisection .docxMATLABAssignment 2Bracketing (Multiple Roots) (4)Bisection .docx
MATLABAssignment 2Bracketing (Multiple Roots) (4)Bisection .docx
 
Primer Punto
Primer PuntoPrimer Punto
Primer Punto
 
Numerical Method for UOG mech stu prd by Abdrehman Ahmed
Numerical Method for UOG mech stu prd by Abdrehman Ahmed Numerical Method for UOG mech stu prd by Abdrehman Ahmed
Numerical Method for UOG mech stu prd by Abdrehman Ahmed
 
Numerical methods generating polynomial
Numerical methods generating polynomialNumerical methods generating polynomial
Numerical methods generating polynomial
 
Introduction to Functional Programming with Haskell and JavaScript
Introduction to Functional Programming with Haskell and JavaScriptIntroduction to Functional Programming with Haskell and JavaScript
Introduction to Functional Programming with Haskell and JavaScript
 
Solucionario_de_Chapra_y_Canale_Quinta_E.pdf
Solucionario_de_Chapra_y_Canale_Quinta_E.pdfSolucionario_de_Chapra_y_Canale_Quinta_E.pdf
Solucionario_de_Chapra_y_Canale_Quinta_E.pdf
 
Performance Portability Through Descriptive Parallelism
Performance Portability Through Descriptive ParallelismPerformance Portability Through Descriptive Parallelism
Performance Portability Through Descriptive Parallelism
 
Mit6 094 iap10_lec03
Mit6 094 iap10_lec03Mit6 094 iap10_lec03
Mit6 094 iap10_lec03
 
Programación funcional con Haskell
Programación funcional con HaskellProgramación funcional con Haskell
Programación funcional con Haskell
 
Sary
SarySary
Sary
 
Gamma beta functions-1
Gamma   beta functions-1Gamma   beta functions-1
Gamma beta functions-1
 
NUMERICAL METHODS WITH MATLAB : bisection,mueller's,newton-raphson,false poin...
NUMERICAL METHODS WITH MATLAB : bisection,mueller's,newton-raphson,false poin...NUMERICAL METHODS WITH MATLAB : bisection,mueller's,newton-raphson,false poin...
NUMERICAL METHODS WITH MATLAB : bisection,mueller's,newton-raphson,false poin...
 
Csci101 lect04 advanced_selection
Csci101 lect04 advanced_selectionCsci101 lect04 advanced_selection
Csci101 lect04 advanced_selection
 
Millionways
MillionwaysMillionways
Millionways
 

Último

Exploring-Pipe-Flanges-Applications-Types-and-Benefits.pptx
Exploring-Pipe-Flanges-Applications-Types-and-Benefits.pptxExploring-Pipe-Flanges-Applications-Types-and-Benefits.pptx
Exploring-Pipe-Flanges-Applications-Types-and-Benefits.pptxTexas Flange
 
NewBase 17 May 2024 Energy News issue - 1725 by Khaled Al Awadi_compresse...
NewBase   17 May  2024  Energy News issue - 1725 by Khaled Al Awadi_compresse...NewBase   17 May  2024  Energy News issue - 1725 by Khaled Al Awadi_compresse...
NewBase 17 May 2024 Energy News issue - 1725 by Khaled Al Awadi_compresse...Khaled Al Awadi
 
Global Internal Audit Standards 2024.pdf
Global Internal Audit Standards 2024.pdfGlobal Internal Audit Standards 2024.pdf
Global Internal Audit Standards 2024.pdfAmer Morgan
 
Powerpoint showing results from tik tok metrics
Powerpoint showing results from tik tok metricsPowerpoint showing results from tik tok metrics
Powerpoint showing results from tik tok metricsCaitlinCummins3
 
What is paper chromatography, principal, procedure,types, diagram, advantages...
What is paper chromatography, principal, procedure,types, diagram, advantages...What is paper chromatography, principal, procedure,types, diagram, advantages...
What is paper chromatography, principal, procedure,types, diagram, advantages...srcw2322l101
 
Presentation4 (2) survey responses clearly labelled
Presentation4 (2) survey responses clearly labelledPresentation4 (2) survey responses clearly labelled
Presentation4 (2) survey responses clearly labelledCaitlinCummins3
 
Future of Trade 2024 - Decoupled and Reconfigured - Snapshot Report
Future of Trade 2024 - Decoupled and Reconfigured - Snapshot ReportFuture of Trade 2024 - Decoupled and Reconfigured - Snapshot Report
Future of Trade 2024 - Decoupled and Reconfigured - Snapshot ReportDubai Multi Commodity Centre
 
MichaelStarkes_UncutGemsProjectSummary.pdf
MichaelStarkes_UncutGemsProjectSummary.pdfMichaelStarkes_UncutGemsProjectSummary.pdf
MichaelStarkes_UncutGemsProjectSummary.pdfmstarkes24
 
Daftar Rumpun, Pohon, dan Cabang Ilmu (2024).pdf
Daftar Rumpun, Pohon, dan Cabang Ilmu (2024).pdfDaftar Rumpun, Pohon, dan Cabang Ilmu (2024).pdf
Daftar Rumpun, Pohon, dan Cabang Ilmu (2024).pdfAgusHalim9
 
Abortion pills in Muscut<Oman(+27737758557) Cytotec available.inn Kuwait City.
Abortion pills in Muscut<Oman(+27737758557) Cytotec available.inn Kuwait City.Abortion pills in Muscut<Oman(+27737758557) Cytotec available.inn Kuwait City.
Abortion pills in Muscut<Oman(+27737758557) Cytotec available.inn Kuwait City.daisycvs
 
Innomantra Viewpoint - Building Moonshots : May-Jun 2024.pdf
Innomantra Viewpoint - Building Moonshots : May-Jun 2024.pdfInnomantra Viewpoint - Building Moonshots : May-Jun 2024.pdf
Innomantra Viewpoint - Building Moonshots : May-Jun 2024.pdfInnomantra
 
ابو ظبي اعلان | - سايتوتك في الامارات حبوب الاجهاض للبيع ف حبوب الإجهاض ... ا...
ابو ظبي اعلان | - سايتوتك في الامارات حبوب الاجهاض للبيع ف حبوب الإجهاض ... ا...ابو ظبي اعلان | - سايتوتك في الامارات حبوب الاجهاض للبيع ف حبوب الإجهاض ... ا...
ابو ظبي اعلان | - سايتوتك في الامارات حبوب الاجهاض للبيع ف حبوب الإجهاض ... ا...brennadilys816
 
The Truth About Dinesh Bafna's Situation.pdf
The Truth About Dinesh Bafna's Situation.pdfThe Truth About Dinesh Bafna's Situation.pdf
The Truth About Dinesh Bafna's Situation.pdfMont Surfaces
 
The Risks of Ignoring Bookkeeping in Your Business
The Risks of Ignoring Bookkeeping in Your BusinessThe Risks of Ignoring Bookkeeping in Your Business
The Risks of Ignoring Bookkeeping in Your BusinessYourLegal Accounting
 
Toyota Kata Coaching for Agile Teams & Transformations
Toyota Kata Coaching for Agile Teams & TransformationsToyota Kata Coaching for Agile Teams & Transformations
Toyota Kata Coaching for Agile Teams & TransformationsStefan Wolpers
 
stock price prediction using machine learning
stock price prediction using machine learningstock price prediction using machine learning
stock price prediction using machine learninggauravwankar27
 
Top^Clinic ^%[+27785538335__Safe*Women's clinic//Abortion Pills In Harare
Top^Clinic ^%[+27785538335__Safe*Women's clinic//Abortion Pills In HarareTop^Clinic ^%[+27785538335__Safe*Women's clinic//Abortion Pills In Harare
Top^Clinic ^%[+27785538335__Safe*Women's clinic//Abortion Pills In Hararedoctorjoe1984
 
HAL Financial Performance Analysis and Future Prospects
HAL Financial Performance Analysis and Future ProspectsHAL Financial Performance Analysis and Future Prospects
HAL Financial Performance Analysis and Future ProspectsRajesh Gupta
 
Inside the Black Box of Venture Capital (VC)
Inside the Black Box of Venture Capital (VC)Inside the Black Box of Venture Capital (VC)
Inside the Black Box of Venture Capital (VC)Alejandro Cremades
 

Último (20)

Exploring-Pipe-Flanges-Applications-Types-and-Benefits.pptx
Exploring-Pipe-Flanges-Applications-Types-and-Benefits.pptxExploring-Pipe-Flanges-Applications-Types-and-Benefits.pptx
Exploring-Pipe-Flanges-Applications-Types-and-Benefits.pptx
 
NewBase 17 May 2024 Energy News issue - 1725 by Khaled Al Awadi_compresse...
NewBase   17 May  2024  Energy News issue - 1725 by Khaled Al Awadi_compresse...NewBase   17 May  2024  Energy News issue - 1725 by Khaled Al Awadi_compresse...
NewBase 17 May 2024 Energy News issue - 1725 by Khaled Al Awadi_compresse...
 
Global Internal Audit Standards 2024.pdf
Global Internal Audit Standards 2024.pdfGlobal Internal Audit Standards 2024.pdf
Global Internal Audit Standards 2024.pdf
 
Powerpoint showing results from tik tok metrics
Powerpoint showing results from tik tok metricsPowerpoint showing results from tik tok metrics
Powerpoint showing results from tik tok metrics
 
What is paper chromatography, principal, procedure,types, diagram, advantages...
What is paper chromatography, principal, procedure,types, diagram, advantages...What is paper chromatography, principal, procedure,types, diagram, advantages...
What is paper chromatography, principal, procedure,types, diagram, advantages...
 
Presentation4 (2) survey responses clearly labelled
Presentation4 (2) survey responses clearly labelledPresentation4 (2) survey responses clearly labelled
Presentation4 (2) survey responses clearly labelled
 
Future of Trade 2024 - Decoupled and Reconfigured - Snapshot Report
Future of Trade 2024 - Decoupled and Reconfigured - Snapshot ReportFuture of Trade 2024 - Decoupled and Reconfigured - Snapshot Report
Future of Trade 2024 - Decoupled and Reconfigured - Snapshot Report
 
MichaelStarkes_UncutGemsProjectSummary.pdf
MichaelStarkes_UncutGemsProjectSummary.pdfMichaelStarkes_UncutGemsProjectSummary.pdf
MichaelStarkes_UncutGemsProjectSummary.pdf
 
Daftar Rumpun, Pohon, dan Cabang Ilmu (2024).pdf
Daftar Rumpun, Pohon, dan Cabang Ilmu (2024).pdfDaftar Rumpun, Pohon, dan Cabang Ilmu (2024).pdf
Daftar Rumpun, Pohon, dan Cabang Ilmu (2024).pdf
 
Abortion pills in Muscut<Oman(+27737758557) Cytotec available.inn Kuwait City.
Abortion pills in Muscut<Oman(+27737758557) Cytotec available.inn Kuwait City.Abortion pills in Muscut<Oman(+27737758557) Cytotec available.inn Kuwait City.
Abortion pills in Muscut<Oman(+27737758557) Cytotec available.inn Kuwait City.
 
Innomantra Viewpoint - Building Moonshots : May-Jun 2024.pdf
Innomantra Viewpoint - Building Moonshots : May-Jun 2024.pdfInnomantra Viewpoint - Building Moonshots : May-Jun 2024.pdf
Innomantra Viewpoint - Building Moonshots : May-Jun 2024.pdf
 
ابو ظبي اعلان | - سايتوتك في الامارات حبوب الاجهاض للبيع ف حبوب الإجهاض ... ا...
ابو ظبي اعلان | - سايتوتك في الامارات حبوب الاجهاض للبيع ف حبوب الإجهاض ... ا...ابو ظبي اعلان | - سايتوتك في الامارات حبوب الاجهاض للبيع ف حبوب الإجهاض ... ا...
ابو ظبي اعلان | - سايتوتك في الامارات حبوب الاجهاض للبيع ف حبوب الإجهاض ... ا...
 
The Truth About Dinesh Bafna's Situation.pdf
The Truth About Dinesh Bafna's Situation.pdfThe Truth About Dinesh Bafna's Situation.pdf
The Truth About Dinesh Bafna's Situation.pdf
 
The Risks of Ignoring Bookkeeping in Your Business
The Risks of Ignoring Bookkeeping in Your BusinessThe Risks of Ignoring Bookkeeping in Your Business
The Risks of Ignoring Bookkeeping in Your Business
 
Toyota Kata Coaching for Agile Teams & Transformations
Toyota Kata Coaching for Agile Teams & TransformationsToyota Kata Coaching for Agile Teams & Transformations
Toyota Kata Coaching for Agile Teams & Transformations
 
WAM Corporate Presentation May 2024_w.pdf
WAM Corporate Presentation May 2024_w.pdfWAM Corporate Presentation May 2024_w.pdf
WAM Corporate Presentation May 2024_w.pdf
 
stock price prediction using machine learning
stock price prediction using machine learningstock price prediction using machine learning
stock price prediction using machine learning
 
Top^Clinic ^%[+27785538335__Safe*Women's clinic//Abortion Pills In Harare
Top^Clinic ^%[+27785538335__Safe*Women's clinic//Abortion Pills In HarareTop^Clinic ^%[+27785538335__Safe*Women's clinic//Abortion Pills In Harare
Top^Clinic ^%[+27785538335__Safe*Women's clinic//Abortion Pills In Harare
 
HAL Financial Performance Analysis and Future Prospects
HAL Financial Performance Analysis and Future ProspectsHAL Financial Performance Analysis and Future Prospects
HAL Financial Performance Analysis and Future Prospects
 
Inside the Black Box of Venture Capital (VC)
Inside the Black Box of Venture Capital (VC)Inside the Black Box of Venture Capital (VC)
Inside the Black Box of Venture Capital (VC)
 

Assignment 3

  • 1. Assignment (3) Q1. Solve the integral using paper and pen or calculator, and then compare the answer to the computational method using the Romberg method. Solution = [x6 /6 + x5 /5 + x4/ 4 + ex] ={ [1/6 (4)6 + 1/5 (4)5 + 1/4(4)4 + e4] –[1/6 (0.5)6 + 1/5 (0.5)5 + 1/4(0.5)4 + e5] } = (1006.06) –(1.752865) = 1004.3071 function [q,ea,iter]=romberg(func,a,b,es,maxit,varargin) % if nargin<3,error('at least 3arguments required'),end if nargin<4||isempty(es),es=0.000001;end if nargin<5||isempty(maxit),maxit=50;end n=1; r(1,1) = trap(func,a,b,n,varargin{:}); iter=0; while iter<maxit iter=iter+1; n=2^iter; I(iter+1,1)=trap(func,a,b,n,varargin{:}); for k=2:iter+1 j=2+iter-k; I(j,k)=(4^(k-1)*I(j+1,k-1)-I(j,k-1))/(4^(k-1)-1); end ea=abs((I(1,iter+1)-I(2,iter))/I(1,iter+1))*100; if ea<=es, break; end end q=I(1,iter+1); function I=trap(func,a,b,n,varargin) if(nargin<3) error('at least 3 input arguments required');
  • 2. end if ~(b>a),error('upper bound must be greater than lower'),end if nargin<4||isempty(n),n=100;end x=a; h=(b-a)/n; s=func(a,varargin{:}); for i=1:n-1 x=x+h; s=s+2*func(x,varargin{:}); end s=s+func(b,varargin{:}); I=(b-a)*s/(2*n); >> f=@(x) x^5+x^4+x^3+exp(x); >> romberg(f,0.5,4) ans = 1.0044e+003
  • 3. Q2. Calculate the integral dt. The exact answer to this integral is 15.41260804810169. Solve the integral using the Romberg method Solution function [q,ea,iter]=romberg(func,a,b,es,maxit,varargin) % if nargin<3,error('at least 3arguments required'),end if nargin<4||isempty(es),es=0.000001;end if nargin<5||isempty(maxit),maxit=50;end n=1; r(1,1) = trap(func,a,b,n,varargin{:}); iter=0; while iter<maxit iter=iter+1; n=2^iter; I(iter+1,1)=trap(func,a,b,n,varargin{:}); for k=2:iter+1 j=2+iter-k; I(j,k)=(4^(k-1)*I(j+1,k-1)-I(j,k-1))/(4^(k-1)-1); end ea=abs((I(1,iter+1)-I(2,iter))/I(1,iter+1))*100; if ea<=es, break; end end q=I(1,iter+1); function I=trap(func,a,b,n,varargin) if(nargin<3) error('at least 3 input arguments required'); end if ~(b>a),error('upper bound must be greater than lower'),end if nargin<4||isempty(n),n=100;end x=a; h=(b-a)/n; s=func(a,varargin{:}); for i=1:n-1 x=x+h; s=s+2*func(x,varargin{:}); end s=s+func(b,varargin{:}); I=(b-a)*s/(2*n);
  • 4. >> f=@(t) (10*exp(-t)*sin(2*pi*t))^2 >> romberg (f,0,0.5) ans = 15.4126