100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached
logo-home
Exam (elaborations) TEST BANK FOR Numerical Methods for Engineers By S £9.05   Add to cart

Exam (elaborations)

Exam (elaborations) TEST BANK FOR Numerical Methods for Engineers By S

 6 views  0 purchase
  • Module
  • Institution

Exam of 516 pages for the course TEST BANK FOR Numerical Methods for Engineers By S at UM (error)

Preview 4 out of 516  pages

  • February 12, 2022
  • 516
  • 2021/2022
  • Exam (elaborations)
  • Questions & answers
avatar-seller
,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 - 5
END 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.) THEN
IF (b <> 0) THEN
r1 = -c/b
ELSE
ier = 1
END IF
ELSE
d = b**2 - 4.*a*c
IF (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) −0.438, -4.56; (b) 0.5; (c) −1.25 + 2.33i; −1.25 −
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 2i −1
x
∑ (2i − 1)!
i =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 n
Step 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
x
approx = approx + ( −1) i-1
factor
Step 9: Determine the error
true − approx
%error = 100%
true
Step 10: Increment the order by one
Step 11: Determine the factorial for the next iteration
factor = factor • (2 • i − 2) • (2 • i − 1)
Step 12: Return to step 7
Step 13: End

The benefits of buying summaries with Stuvia:

Guaranteed quality through customer reviews

Guaranteed quality through customer reviews

Stuvia customers have reviewed more than 700,000 summaries. This how you know that you are buying the best documents.

Quick and easy check-out

Quick and easy check-out

You can quickly pay through credit card for the summaries. There is no membership needed.

Focus on what matters

Focus on what matters

Your fellow students write the study notes themselves, which is why the documents are always reliable and up-to-date. This ensures you quickly get to the core!

Frequently asked questions

What do I get when I buy this document?

You get a PDF, available immediately after your purchase. The purchased document is accessible anytime, anywhere and indefinitely through your profile.

Satisfaction guarantee: how does it work?

Our satisfaction guarantee ensures that you always find a study document that suits you well. You fill out a form, and our customer service team takes care of the rest.

Who am I buying these notes from?

Stuvia is a marketplace, so you are not buying this document from us, but from seller COURSEHERO2. Stuvia facilitates payment to the seller.

Will I be stuck with a subscription?

No, you only buy these notes for £9.05. You're not tied to anything after your purchase.

Can Stuvia be trusted?

4.6 stars on Google & Trustpilot (+1000 reviews)

78637 documents were sold in the last 30 days

Founded in 2010, the go-to place to buy revision notes and other study material for 14 years now

Start selling
£9.05
  • (0)
  Add to cart