Symbolic integral simplified doesn't give an error and not simplified does

1 回表示 (過去 30 日間)
Ricardo J.
Ricardo J. 2019 年 3 月 19 日
コメント済み: madhan ravi 2019 年 3 月 19 日
Hi there.
I had to compute a surface integral for my class, but it started to give an error, so I handed it over to my teacher and she finally found the key point.
syms r theta
dS = sqrt(9/(9-r^2));
mass = int(int(r^2*dS,r,0,3),theta,0,2*pi);
It can't solve the integral and if I try to obtain a numerical value
double(mass)
It just goes crazy and gives me the following error:
Error using symengine
Unable to convert expression into double array.
Error in sym/double (line 672)
Xstr = mupadmex('symobj::double', S.s, 0);
But if I simplify the expression beforehand (which I just didn't realize to do) as,
syms r theta
dS = 3/sqrt(9-r^2)
mass = int(int(r^2*dS,r,0,3),theta,0,2*pi);
It returns a symbolic value which I can convert to a double,
double(mass)
With no error whatsoever.
This error was the reason why I thought the question of my problem was wrong, so I used r^3 as a factor before dS (which is equal to the square of the distance to the OZ axis by the Jacobian r), and this time it gave no error, although the dS was the same and wasn't simplified either.
syms r theta
dS = sqrt(9/(9-r^2));
mass = int(int(r^3*dS,r,0,3),theta,0,2*pi)
double(mass)
Has anybody have any explanation for this?
I'd really appreacite it, just in case something similar happened to me in some other occasion.
Thanks!
  3 件のコメント
Ricardo J.
Ricardo J. 2019 年 3 月 19 日
If with ~= you mean equivalent, it's not correct.
sqrt(9/(9-r^2)) ~= 3/sqrt(9-r^2)
madhan ravi
madhan ravi 2019 年 3 月 19 日
Oops, yes your right!

サインインしてコメントする。

採用された回答

Walter Roberson
Walter Roberson 2019 年 3 月 19 日
編集済み: Walter Roberson 2019 年 3 月 19 日
If you add the int() option 'ignoreanalyticconstraints', true then it can solve the problem.
  1 件のコメント
Ricardo J.
Ricardo J. 2019 年 3 月 19 日
編集済み: Ricardo J. 2019 年 3 月 19 日
How could I do that in my example?
Where should I add that option?
int(int(r^2*dS,r,0,3),theta,0,2*pi)
EDIT:
I found it in the official documentation.
int(int(r^2*dS,r,0,3, 'IgnoreAnalyticConstraints', true),theta,0,2*pi)
And it works.
So thanks!

サインインしてコメントする。

その他の回答 (0 件)

Community Treasure Hunt

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

Start Hunting!

Translated by