# matlab not displaying an approximated value of an improper integral?

4 visualizzazioni (ultimi 30 giorni)
Lahcen il 23 Ago 2023
Spostato: John D'Errico il 28 Ago 2023
I want to calculate an approximate value of an improper integral:
>> fun= 4./(x.*(1-x).*(2-x).*(pi.^2+(log(x./(1-x)).^2))
>> vpa(int(fun,0,1))
then matlab displays the result:
ans =
vpaintegral(4/(x*(log(-x/(x - 1))^2 + 2778046668940015/281474976710656)*(x - 1)*(x - 2)), x, 0, 1).
how can I get the approximate value of this improper integral? thanks in advance.
##### 6 CommentiMostra 4 commenti meno recentiNascondi 4 commenti meno recenti
Dyuman Joshi il 23 Ago 2023
I had an inkling because of the value but wasn't sure due to the format of the value -
sqrt(2778046668940015/281474976710656)
ans = 3.1416
Lahcen il 24 Ago 2023
Spostato: John D'Errico il 28 Ago 2023

Thank you al, Mr Nathan Hardenberg, Mr Dyuman Joshi and Mr Steven Lord,  for your helpful responses in addressing my improper integral calculation issue on the Matlab forum. Your assistance was greatly appreciated!. Indeed, I worked by the idea of Mr Nathan Hardenberg.

I'd also like to note that the integral in question is convergent, whereas the numerical methods provided by Matlab seem to be getting stuck without yielding the desired result. It appears that there is a need for the development of more reliable numerical techniques.

Many thanks.

Accedi per commentare.

### Risposta accettata

Nathan Hardenberg il 23 Ago 2023
Modificato: Nathan Hardenberg il 23 Ago 2023
Here are some ideas, but please still regard my comment.
1. You have two variables x and p. You can not approximate numerically then.
2. "To approximate integrals directly, use vpaintegral instead of vpa. The vpaintegral function is faster and provides control over integration tolerances." [source]
3. Specify that you want to use x as your variable (int(fun, x, [a b]))
4. You can not numerically approximate if your denomenator gets 0 at some point (see example below)
-- EDIT --
Your problem is nr. 4. Your denomenator gets 0 to fix this you can simply choose values close to 0 and 1. See example below:
syms x
p = pi; % edited to be p = pi
fun = 4./(x.*(1-x).*(2-x).*(p.^2+(log(x./(1-x)).^2)))
fun =
vpa(int(fun, 0.001, 0.999)) % choosing values slightly above 0 and below 1
ans =
2.0701395395280001703925025323768
But maybe this is not good enough, since the solution can get quite a bit different when getting closer to the limits:
vpa(int(fun, 1e-110, 1 - 1e-13)) % choosing tighter values
ans =
2.7443512001078913067737891865659
-- EDIT END --
% Example of nr. 4 from above
syms x
f = 1/x;
Fvpaint = vpaintegral(f,x,[0 1])
Error using sym/vpaintegral
Failed precision goal. Try using 'MaxFunctionCalls'.
##### 8 CommentiMostra 6 commenti meno recentiNascondi 6 commenti meno recenti
Lahcen il 25 Ago 2023
Modificato: Lahcen il 26 Ago 2023
Attached you will find a reference about A, concerning your question, (but they are references in French).
But using what you found like, one can find what my published. Indeed, Let a<1 and let put
by setting we find,
then
Now, this integral is converge if and only if
which is equivalent .
I hope you like the proof.
Nathan Hardenberg il 27 Ago 2023
@Lahcen Thanks a lot :D

Accedi per commentare.

### Categorie

Scopri di più su Loops and Conditional Statements in Help Center e File Exchange

### Community Treasure Hunt

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

Start Hunting!

Translated by