Skip to content

update #8

Merged
merged 3 commits into from
Mar 22, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion HW4/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Homework #3
# Homework #4
## due 3/1/17 by 11:59pm


Expand Down
53 changes: 53 additions & 0 deletions HW5/README.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Style-Type" content="text/css" />
<meta name="generator" content="pandoc" />
<title></title>
<style type="text/css">code{white-space: pre;}</style>
<script src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"></script>
</head>
<body>
<h1 id="homework-5">Homework #5</h1>
<h2 id="due-32817-by-1159pm">due 3/28/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 ‘linear_algebra’.</p>
<ol style="list-style-type: lower-alpha">
<li><p>Add rcc02007 and pez16103 as collaborators.</p></li>
<li><p>Clone the repository to your computer.</p></li>
</ol></li>
<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>Test your function on the matrices A3, A4, …, A10 generated with <code>test_arrays.m</code> Solving for <code>b=ones(N,1);</code> where N is the size of A. In your <code>README.md</code> file, compare the norm of the error between your result and the result of AN.</p></li>
</ol>
<pre><code>| size of A | norm(error) |
|-----------|-------------|
| 3 | ... |
| 4 | ... |</code></pre>
<div class="figure">
<img src="spring_mass.png" alt="Spring-mass system for analysis" />
<p class="caption">Spring-mass system for analysis</p>
</div>
<ol start="5" 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. Determine the eigenvalues and natural frequencies.</p></li>
<li><p>The curvature of a slender column subject to an axial load P (Fig. P13.10) 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>
<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>
<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 eigenvalues for the beam? How many eigenvalues are there?</p>
<pre><code>| # of segments | largest | smallest | # of eigenvalues |
| --- | --- | --- | --- |
| 5 | ... | ... | ... |
| 6 | ... | ... | ... |
| 10 | ... | ... | ... |</code></pre>
<p>If the segment length approaches 0, how many eigenvalues would there be?</p>
</body>
</html>
83 changes: 83 additions & 0 deletions HW5/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
# Homework #5
## due 3/28/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*

1. Create a new github repository called 'linear_algebra'.

a. Add rcc02007 and pez16103 as collaborators.

b. Clone the repository to your computer.

2. 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.

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

3. Use the output from `lu_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
the backslash solver `\`, create an algebraic solution*

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

4. Test your function on the matrices A3, A4, ..., A10 generated with `test_arrays.m`
Solving for `b=ones(N,1);` where N is the size of A. In your `README.md` file, compare
the norm of the error between your result and the result of AN\b.

```
| size of A | norm(error) |
|-----------|-------------|
| 3 | ... |
| 4 | ... |
```

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

5. 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. Determine
the eigenvalues and natural frequencies.

6. The curvature of a slender column subject to an axial load P (Fig. P13.10) can be
modeled by

$\frac{d^{2}y}{dx^{2}} + p^{2} y = 0$

where $p^{2} = \frac{P}{EI}$

where E = the modulus of elasticity, and I = the moment of inertia of the cross section
about its neutral axis.

This model can be converted into an eigenvalue problem by
substituting a centered finite-difference approximation for the second derivative to give
$\frac{y_{i+1} -2y_{i} + y_{i-1} }{\Delta x^{2}}+ p^{2} y_{i}$

where i = a node located at a position along the rod’s interior, and $\Delta x$ = the
spacing between nodes. This equation can be expressed as $y_{i-1} - (2 - \Delta x^{2}
p^{2} )y_{i} y_{i+1} = 0$ 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)

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 (
[http://people.bath.ac.uk/taf21/sports_whole.htm](http://people.bath.ac.uk/taf21/sports_whole.htm))
E=76E9 Pa, I=4E-8 m^4, and L= 5m.

Include a table in the `README.md` that shows the following results:
What are the largest and smallest eigenvalues for the beam? How many eigenvalues are
there?

```
| # of segments | largest | smallest | # of eigenvalues |
| --- | --- | --- | --- |
| 5 | ... | ... | ... |
| 6 | ... | ... | ... |
| 10 | ... | ... | ... |
```

If the segment length ($\Delta x$) approaches 0, how many eigenvalues would there be?
Binary file added HW5/README.pdf
Binary file not shown.
12 changes: 12 additions & 0 deletions HW5/lu_tridiag.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
function [ud,uo,lo]=lu_tridiag(e,f,g);```
% lu_tridiag calculates the components for LU-decomposition of a tridiagonal matrix
% given its off-diagonal vectors, e and g
% and diagonal vector f
% the output is
% the diagonal of the Upper matrix, ud
% the off-diagonal of the Upper matrix, uo
% and the off-diagonal of the Lower matrix, lo
% note: the diagonal of the Lower matrix is all ones

end

11 changes: 11 additions & 0 deletions HW5/solve_tridiag.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
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 vector b
% note: the diagonal of the Lower matrix is all ones

end

Binary file added HW5/spring_mass.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading