Captain
Captain

Reputation: 193

How to calculate out put definite integral in matlab

I have run the following for computing the numerical integration of the following function.

But in Matlab instead of a number as an output, it gives me a big expression.

gamma = sqrt(alpha^2 - beta^2);
K1=besselk(1,alpha*sqrt(delta^2+(x-mu)^2));
pdf = alpha*delta* K1/(pi*sqrt(delta^2+(x-mu)^2)) * exp(delta*gamma+ beta*(x-mu));

prob = int(pdf , x, 0,0.5);

with the following parameters :

mu = 0.034 ; 


delta = 2.12; 

alpha = 0.05;
beta = -0.001; 

I have recived this result.

int((53*exp(59679899628370215233/562949953421312000000 - x/1000)*besselk(1, ((x - 17/500)^2 + 2809/625)^(1/2)/20))/(500*pi*((x - 17/500)^2 + 2809/625)^(1/2)), x, 0, 1/2)

I would appreciate any solution to answer this question. How can I compute this expression in Matlab?

Upvotes: 0

Views: 48

Answers (1)

rinkert
rinkert

Reputation: 6863

The result you got is just not evaluated yet. To obtain a numerical answer with n significant digits, use,

prob_vpa = vpa(prob, n); 

The result will still be a symbolic variable, for further symbolic computations. You can also convert it to double,

prob_double = double(prob);

Upvotes: 1

Related Questions