Getting complex value for real integration

I'm getting complex value in real integration while trying to find area under ellipse as shown in below figure. Please advise

9 comentarios

I need help in finding the area of the shaded region in terms of w,a,b
Torsten
Torsten el 31 de Mzo. de 2022
Editada: Torsten el 31 de Mzo. de 2022
Did you specify somewhere that
4*a^2 >= w^2
?
No, you didn't. That's why your "sqrt" can become complex-valued.
Maybe an "assume" will work.
Even after applying the assumption, I'm getting the same answer. Please check it once.
Torsten
Torsten el 31 de Mzo. de 2022
Your assumption w <= 2a is not sufficient.
It is not equivalent to the assumption w^2 <= 4*a^2.
Still, I'm getting the same. Please check this once.
Steven Lord
Steven Lord el 4 de Abr. de 2022
Please state with words and equations (not code) the specific problem you're trying to solve, so we can check that the code you've written is the correct code to solve that problem.
You're trying to compute the area bounded by a portion of an ellipse, the x axis, and potentially part of the y axis (from the way your picture is drawn.) Where are the foci of the ellipse, what are its major and minor axes lengths, or what is the equation that generates this ellipse?
Torsten
Torsten el 4 de Abr. de 2022
Editada: Torsten el 4 de Abr. de 2022
If you hope to find the area (or half the area) of the ellipse, you are mistaken.
This would only work if the y-coordinate for the center of the ellipse lies on the x-axis.
@Steven Lord Yes, I'm trying to find the area bounded by a portion of the ellipse. Lengths of minoand major axes of the ellipse are 2a,2b respectively. Equation that generates this ellipse is provided below the picture drawn.
@Torsten I was able to find the area after taking some assumptions and modifying the code.
@Torsten and @Steven Lord Thanks for your help, I'm able to find the required area after specifying some assumptions and simplifying the equation.

Iniciar sesión para comentar.

 Respuesta aceptada

David Goodmanson
David Goodmanson el 4 de Abr. de 2022
Editada: David Goodmanson el 4 de Abr. de 2022
Hi Mithun,
One of the more straightforward methods is to forget about symbolics and just write down the solution for y. The ellipse has semimajor axis a along x, semiminor axis b along y, and is centered at
( w/2, -(b/(2*a))*sqrt(4*a^2-w^2) )
so that the ellipse passes through both the origin and (w,0). w has to be less than 2*a, the major axis. Solve the ellipse equation for y,
( y + (b/(2*a))*sqrt(4*a^2-w^2) )^2/b^2 = 1 - (x-w/2).^2/a^2
take the sqrt of both sides**, rearrange
y = -(b/(2*a))*sqrt(4*a^2-w^2) +- b*sqrt((1-(x-w/2).^2/a^2)).
** the sqrt of the left hand side is taken as positive. The sqrt of the right hand side can be either sign, but the positive sqrt is chosen since from the figure, y>=0. So
a = 3; b = 2; w = 5;
fun = @(x) -(b/(2*a))*sqrt(4*a^2-w^2) + b*sqrt((1-(x-w/2).^2/a^2));
integral(fun,0,w)
ans = 3.1468

3 comentarios

David Goodmanson
David Goodmanson el 4 de Abr. de 2022
Hi Mithun,
you're most welcome. One thing I forgot to mention is that when you post a question it's not best practice to post images of code. It's much better to copy in the code as text. That way, people looking to assist can just copy the code and run it, rather than having to type it in by hand.
Yeah David, thanks for the tip. This is my first time posting anything in such discussion forums. I'll follow this good practice from next time.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Mathematics en Centro de ayuda y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by