Error trying to compute symbolic integral
1 view (last 30 days)
Show older comments
abraham rodriguez
on 15 Sep 2018
Answered: Walter Roberson
on 16 Sep 2018
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);
0 Comments
Accepted Answer
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.
0 Comments
More Answers (0)
See Also
Categories
Find more on Calculus in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!