Data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 7387c8f97b
commit cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions

View file

@ -0,0 +1,8 @@
function integral = leftRectIntegration(f,a,b,n)
format long;
width = (b-a)/n; %calculate the width of each devision
x = linspace(a,b,n); %define x-axis
integral = width * sum( f(x(1:n-1)) );
end

View file

@ -0,0 +1,8 @@
function integral = rightRectIntegration(f,a,b,n)
format long;
width = (b-a)/n; %calculate the width of each devision
x = linspace(a,b,n); %define x-axis
integral = width * sum( f(x(2:n)) );
end

View file

@ -0,0 +1,8 @@
function integral = midPointRectIntegration(f,a,b,n)
format long;
width = (b-a)/n; %calculate the width of each devision
x = linspace(a,b,n); %define x-axis
integral = width * sum( f( (x(1:n-1)+x(2:n))/2 ) );
end

View file

@ -0,0 +1,7 @@
function integral = trapezoidalIntegration(f,a,b,n)
format long;
x = linspace(a,b,n); %define x-axis
integral = trapz( x,f(x) );
end

View file

@ -0,0 +1 @@
integral = quad(f,a,b,tol)

View file

@ -0,0 +1,5 @@
trapezoidalIntegration(@(x)( exp(-(x.^2)) ),0,10,100000)
ans =
0.886226925452753

View file

@ -0,0 +1,5 @@
quad(@sin,0,pi,1/1000000000000)
ans =
2.000000000000000

View file

@ -0,0 +1,4 @@
function answer = fermiDirac(x)
k = 8.617343e-5; %Boltazmann's Constant in eV/K
answer = 1./( 1+exp( (x)/(k*2000) ) ); %Fermi-Dirac distribution with mu = 0 and T = 2000K
end

View file

@ -0,0 +1,5 @@
rightRectIntegration(@fermiDirac,-1,1,1000000)
ans =
0.999998006023282