Midterm solution for MAE 185
by Nasser Abbasi
less work this command displays the content of the file to standard output. Here the file is called 'work'. It allows backward and forward movement. The less command does not have to read the whole file to memory before starting to display its content, which can be useful for large files as it can be faster.
more work this command displays the content of the file to standard output. The display is made one page at a time. the command more does not have the advantages that the command less has mentioned above.
pwd print the name of the current working directory.
wc -l the command 'wc' with the argument '-l' counts and prints the number of new lines in its input.
!p This command reissues the first occurence in the commands history file the command that starts with the letter 'p'. It has the same effect as if one typed the same command again. It saves one from having to retype that command fully again.
Given
(1) write the system of equations in matrix form (3pt)
Answer:
(2) Solve the system using cramer Rule. Show all steps. (5pt)
Answer:
In cramer rule we write
Where is the matrix with the column replaced by the column.
Start by finding
Now find
Similarly
And finally
Hence
(3) Solve the system using Gaussian elimination method using partial pivoting. Show all steps. (5 pts).
Partial pivoting means the interchanging of rows only. Full pivoting is where we interchange both rows and columns. Here we are asked to use partial pivoting, which is the common method we learned.
Start by writing down the augmented matrix
The goal is to convert the above matrix to this form
Then we preform back substitutions to solve for
Now we start the process.
From the augmented matrix, make the first row the row with the smallest first element. This is called the pivot row and the first element in that row is the pivot element. So switch third row with the first row we obtain
Now add first row to the second row and add 12first row to the 3rd row we obtain
Now we are done with the first row, we want the second row to be the pivot row with the element the pivot element. Again we want the pivot element to be the smallest element. But not zero as the case is now. so we need to switch row 2 with row 3 to obtain
This completes the forward elimination process. So now rewrite the system of equations, we obtain
Now do the Back substituion process. From the last row we solve for
Hence from second row we obtain
Now, from the first row
So final answer is which agrees with cramer rule method as expected.
Provide the first 3 terms in Taylor series for the following (3pts)
Taylor expansion is
Apply the above using the first 3 terms only, we obtain for
Let hence we need to expand , and from above it is
Now replace back by the above becomes
Hence
:
Let be a function called and apply Taylor expansion on we obtain from above
Now replace back by we obtain
Here we expand around the point hence since another way to write Taylor series is
Where in the above we expand around
Then we obtain
The above is expanding using 3 terms in the Taylor series of around zero.
To obtain 3 terms in the final series, we need to take more terms in the taylor expansion to obtain
Determine the lowest positive root of
using Newton-Raphson method (3 iterations, ) (9pts)
First note that
In NR method, the iteration step is
Hence starting with and we obtain
Hence using 3 iterations the smallest root found starting from is
Using the secant method with and (9pts)
In secant method, the iteration process is
Hence with and we start the process with
Hence using 3 iterations the smallest root found using secant method is
Implement Euler method to solve a first order ODE in FORTRAN (7pts)
Given an ODE such as with some initial conditions such as
The Euler method algorithm solves for as follows
where for we use the initial condition. Hence