homework solution

© All Rights Reserved

16 views

homework solution

© All Rights Reserved

- Sop Data Analytics
- 1971-TYC_BLL.pdf
- msg00009
- HHT-Basics
- Important Notes of 10th Class Math Exercise 5.1
- Matrix Analysis of Trusses
- 1Probability Exam
- hw7_sol
- Amcat Question QUANTITATIVE ABILITY Papers-2. _ FresherLine - Jobs, Recruitment,Fresher _ Fresherline
- Week 3 - HW
- 11th Std Paper 10 Copies
- 1985_BookMatter_CalculusI_2.pdf
- International Arts and Science Journal 2012 Price List
- Wealth Variation Calculator
- Pg Timetable 2014
- Ramin Shamshiri ABE6981 HW_05
- appg_freq domain plots.pdf
- mc_pogany
- mundur
- Jee Main 2016 Detailed Analysis by Resonance Eduventures

You are on page 1of 4

2.0450

2.0500

9.1440

9.4173

10000

8000

6000

4000

2000

1950

2000

2050

function [t,y] = midpoint(dydt,tspan,y0,h)

% [t,y] = midpoint(dydt,tspan,y0,h):

%

uses the midpoint method to integrate an ODE

% input:

%

dydt = name of the M-file that evaluates the ODE

%

tspan = [ti, tf] where ti and tf = initial and

%

final values of independent variable

%

y0 = initial value of dependent variable

%

h = step size

% output:

%

t = vector of independent variable

%

y = vector of solution for dependent variable

ti = tspan(1);

tf = tspan(2);

t = (ti:h:tf)';

n = length(t);

% if necessary, add an additional value of t

% so that range goes from t = ti to tf

if t(n)<tf

t(n+1) = tf;

n = n+1;

end

y = y0*ones(n,1); %preallocate y to improve efficiency

for i = 1:n-1

hh = t(i+1) - t(i);

k1 = feval(dydt,t(i),y(i));

ymid = y(i) + k1*hh/2;

k2 = feval(dydt,t(i)+hh/2,ymid);

y(i+1) = y(i) + k2*hh;

end

plot(t,y)

Here is the test of the solution of Prob. 22.5. First, an M-file holding the differential equation is written as

function dp = dpdt(t, p)

dp = 0.026*(1-p/12000)*p;

Then the M-file can be invoked and the results plotted with the following script

PROPRIETARY MATERIAL. The McGraw-Hill Companies, Inc. All rights reserved. No part of this Manual

may be displayed, reproduced or distributed in any form or by any means, without the prior written permission of the

publisher, or used beyond the limited distribution to teachers and educators permitted by McGraw-Hill for their

individual course preparation. If you are a student using this Manual, you are using it without permission.

15

clear,clc,clf

[t,p]=midpoint(@dpdt,[1950 2050],2560,5);

