Error trying to compute symbolic integral

1 次查看(过去 30 天)
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);

采纳的回答

Walter Roberson
Walter Roberson 2018-9-16
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 个)

类别

Help CenterFile Exchange 中查找有关 Calculus 的更多信息

产品


版本

R2017a

Community Treasure Hunt

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

Start Hunting!

Translated by