forked from rcc02007/ME3255F2017
-
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
Showing
17 changed files
with
4,190 additions
and
0 deletions.
There are no files selected for viewing
1,439 changes: 1,439 additions & 0 deletions
1,439
16_splines/.ipynb_checkpoints/16_splines-checkpoint.ipynb
Large diffs are not rendered by default.
Oops, something went wrong.
497 changes: 497 additions & 0 deletions
497
16_splines/.ipynb_checkpoints/lecture 19-checkpoint.ipynb
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
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,34 @@ | ||
function yint = Newtint(x,y,xx) | ||
% Newtint: Newton interpolating polynomial | ||
% yint = Newtint(x,y,xx): Uses an (n - 1)-order Newton | ||
% interpolating polynomial based on n data points (x, y) | ||
% to determine a value of the dependent variable (yint) | ||
% at a given value of the independent variable, xx. | ||
% input: | ||
% x = independent variable | ||
% y = dependent variable | ||
% xx = value of independent variable at which | ||
% interpolation is calculated | ||
% output: | ||
% yint = interpolated value of dependent variable | ||
|
||
% compute the finite divided differences in the form of a | ||
% difference table | ||
n = length(x); | ||
if length(y)~=n, error('x and y must be same length'); end | ||
b = zeros(n,n); | ||
% assign dependent variables to the first column of b. | ||
b(:,1) = y(:); % the (:) ensures that y is a column vector. | ||
for j = 2:n | ||
for i = 1:n-j+1 | ||
b(i,j) = (b(i+1,j-1)-b(i,j-1))/(x(i+j-1)-x(i)); | ||
end | ||
end | ||
%b | ||
% use the finite divided differences to interpolate | ||
xt = 1; | ||
yint = b(1,1); | ||
for j = 1:n-1 | ||
xt = xt*(xx-x(j)); | ||
yint = yint+b(1,j+1)*xt; | ||
end |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
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,23 @@ | ||
function I = simpson3(func,a,b,n,varargin) | ||
% simpson3: composite simpson's 1/3 rule | ||
% I = simpson3(func,a,b,n,pl,p2,...): | ||
% composite trapezoidal rule | ||
% input: | ||
% func = name of function to be integrated | ||
% a, b = integration limits | ||
% n = number of segments (default = 100) | ||
% pl,p2,... = additional parameters used by func | ||
% output: | ||
% I = integral estimate | ||
if nargin<3,error('at least 3 input arguments required'),end | ||
if ~(b>a),error('upper bound must be greater than lower'),end | ||
if nargin<4|isempty(n),n=100;end | ||
x = a; h = (b - a)/n; | ||
|
||
xvals=linspace(a,b,n+1); | ||
fvals=func(xvals,varargin{:}); | ||
s=fvals(1); | ||
s = s + 4*sum(fvals(2:2:end-1)); | ||
s = s + 2*sum(fvals(3:2:end-2)); | ||
s = s + fvals(end); | ||
I = (b - a) * s/(3*n); |
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,22 @@ | ||
function I = trap(func,a,b,n,varargin) | ||
% trap: composite trapezoidal rule quadrature | ||
% I = trap(func,a,b,n,pl,p2,...): | ||
% composite trapezoidal rule | ||
% input: | ||
% func = name of function to be integrated | ||
% a, b = integration limits | ||
% n = number of segments (default = 100) | ||
% pl,p2,... = additional parameters used by func | ||
% output: | ||
% I = integral estimate | ||
if nargin<3,error('at least 3 input arguments required'),end | ||
if ~(b>a),error('upper bound must be greater than lower'),end | ||
if nargin<4|isempty(n),n=100;end | ||
|
||
x = a; h = (b - a)/n; | ||
xvals=linspace(a,b,n); | ||
fvals=func(xvals,varargin{:}); | ||
s=func(a,varargin{:}); | ||
s = s + 2*sum(fvals(2:n-1)); | ||
s = s + func(b,varargin{:}); | ||
I = (b - a) * s/(2*n); |
608 changes: 608 additions & 0 deletions
608
17_integrals_and_derivatives/.ipynb_checkpoints/17_integrals-checkpoint.ipynb
Large diffs are not rendered by default.
Oops, something went wrong.
6 changes: 6 additions & 0 deletions
6
17_integrals_and_derivatives/.ipynb_checkpoints/lecture_20-checkpoint.ipynb
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,6 @@ | ||
{ | ||
"cells": [], | ||
"metadata": {}, | ||
"nbformat": 4, | ||
"nbformat_minor": 2 | ||
} |
Large diffs are not rendered by default.
Oops, something went wrong.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
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 @@ | ||
1.0208494318e-05 1.6556901722 | ||
0.00241601032192 33.1999376148 | ||
0.00420249682757 53.9506164087 | ||
0.00603492155765 82.1777412288 | ||
0.00844582763241 114.552704897 | ||
0.00959768607462 122.017666367 | ||
0.0207793901842 141.840010208 | ||
0.0369377352739 161.610673548 | ||
0.0574942399989 177.181817537 | ||
0.0774314294019 181.959392878 | ||
0.100609815751 174.241771174 | ||
0.117644389936 156.618719826 |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 @@ | ||
1.0208494318e-05 1.6556901722 | ||
0.00180179924712 23.2370851913 | ||
0.00242111456908 34.0306538399 | ||
0.00298938741945 36.5170602372 | ||
0.00410551613155 38.1670081313 | ||
0.0113042060414 39.7537909669 | ||
0.026807506079 42.9158720819 | ||
0.0450807109082 46.8799580317 | ||
0.063896667352 49.1768692533 | ||
0.0937667217264 50.5282186886 | ||
0.134122601181 48.4475999405 | ||
0.194912483429 42.0009357786 | ||
0.224198952211 38.3737301413 |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.