numerical method for engineers-chapter 21

23

Click here to load reader

Upload: mrbudakbaek

Post on 22-Oct-2014

369 views

Category:

Documents


31 download

TRANSCRIPT

Page 1: Numerical Method for engineers-chapter 21

1

CHAPTER 21

21.1 (a) Analytical solution:

(b) Trapezoidal rule (n = 1):

(c) Trapezoidal rule (n = 2):

Trapezoidal rule (n = 4):

(d) Simpson’s 1/3 rule:

(e) Simpson’s rule (n = 4):

(f) Simpson’s 3/8 rule:

(g) Simpson’s rules (n = 5):

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.

Page 2: Numerical Method for engineers-chapter 21

2

21.2 (a) Analytical solution:

(b) Trapezoidal rule (n = 1):

(c) Trapezoidal rule (n = 2):

Trapezoidal rule (n = 4):

(d) Simpson’s 1/3 rule:

(e) Simpson’s rule (n = 4):

(f) Simpson’s 3/8 rule:

(g) Simpson’s rules (n = 5):

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.

Page 3: Numerical Method for engineers-chapter 21

3

21.3 (a) Analytical solution:

(b) Trapezoidal rule (n = 1):

(c) Trapezoidal rule (n = 2):

Trapezoidal rule (n = 4):

(d) Simpson’s 1/3 rule (n = 2):

(e) Simpson’s 3/8 rule:

(f) Boole’s rule (n = 5):

21.4 Analytical solution:

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.

Page 4: Numerical Method for engineers-chapter 21

4

Trapezoidal rule (n = 1):

The results are summarized below:

n Integral t1 9 8%2 8.513889 2.167%3 8.415185 0.982%4 8.379725 0.557%

21.5 Analytical solution:

Simpson’s rule (n = 4):

Simpson’s rules (n = 5):

Because Simpson’s rules are perfect for cubics, both versions yield the exact result for this cubic polynomial.

21.6 Analytical solution:

Trapezoidal rule (n = 4):

Simpson’s rule (n = 4):

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.

Page 5: Numerical Method for engineers-chapter 21

5

21.7 Analytical solution:

(a) Trapezoidal rule (n = 1):

(b) Simpson’s 1/3 rule (n = 2):

(c) Simpson’s 3/8 rule:

(d) Boole’s rule:

(e) Midpoint method:

(f) 3-segment-2-point open integration formula:

(g) 4-segment-3-point open integration formula:

21.8 Analytical solution:

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.

Page 6: Numerical Method for engineers-chapter 21

6

(a) Trapezoidal rule (n = 1):

(b) Simpson’s 1/3 rule (n = 2):

(c) Simpson’s 3/8 rule:

(d) Simpson’s rules (n = 5):

(e) Boole’s rule:

(f) Midpoint method:

(g) 3-segment-2-point open integration formula:

(h) 4-segment-3-point open integration formula:

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.

Page 7: Numerical Method for engineers-chapter 21

7

21.9 Analytical solution:

Thus, the result to 3 significant digits is 334. Here are results for various multiple-segment trapezoidal rules:

n I1 246.95932 314.40263 325.48354 329.2165 330.92256 331.84437 332.39848 332.75739 333.003110 333.178811 333.308712 333.407413 333.484214 333.5452

Thus, a 14-segment application gives the result to 4 significant digits.

21.10 (a) Trapezoidal rule (n = 5):

(b) Simpson’s rules (n = 5):

21.11 (a) Trapezoidal rule (n = 6):

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.

Page 8: Numerical Method for engineers-chapter 21

8

(b) Simpson’s rules (n = 6):

21.12 (a) A graph suggests that the mean value is about 80.

y = -0.075x4 + 2x3 - 14x2 + 45x - 46

0

50

100

150

200

250

300

0 2 4 6 8 10 12

80

(b) Analytical solution:

(c) Numerical solution:

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.

