diff --git a/HW6/README.md b/HW6/README.md index 1f3c86c..c72ba05 100644 --- a/HW6/README.md +++ b/HW6/README.md @@ -34,12 +34,14 @@ variable is failure (1=fail, 0=pass). Create a function called `cost_logistic.m` takes the vector `a`, and independent variable `x` and dependent variable `y`. Use the function, $\sigma(t)=\frac{1}{1+e^{-t}}$ where $t=a_{0}+a_{1}x$. Use the cost function, - $J(a_{0},a_{1})=\sum_{i=1}^{n}\left[-y_{i}\log(\sigma(t_{i}))-(1-y_{i})\log((1-\sigma(t_{i})))\right]$ + $J(a_{0},a_{1})=1/m\sum_{i=1}^{n}\left[-y_{i}\log(\sigma(t_{i}))-(1-y_{i})\log((1-\sigma(t_{i})))\right]$ and gradient $\frac{\partial J}{\partial a_{i}}= - 1/m\sum_{k=1}^{N}\left(\sigma(t_{k})-y_{k}\right)t_{k}$ + 1/m\sum_{k=1}^{N}\left(\sigma(t_{k})-y_{k}\right)x_{k}^{i}$ + + where $x_{k}^{i} is the k-th value of temperature raised to the i-th power (0, and 1) a. edit `cost_logistic.m` so that the output is `[J,grad]` or [cost, gradient] diff --git a/HW6/problem_1_data.m b/HW6/problem_1_data.m index 6af2956..3606608 100644 --- a/HW6/problem_1_data.m +++ b/HW6/problem_1_data.m @@ -1,7 +1,7 @@ % part a xa=[1 2 3 4 5]'; -yb=[2.2 2.8 3.6 4.5 5.5]'; +ya=[2.2 2.8 3.6 4.5 5.5]'; % part b @@ -10,6 +10,6 @@ % part c -xc=[0.5 1 2 3 4 5 6 7 9]; -yc=[6 4.4 3.2 2.7 2.2 1.9 1.7 1.4 1.1]; +xc=[0.5 1 2 3 4 5 6 7 9]'; +yc=[6 4.4 3.2 2.7 2.2 1.9 1.7 1.4 1.1]'; diff --git a/final_project/README.md b/final_project/README.md new file mode 100644 index 0000000..cee3ee3 --- /dev/null +++ b/final_project/README.md @@ -0,0 +1,103 @@ +# ME 3255 - Final Project +## Due May 1 by 11:59pm + +In this project you are going to solve for the shape of a beam under different loading +conditions. The shape of the beam varies along the x-axis and as a function of time. + +Notes: Label the plots with legends, x- and y-axis labels and make sure the plots are easy +to read (you can use the `setdefaults.m` script we have used in class). All functions +should have a help file and your README.md should describe each file in your repository +and provide a description of each problem and each solution (use `#`-headings in your file +to show the start of new problems) + +You will be graded both on documentation and implementation of the solutions. + +![Diagram of beam and loading conditions](beam.png) + +We will use the Euler-Bernoulli beam equation to describe the shape of the beam, the +differential equation that governs the solution is: + +$\frac{\partial^4 w}{\partial x^4}-\frac{P}{EI}\frac{\partial^2 w}{\partial +x^2}+\frac{\rho A}{EI}\frac{\partial^2 w}{\partial t^2}=q(x)$ (1) + +Where w(x,t) is the displacement of the beam away from the neutral axis as a function of +position along the beam, x, and time, t, P is the transverse loading of the beam, E is the +Young's modulus, I is the second moment of Inertia of the beam, $\rho$ is the density, A +is the cross-sectional area, and q(x) is the transverse distributed load (for a uniform +pressure, it is the applied pressure times the width of the beam, in units of +force/length). + +We can separate the function $w(x,t)=w(x)e^{i\omega t}$, now equation (1) becomes + +$\left(\frac{\partial^4 w}{\partial x^4}-\frac{P}{EI}\frac{\partial^2 w}{\partial +x^2}-\frac{\rho A \omega^{2}}{EI}w\right)e^{i\omega t}=\frac{q(x)}{EI}$ (2) + +For the simply-supported beam shown in Figure 1, the boundary conditions are: + +$w(0)=w(L)=0$ + +$w''(0)=w''(L)=0$ + +The material is aluminum, E=70 GPa, $\rho$=2700 kg/m$^3$. The bar is 1-m-long with a base +width, b=0.1 m, and height, h=0.01 m, and the second moment of inertia, +I=$\frac{bh^3}{12}$. + +1. Analytically solve for the shape of the beam if q(x)=cst, P=0, and $\omega$=0 and +create a function called `shape_simple_support.m` that returns the displacement w(x) given +q and x + +``` +w=shape_simple_support(x,q); +``` + +a. Plot q vs the maximum deflection, $\delta x$, of the beam + +b. Use a Monte Carlo model to determine the mean and standard deviation for the +maximum deflection $\delta x$ if b and h are normally distributed random variables +with 0.1 % standard deviations at q=50 N/m. + +3. Now use the central difference approximation to set up a system of equations for the +beam for q(x)=cst, P=0, and $\omega=0$. Use the boundary conditions with a numerical +differentiation to determine the valuea of the end points + + a. set up the system of equations for 6 segments as a function of q + + b. set up the system of equations for 10 segments as a function of q + + c. set up the system of equations for 20 segments as a function of q + + d. solve a-c for q=1,10,20,30,50 and plot the numerical results of q vs $\delta x$ + + e. Comment on the results from the analytical and numerical approaches (if you used + functions then provide help files, if you used scripts, then describe the steps used) + +4. Now set up the system of equations using a central difference method if P>0 and +$\omega=0$ + + a. set up the system of equations for 6 segments as a function of q and P + + b. set up the system of equations for 10 segments as a function of q and P + + c. set up the system of equations for 20 segments as a function of q and P + + d. solve a-c for q=1,10,20,30,50 and plot the numerical results of q vs $\delta x$ for + P=0, 100, 200, 300 (4 lines, labeled as P=0,P=100,...) + +5. Now set up an eigenvalue problem to solve for the natural frequencies of the simply +supported beam if P=0 and q=0. + + a. set up the system of equations for 6 segments + + b. set up the system of equations for 10 segments + + c. set up the system of equations for 20 segments + + d. solve for the natural frequencies ($\omega_{1}$, $\omega_{2}$,...) + + e. Plot the shape of the beam for the first 3 natural frequencies + +6. (Bonus 5pt) Create a function to return the system of equations for the eigenvalue +problem as a function of P, if P>0. Then, plot the lowest natural frequency vs the applied +load P. + + diff --git a/final_project/beam.png b/final_project/beam.png new file mode 100644 index 0000000..271d614 Binary files /dev/null and b/final_project/beam.png differ diff --git a/final_project/beam.svg b/final_project/beam.svg new file mode 100644 index 0000000..b02b62d --- /dev/null +++ b/final_project/beam.svg @@ -0,0 +1,615 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + q(x) + P + P + + + w(x) + + + x + y + + diff --git a/final_project/final_project.pdf b/final_project/final_project.pdf new file mode 100644 index 0000000..3df5f1f Binary files /dev/null and b/final_project/final_project.pdf differ diff --git a/final_project/rubric.md b/final_project/rubric.md new file mode 100644 index 0000000..08248bd --- /dev/null +++ b/final_project/rubric.md @@ -0,0 +1,27 @@ +# Grading Rubric + +| Component | Grade | Description | +| --------- |------ |--------------------------------- | +|Solutions | 50 % | Problems are solved correctly and solution makes sense | +|Documentation| 30 % | All files have comments and all functions have help files | +|Problem Statements | 10% | Descriptions of each problem and the approach | +|Team Work | 10% | Each group member made commits to repository| +|Github Bonus | 5% | If a group member opens an [issue](https://guides.github.com/features/issues/) and you commit code to close it| + +The Documentation and Problem Statements will be assessed based upon the included m-files +and the main README.md documentation. This is a final report, so make sure the README.md +is easy to understand with headers (`#`, `##`, ...) to start each problem and sub-problem. + +The Solutions will be graded based upon correctness and the approach. The plots will be +graded based upon the axis labels, titles, legend, correctness, and design. +If you are asked to solve for a value, you can choose to put it in a table or in a +paragraph, but it must be easy to read/understand. + +The Team Work section is meant to demonstrate working knowledge of Github (now as a +collaborative project). If everyone makes commits to the project, then you will receive +credit. + +The Github Bonus requires extra reading. Create an issue and tag your group member. That +group member can then respond and *fix* the issue with a commit. This is a bonus 5pts (on +an individual basis, for everyone to get credit, everyone in the group would need to close +an issue) diff --git a/lecture_17/octave-workspace b/lecture_17/octave-workspace index c9ec2aa..8c437bb 100644 Binary files a/lecture_17/octave-workspace and b/lecture_17/octave-workspace differ diff --git a/lecture_18/octave-workspace b/lecture_18/octave-workspace index d40f9ac..8c437bb 100644 Binary files a/lecture_18/octave-workspace and b/lecture_18/octave-workspace differ diff --git a/lecture_19/octave-workspace b/lecture_19/octave-workspace index 4bd89dd..8c437bb 100644 Binary files a/lecture_19/octave-workspace and b/lecture_19/octave-workspace differ diff --git a/lecture_20/lecture_20.ipynb b/lecture_20/lecture_20.ipynb index 50f858a..da8c4ac 100644 --- a/lecture_20/lecture_20.ipynb +++ b/lecture_20/lecture_20.ipynb @@ -2,7 +2,7 @@ "cells": [ { "cell_type": "code", - "execution_count": 1, + "execution_count": 152, "metadata": { "collapsed": true }, @@ -13,7 +13,7 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": 153, "metadata": { "collapsed": true }, @@ -97,17 +97,19 @@ "source": [ "# Integrals in practice\n", "\n", - "### Example: Compare toughness of two steels\n", + "### Example: Compare toughness of Stainless steel to Structural steel\n", "\n", "![Stress-strain plot of steel](steel_psi.jpg)\n", "\n", + "### Step 1 - G3Data to get points \n", + "\n", "Use the plot shown to determine the toughness of stainless steel and the toughness of structural steel.\n", "\n" ] }, { "cell_type": "code", - "execution_count": 49, + "execution_count": 154, "metadata": { "collapsed": false }, @@ -162,7 +164,7 @@ }, { "cell_type": "code", - "execution_count": 147, + "execution_count": 155, "metadata": { "collapsed": false }, @@ -347,7 +349,7 @@ }, { "cell_type": "code", - "execution_count": 148, + "execution_count": 156, "metadata": { "collapsed": false }, @@ -429,7 +431,7 @@ }, { "cell_type": "code", - "execution_count": 15, + "execution_count": 157, "metadata": { "collapsed": true }, @@ -448,7 +450,7 @@ }, { "cell_type": "code", - "execution_count": 13, + "execution_count": 159, "metadata": { "collapsed": false }, @@ -457,12 +459,12 @@ "name": "stdout", "output_type": "stream", "text": [ - "ans = 3.5000\r\n" + "ans = 6.6250\r\n" ] } ], "source": [ - "gauss_1pt(f1,2,3)" + "gauss_1pt(f2,2,3)" ] }, { @@ -496,7 +498,7 @@ }, { "cell_type": "code", - "execution_count": 149, + "execution_count": 164, "metadata": { "collapsed": false }, @@ -507,7 +509,13 @@ "text": [ "ans = 6.6667\n", "ans = 6.6667\n", - "ans = 6.6667\n" + "ans = 6.6667\n", + "f_c =\n", + "\n", + "@(x) cosh (x / 30) + exp (-10 * x) .* erf (x)\n", + "\n", + "ans = 2.0048\n", + "ans = 2.0048\n" ] } ], @@ -515,7 +523,11 @@ "% integral of quadratic\n", "quad(f2,2,3)\n", "quadl(f2,2,3)\n", - "f3(3)-f3(2)" + "f3(3)-f3(2)\n", + "f_c=@(x) cosh(x/30)+exp(-10*x).*erf(x)\n", + "\n", + "quad(f_c,1,3)\n", + "quadl(f_c,1,3)" ] }, { @@ -531,7 +543,7 @@ }, { "cell_type": "code", - "execution_count": 82, + "execution_count": 165, "metadata": { "collapsed": false }, @@ -682,7 +694,7 @@ "\t\n", "\tgnuplot_plot_2a\n", "\n", - "\t\n", + "\t\n", "\t\n", "\n", "\n", @@ -713,7 +725,7 @@ }, { "cell_type": "code", - "execution_count": 98, + "execution_count": 166, "metadata": { "collapsed": false }, @@ -767,31 +779,36 @@ "\n", "\n", "\t\t\n", + "\t\t-2\n", + "\t\n", + "\n", + "\n", + "\t\t\n", "\t\t-1.5\n", "\t\n", "\n", "\n", - "\t\t\n", + "\t\t\n", "\t\t-1\n", "\t\n", "\n", "\n", - "\t\t\n", + "\t\t\n", "\t\t-0.5\n", "\t\n", "\n", "\n", - "\t\t\n", + "\t\t\n", "\t\t0\n", "\t\n", "\n", "\n", - "\t\t\n", + "\t\t\n", "\t\t0.5\n", "\t\n", "\n", "\n", - "\t\t\n", + "\t\t\n", "\t\t1\n", "\t\n", "\n", @@ -860,11 +877,11 @@ "\n", "\n", "\n", - "\t\n", + "\t\n", "\t\n", "\tgnuplot_plot_2a\n", "\n", - "\t\n", + "\t\n", "\t\n", "\n", "\n", @@ -919,7 +936,7 @@ }, { "cell_type": "code", - "execution_count": 99, + "execution_count": 168, "metadata": { "collapsed": false }, @@ -973,31 +990,36 @@ "\n", "\n", "\t\t\n", + "\t\t-2\n", + "\t\n", + "\n", + "\n", + "\t\t\n", "\t\t-1.5\n", "\t\n", "\n", "\n", - "\t\t\n", + "\t\t\n", "\t\t-1\n", "\t\n", "\n", "\n", - "\t\t\n", + "\t\t\n", "\t\t-0.5\n", "\t\n", "\n", "\n", - "\t\t\n", + "\t\t\n", "\t\t0\n", "\t\n", "\n", "\n", - "\t\t\n", + "\t\t\n", "\t\t0.5\n", "\t\n", "\n", "\n", - "\t\t\n", + "\t\t\n", "\t\t1\n", "\t\n", "\n", @@ -1070,7 +1092,7 @@ "\t\n", "\n", "\n", - "\t\n", + "\t\n", "\t\n", "\tno change\n", "\n", @@ -1079,7 +1101,7 @@ "\t\n", "\n", "\n", - "\t\n", + "\t\n", "\t\n", "\n", "\n", @@ -1110,7 +1132,7 @@ }, { "cell_type": "code", - "execution_count": 100, + "execution_count": 169, "metadata": { "collapsed": false }, @@ -1119,7 +1141,7 @@ "name": "stdout", "output_type": "stream", "text": [ - "a = 0.99838\r\n" + "a = 1.0007\r\n" ] }, { @@ -1259,11 +1281,11 @@ "\n", "\n", "\n", - "\t\n", + "\t\n", "\t\n", "\tgnuplot_plot_2a\n", "\n", - "\t\n", + "\t\n", "\t\n", "\n", "\n", @@ -1554,39 +1576,7 @@ }, { "cell_type": "code", - "execution_count": 120, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "a =\n", - "\n", - " 1 2 3 4 5\n", - "\n", - "pa =\n", - "\n", - " 2 1 1 2 3 4 5 5 4\n", - "\n", - "ans =\n", - "\n", - " 1 9\n", - "\n" - ] - } - ], - "source": [ - "a=[1,2,3,4,5]\n", - "pa=[a(4/2:-1:1) a a(end:-1:end-4/2+1)]\n", - "size(pa)" - ] - }, - { - "cell_type": "code", - "execution_count": 137, + "execution_count": 170, "metadata": { "collapsed": false }, @@ -1738,111 +1728,111 @@ "\n", "\n", "\n", - "\t\n", + "\t\n", "\t\n", "\tgnuplot_plot_2a\n", "\n", "\t \n", - "\t\n", - "\t\n", - "\t\n", - "\t\n", - "\t\n", - "\t\n", - "\t\n", - "\t\n", - "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", "\t\n", - "\t\n", - "\t\n", - "\t\n", - "\t\n", - "\t\n", - "\t\n", - "\t\n", - "\t\n", - "\t\n", - "\t\n", - "\t\n", - "\t\n", - "\t\n", - "\t\n", - "\t\n", - "\t\n", - "\t\n", - "\t\n", - "\t\n", - "\t\n", - "\t\n", - "\t\n", - "\t\n", - "\t\n", - "\t\n", - "\t\n", - "\t\n", - "\t\n", - "\t\n", - "\t\n", - "\t\n", - "\t\n", - "\t\n", - "\t\n", - "\t\n", - "\t\n", - "\t\n", - "\t\n", - "\t\n", - "\t\n", - "\t\n", - "\t\n", - "\t\n", - "\t\n", - "\t\n", - "\t\n", - "\t\n", - "\t\n", - "\t\n", - "\t\n", - "\t\n", - "\t\n", - "\t\n", - "\t\n", - "\t\n", - "\t\n", - "\t\n", - "\t\n", - "\t\n", - "\t\n", - "\t\n", - "\t\n", - "\t\n", - "\t\n", - "\t\n", - "\t\n", - "\t\n", - "\t\n", - "\t\n", - "\t\n", - "\t\n", - "\t\n", - "\t\n", - "\t\n", - "\t\n", - "\t\n", - "\t\n", - "\t\n", - "\t\n", - "\t\n", - "\t\n", - "\t\n", - "\t\n", - "\t\n", - "\t\n", - "\t\n", - "\t\n", - "\t\n", - "\t\n", - "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", "\n", "\t\n", "\n", @@ -1879,7 +1869,7 @@ }, { "cell_type": "code", - "execution_count": 138, + "execution_count": 171, "metadata": { "collapsed": false }, @@ -1933,31 +1923,36 @@ "\n", "\n", "\t\t\n", + "\t\t-2\n", + "\t\n", + "\n", + "\n", + "\t\t\n", "\t\t-1.5\n", "\t\n", "\n", "\n", - "\t\t\n", + "\t\t\n", "\t\t-1\n", "\t\n", "\n", "\n", - "\t\t\n", + "\t\t\n", "\t\t-0.5\n", "\t\n", "\n", "\n", - "\t\t\n", + "\t\t\n", "\t\t0\n", "\t\n", "\n", "\n", - "\t\t\n", + "\t\t\n", "\t\t0.5\n", "\t\n", "\n", "\n", - "\t\t\n", + "\t\t\n", "\t\t1\n", "\t\n", "\n", @@ -2026,113 +2021,113 @@ "\n", "\n", "\n", - "\t\n", + "\t\n", "\t\n", "\tgnuplot_plot_2a\n", "\n", - "\t\n", + "\t\n", "\t\n", "\tgnuplot_plot_3a\n", "\n", "\t \n", - "\t\n", - "\t\n", - "\t\n", - "\t\n", - "\t\n", - "\t\n", - "\t\n", - "\t\n", - "\t\n", - "\t\n", - "\t\n", - "\t\n", - "\t\n", - "\t\n", - "\t\n", - "\t\n", - "\t\n", - "\t\n", - "\t\n", - "\t\n", - "\t\n", - "\t\n", - "\t\n", - "\t\n", - "\t\n", - "\t\n", - "\t\n", - "\t\n", - "\t\n", - "\t\n", - "\t\n", - "\t\n", - "\t\n", - "\t\n", - "\t\n", - "\t\n", - "\t\n", - "\t\n", - "\t\n", - "\t\n", - "\t\n", - "\t\n", - "\t\n", - "\t\n", - "\t\n", - "\t\n", - "\t\n", - "\t\n", - "\t\n", - "\t\n", - "\t\n", - "\t\n", - "\t\n", - "\t\n", - "\t\n", - "\t\n", - "\t\n", - "\t\n", - "\t\n", - "\t\n", - "\t\n", - "\t\n", - "\t\n", - "\t\n", - "\t\n", - "\t\n", - "\t\n", - "\t\n", - "\t\n", - "\t\n", - "\t\n", - "\t\n", - "\t\n", - "\t\n", - "\t\n", - "\t\n", - "\t\n", - "\t\n", - "\t\n", - "\t\n", - "\t\n", - "\t\n", - "\t\n", - "\t\n", - "\t\n", - "\t\n", - "\t\n", - "\t\n", - "\t\n", - "\t\n", - "\t\n", - "\t\n", - "\t\n", - "\t\n", - "\t\n", - "\t\n", - "\t\n", - "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", "\n", "\t\n", "\n", diff --git a/lecture_20/octave-workspace b/lecture_20/octave-workspace new file mode 100644 index 0000000..41ef164 Binary files /dev/null and b/lecture_20/octave-workspace differ diff --git a/lecture_21/.ipynb_checkpoints/lecture_21-checkpoint.ipynb b/lecture_21/.ipynb_checkpoints/lecture_21-checkpoint.ipynb new file mode 100644 index 0000000..2fd6442 --- /dev/null +++ b/lecture_21/.ipynb_checkpoints/lecture_21-checkpoint.ipynb @@ -0,0 +1,6 @@ +{ + "cells": [], + "metadata": {}, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/lecture_21/lecture_21.ipynb b/lecture_21/lecture_21.ipynb new file mode 100644 index 0000000..c2547e6 --- /dev/null +++ b/lecture_21/lecture_21.ipynb @@ -0,0 +1,430 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 1, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "%plot --format svg" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "setdefaults" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "![q1](q1.png)\n", + "\n", + "![q2](q2.png)\n", + "\n", + "## Reduce Noise in derivative of data\n", + "\n", + "![reduce noise](reduce_noise.png)\n", + "\n", + "- Turn the volume down!\n", + "\n", + "- Use robust statistics like median and mean absolute deviation\n", + "\n", + "- Gauss quadrature\n", + "\n", + "- Put a filter on it\n", + "\n", + "- Take the average\n", + "\n", + "- Low-pass filter\n", + "\n", + "- Expand the Taylor series\n", + "\n", + "- Fit a function and derive that\n", + "\n", + "\n" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "error: subscript indices must be either positive integers less than 2^31 or logicals\n", + "ans =\n", + "\n", + " 1 100\n", + "\n" + ] + }, + { + "data": { + "image/svg+xml": [ + "\n", + "\n", + "Gnuplot\n", + "Produced by GNUPLOT 5.0 patchlevel 3 \n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t \n", + "\t \n", + "\t\n", + "\t\n", + "\t \n", + "\t \n", + "\t\n", + "\n", + "\n", + "\n", + "\n", + "\t\n", + "\t\t\n", + "\t\n", + "\n", + "\n", + "\n", + "\n", + "\t\t\n", + "\t\t-1.5\n", + "\t\n", + "\n", + "\n", + "\t\t\n", + "\t\t-1\n", + "\t\n", + "\n", + "\n", + "\t\t\n", + "\t\t-0.5\n", + "\t\n", + "\n", + "\n", + "\t\t\n", + "\t\t0\n", + "\t\n", + "\n", + "\n", + "\t\t\n", + "\t\t0.5\n", + "\t\n", + "\n", + "\n", + "\t\t\n", + "\t\t1\n", + "\t\n", + "\n", + "\n", + "\t\t\n", + "\t\t1.5\n", + "\t\n", + "\n", + "\n", + "\t\t\n", + "\t\t-4\n", + "\t\n", + "\n", + "\n", + "\t\t\n", + "\t\t-3\n", + "\t\n", + "\n", + "\n", + "\t\t\n", + "\t\t-2\n", + "\t\n", + "\n", + "\n", + "\t\t\n", + "\t\t-1\n", + "\t\n", + "\n", + "\n", + "\t\t\n", + "\t\t0\n", + "\t\n", + "\n", + "\n", + "\t\t\n", + "\t\t1\n", + "\t\n", + "\n", + "\n", + "\t\t\n", + "\t\t2\n", + "\t\n", + "\n", + "\n", + "\t\t\n", + "\t\t3\n", + "\t\n", + "\n", + "\n", + "\t\t\n", + "\t\t4\n", + "\t\n", + "\n", + "\n", + "\n", + "\n", + "\t\n", + "\n", + "\n", + "\tgnuplot_plot_1a\n", + "\n", + "\n", + "\n", + "\t\n", + "\t\n", + "\tgnuplot_plot_2a\n", + "\n", + "\t \n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\n", + "\t\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "x=linspace(-pi,pi);\n", + "y_smooth=sin(x);\n", + "y_noise =y_smooth+rand(size(x))*0.1-0.05;\n", + "\n", + "% Smooth data\n", + "N=20; % average data between 10 points (forward/backward)\n", + "y_data=[y_noise(N/2:-1:1) y_noise y_noise(end:-1:end-N/2+1)];\n", + "y_filter=y_data;\n", + "for i=6:length(x)\n", + " y_filter(i)=mean(y_data(i-10:i));\n", + "end\n", + "y_filter=y_filter(N/2:end-N/2-1);\n", + "size(y_filter)\n", + "plot(x,y_filter,x,y_noise,'.')" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Homework Review\n", + "\n", + "### HW #4\n", + "\n", + "![collar mass](../HW4/collar_mass.png)\n", + "\n", + "$E_{total}=m x_C g\\sin(\\theta)+\\frac{K}{2}\\left(0.5 - \\sqrt{0.5^2+(0.5-x_C)^2}\\right)^{2}$" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "```matlab\n", + "% Define function ...\n", + "function collar_potential_energy(x,theta)\n", + " % function to evaluate E_total\n", + " Etotal = m*x*g.*sin(theta)+K/2*(0.5-sqrt(0.5^2+(0.5-x).^2);\n", + "end\n", + "\n", + "% solve for x\n", + "\n", + "x=goldmin(@(x) collar_potential_energy(x,theta),xl,xu)\n", + "```" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## HW #5\n", + "\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Initial Value Problem" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Octave", + "language": "octave", + "name": "octave" + }, + "language_info": { + "file_extension": ".m", + "help_links": [ + { + "text": "MetaKernel Magics", + "url": "https://github.com/calysto/metakernel/blob/master/metakernel/magics/README.md" + } + ], + "mimetype": "text/x-octave", + "name": "octave", + "version": "0.19.14" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/lecture_21/q1.png b/lecture_21/q1.png new file mode 100644 index 0000000..3145b8d Binary files /dev/null and b/lecture_21/q1.png differ diff --git a/lecture_21/q2.png b/lecture_21/q2.png new file mode 100644 index 0000000..2def4d3 Binary files /dev/null and b/lecture_21/q2.png differ diff --git a/lecture_21/reduce_noise.png b/lecture_21/reduce_noise.png new file mode 100644 index 0000000..5a67ad5 Binary files /dev/null and b/lecture_21/reduce_noise.png differ