Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
added final project
  • Loading branch information
rcc02007 committed Nov 20, 2017
1 parent 54ddb55 commit f88580c
Show file tree
Hide file tree
Showing 14 changed files with 1,729 additions and 153 deletions.
241 changes: 88 additions & 153 deletions 17_integrals_and_derivatives/17_integrals.ipynb
Expand Up @@ -4,9 +4,10 @@
"cell_type": "code",
"execution_count": 1,
"metadata": {
"collapsed": true,
"slideshow": {
"slide_type": "skip"
"attributes": {
"classes": [],
"id": "",
"n": "1"
}
},
"outputs": [],
Expand All @@ -18,9 +19,10 @@
"cell_type": "code",
"execution_count": 2,
"metadata": {
"collapsed": true,
"slideshow": {
"slide_type": "skip"
"attributes": {
"classes": [],
"id": "",
"n": "2"
}
},
"outputs": [],
Expand All @@ -30,42 +32,30 @@
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"# Numerical Integrals"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"metadata": {},
"source": [
"# Numerical Integrals\n",
"\n",
"# Integrals in practice\n",
"\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",
"### 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"
"Use the plot shown to determine the toughness of stainless steel and the\n",
"toughness of structural steel."
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {
"collapsed": false,
"slideshow": {
"slide_type": "slide"
"attributes": {
"classes": [],
"id": "",
"n": "9"
}
},
"outputs": [
Expand All @@ -91,30 +81,20 @@
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"metadata": {},
"source": [
"# Gauss Quadrature (for functions)\n",
"\n",
"Evaluating an integral, we assumed a polynomial form for each Newton-Cotes approximation.\n",
"Evaluating an integral, we assumed a polynomial form for each Newton-Cotes\n",
"approximation.\n",
"\n",
"If we can evaluate the function at any point, it makes more sense to choose points more wisely rather than just using endpoints\n",
"If we can evaluate the function at any point, it makes more sense to choose\n",
"points more wisely rather than just using endpoints\n",
"\n",
"![trapezoidal example](trap_example.png)"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"Set up two unknown constants, $c_{0}$ and $x_{0}$ and determine a *wise* place to evaluate f(x) such that \n",
"![trapezoidal example](trap_example.png)\n",
"\n",
"Set up two unknown constants, $c_{0}$ and $x_{0}$ and determine a *wise* place\n",
"to evaluate f(x) such that\n",
"\n",
"$I=c_{0}f(x_{0})$\n",
"\n",
Expand All @@ -133,9 +113,10 @@
"cell_type": "code",
"execution_count": 10,
"metadata": {
"collapsed": false,
"slideshow": {
"slide_type": "subslide"
"attributes": {
"classes": [],
"id": "",
"n": "10"
}
},
"outputs": [
Expand Down Expand Up @@ -321,9 +302,10 @@
"cell_type": "code",
"execution_count": 11,
"metadata": {
"collapsed": false,
"slideshow": {
"slide_type": "slide"
"attributes": {
"classes": [],
"id": "",
"n": "11"
}
},
"outputs": [
Expand All @@ -348,13 +330,10 @@
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"metadata": {},
"source": [
"This process is called **Gauss Quadrature**. Usually, the bounds are fixed at -1 and 1 instead of a and b\n",
"This process is called **Gauss Quadrature**. Usually, the bounds are fixed at -1\n",
"and 1 instead of a and b\n",
"\n",
"$I=c_{0}f(x_{0})$\n",
"\n",
Expand All @@ -366,17 +345,8 @@
"\n",
"so $c_{0}=2$ and $x_{0}=0$\n",
"\n",
"$I=\\int_{-1}^{1}f(x)dx \\approx 2f\\left(0\\right)$"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"source": [
"$I=\\int_{-1}^{1}f(x)dx \\approx 2f\\left(0\\right)$\n",
"\n",
"Now, integrals can be performed with a change of variable\n",
"\n",
"a=2\n",
Expand All @@ -391,18 +361,9 @@
"\n",
"at $x_{d}=-1$, x=a\n",
"\n",
"at $x_{d}=1$, x=b"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"source": [
"so \n",
"at $x_{d}=1$, x=b\n",
"\n",
"so\n",
"\n",
"$x=\\frac{(b+a) +(b-a)x_{d}}{2}$\n",
"\n",
Expand All @@ -414,27 +375,20 @@
"\n",
"$\\int_{2}^{3}x+1dx=\\int_{-1}^{1}\\left(\\frac{5 +x_{d}}{2}\n",
"+1\\right)\n",
"\\frac{3-2}{2}dx_{d}$"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "fragment"
}
},
"source": [
"$\\int_{2}^{3}x+1dx=\\int_{-1}^{1}\\left(\\frac{7}{4}+\\frac{1}{4}x_{d}\\right)dx_{d}=2\\frac{7}{4}=3.5$"
"\\frac{3-2}{2}dx_{d}$\n",
"\n",
"$\\int_{2}^{3}x+1dx=\\int_{-1}^{1}\\left(\\frac{7}{4}+\\frac{1}{4}x_{d}\\right)dx_{d}=\n",
"2\\frac{7}{4}=3.5$"
]
},
{
"cell_type": "code",
"execution_count": 12,
"metadata": {
"collapsed": true,
"slideshow": {
"slide_type": "slide"
"attributes": {
"classes": [],
"id": "",
"n": "12"
}
},
"outputs": [],
Expand All @@ -454,9 +408,10 @@
"cell_type": "code",
"execution_count": 14,
"metadata": {
"collapsed": false,
"slideshow": {
"slide_type": "fragment"
"attributes": {
"classes": [],
"id": "",
"n": "14"
}
},
"outputs": [
Expand All @@ -474,53 +429,55 @@
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"metadata": {},
"source": [
"## General Gauss weights and points\n",
"\n",
"![Gauss quadrature table](gauss_weights.png)"
"![Gauss quadrature table](gauss_weights.png)\n",
"\n",
"### If you need to evaluate an integral, to increase accuracy, increase number\n",
"of Gauss points\n",
"\n",
"### Adaptive Quadrature\n",
"\n",
"Matlab/Octave built-in functions use two types of adaptive quadrature to\n",
"increase accuracy of integrals of functions.\n",
"\n",
"1. `quad`: Simpson quadrature good for nonsmooth functions\n",
"\n",
"2. `quadl`: Lobatto quadrature good for smooth functions"
]
},
{
"cell_type": "markdown",
"cell_type": "code",
"execution_count": null,
"metadata": {
"slideshow": {
"slide_type": "slide"
"attributes": {
"classes": [
"matlab"
],
"id": ""
}
},
"outputs": [],
"source": [
"### If you need to evaluate an integral, to increase accuracy, increase number of Gauss points\n",
"\n",
"### Adaptive Quadrature\n",
"\n",
"Matlab/Octave built-in functions use two types of adaptive quadrature to increase accuracy of integrals of functions. \n",
"\n",
"1. `quad`: Simpson quadrature good for nonsmooth functions\n",
"\n",
"2. `quadl`: Lobatto quadrature good for smooth functions\n",
"\n",
"```matlab\n",
"q = quad(fun, a, b, tol, trace, p1, p2, …)\n",
"fun : function to be integrates\n",
"a, b: integration bounds\n",
"tol: desired absolute tolerance (default: 10-6)\n",
"trace: flag to display details or not\n",
"p1, p2, …: extra parameters for fun\n",
"quadl has the same arguments\n",
"```"
"quadl has the same arguments"
]
},
{
"cell_type": "code",
"execution_count": 15,
"metadata": {
"collapsed": false,
"slideshow": {
"slide_type": "subslide"
"attributes": {
"classes": [],
"id": "",
"n": "15"
}
},
"outputs": [
Expand All @@ -545,9 +502,10 @@
"cell_type": "code",
"execution_count": 16,
"metadata": {
"collapsed": false,
"slideshow": {
"slide_type": "subslide"
"attributes": {
"classes": [],
"id": "",
"n": "16"
}
},
"outputs": [
Expand All @@ -573,36 +531,13 @@
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"metadata": {},
"source": [
"# Thanks"
]
}
],
"metadata": {
"celltoolbar": "Slideshow",
"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"
}
},
"metadata": {},
"nbformat": 4,
"nbformat_minor": 2
}

0 comments on commit f88580c

Please sign in to comment.