Page 9: Numerical Method for engineers-chapter 21

9

21.13 (a) Analytical solution:

(b) Trapezoidal rule

(c) Trapezoidal/Simpson’s rules

21.14 (a) Analytical solution:

(b) Sweeping across the x dimension:

y = –1:

y = 0:

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.

Page 10: Numerical Method for engineers-chapter 21

10

y = 1:

These values can then be integrated along the y dimension:

(c) Sweeping across the x dimension:

y = –1:

y = 0:

y = 1:

These values can then be integrated along the y dimension:

21.15 (a) Analytical solution:

(b) For z = –2, sweeping across the x dimension:

z = –2; y = 0:

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.

Page 11: Numerical Method for engineers-chapter 21

11

z = –2; y = 1:

z = –2; y = 2:

These values can then be integrated along the y dimension:

For z = 0, similar calculations yield

z = 0; y = 0: I = –20z = 0; y = 1: I = –20z = 0; y = 2: I = –20

These values can then be integrated along the y dimension:

For z = 2, similar calculations yield

z = 2; y = 0: I = –20z = 2; y = 1: I = –44z = 2; y = 2: I = –68

These values can then be integrated along the y dimension:

Finally, these results can be integrated along the z dimension,

21.16 Here is a VBA program that is set up to duplicate the computation performed in Example 21.2.

Option Explicit

Sub TestTrapm()Dim n As Integer, i As Integer

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.

Page 12: Numerical Method for engineers-chapter 21

12

Dim a As Double, b As Double, h As DoubleDim x(100) As Double, f(100) As Double'Enter data and integration parametersa = 0b = 0.8n = 2h = (b - a) / n'generate data from functionx(0) = af(0) = fx(a)For i = 1 To n x(i) = x(i - 1) + h f(i) = fx(x(i))Next i'invoke function to determine and display integralMsgBox "The integral is " & Trapm(h, n, f)End Sub

Function Trapm(h, n, f)Dim i As Integer, sum As Doublesum = f(0)For i = 1 To n - 1 sum = sum + 2 * f(i)Next isum = sum + f(n)Trapm = h * sum / 2End Function

Function fx(x)fx = 0.2 + 25 * x - 200 * x ^ 2 + 675 * x ^ 3 - 900 * x ^ 4 + 400 * x ^ 5End Function

21.17 Here is a VBA program that is set up to duplicate the computation performed in Example 21.5.

Option Explicit

Sub TestSimpm()Dim n As Integer, i As IntegerDim a As Double, b As Double, h As DoubleDim x(100) As Double, f(100) As Double'Enter data and integration parametersa = 0b = 0.8n = 4h = (b - a) / n'generate data from functionx(0) = af(0) = fx(a)For i = 1 To n x(i) = x(i - 1) + h f(i) = fx(x(i))Next i'invoke function to determine and display integralMsgBox "The integral is " & Simp13m(h, n, f)End Sub

Function Simp13m(h, n, f)Dim i As IntegerDim sum As Doublesum = f(0)

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.

Page 13: Numerical Method for engineers-chapter 21

13

For i = 1 To n - 2 Step 2 sum = sum + 4 * f(i) + 2 * f(i + 1)Next isum = sum + 4 * f(n - 1) + f(n)Simp13m = h * sum / 3End Function

Function fx(x)fx = 0.2 + 25 * x - 200 * x ^ 2 + 675 * x ^ 3 - 900 * x ^ 4 + 400 * x ^ 5End Function

21.18 Here is a VBA program that is set up to duplicate the computation performed in Example 21.8.

Option Explicit

Sub TestUneven()Dim n As Integer, i As IntegerDim label As StringDim a As Double, b As Double, h As DoubleDim x(100) As Double, f(100) As Double'Enter dataSheets("Sheet1").SelectRange("a6").Selectn = ActiveCell.RowSelection.End(xlDown).Selectn = ActiveCell.Row - n'Input data from sheetRange("a6").SelectFor i = 0 To n x(i) = ActiveCell.Value ActiveCell.Offset(0, 1).Select f(i) = ActiveCell.Value ActiveCell.Offset(1, -1).SelectNext i'invoke function to determine and display integralMsgBox "The integral is " & Uneven(n, x, f)End Sub

