Why is the following numerical integration not working?

1 view (last 30 days)
clc;clear;close all
k = 2;theta = 0;
Integrand = Optics(k,theta);
area = @Optics;
TMD = integral2(Optics,0,2,0,2*pi);
function Integrand = Optics(k,theta)
gamma = 0.2;
pi = 3.14;
a = 0.3;
hbar = 0.2;
electron = 0.2;
w = 1;
correction = 0.001;
Normalization = 1/sqrt(2*gamma*(exp(1i*a*k*cos(theta))+2*exp(-0.5*1i*a*k*cos(theta))*cos(sqrt(3)/2*a*k*sin(theta)))*(exp(-1i*a*k*cos(theta))+2*exp(0.5*1i*a*k*cos(theta))*cos(sqrt(3)/2*a*k*sin(theta))));
SolutionOne = Normalization*[gamma*(exp(1i*a*k*cos(theta))+2*exp(-0.5*1i*a*k*cos(theta))*cos(sqrt(3)/2*a*k*sin(theta)));sqrt(gamma*(exp(1i*a*k*cos(theta))+2*exp(-0.5*1i*a*k*cos(theta))*cos(sqrt(3)/2*a*k*sin(theta)))*(exp(-1i*a*k*cos(theta))+2*exp(0.5*1i*a*k*cos(theta))*cos(sqrt(3)/2*a*k*sin(theta))))];
SolutionTwo = Normalization*[sqrt(gamma*(exp(1i*a*k*cos(theta))+2*exp(-0.5*1i*a*k*cos(theta))*cos(sqrt(3)/2*a*k*sin(theta)))*(exp(-1i*a*k*cos(theta))+2*exp(0.5*1i*a*k*cos(theta))*cos(sqrt(3)/2*a*k*sin(theta))));-gamma*(exp(1i*a*k*cos(theta))+2*exp(-0.5*1i*a*k*cos(theta))*cos(sqrt(3)/2*a*k*sin(theta)))];
velocity = [0 1i*a*gamma*(exp(1i*k*a*cos(theta))-exp(-1i*k*a*cos(theta))*cos(k*sin(theta)*a*sqrt(3)/2));-1i*a*gamma*(exp(-1i*k*a*cos(theta))-exp(1i*k*a*cos(theta))*cos(k*sin(theta)*a*sqrt(3)/2)) 0];
EigenOne = sqrt(gamma*(exp(1i*a*k*cos(theta))+2*exp(-0.5*1i*a*k*cos(theta))*cos(sqrt(3)/2*a*k*sin(theta)))*(exp(-1i*a*k*cos(theta))+2*exp(0.5*1i*a*k*cos(theta))*cos(sqrt(3)/2*a*k*sin(theta))));
EigenTwo = -EigenOne;
Jumper = SolutionOne'*velocity*SolutionTwo;
Integrand = k*1i*hbar*electron*electron/(2*pi)^2/(EigenOne-EigenTwo)*(Jumper')*Jumper/(hbar*w-(EigenOne-EigenTwo)+correction);
end
This is a 2D integral but Matlab always responds with 'Not enough inputs'

Answers (2)

Star Strider
Star Strider on 6 Oct 2020
Try this:
TMD = integral2(@Optics,0,2,0,2*pi);
(I did not run your code, so there may be other errors as well.)

randerss simil
randerss simil on 9 Feb 2021
TMD = integral2(area,0,2,0,2*pi);
Alternate way

Categories

Find more on Particle & Nuclear Physics in Help Center and File Exchange

Products


Release

R2019b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!