diff options
Diffstat (limited to 'Functions/README.md')
| -rw-r--r-- | Functions/README.md | 107 |
1 files changed, 107 insertions, 0 deletions
diff --git a/Functions/README.md b/Functions/README.md new file mode 100644 index 0000000..a198244 --- /dev/null +++ b/Functions/README.md @@ -0,0 +1,107 @@ +# Functions +This directory contains the functions written throught the course. +* days.m +* falsePositive.m +* heun.m +* luFactor.m +* simpson.m +* spacialMatrix.m + +--- + +## [days.m](days.m) +Function to count the total days elapsed in a year according to a given date. +The syntax of the function is `days(<months>, <days>, <leap>)` where `<months>` is a integer (1-12). `<days>` is an integer from 1-31 and `<leap>` accounts for leap years. + +### Input +* `months` - month number (1-12). Example: `8` represents August. +* `days` - day number of the month. +* `leap` - indicates if the year is a leapyear or a regular year. `0` for regular and `1` for leap year. + +### Output +`nd` - number of days elapsed in the year. + +### Example: +`days(8,4,0)` represents August 8th in a regular year (non-leap year). + +--- + +## [falsePositive.m](falsePositive.m) +Function finds the root of an anonymous function using the false position method. +Synopsis: `[root, fx, ea, iter] = falsePosition(func, xl, xu, es, maxit, varargin)`. + +### Input +`func` - the function being evaluated. +`xl` - lower bound guess. +`xu` - upper bound guess. +`es` - desired relative error (default 0.0001%) +`maxit` - maximum number of iterations (default 200) +`varargin` - any additional parameters used by the function + +### Output +`root` - estimated root location. +`fx` - function evaluated at root location. +`ea` - approximated relative error (%). +`iter` - number of iterations performed. + +### Notes: +Known issue: the output of `iter` needs fixing. The output is incorrect. + +--- + +## [heun.m](heun.m) +Uses the heun method to integrate an ODE. +Synopsis: `[t,y] = Heun(dydt,tspan,y0,h)`. + +### Input +`dydt` -the differential equation of interest (must be anonymous function). +`tspan` - the initial and final values of the independent variable as a vector with length=2 [ti,tf]. +`y0` - the initial value of the dependent variable. +`h` - step size. +`es` - stopping criterion (%), optional (default = 0.001). +`maxit` - maximum iterations of corrector, optional (default = 50). + +### Output +`t` - vector of independent variable values +`y` - vector of solution for dependent variable + +### Notes: +This function needs some working on to compute a correct solution when using multiple steps with an irregular step size at the end. + +--- + +## [luFactor.m](luFactor.m) + +Performs LU decomposition with pivoting. +Synopsis: `[L, U, P] = luFactor(A)`. + +### Input +`A` - a coefficient matrix. + +### Output +`L` - lower triangular matrix, with 1's along the diagonals. +`U` - upper triangular matrix. +`P` - the permutation matrix. + +### Notes: +Be cautious when using this function on bigger matrices. The `L` variable is known to be incorrect. + +--- + +## [simpson.m](simpson.m) +Evaluates the integral of two vectors by Simpsons 1/3 rule. +Synopsis: `[I] = Simpson(x, y)` + +### Input +`x` - the vector of equally spaced independent variable. +`y` - the vector of function values with respect to x. + +### Output +`I` - numerical calculated integral. + +### Notes: +The current state of this function is **deprecated**. The algorithm fails compute the correct trapeziodal rule given 2 data points as well as 3 data points. Thus, failing to solve real problem. Pull requests are welcomed. + +--- + +## [specialMatrix.m](specialMatrix.m) |
