0% found this document useful (0 votes)
54 views2 pages

ME310 Assignment 2 Fall2021

This document provides instructions for a programming project assignment on numerical methods for mechanical engineering. Students are asked to write a computer program to solve a linear system of equations modeling the probability of an object moving between discrete locations. The program must use Gauss elimination to efficiently solve the system, output solutions to a text file, and be submitted with documentation in a short report.

Uploaded by

Ege Uygunturk
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
54 views2 pages

ME310 Assignment 2 Fall2021

This document provides instructions for a programming project assignment on numerical methods for mechanical engineering. Students are asked to write a computer program to solve a linear system of equations modeling the probability of an object moving between discrete locations. The program must use Gauss elimination to efficiently solve the system, output solutions to a text file, and be submitted with documentation in a short report.

Uploaded by

Ege Uygunturk
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Middle East Technical University

Department of Mechanical Engineering


ME 310 Numerical Methods
Fall 2021
Programming Project II
Assignment Date: 10/12/2021
Due Date: 26/12/2021

The programming project will be submitted through METU-Class, as described in the


“Programming Project Assignment Guidelines”, which is posted on METU-Class.

Suppose that an object can be at any one of the N +1 equally spaced points, x0 , x1 , x2 , . . . , xN .
If an object is at location xi , it has a probability of α to move to xi−1 , 1 − α to move to xi+1 and
cannot move directly to any other location. Consider the probabilities, Pi for n = 0, 1, . . . , N ,
that an object starting at location xi will reach the left end point before reaching right end point.
In other words, P0 = 1 and PN = 0. Since the object can move to xi only from xi−1 or xi+1 with
probability of α or (1 − α) from each of these locations,

Pi = αPi−1 + (1 − α)Pi+1 , 0 < α < 1.

a) By writing the first 3 equations for α = 21 , show that


 
1 − 12 0 ...
0    
1
.. ..   P1 
 
 1 1 2
− 2 1 −2 ..  
  P2  0
    
...

− 12 1  =  .

 0 0   .   .. 
 ..

... ... ...  .. 
  .
1
 . −2    
  PN −1 0
0. . . . 0 − 21 1 | {z } |{z}
| {z } P B
A

is the linear system of equations for this problem by embedding the known values P0 = 1 and
PN = 0. Here, A is the coefficient matrix in the size of (N − 1) × (N − 1). P and B are the
unknown and right-hand-side vectors, respectively, in the length of (N − 1).

b) Write a computer program that solves this problem for any α and N using Gauss elimination.
Your code must

• benefit from the special structure of the system,


• avoid any redundant operation,
• avoid any redundant storage.
Hint: Holding lower main diagonal, upper main diagonal and diagonal entries in three sepa-
rate vectors can simplify the computations and reduce the storage size.

c) Counting the number of floating point operations in your implementation, show that arith-
metic complexity of Gauss elimination algorithm for this system can be reduced to O(N − 1).
Note that arithmetic complexity of Gauss elimination for general dense matrices of size n × n
is O(n3 ).

For the submission of project:

• Your code should include "input.txt", "Gauss.ext" and your main file, "e123456.ext" in the
same folder. The input file should include the value of α and N . A sample input file can be
as follows
do not include this column, it is just for information
0.4 α
100 N

• After the execution, your code ("e123456.ext") should read input file, perform required
operation to form the linear system to be solved, call "Gauss.ext" function and create "out-
put.txt". The output file includes point-wise solutions (i.e. at x1 , x2 , . . . , N − 1) obtained
from Gauss elimination process. A sample output file can be as follows:
Point Gauss Elimination do not include this row, it is just for information
1 0.66667
2 0.44444
3 0.29630
.. ..
. .

• In addition to created output file, the α value and the number of points, N should be
printed to the computer screen.

• Present your results in a short report (a few pages of a word document only, saved as a pdf
document) which should include the following:

– basic introduction paragraph,


– necessary formulations and hand calculations to write your code (type it in the word
document)
– your numerical results for a set of input parameters,
– your plotted graphics (e.g. solution at points for various α).
– discussion of the results and conclusion,
– appendix section including your code.

You might also like