-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ddb2a0d
commit 94cb53b
Showing
130 changed files
with
6,773 additions
and
652 deletions.
There are no files selected for viewing
81 changes: 81 additions & 0 deletions
81
MATH5620_NumericalSolutionsOfDifferentialEquations/5.1IVP/IVP_test.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
--- | ||
title: IVP Test | ||
math: true | ||
layout: default | ||
--- | ||
|
||
{% include mathjax.html %} | ||
|
||
<a href="https://philipnelson5.github.io/MATH5620/SoftwareManual"> Table of Contents </a> | ||
# First Order IVP Solver | ||
|
||
**Routine Name:** firstOrderIVPSolver | ||
|
||
**Author:** Philip Nelson | ||
|
||
**Language:** C++ | ||
|
||
## Description | ||
|
||
This method is used to solve the simple first order initial value problem | ||
|
||
\\[u` = \lambda u\\] | ||
|
||
with \\(u(0)=P_0\\). This ordinary differential equations has the soltion | ||
|
||
\\[u(t)=\alpha e^{\lambda t}\\] | ||
|
||
## Input | ||
|
||
`firstOrderIVPSolver(const T& lambda, const T& alpha)` requires: | ||
|
||
* `const T& l` - \\(\lambda\\) | ||
* `const T& a` - \\(\alpha\\) | ||
|
||
## Output | ||
|
||
This method returns a function that can be evaluated at any time \\(t\\) | ||
to obtain the exact solution to the analytic equation | ||
(including roundoff error). | ||
|
||
## Code | ||
{% highlight c++ %} | ||
template <typename T> | ||
auto firstOrderIVPSolver(const T& l, const T& a) | ||
{ | ||
return [=](const T& t) { return a * std::exp(l * t); }; | ||
} | ||
{% endhighlight %} | ||
|
||
## Example | ||
{% highlight c++ %} | ||
int main() | ||
{ | ||
|
||
auto solveIVP = firstOrderIVPSolver(-1.5, 7.3); | ||
|
||
for(auto t = 0; t < 10; ++t) | ||
{ | ||
std::cout << "t = " << t << " -> " << solveIVP(t) | ||
<< "\tt = " << t+10 << " -> " << solveIVP(t+10) << '\n'; | ||
} | ||
|
||
return EXIT_SUCCESS; | ||
} | ||
{% endhighlight %} | ||
|
||
## Result | ||
``` | ||
t = 0 -> 7.3 t = 10 -> 2.23309e-06 | ||
t = 1 -> 1.62885 t = 11 -> 4.98269e-07 | ||
t = 2 -> 0.363446 t = 12 -> 1.11179e-07 | ||
t = 3 -> 0.0810957 t = 13 -> 2.48074e-08 | ||
t = 4 -> 0.0180949 t = 14 -> 5.53527e-09 | ||
t = 5 -> 0.00403752 t = 15 -> 1.23509e-09 | ||
t = 6 -> 0.000900892 t = 16 -> 2.75585e-10 | ||
t = 7 -> 0.000201016 t = 17 -> 6.14913e-11 | ||
t = 8 -> 4.48528e-05 t = 18 -> 1.37206e-11 | ||
t = 9 -> 1.0008e-05 t = 19 -> 3.06147e-12 | ||
``` | ||
|
||
**Last Modification date:** 3 April 2018 |
12 changes: 12 additions & 0 deletions
12
MATH5620_NumericalSolutionsOfDifferentialEquations/5.1IVP/Makefile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
OBJS = main.cpp firstOrderIVP.hpp | ||
|
||
CC = g++ | ||
FLAGS = -std=c++17 | ||
DEBUG_FLAGS = -Og -g3 -Wall -Wextra -Werror | ||
RELEASE_FLAGS = -O3 | ||
|
||
release: $(OBJS) | ||
$(CC) $(RELEASE_FLAGS) $(FLAGS) $(OBJS) -o ivp.out | ||
|
||
debug: $(OBJS) | ||
$(CC) $(DEBUG_FLAGS) $(FLAGS) $(OBJS) -o debug.out |
13 changes: 13 additions & 0 deletions
13
MATH5620_NumericalSolutionsOfDifferentialEquations/5.1IVP/firstOrderIVP.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#ifndef FIRST_ORDER_IVP_HPP | ||
#define FIRST_ORDER_IVP_HPP | ||
|
||
#include <cmath> | ||
#include <functional> | ||
|
||
template <typename T> | ||
auto firstOrderIVPSolver(const T& l, const T& a) | ||
{ | ||
return [=](const T& t) { return a * std::exp(l * t); }; | ||
} | ||
|
||
#endif |
17 changes: 17 additions & 0 deletions
17
MATH5620_NumericalSolutionsOfDifferentialEquations/5.1IVP/main.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#include <iostream> | ||
#include <iomanip> | ||
#include "firstOrderIVP.hpp" | ||
|
||
int main() | ||
{ | ||
|
||
auto solveIVP = firstOrderIVPSolver(-1.5, 7.3); | ||
|
||
for(auto t = 0; t < 10; ++t) | ||
{ | ||
std::cout << "t = " << t << " -> " << solveIVP(t) | ||
<< "\tt = " << t+10 << " -> " << solveIVP(t+10) << '\n'; | ||
} | ||
|
||
return EXIT_SUCCESS; | ||
} |
Binary file not shown.
420 changes: 0 additions & 420 deletions
420
MATH5620_NumericalSolutionsOfDifferentialEquations/HW/1/eigen.html
This file was deleted.
Oops, something went wrong.
25 changes: 0 additions & 25 deletions
25
MATH5620_NumericalSolutionsOfDifferentialEquations/HW/1/eigen.py
This file was deleted.
Oops, something went wrong.
Binary file removed
BIN
-398 Bytes
MATH5620_NumericalSolutionsOfDifferentialEquations/HW/1/eigen.pyc
Binary file not shown.
36 changes: 0 additions & 36 deletions
36
MATH5620_NumericalSolutionsOfDifferentialEquations/HW/1/eigen.rmd
This file was deleted.
Oops, something went wrong.
160 changes: 156 additions & 4 deletions
160
MATH5620_NumericalSolutionsOfDifferentialEquations/SoftwareManual.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,163 @@ | ||
--- | ||
layout: default | ||
title: MATH 5620 Software Manual | ||
--- | ||
|
||
<a href="https://philipnelson5.github.io">Home</a> | ||
|
||
# Table of Contents | ||
|
||
_(Homework problems below)_ | ||
|
||
### Basic Routines | ||
- [Machine Epsilon](https://philipnelson5.github.io/class-projects/MATH5620_NumericalSolutionsOfDifferentialEquations/machineEpsilon/manual) | ||
- [Absolute and Relative Error](https://philipnelson5.github.io/class-projects/MATH5620_NumericalSolutionsOfDifferentialEquations/error/manual) | ||
- [Logistic Differential Equation](https://philipnelson5.github.io/class-projects/MATH5620_NumericalSolutionsOfDifferentialEquations/logistic/manual) | ||
- [Second Order Linear DE with Constant Coefficents](https://philipnelson5.github.io/class-projects/MATH5620_NumericalSolutionsOfDifferentialEquations/secondOrderLinear/manual) | ||
- [Machine Epsilon](./machineEpsilon/manual) | ||
- [Absolute and Relative Error](./error/manual) | ||
- [Logistic Differential Equation](./logistic/manual) | ||
- [Second Order Linear DE with Constant Coefficients](./secondOrderLinear/manual) | ||
|
||
### Norms | ||
- [Vector P Norm](./matrix/manual_vector_pnorm) | ||
- [Vector Infinity Norm](./matrix/manual_vector_infinity_norm) | ||
- [Matrix One Norm](./matrix/manual_matrix_one_norm) | ||
- [Matrix Infinity Norm](./matrix/manual_matrix_infinity_norm) | ||
|
||
### Linear Solvers | ||
- [Thomas Algorithm](./matrix/manual_thomas_algorithm) | ||
- [Jacobi Iteration](./matrix/manual_jacobi_iteration) | ||
- [Conjugate Gradient](./conjugateGradient/manual_conjugate_gradient) | ||
- [Linear Solver by LU Factorization](./matrix/manual_linear_solve_lu) | ||
- [Lu Factorization](./matrix./manual_lu_factorization) | ||
- [Forward Substitution](./matrix./manual_forward_sub) | ||
- [Back Substitution](./matrix./manual_back_sub) | ||
|
||
### Eigenvalue Methods | ||
- [Power Method Iteration for Largest Eigenvalue](./matrix/manual_power_iteration) | ||
- [Inverse Power Method for Smallest Eigenvalue](./matrix/manual_inverse_power_iteration) | ||
- [Power Method Iteration for Solving 2nd Order FD Elliptic ODE](./matrix/example_power_iteration_elliptic_ode) | ||
- [Inverse Power Method for Solving 2nd Order FD Elliptic ODE](./matrix/example_inverse_power_iteration_elliptic_ode) | ||
|
||
### Elliptic Problems | ||
- [Finite Difference Coefficients](./finiteDiffMethods/manual_finite_diff_coeff) | ||
- [Initialize Elliptic ODE](./finiteDiffMethods/manual_init_elliptic_ode) | ||
- [Solve Elliptic ODE](./finiteDiffMethods/manual_solve_elliptic_ode) | ||
- [Solve Laplace Equation with 5-point Stencil](./matrix/manual_solve_five_point_stencil) | ||
- [Generate 5-point Stencil](./matrix/manual_gen_five_point_stencil) | ||
- [Generate Mesh](./matrix/manual_gen_mesh) | ||
- [Initialize B for Mesh](./matrix/manual_init_b) | ||
|
||
### First Order IVPs | ||
- [Explicit Euler](./explicitEuler/manual_explicit_euler) | ||
- [Implicit Euler](./implicitEuler/manual_implicit_euler) | ||
- [Newton's Method](./newtonsMethod/manual_newtons_method) | ||
- [Runge Kutta order 2](./rungeKuttaOrder2/manual_runge_kutta_order2) | ||
- [Runge Kutta order 4](./rungeKuttaOrder4/manual_runge_kutta_order4) | ||
- [Predicticor Corrector - Adams Bashforth / Adams Moulton](./predictorCorrector/manual_predictor_corrector) | ||
|
||
### Parabolic Problems | ||
- [Upwinding](./upwinding/manual_upwinding) | ||
- [Lax-Wendorff Method](./laxWendroff/manual_lax_wendroff) | ||
- [Warming and Beam Method](./warmingAndBeam/manual_warming_and_beam) | ||
|
||
--- | ||
|
||
### Homework 1 | ||
*due: 25 January 2018* | ||
|
||
| Problem | Software Manual| | ||
| :-----------------|:---------------| | ||
| **Problem 2-3.** | [Machine Epsilon](./machineEpsilon/manual)| | ||
| **Problem 4.** | [Absolute and Relative Error](./error/manual)| | ||
| **Problem 6.** | [Logistic Differential Equation](./logistic/manual)| | ||
| **Problem 7.** | [Second Order Linear DE with Constant Coefficients](./secondOrderLinear/manual)| | ||
|
||
|
||
### Homework 2 | ||
*due: 8 February 2018* | ||
|
||
| Problem | Software Manual| | ||
| :-----------------|:---------------| | ||
| **Problem 1-2.** | [Finite Difference Coefficients](./finiteDiffMethods/manual_finite_diff_coeff)| | ||
| **Problem 3.** | [Initialize Elliptic ODE](./finiteDiffMethods/manual_init_elliptic_ode)| | ||
| **Problem 4.** | [Thomas Algorithm](./matrix/manual_thomas_algorithm)| | ||
| **Problem 5.** | [Linear Solver by LU Factorization](./matrix/manual_linear_solve_lu)| | ||
| | [Lu Factorization](./matrix/manual_lu_factorize)| | ||
| | [Forward Substitution](./matrix/manual_forward_sub)| | ||
| | [Back Substitution](./matrix/manual_back_sub)| | ||
| **Problem 6.** | [Jacobi Iteration](./matrix/manual_jacobi_iteration)| | ||
| **Problem 8.** | [Solve Elliptic ODE](./finiteDiffMethods/manual_solve_elliptic_ode)| | ||
| | [Vector P Norm](./matrix/manual_vector_pnorm)| | ||
| | [Vector Infinity Norm](./matrix/manual_vector_infinity_norm)| | ||
|
||
### Homework 3 | ||
*due: 1 March 2018* | ||
|
||
| Problem | Software Manual| | ||
| :-----------------|:---------------| | ||
| **Problem 1.** | [Matrix One Norm](./matrix/manual_matrix_one_norm)| | ||
| | [Matrix Infinity Norm](./matrix/manual_matrix_infinity_norm)| | ||
| **Problem 2.** | [Power Method Iteration for Largest Eigenvalue](./matrix/manual_power_iteration)| | ||
| | [Inverse Power Method for Smallest Eigenvalue](./matrix/manual_inverse_power_iteration)| | ||
| **Problem 3.** | [Power Method Iteration for Solving 2nd Order FD Elliptic ODE](./matrix/example_power_iteration_elliptic_ode)| | ||
| **Problem 4.** | [Inverse Power Method for Solving 2nd Order FD Elliptic ODE](./matrix/example_inverse_power_iteration_elliptic_ode)| | ||
| **Problem 5.** | [Solve Laplace Equation with 5-point Stencil](./matrix/manual_solve_five_point_stencil)| | ||
| | [Generate 5-point Stencil](./matrix/manual_gen_five_point_stencil)| | ||
| | [Generate Mesh](./matrix/manual_gen_mesh)| | ||
| | [Initialize B for Mesh](./matrix/manual_init_b)| | ||
| **Problem 6.** | [Solve Laplace Equation with 9-point Stencil](./matrix/manual_solve_nine_point_stencil)| | ||
| | [Generate 9-point Stencil](./matrix/manual_gen_nine_point_stencil)| | ||
|
||
### Homework 4 | ||
*due: 22 March 2018* | ||
|
||
| Problem | Software Manual| | ||
| :-----------------|:---------------| | ||
| **Problem 1.** | [Gauss-Seidel](./gaussSidel/manual_gauss_sidel)| | ||
| **Problem 2.** | [Conjugate Gradient](./conjugateGradient/manual_conjugate_gradient)| | ||
| **Problem 3.** | [Application of Conjugate Gradient](./testConjugateGradientFivePoint/manual_solve_five_point_stencil_test)| | ||
| **Problem 4.** | [Explicit Euler](./explicitEuler/manual_explicit_euler)| | ||
|
||
### Homework 5 | ||
*due: 3 April 2018* | ||
|
||
| Problem | Software Manual| | ||
| :-----------------|:---------------| | ||
| **Problem 1.** | [First Order IVP Test](./5.1IVP/IVP_test)| | ||
| | [Logistic Model Test](./logistic2/manual)| | ||
| **Problem 2.** | [IVP via Explicit Euler Test](./explicitEulerTest/manual_explicit_euler_test)| | ||
| **Problem 3.** | [Implicit Euler](./implicitEuler/manual_implicit_euler)| | ||
| | [Newton's Method](./newtonsMethod/manual_newtons_method)| | ||
| **Problem 4.** | [Runge Kutta order 2](./rungeKuttaOrder2/manual_runge_kutta_order2)| | ||
| | [Runge Kutta order 4](./rungeKuttaOrder4/manual_runge_kutta_order4)| | ||
| **Problem 5.** | [Adam's Bashford](./predictorCorrector/manual_predictor_corrector)| | ||
| **Problem 6.** | [Summary of Iterative Methods](./SumaryOfIterativeMethods)| | ||
|
||
### Homework 6 | ||
*due: 24 April 2018* | ||
|
||
| Problem | Software Manual| | ||
| :-----------------|:---------------| | ||
| **Write up** | [Experiments 7.1, 7.2, 7.4](./hw6_experiments.md)| | ||
|
||
### Homework 7 | ||
*due: 5 May 2018* | ||
|
||
| Problem | Software Manual| | ||
| :-----------------|:---------------| | ||
| **Problem 1.** | [Heat Equation - Explicit Euler](./heatEquations/manual_heat_equation_explicit_euler)| | ||
| **Problem 2.** | [Heat Equation - Implicit Euler](./heatEquations/manual_heat_equation_implicit_euler)| | ||
| **Problem 4.** | [Heat Equation - Predictor Corrector](./heatEquations/manual_heat_equation_predictor_corrector)| | ||
| **Problem 5.** | [Heat Equation - Runge Kutta Order 4](./heatEquations/manual_heat_equation_runge_kutta)| | ||
{% comment %} | ||
| **Problem 3.** | [Changing Time Time Step](./heatEquations/manual_heat_equation)| | ||
{% endcomment %} | ||
|
||
### Homework 8 | ||
*due: 5 May 2018* | ||
|
||
| Problem | Software Manual| | ||
| :-----------------|:---------------| | ||
| **Problem 1.1** | [Upwinding](./upwinding/manual_upwinding)| | ||
| **Problem 1.2** | [Lax-Wendorff Method](./laxWendroff/manual_lax_wendroff)| | ||
| **Problem 1.3** | [Warming and Beam Method](./warmingAndBeam/manual_warming_and_beam)| | ||
| **Problem 2.1** | [vonNeuman Stability Analysis Lax Wendroff](./stabilityAnalysis/laxWendroff)| | ||
| **Problem 2.2** | [vonNeuman Stability Analysis Warming and Beam](./stabilityAnalysis/warmingAndBeam)| |
19 changes: 19 additions & 0 deletions
19
MATH5620_NumericalSolutionsOfDifferentialEquations/SumaryOfIterativeMethods.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
--- | ||
title: IVP Test | ||
math: true | ||
layout: default | ||
--- | ||
|
||
{% include mathjax.html %} | ||
|
||
# Iterative Methods Summary | ||
|
||
Iterative methods studied in assignment 5 are examples iterative methods used to solve initial value problems. | ||
Each method has it's strengths and weaknesses, there is best method. Each has different conditions for convergence, but some have better overall performance. | ||
|
||
The Explicit Euler Method is a very simple technique compared to Runge Kutta and Adams Bashforth and Adams Moulton. This method represents a single step of integration at a point. The Implicit Euler technique, however uses the unknown next value of the iteration in the same setup. This results in an equation that must be solved using some other method such as the Newton method for finding zeroes. The Implicit Euler Method has order one. This means that the local truncation error is \\(O(h^{2})\\). The error at a specific time \\(t\\) is \\(O(h)\\). | ||
|
||
Runge Kutta, which is favored of engineers, is favored due to its stability and ease of use. Runge Kutta techniques exist for arbitrary order, the Kunge Kutta order 4 is the most widely known and is referred to as the "classical Runge Kutta method". | ||
|
||
The Predictor Corrector method used Adams Bashforth for the prediction step then Adams Moulton for the corrector. This is the typical form that predictor-corrector methods take, an explicit method for the predictor step and an implicit method for the corrector step. The Adams–Bashforth methods are explicit methods. The coefficients are \\(a_{s-1}=-1\\) and \\(a_{s-2}=\cdots =a_0=0\\), while the \\(b_j\\) are chosen such that the methods has order s (this determines the methods uniquely). The Adams–Moulton methods are similar to the Adams–Bashforth methods in that they also have \\(a_{s-1}=-1\\) and \\(a_{s-2}=\cdots =a_0=0\\). Again the b coefficients are chosen to obtain the highest order possible. However, the Adams–Moulton methods are implicit methods. By removing the restriction that \\(b_s = 0\\) , an s-step Adams–Moulton method can reach order s+1, while an s-step Adams–Bashforth methods has only order s. | ||
|
3 changes: 3 additions & 0 deletions
3
MATH5620_NumericalSolutionsOfDifferentialEquations/_config.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
theme: jekyll-theme-modernist | ||
markdown: kramdown | ||
mathjax: true |
3 changes: 3 additions & 0 deletions
3
MATH5620_NumericalSolutionsOfDifferentialEquations/_includes/mathjax.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<script type="text/javascript" async | ||
src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.2/MathJax.js?config=TeX-MML-AM_CHTML"> | ||
</script> |
Oops, something went wrong.