SOLUTION MANUAL FOR
NUMERICAL METHODS
FOR ENGINEERS 8TH
EDITION BY STEVEN C.
CHAPRA, RAYMOND P.
CANALE.2025 A+
,CHAPTER 2
2.1
IF X < 10 THEN IF X < 5
THEN
X= 5
ELSE
PRINT X
END IF
ELSE
DO
IF X < 50 EXIT
X = X - 5END
DO
END IF
2.2
Step 1: Start
Step 2: Initialize Sum And Count To Zero
Step 3: Examine Top Card.
Step 4: If It Says “End Of Data” Proceed To Step 9; Otherwise, Proceed To Next
Step.Step 5: Add Value From Top Card To Sum.
Step 6: Increase Count By
1.Step 7: Discard Top Card
Step 8: Return To Step 3.
Step 9: Is The Count Greater Than Zero?
If Yes, Proceed To Step
10. If No, Proceed To Step
11.
Step 10: Calculate Average = Sum/Count
Step 11: End
2.3
start
sum = 0
count = 0
T
count > 0
INPUT
value
F
average = sum/count
value = T
“end of data”
F end
sum = sum + value
count = count + 1
,2.4
Students Could Implement The Subprogram In Any Number Of Languages. The Following
Fortran 90 Program Is One Example. It Should Be Noted That The Availability Of Complex
Variables In Fortran 90, Would Allow This Subroutine To Be Made Even More Concise.
However, We Did Not Exploit This Feature, In Order To Make The Code More Compatible
With Visual BASIC, MATLAB, Etc.
PROGRAM Rootfind
IMPLICIT NONE
INTEGER::Ier
REAL::A, B, C, R1, I1, R2, I2
DATA A,B,C/1.,5.,2./
CALL Roots(A, B, C, Ier, R1, I1, R2, I2)IF (Ier .EQ. 0) THEN
PRINT *, R1,I1," I"
PRINT *, R2,I2," I"ELSE
PRINT *, "No Roots"END IF
END
SUBROUTINE Roots(A, B, C, Ier, R1, I1, R2, I2)IMPLICIT NONE
INTEGER::Ier
REAL::A, B, C, D, R1, I1, R2, I2 R1=0.
R2=0.
I1=0.
I2=0.
IF (A .EQ. 0.) THENIF (B <> 0)
THEN
R1 = -C/B
ELSE
Ier = 1 END
IF
ELSE
D = B**2 - 4.*A*CIF (D >=
0) THEN
R1 = (-B + SQRT(D))/(2*A)
R2 = (-B - SQRT(D))/(2*A) ELSE
R1 = -B/(2*A)R2 =
R1
I1 = SQRT(ABS(D))/(2*A)
I2 = -I1 END
IF
END IF
END
The Answers For The 3 Test Cases Are: (A) -4.56; (B) 0.5; (C) + 2.33i;
2.33i.
Several Features Of This Subroutine Bear Mention:
The Subroutine Does Not Involve Input Or Output. Rather, Information Is Passed In And
Out Via The Arguments. This Is Often The Preferred Style, Because The I/O Is Left To
The Discretion Of The Programmer Within The Calling Program.
Note That An Error Code Is Passed (IER = 1) For The Case Where No Roots Are Possible.
, 2.5 The Development Of The Algorithm Hinges On Recognizing That The Series Approximation Of
The Sine Can Be Represented Concisely By The Summation,
n
X 2i
(2i 1)!
Where I = The Order Of The Approximation. The Following Algorithm Implements This
Summation:
Step 1: Start
Step 2: Input Value To Be Evaluated X And Maximum
Order NStep 3: Set Order (I) Equal To One
Step 4: Set Accumulator For Approximation (Approx) To Zero
Step 5: Set Accumulator For Factorial Product (Fact) Equal To
One Step 6: Calculate True Value Of Sin(X)
Step 7: If Order Is Greater Than N Then Proceed To Step 13
Otherwise, Proceed To Next Step
Step 8: Calculate The Approximation With The Formula
2i-1
I-1
X
Approx Approx
Facto
Step 9: Determine The Error r
%Error 100%
True
Step 10: Increment The Order By One
Step 11: Determine The Factorial For The Next Iteration
Factor Factor (2 I I 1)
Step 12: Return To Step 7
Step 13: End
NUMERICAL METHODS
FOR ENGINEERS 8TH
EDITION BY STEVEN C.
CHAPRA, RAYMOND P.
CANALE.2025 A+
,CHAPTER 2
2.1
IF X < 10 THEN IF X < 5
THEN
X= 5
ELSE
PRINT X
END IF
ELSE
DO
IF X < 50 EXIT
X = X - 5END
DO
END IF
2.2
Step 1: Start
Step 2: Initialize Sum And Count To Zero
Step 3: Examine Top Card.
Step 4: If It Says “End Of Data” Proceed To Step 9; Otherwise, Proceed To Next
Step.Step 5: Add Value From Top Card To Sum.
Step 6: Increase Count By
1.Step 7: Discard Top Card
Step 8: Return To Step 3.
Step 9: Is The Count Greater Than Zero?
If Yes, Proceed To Step
10. If No, Proceed To Step
11.
Step 10: Calculate Average = Sum/Count
Step 11: End
2.3
start
sum = 0
count = 0
T
count > 0
INPUT
value
F
average = sum/count
value = T
“end of data”
F end
sum = sum + value
count = count + 1
,2.4
Students Could Implement The Subprogram In Any Number Of Languages. The Following
Fortran 90 Program Is One Example. It Should Be Noted That The Availability Of Complex
Variables In Fortran 90, Would Allow This Subroutine To Be Made Even More Concise.
However, We Did Not Exploit This Feature, In Order To Make The Code More Compatible
With Visual BASIC, MATLAB, Etc.
PROGRAM Rootfind
IMPLICIT NONE
INTEGER::Ier
REAL::A, B, C, R1, I1, R2, I2
DATA A,B,C/1.,5.,2./
CALL Roots(A, B, C, Ier, R1, I1, R2, I2)IF (Ier .EQ. 0) THEN
PRINT *, R1,I1," I"
PRINT *, R2,I2," I"ELSE
PRINT *, "No Roots"END IF
END
SUBROUTINE Roots(A, B, C, Ier, R1, I1, R2, I2)IMPLICIT NONE
INTEGER::Ier
REAL::A, B, C, D, R1, I1, R2, I2 R1=0.
R2=0.
I1=0.
I2=0.
IF (A .EQ. 0.) THENIF (B <> 0)
THEN
R1 = -C/B
ELSE
Ier = 1 END
IF
ELSE
D = B**2 - 4.*A*CIF (D >=
0) THEN
R1 = (-B + SQRT(D))/(2*A)
R2 = (-B - SQRT(D))/(2*A) ELSE
R1 = -B/(2*A)R2 =
R1
I1 = SQRT(ABS(D))/(2*A)
I2 = -I1 END
IF
END IF
END
The Answers For The 3 Test Cases Are: (A) -4.56; (B) 0.5; (C) + 2.33i;
2.33i.
Several Features Of This Subroutine Bear Mention:
The Subroutine Does Not Involve Input Or Output. Rather, Information Is Passed In And
Out Via The Arguments. This Is Often The Preferred Style, Because The I/O Is Left To
The Discretion Of The Programmer Within The Calling Program.
Note That An Error Code Is Passed (IER = 1) For The Case Where No Roots Are Possible.
, 2.5 The Development Of The Algorithm Hinges On Recognizing That The Series Approximation Of
The Sine Can Be Represented Concisely By The Summation,
n
X 2i
(2i 1)!
Where I = The Order Of The Approximation. The Following Algorithm Implements This
Summation:
Step 1: Start
Step 2: Input Value To Be Evaluated X And Maximum
Order NStep 3: Set Order (I) Equal To One
Step 4: Set Accumulator For Approximation (Approx) To Zero
Step 5: Set Accumulator For Factorial Product (Fact) Equal To
One Step 6: Calculate True Value Of Sin(X)
Step 7: If Order Is Greater Than N Then Proceed To Step 13
Otherwise, Proceed To Next Step
Step 8: Calculate The Approximation With The Formula
2i-1
I-1
X
Approx Approx
Facto
Step 9: Determine The Error r
%Error 100%
True
Step 10: Increment The Order By One
Step 11: Determine The Factorial For The Next Iteration
Factor Factor (2 I I 1)
Step 12: Return To Step 7
Step 13: End