disp([t',p])

plot(t',p)

1950

1955

1960

1965

1970

1975

1980

1985

1990

1995

2000

2005

2010

2015

2020

2025

2030

2035

2040

2045

2050

2560

2831.4

3122

3431.4

3758.5

4102

4459.8

4829.8

5209.4

5595.5

5985

6374.7

6761.2

7141.3

7512.2

7871.1

8215.7

8544.1

8854.9

9147

9419.9

10000

8000

6000

4000

2000

1950

2000

2050

function [t,y] = rk4(dydt,tspan,y0,h)

% [t,y] = rk4(dydt,tspan,y0,h):

%

uses the fourth-order Runge-Kutta method to integrate an ODE

% input:

%

dydt = name of the M-file that evaluates the ODE

%

tspan = [ti, tf] where ti and tf = initial and

%

final values of independent variable

%

y0 = initial value of dependent variable

%

h = step size

% output:

%

t = vector of independent variable

%

y = vector of solution for dependent variable

ti = tspan(1);

tf = tspan(2);

t = (ti:h:tf)';

n = length(t);

PROPRIETARY MATERIAL. The McGraw-Hill Companies, Inc. All rights reserved. No part of this Manual

may be displayed, reproduced or distributed in any form or by any means, without the prior written permission of the

publisher, or used beyond the limited distribution to teachers and educators permitted by McGraw-Hill for their

individual course preparation. If you are a student using this Manual, you are using it without permission.

16

% if necessary, add an additional value of t

% so that range goes from t = ti to tf

if t(n)<tf

t(n+1) = tf;

n = n+1;

end

y = y0*ones(n,1); %preallocate y to improve efficiency

for i = 1:n-1

hh = t(i+1) - t(i);

k1 = feval(dydt,t(i),y(i));

ymid = y(i) + k1*hh/2;

k2 = feval(dydt,t(i)+hh/2,ymid);

ymid = y(i) + k2*hh/2;

k3 = feval(dydt,t(i)+hh/2,ymid);

yend = y(i) + k3*hh;

k4 = feval(dydt,t(i)+hh,yend);

phi = (k1+2*(k2+k3)+k4)/6;

y(i+1) = y(i) + phi*hh;

end

plot(t,y)

Here is the test of the solution of Prob. 22.2. First, an M-file holding the differential equation is written as

function dy = dydx(x, y)

dy = (1+4*x)*sqrt(y);

Then the M-file can be invoked and the results plotted with the following script

clear,clc,clf

[x,y]=rk4(@dydx,[0 1],1,0.1);

disp([x,y])

plot(x,y)

0

0.1000

0.2000

0.3000

0.4000

0.5000

0.6000

0.7000

0.8000

0.9000

1.0000

1.0000

1.1236

1.2996

1.5376

1.8496

2.2500

2.7556

3.3856

4.1616

5.1076

6.2500

7

6

5

4

3

2

1

0

0.2

0.4

0.6

0.8

22.13 The following function is patterned on the code for the fourth-order RK method from Fig. 22.8:

PROPRIETARY MATERIAL. The McGraw-Hill Companies, Inc. All rights reserved. No part of this Manual

may be displayed, reproduced or distributed in any form or by any means, without the prior written permission of the

publisher, or used beyond the limited distribution to teachers and educators permitted by McGraw-Hill for their

individual course preparation. If you are a student using this Manual, you are using it without permission.

This!can!be!plotted!as!follows:!

- Sop Data AnalyticsUploaded byrei
- 1971-TYC_BLL.pdfUploaded byAnatoli Krasilnikov
- msg00009Uploaded byAswath78
- HHT-BasicsUploaded bysoup
- Important Notes of 10th Class Math Exercise 5.1Uploaded byTayyabah Shah
- Matrix Analysis of TrussesUploaded byRina Arsianti
- 1Probability ExamUploaded bynglok
- hw7_solUploaded byDylan Ler
- Amcat Question QUANTITATIVE ABILITY Papers-2. _ FresherLine - Jobs, Recruitment,Fresher _ FresherlineUploaded byPrashant Kumar Tiwari
- Week 3 - HWUploaded bymisterreid
- 11th Std Paper 10 CopiesUploaded byMayur Agarwal
- 1985_BookMatter_CalculusI_2.pdfUploaded byමිලන්
- International Arts and Science Journal 2012 Price ListUploaded byTamizharasi Karuppanasamy
- Wealth Variation CalculatorUploaded bymorrisonkaniu8283
- Pg Timetable 2014Uploaded byPontharani Marimuthu
- Ramin Shamshiri ABE6981 HW_05Uploaded byRaminShamshiri
- appg_freq domain plots.pdfUploaded byBhaskar K
- mc_poganyUploaded byYarden Mazor
- mundurUploaded byProfanwar Santosomsc
- Jee Main 2016 Detailed Analysis by Resonance EduventuresUploaded byharshit
- p-ADIC HULLS OF TAYLOR, POISSON, OPEN IDEALS AND THE COUNTABILITY OF CHEBYSHEV GROUPSUploaded byBennettRennier
- At a Tough SchoolUploaded byIzwana Ariffin
- Tuning CriteriaUploaded byDolly Cotw
- CALCULATION.docxUploaded byputeri
- PC Summer WorkUploaded byklb925
- Algebra CalculusUploaded byعبدالله Abdullah Furqan
- Quiz PrelimsUploaded byQount It
- MathUploaded byBezalel Ilagan
- modeling periodic data notesUploaded byapi-239214491
- ME-2012-solved.pdfUploaded bySiva Viknesh

- 64 Interview QuestionsUploaded byshivakumar N
- Sap on if IcationUploaded bySYZC
- 6 Solutions to Tutorial 5 2012Uploaded bySYZC
- Mcclary Terry g 1963Uploaded bySYZC
- Introduction to Probability and StatisticsUploaded byAaron Tan ShiYi
- Water Methanol FAQsUploaded bySYZC
- SO2 Emissions 2Uploaded bySYZC
- Kraller Et Al-2016-Asia-Pacific Journal of Chemical EngineeringUploaded bySYZC
- fdsfUploaded byKerry
- Bioc202 Problem SetsUploaded bySYZC
- lecture32(1)Uploaded bySYZC
- organic chemistry syllabusUploaded bySYZC
- 32. Wood.pdfUploaded bySYZC
- 27. Engineering Ceramics(1)Uploaded bySYZC
- The Importance of Biochemical Oxygen Demand Bod in the Water Analysis SectorUploaded bySYZC
- f16stat251ch3Uploaded bySYZC
- HW#9_SolUploaded bySYZC
- HW#1_SolUploaded bySYZC
- Unit Operation of Chemical EngineeringUploaded byDQZ
- Chapter 4Uploaded bySYZC
- Lecture31 Entropy Departure FunctionUploaded bySYZC
- Lecture 10- Work heat energyUploaded bySYZC

- Ch11Uploaded byAla Vin
- GlsUploaded byArsenal Holic
- 1 MT-301Uploaded bymrajshre.jod
- Chapter 18Uploaded byLin Chong
- H.K. Moffatt- Viscous Eddies Near a Sharp CornerUploaded byYokdm
- 4. 2017-2018 Syllabus, Timeline & ExpectationsUploaded byLim Kew Chong
- 4 Multi Variable Control System DesignUploaded by王轩
- Finding the Center of Mass Coordinates for an Object of Uniform Density but NonUploaded byJames Lee
- tb-ansys-maxwell-magnetic-field-formulation.pdfUploaded byराहुल शर्मा
- Cam dynamicsUploaded byBharath Subramanian
- Binomial FiltersUploaded byverdos
- NormalfinalUploaded byCorina-Ştefania Tudorache
- AM 4.1 HW.pdfUploaded byLuis Avila
- Lecture_07 Monotone Comparative StaticsUploaded byAhmed Gouda
- Leibniz First Published Rules for the Derivative - National Curve Bank a Math ArchiveUploaded byFrancisco Gurrola
- Intersection of planes in Three dimensional spaceUploaded byNarendran Sairam
- gauss-markov theoremUploaded bymaxangelicdemon
- Final Exam Reviewer - CarandangUploaded byMary Ann Munda
- RespuestasUploaded byAndres Heredia
- Rouche's TheoremUploaded byJeoff Libo-on
- recommended prob_ ch3 - Copy.docxUploaded bynomio12
- Sol1Uploaded byfofo
- TFCUploaded byxamanian
- math term paperUploaded byJasbir Singh
- Normal distribution.pdfUploaded bysamriddha_671019633
- Fluid Structure Interaction Based Upon a Stabilied (ALE) Finite Element MethodUploaded byBella Tran
- PCA.interestingUploaded bydsdamos
- MM SOLAF 1 PAPER 2Uploaded byHawa
- wb03_blk3Uploaded bygomson
- A Theoretical Physics FAQUploaded byahmedkq1974