Definite integration using int command

14 visualizaciones (últimos 30 días)
Wisaruth Maethasith
Wisaruth Maethasith el 17 de En. de 2022
Comentada: Walter Roberson el 18 de En. de 2022
Firstly, I'm quite new with matlab
I am currently trying to do a definite integral with respect to y of a particular function. The function that I want to integrate is
(note that the big parenthesis is multiplying with the first factor - I can't get the latex to not make it look like power)
I have tried plugging the above integral into Desmos and it worked as intended. My plan was to vary the value of x and y and will be using for loop via matlab.
However, after trying to use the int function to calculate the definite integral with the code as follow:
h = 5;
a = 2;
syms y
x = 3.8;
p = 2.*x.^2+2.*a.*y;
q = x.^2+y.^2;
r = x.^2+a.^2;
f = (-1./sqrt(1-(p.^2./(4.*q.*r)))).*(2.*sqrt(q).*sqrt(r).*2.*a-p.*2.*y.*sqrt(r)./sqrt(q))./(4.*q.*r);
theta = int(f,y,a+0.01,h) %the integral is undefined at y=2, hence the +0.01
the result is not quite as expected
theta =
int(-((8*461^(1/2)*(y^2 + 361/25)^(1/2))/5 - (461^(1/2)*y*(8*y + 1444/25))/(5*(y^2 + 361/25)^(1/2)))/((1 - (4*y + 722/25)^2/((1844*y^2)/25 + 665684/625))^(1/2)*((1844*y^2)/25 + 665684/625)), y, 21/10, 5)
After browsing through various posts, the common mistake is the undefined interval but the +0.01 should have fixed it. Any guidance on what went wrong is much appreciated.
  2 comentarios
jessupj
jessupj el 17 de En. de 2022
Editada: jessupj el 17 de En. de 2022
does this not simplify somehow?... the integrand looks like it might reduce nicely to the form du/sqrt(1-u) or similar.
Wisaruth Maethasith
Wisaruth Maethasith el 17 de En. de 2022
I tried to simplify using wolfram - it did simplify into this.
Same problem persists when using this one though sadly.

Iniciar sesión para comentar.

Respuestas (1)

Walter Roberson
Walter Roberson el 17 de En. de 2022
h = 5;
a = 2;
syms y
x = 3.8;
p = 2.*x.^2+2.*a.*y;
q = x.^2+y.^2;
r = x.^2+a.^2;
f = (-1./sqrt(1-(p.^2./(4.*q.*r)))).*(2.*sqrt(q).*sqrt(r).*2.*a-p.*2.*y.*sqrt(r)./sqrt(q))./(4.*q.*r);
temp = simplify(int(f,y,a,h))
temp = 
theta = rewrite(temp,'exp')
theta = 
  4 comentarios
Paul
Paul el 18 de En. de 2022
Repeating the code from your answer:
h = 5;
a = 2;
syms y
x = 3.8;
p = 2.*x.^2+2.*a.*y;
q = x.^2+y.^2;
r = x.^2+a.^2;
f = (-1./sqrt(1-(p.^2./(4.*q.*r)))).*(2.*sqrt(q).*sqrt(r).*2.*a-p.*2.*y.*sqrt(r)./sqrt(q))./(4.*q.*r);
temp = simplify(int(f,y,a,h))
temp = 
simplify(temp,100)
ans = 
Any idea why the user has to do the simplify() twice? I mean, why doesn't the engine do simplify() internally? The engine could have come up with the solution pretty easily on its own; at least so it appears.
Also, I'm not clear on why this line worked:
rewrite(temp,'exp')
ans = 
I thought that rewrite() call is supposed to rewrite all "All trigonometric and hyperbolic functions including inverse functions" in temp and replace them with "exp, log". But temp doesn't have any of those types of functions and rewrite() actually resulted in an expression in terms of one of the functions that it was supposed to replace.
Walter Roberson
Walter Roberson el 18 de En. de 2022
You only need one simplify() if you give it enough steps. 10 is enough.
h = 5;
a = 2;
syms y
x = 3.8;
p = 2.*x.^2+2.*a.*y;
q = x.^2+y.^2;
r = x.^2+a.^2;
f = (-1./sqrt(1-(p.^2./(4.*q.*r)))).*(2.*sqrt(q).*sqrt(r).*2.*a-p.*2.*y.*sqrt(r)./sqrt(q))./(4.*q.*r);
temp = int(f,y,a,h)
temp = 
simplify(temp,10)
ans = 

Iniciar sesión para comentar.

Productos


Versión

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by