Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
updated HW4
  • Loading branch information
rcc02007 committed Oct 24, 2017
1 parent 6a2f332 commit 90b323b
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 44 deletions.
39 changes: 26 additions & 13 deletions HW4/README.html
Expand Up @@ -10,29 +10,34 @@
</head>
<body>
<h1 id="homework-4">Homework #4</h1>
<h2 id="due-32817-by-1159pm">due 3/28/17 by 11:59pm</h2>
<h2 id="final-commit-due-11217-by-1159pm">final commit due 11/2/17 by 11:59pm</h2>
<p><em>Include all work as either an m-file script, m-file function, or example code included with ``` and document your code in the README.md file</em></p>
<ol style="list-style-type: decimal">
<li><p>Create a new github repository called ‘04_linear_algebra’.</p>
<ol style="list-style-type: lower-alpha">
<li><p>Add rcc02007 and pez16103 as collaborators.</p></li>
<li><p>Add rcc02007 and zhs15101 as collaborators.</p></li>
<li><p>Clone the repository to your computer.</p></li>
<li><p>Complete this before 10/26 by midnight</p></li>
</ol></li>
<li><p>Create the 4x4 and 5x5 Hilbert matrix as H:</p></li>
</ol>
<h3 id="p2-due-1026">P2 Due 10/26</h3>
<ol start="2" style="list-style-type: decimal">
<li>Create the 4x4 and 5x5 <a href="https://en.wikipedia.org/wiki/Hilbert_matrix">Hilbert matrix</a> as H. Include the following results in your README before 10/26 by midnight:</li>
</ol>
<ol style="list-style-type: lower-alpha">
<li><p>What are the 2-norm, frobenius-norm, 0-norm and infinity-norm of the 4x4 and 5x5 Hilbert matrices?</p></li>
<li><p>What are the 2-norm, frobenius-norm, 0-norm and infinity-norm of the 4x4 and 5x5 inverse Hilbert matrices?</p></li>
<li><p>What are the condition numbers for the 2-norm, frobenius-norm, 0-norm and infinity-norm of the 4x4 and 5x5 Hilbert matrices?</p></li>
</ol>
<h3 id="p3-4-due-1030">P3-4 Due 10/30</h3>
<ol start="3" style="list-style-type: decimal">
<li><p>Create an LU-decomposition function called <code>lu_tridiag.m</code> that takes 3 vectors as inputs and calculates the LU-decomposition of a tridiagonal matrix. The output should be 3 vectors, the diagonal of the Upper matrix, and the two off-diagonal vectors of the Lower and Upper matrices.</p>
<p><code>[ud,uo,lo]=lu_tridiag(e,f,g);</code></p></li>
<li><p>Use the output from <code>lu_tridiag.m</code> to create a forward substitution and back-substitution function called <code>solve_tridiag.m</code> that provides the solution of Ax=b given the vectors from the output of [ud,uo,lo]=lu_tridiag(e,f,g). <em>Note: do not use the backslash solver <code>\</code>, create an algebraic solution</em></p>
<p><code>x=solve_tridiag(ud,uo,lo,b);</code></p></li>
<li><p>Create a Cholesky factorization function called <code>chol_tridiag.m</code> that takes 2 vectors as inputs and calculates the Cholseky factorization of a tridiagonal matrix. The output should be 2 vectors, the diagonal and the off-diagonal vector of the Cholesky matrix.</p>
<p><code>[d,u]=chol_tridiag(e,f);</code></p></li>
<li><p>Use the output from <code>chol_tridiag.m</code> to create a forward substitution and back-substitution function called <code>solve_tridiag.m</code> that provides the solution of Ax=b given the vectors from the output of [d,u]=lu_tridiag(e,f). <em>Note: do not use the backslash solver <code>\</code>, create an algebraic solution</em></p>
<p><code>x=solve_tridiag(d,u,b);</code></p></li>
</ol>
<div class="figure">
<img src="mass_springs.png" alt="Spring-mass system for problem 5" />
<img src="./figures/mass_springs.png" alt="Spring-mass system for problem 5" />
<p class="caption">Spring-mass system for problem 5</p>
</div>
<ol start="5" style="list-style-type: decimal">
Expand All @@ -44,28 +49,36 @@
<li><p>K1=K3=K4=1000 N/m, K2=1000e-12 N/m</p></li>
</ol>
<ol start="6" style="list-style-type: decimal">
<li>Use <code>lu_tridiag.m</code> and <code>solve_tridiag.m</code> to solve for the displacements of hanging masses 1-4 shown above, if all masses are 1 kg.</li>
<li>Use <code>chol_tridiag.m</code> and <code>solve_tridiag.m</code> to solve for the displacements of hanging masses 1-4 shown above in 5a-c, if all masses are 1 kg.</li>
</ol>
<div class="figure">
<img src="spring_mass.png" alt="Spring-mass system for analysis" />
<img src="./figures/spring_mass.png" alt="Spring-mass system for analysis" />
<p class="caption">Spring-mass system for analysis</p>
</div>
<ol start="7" style="list-style-type: decimal">
<li><p>In the system shown above, determine the three differential equations for the position of masses 1, 2, and 3. Solve for the vibrational modes of the spring-mass system if k1=10 N/m, k2=k3=20 N/m, and k4=10 N/m. The masses are m1=1 kg, m2=2 kg and m3=4 kg. Create a function, <code>mass_spring_vibrate.m</code> that outputs the vibration modes and natural frequencies based upon the parameters, k1, k2, k3, and k4.</p></li>
<li><p>The curvature of a slender column subject to an axial load P can be modeled by</p></li>
</ol>
<p><span class="math inline">\(\frac{d^{2}y}{dx^{2}} + p^{2} y = 0\)</span></p>
<p>where <span class="math inline">\(p^{2} = \frac{P}{EI}\)</span></p>
<div class="figure">
<img src="./equations/d2ydx2.png" />

</div>
<p>where <span class="math inline">\(p^{2} = \frac{P}{EI}\)</span> <img src="./equations/p2.png" /></p>
<p>where E = the modulus of elasticity, and I = the moment of inertia of the cross section about its neutral axis.</p>
<p>This model can be converted into an eigenvalue problem by substituting a centered finite-difference approximation for the second derivative to give <span class="math inline">\(\frac{y_{i+1} -2y_{i} + y_{i-1} }{\Delta x^{2}}+ p^{2} y_{i}\)</span></p>
<p>where i = a node located at a position along the rod’s interior, and <span class="math inline">\(\Delta x\)</span> = the spacing between nodes. This equation can be expressed as <span class="math inline">\(y_{i-1} - (2 - \Delta x^{2} p^{2} )y_{i} y_{i+1} = 0\)</span> Writing this equation for a series of interior nodes along the axis of the column yields a homogeneous system of equations. (See 13.10 for 4 interior-node example)</p>
<div class="figure">
<img src="./equations/delta2y.png" />

</div>
<p>where i = a node located at a position along the rod’s interior, and <span class="math inline">\(\Delta x\)</span> = the spacing between nodes. This equation can be expressed as <span class="math inline">\(y_{i-1} - (2 - \Delta x^{2} p^{2} )y_{i} +y_{i+1} = 0\)</span> <img src="./equations/solve.png" /> Writing this equation for a series of interior nodes along the axis of the column yields a homogeneous system of equations. (See 13.10 for 4 interior-node example)</p>
<p>Determine the eigenvalues for a 5-segment (4-interior nodes), 6-segment (5-interior nodes), and 10-segment (9-interior nodes). Using the modulus and moment of inertia of a pole for pole-vaulting ( <a href="http://people.bath.ac.uk/taf21/sports_whole.htm" class="uri">http://people.bath.ac.uk/taf21/sports_whole.htm</a>) E=76E9 Pa, I=4E-8 m^4, and L= 5m.</p>
<p>Include a table in the <code>README.md</code> that shows the following results: What are the largest and smallest loads in the beam based upon the different shapes? How many eigenvalues are there?</p>
<pre><code>| # of segments | largest load (N) | smallest load (N) | # of eigenvalues |
| --- | --- | --- | --- |
| 5 | ... | ... | ... |
| 6 | ... | ... | ... |
| 10 | ... | ... | ... |</code></pre>
<p>If the segment length (<span class="math inline">\(\Delta x\)</span>) approaches 0, how many eigenvalues would there be?</p>
<p>If the segment length approaches 0, how many eigenvalues would there be?</p>
</body>
</html>
34 changes: 19 additions & 15 deletions HW4/README.md
@@ -1,18 +1,21 @@
# Homework #4
## due 11/2/17 by 11:59pm
## final commit due 11/2/17 by 11:59pm

*Include all work as either an m-file script, m-file function, or example code included
with \`\`\` and document your code in the README.md file*

### P1-2 Due 10/26

1. Create a new github repository called '04_linear_algebra'.

a. Add rcc02007 and zhs15101 as collaborators.

b. Clone the repository to your computer.

c. Complete this before 10/26 by midnight
c. Submit clone repo link to
[https://goo.gl/forms/gFNxhNM4qJJKj8hE3](https://goo.gl/forms/gFNxhNM4qJJKj8hE3)

2. Create the 4x4 and 5x5 Hilbert matrix as H. Include the following results in your
2. Create the 4x4 and 5x5 [Hilbert matrix](https://en.wikipedia.org/wiki/Hilbert_matrix) as H. Include the following results in your
README before 10/26 by midnight:

a. What are the 2-norm, frobenius-norm, 0-norm and infinity-norm of the 4x4 and 5x5
Expand All @@ -24,21 +27,22 @@ README before 10/26 by midnight:
c. What are the condition numbers for the 2-norm, frobenius-norm, 0-norm and
infinity-norm of the 4x4 and 5x5 Hilbert matrices?

3. Create an LU-decomposition function called `lu_tridiag.m` that takes 3 vectors as inputs
and calculates the LU-decomposition of a tridiagonal matrix. The output should be 3
vectors, the diagonal of the Upper matrix, and the two off-diagonal vectors of the Lower
and Upper matrices.
### P3-4 Due 10/30

3. Create a Cholesky factorization function called `chol_tridiag.m` that takes 2 vectors
as inputs and calculates the Cholseky factorization of a tridiagonal matrix. The output
should be 2 vectors, the diagonal and the off-diagonal vector of the Cholesky matrix.

```[ud,uo,lo]=lu_tridiag(e,f,g);```
```[d,u]=chol_tridiag(e,f);```

4. Use the output from `lu_tridiag.m` to create a forward substitution and
4. Use the output from `chol_tridiag.m` to create a forward substitution and
back-substitution function called `solve_tridiag.m` that provides the solution of
Ax=b given the vectors from the output of [ud,uo,lo]=lu_tridiag(e,f,g). *Note: do not use
Ax=b given the vectors from the output of [d,u]=lu_tridiag(e,f). *Note: do not use
the backslash solver `\`, create an algebraic solution*

```x=solve_tridiag(ud,uo,lo,b);```
```x=solve_tridiag(d,u,b);```

![Spring-mass system for problem 5](mass_springs.png)
![Spring-mass system for problem 5](./figures/mass_springs.png)

5. Create the stiffness matrix for the 4-mass system shown above
for cases a-c. Calculate the condition of the stiffness matrices. What is the expected error
Expand All @@ -50,10 +54,10 @@ when calculating the displacements of the 4 masses? Include the analysis and res

c. K1=K3=K4=1000 N/m, K2=1000e-12 N/m

6. Use `lu_tridiag.m` and `solve_tridiag.m` to solve for the displacements of hanging
masses 1-4 shown above, if all masses are 1 kg.
6. Use `chol_tridiag.m` and `solve_tridiag.m` to solve for the displacements of hanging
masses 1-4 shown above in 5a-c, if all masses are 1 kg.

![Spring-mass system for analysis](spring_mass.png)
![Spring-mass system for analysis](./figures/spring_mass.png)

7. In the system shown above, determine the three differential equations for the position
of masses 1, 2, and 3. Solve for the vibrational modes of the spring-mass system if k1=10
Expand Down
11 changes: 11 additions & 0 deletions HW4/chol_tridiag.m
@@ -0,0 +1,11 @@
function [d,u]=lu_tridiag(e,f);
% chol_tridiag calculates the components for Cholesky factorization of a symmetric
% positive definite tridiagonal matrix
% given its off-diagonal vector, e
% and diagonal vector f
% the output is
% the diagonal of the Upper matrix, d
% the off-diagonal of the Upper matrix, u

end

12 changes: 0 additions & 12 deletions HW4/lu_tridiag.m

This file was deleted.

6 changes: 2 additions & 4 deletions HW4/solve_tridiag.m
@@ -1,11 +1,9 @@
function x=solve_tridiag(ud,uo,lo,b);```
% solve_tridiag solves Ax=b for x
% given
% the diagonal of the Upper matrix, ud
% the off-diagonal of the Upper matrix, uo
% the off-diagonal of the Lower matrix, lo
% the diagonal of the Cholesky matrix, d
% the off-diagonal of the Upper matrix, u
% the vector b
% note: the diagonal of the Lower matrix is all ones

end

0 comments on commit 90b323b

Please sign in to comment.