Old Final Exam with Answer Key for Introduction to Computers for Engineers | 440 127, Exams of Engineering

Material Type: Exam; Class: 440 - INT COMPUTER FOR ENG; Subject: GENERAL ENGINEERING; University: Rutgers University; Term: Unknown 1989;

Typology: Exams

Pre 2010

Uploaded on 09/17/2009

koofers-user-i5t
koofers-user-i5t 🇺🇸

5

(1)

10 documents

1 / 8

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
440:127 Final Exam Spring 1999
Name________________________________________________Student Number___________________________
Recitation Section________________________Recitation Instructor______________________________________
Question 1: Warm Up
Trace through the following program and predict the output.
Real A(3,3), B(3), C(3)
DATA A/1, 2, 3, 4, 5, 6, 7, 8, 9/
DATA B/1, 2, 3/
DO I = 1,3
C(I) = 0.0
DO J = 1,3
C(I) = C(I) + A(I,J)*B(J)
END DO
END DO
PRINT 30, C
30 FORMAT(3(F6.1, 2X))
END
pf3
pf4
pf5
pf8

Partial preview of the text

Download Old Final Exam with Answer Key for Introduction to Computers for Engineers | 440 127 and more Exams Engineering in PDF only on Docsity!

Name________________________________________________Student Number___________________________

Question 1: Warm Up Trace through the following program and predict the output.

Real A(3,3), B(3), C(3) DATA A/1, 2, 3, 4, 5, 6, 7, 8, 9/ DATA B/1, 2, 3/ DO I = 1, C(I) = 0. DO J = 1, C(I) = C(I) + A(I,J)*B(J) END DO END DO PRINT 30, C 30 FORMAT(3(F6.1, 2X)) END

Name________________________________________________Student Number___________________________

Question 2: Error Analysis

Write a program that uses the 5-point weighted average method for data smoothing of 50 data points.

In the weighted averaging method, each of the five points used in calculating the average is first multiplied by a weighting factor. The weighting factor for the first of the five points is read in as program input. The remaining four are calculated by doubling the previous weight and alternating its sign. Thus, the first, third, and fifth weighting factors are positive and the second and fourth are negative. Make an appropriate decision on how to handle the end points.

Name________________________________________________Student Number___________________________

Question 4: Curve Fitting You are given a data set of 20 points in X and Y that are thought to fit the relation given below,

 a

X

Y

Write a Fortran program to determine the value of a in the equation.

Note: You may assume that a correctly written and compiled LSQF(X,Y,N,M,B,R) subroutine is present in your execution environment.

Name________________________________________________Student Number___________________________

Question 5: Curve Fitting An experiment has been repeated 3 times and 10 data points have been recorded each time. The data points should fit

the equation y = m exp(x) + b. Write a program that does the following:

a) Reads in the 3 data sets from 3 different files DAT1.F90, DAT2.F90, and DAT3.F b) Makes the appropriate linearizing transformation c) Calculates and compares the correlation coefficients d) Averages the three values of M and B and prints the results of this averaging and of the correlation coefficient comparison.

Note: You may assume that a correctly written and compiled LSQF(X,Y,N,M,B,R) subroutine is present in your execution environment.

Name________________________________________________Student Number___________________________

Question 7: Roots of an Equation The Bisection method cannot be used if no sign change occurs near the root, as in the case of f(X) = X 2 -2X+1, which has a root at X=1. If we evaluate the function at X = 0.9 and at X = 1.1, the results are f(0.9) = 0.01 & f(1.1) = 0.01.

A strategy for detecting roots for these kinds of functions is as follows. While performing the interval search, we can check the sign of both the function and its derivative. If f(X) changes sign, then the conventional bisection method can be used. If f(X) does not change sign, but the derivative f '(X) changes sign in the interval and the value of f(X) is

sufficiently small (you decide!) the root is bracketed. The root is located when the function and its derivative are

both zero.

Write a Fortran subroutine to determine the root of a function using a bisection methodology that incorporates the above strategy in addition to the traditional approach. For example, when you make your initial logical check of f(X (^) L) * f(X (^) U ) < 0.0, a false result does not result in an error, but rather you must also check f '(XL) * f '(X (^) U ) < 0.0. If this too is false, then you must exit with an error message. Otherwise proceed in this dual manner to find the root.

This type of program is prone to infinite loops. Write your program with code to minimize the possibility of hanging.

Name________________________________________________Student Number___________________________

Question 8: Cramer's Rule Cramer's Rule is used for solving equations of the form

An x n. Xn x 1 = Bn x 1

Where A is a n x n matrix and X and B are n x 1 matrices. This nomenclature represents a system of n equations with n unknowns. A and B are constant matrices and X is the variable matrix.

Write a Fortran subroutine using Cramer's Rule for any n x n matrix. Name the subroutine CRAMER(N, A, B, X). A rough shell of the subroutine is given below to get you going!

A major problem with using Cramer's methods for a wide range of system sizes is that you need to calculate the determinant. For this problem, calculate the determinant by upper triangulating the matrix with subroutine TRIANG(N, A) [Do not write! Assume it is present in your execution environment], and then write a subprogram DET(N, A) to calculate the determinate by the diagonal product rule.

===================================== SUBROUTINE CRAMER (N,A,B,X) REAL A(N,N), B(N), X(N), A1(N,N) . . . DO I = 1, N A1 = A DO J = 1, N . . . ENDDO . . . ENDDO RETURN END