Function Uneven(n, x, f)Dim k As Integer, j As IntegerDim h As Double, sum As Double, hf As Doubleh = x(1) - x(0)k = 1sum = 0#For j = 1 To n hf = x(j + 1) - x(j) If Abs(h - hf) < 0.000001 Then If k = 3 Then sum = sum + Simp13(h, f(j - 3), f(j - 2), f(j - 1)) k = k - 1 Else k = k + 1 End If Else If k = 1 Then sum = sum + Trap(h, f(j - 1), f(j)) Else If k = 2 Then sum = sum + Simp13(h, f(j - 2), f(j - 1), f(j)) Else

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.

Page 14: Numerical Method for engineers-chapter 21

14

sum = sum + Simp38(h, f(j - 3), f(j - 2), f(j - 1), f(j)) End If k = 1 End If End If h = hfNext jUneven = sumEnd Function

Function Trap(h, f0, f1)Trap = h * (f0 + f1) / 2End Function

Function Simp13(h, f0, f1, f2)Simp13 = 2 * h * (f0 + 4 * f1 + f2) / 6End Function

Function Simp38(h, f0, f1, f2, f3)Simp38 = 3 * h * (f0 + 3 * (f1 + f2) + f3) / 8End Function

Function fx(x)fx = 0.2 + 25 * x - 200 * x ^ 2 + 675 * x ^ 3 - 900 * x ^ 4 + 400 * x ^ 5End Function

To run the program, the data is entered in columns A and B on a worksheet labeled Sheet1. After the macro is run, a message box displays the integral estimate as shown.

21.19 (a) Analytical solution:

(b) Trapezoidal rule:

(c) Simpson’s rule:

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.

Page 15: Numerical Method for engineers-chapter 21

15

21.20 Trapezoidal/Simpsons rules

21.21 (a) Trapezoidal rule

(b) Trapezoidal/Simpsons rules

(c) We can use regression to fit a quadratic equation to the data

y = -0.1117x2 + 1.3526x + 3.4447

R2 = 0.5742

0

5

10

0 2 4 6 8 10 12

This equation can be integrated to yield

We can use regression to fit a cubic equation to the data

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.

Page 16: Numerical Method for engineers-chapter 21

16

y = -0.01646x3 + 0.16253x2 + 0.07881x + 4.85467

R2 = 0.63442

0

5

10

0 2 4 6 8 10 12

This equation can be integrated to yield

21.22 We can set up a table that contains the values comprising the integrand

x, cm , g/cm3 Ac, cm2Ac, g/cm

0 4 100 400200 3.95 103 406.85300 3.89 106 412.34400 3.8 110 418600 3.6 120 432800 3.41 133 453.531000 3.3 150 495

We can integrate this data using a combination of the trapezoidal and Simpson’s rules,

21.23 We can set up a table that contains the values comprising the integrand

t, hr t, drate

(cars/4 min)rate

(cars/d)7:30 0.312500 18 64807:45 0.322917 24 86408:00 0.333333 14 50408:15 0.343750 24 8640

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.

Page 17: Numerical Method for engineers-chapter 21

17

8:45 0.364583 21 75609:15 0.385417 9 3240

We can integrate this data using a combination of Simpson’s 3/8 and 1/3 rules. This yields the number of cars that go through the intersection between 7:30 and 9:15,

The number of cars going through the intersection per minute can be computed as

21.24 We can use Simpson’s 1/3 rule to integrate across the y dimension,

x = 0:

x = 4:

x = 8:

x = 12:

These values can then be integrated along the x dimension with Simpson’s 3/8 rule:

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.