# Dirac delta Function Approximation

DIRAC(X) is zero for all X, except X == 0 where it is infinite.
DIRAC(X) is not a function in the strict sense, but rather a distribution with
int(dirac(x-a)*f(x),-inf,inf) = f(a) and diff(heaviside(x),x) = dirac(x).

Dirac.m
function Y = dirac(X)
Y = zeros(size(X));
Y(X == 0) = Inf;

< Approximate Dirac delta Function >
< Matabl Promgram Source >
[code matlab]
t=[-5:0.001:5];    % 시구간을 -5부터 5까지로 지정
a=[0.01;0.1;0.5]; % a 값을 0.01, 0.1, 0.5로 지정

for i=1:3             % 세 경우 연산을 동시에 수행, 계산 결과는 각 열에 저장
g(i,:)=1/(sqrt(2*pi)*a(i))*exp(-t.^2/(2*a(i).^2));
c(i,:)=2*a(i)./(a(i)^2+4*pi^2*t.^2);
end
area_g=sum(g,2)*0.001; % area Gauss % 각 열에 대해서 덧셈연산을 수행
area_c=sum(c,2)*0.001; % area Cauchy %  각 열에 대해서 덧셈연산을 수행

figure(1) % Gauss 에 대한 Figure 생성
plot(t,g); % 그래프 작성 및 설정
title(‘g(t)=1/(sqrt(2\pi)a)*exp(-t^2/2a^2), a>0’)
legend(‘a=0.01′,’a=0.1′,’a=0.5’)
text(2.0,30,sprintf(‘a=0.01 area: %.4f’,area_g(1)))
text(2.0,28.5,sprintf(‘a=0.1 area: %.4f’,area_g(2)))
text(2.0,27,sprintf(‘a=0.5 area: %.4f’,area_g(3)))

figure(2)
plot(t,c);
title(‘c(t)=2a/(a^2+4\pi^2t^2), a>0’)
legend(‘a=0.01′,’a=0.1′,’a=0.5’)
text(2.0,150,sprintf(‘a=0.01 area: %.4f’,area_c(1)))
text(2.0,140,sprintf(‘a=0.1 area: %.4f’,area_c(2)))
text(2.0,130,sprintf(‘a=0.5 area: %.4f’,area_c(3)))
[/code]
< Figure >