Error trying to compute symbolic integral

1 view (last 30 days)
Im trying to evaluate the volume of a cone in cartesian coordinates, but somehow matlab is having trouble in evaluating the second integral, it shows a weird output with hypergeom and piecewise.
% code
syms x y z r h % radius r and height h
firstInt = int(1,z,h/r*sqrt(x^2+y^2),h);
SecondInt = int(FirstInt,y,-sqrt(r^2-x^2),sqrt(r^2-x^2));
ThirdInt = int(SecondInt,x,-r,r);

Accepted Answer

Walter Roberson
Walter Roberson on 16 Sep 2018
What the output of SecondInt is telling you is that MATLAB is not able to find a closed form solution for the integral, except in the case where x = -1 or +1 in which case it can be expressed as a hypergeom.
There is actually a closed form solution for the second integral. And MATLAB can even compute one under reasonable circumstances:
syms x y real
syms z r h nonnegative % radius r and height h
FirstInt = int(1,z,h/r*sqrt(x^2+y^2),h);
SecondInt = int(FirstInt,y,-sqrt(r^2-x^2),sqrt(r^2-x^2));
ThirdInt = int(SecondInt,x,-r,r);
This will give you a closed form SecondInt involving log. You would get a numeric error if you evaluate this at x = 0 because one term would involve log(0), but the limit as x = 0 is not a problem.
Unfortunately if there is a closed form solution for ThirdInt then it is difficult to find.

More Answers (0)

Products


Release

R2017a

Community Treasure Hunt

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

Start Hunting!