Computing an specific numerical Integral

Hi,
Can anyone help me in computing the following integral?
Thanks
integral.jpg

2 commentaires

John D'Errico
John D'Errico le 8 Fév 2020
Homework?
Coo Boo
Coo Boo le 8 Fév 2020
Modifié(e) : Coo Boo le 8 Fév 2020
Is it really so simple that it seems to be a homework? No, it's not really a homework. It is actually the first step in a research work. It is a fitness function that I have to optimize it through heuristic methods considering weights (wi) as the optimization variables.

Connectez-vous pour commenter.

 Réponse acceptée

David Hill
David Hill le 8 Fév 2020
You could just expand the sumations since there are only 5.
fun=@(x)(.5*(1-x).^4+6*x.*(1-x).^3+4.5*x.^2.*(1-x).^2+4*x.^3.*(1-x)+.5*x.^4).*log(.5*(1-x).^4+6*x.*(1-x).^3+4.5*x.^2.*(1-x).^2+4*x.^3.*(1-x)+.5*x.^4);
y=integral(fun,0,1);

3 commentaires

Coo Boo
Coo Boo le 8 Fév 2020
Thanks so much.
1. How can I use a 'for' loop or vectorized summation for any arbitrary n, e.g., n=100?
2. Why did you use '.*' and '.^' instead of '*' and '^'?
You could play with somethng like this.
w=[.1 .3 .3 .2 .1];%size w will have to increase with n
fun=@(x,n)sum(reshape(cell2mat(arrayfun(@(y)w(y)*factorial(n)/factorial(y-1)/factorial(n-y).*x.^(y-1).*(1-x).^(n-y),1:n,'UniformOutput',false)),length(x),[]),2);
z=integral(@(x)fun(x,5).*log(fun(x,5)),0,1,'ArrayValued',true);%n=5
Coo Boo
Coo Boo le 8 Fév 2020
Modifié(e) : Coo Boo le 8 Fév 2020
Thanks for your help.

Connectez-vous pour commenter.

Plus de réponses (1)

Stijn Haenen
Stijn Haenen le 8 Fév 2020

0 votes

I think you should use a Riemann integral to estimate the answer of this integral.
Or maybe wolfram Mathematica can solve it for you.

1 commentaire

Coo Boo
Coo Boo le 8 Fév 2020
Thanks. But I need it in Matlab. Do you have any idea for solving it in Matlab with a 'for' loop or vectorized summation for any arbitrary n, e.g., n=100?

Connectez-vous pour commenter.

Catégories

En savoir plus sur Programming dans Centre d'aide et File Exchange

Produits

Version

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by