Solving an integration problem

5 ビュー (過去 30 日間)
Babacar Ndiaye
Babacar Ndiaye 2018 年 5 月 12 日
コメント済み: Walter Roberson 2018 年 5 月 17 日
Good morning,
I am tring to solve an integration problem. But Matlab don't give me the value. Can you help me please.
Here is the code:
--------------------
clc; clear all;
syms R t r c d x y z s2 D N g;
x = cos(t)+d./(c*r);
y = sin(t);
s1 = x^2+y^2;
z = cos(t)+d./(c*R);
s2 = z^2+y^2;
D = simplify(c^4*R^2*r*s1*s2)
N = (r-R)^2;
%function to integrate
g = expand(N/D)
%-first integral-%
f = @(t) g;
I = int(f, t, 0, 2*pi)
---------------------------
Best regards

回答 (2 件)

Ameer Hamza
Ameer Hamza 2018 年 5 月 12 日
You need to pass symbolic expression directly into int as follow
I = int(g, t, 0, 2*pi);
int() tries to find an analytical solution for the integration. And since there are so many symbols, it is highly unlikely that you will get a useful solution. Try pre-defining the values of r, c, d and R, and only define t as sym because it is variable of integration. So modify your code as follow
syms t;
d = 1; % give appropriate values
c = 10;
r = 1;
R = 200;
x = cos(t)+d./(c*r);
y = sin(t);
s1 = x^2+y^2;
z = cos(t)+d./(c*R);
s2 = z^2+y^2;
D = c^4*R^2*r*s1*s2;
N = (r-R)^2;
%function to integrate
g = N/D;
%-first integral-%
I = int(g, t, 0, 2*pi)

Babacar Ndiaye
Babacar Ndiaye 2018 年 5 月 16 日
Dear Ameer Hamza, Thank you for your answer. However, I have a double intregral. On the one hand, I am trying to solve the first one. That's the reason why I put "R t r c d x y z s2 D N g" as parameters. I add here the expression of the two integrals. I need just the expression, because I will Minimize this expression (after calculating this 2 integrals) where R, C and d will be the variables.
clc; clear all;
syms R t r c d x y z s2 D N g;
x = cos(t)+d./(c*r);
y = sin(t);
s1 = x^2+y^2;
z = cos(t)+d./(c*R);
s2 = z^2+y^2;
D = simplify(c^4*R^2*r*s1*s2)
N = (r-R)^2;
%function to integrate
g = N/D;
%-first integral-%
I = int(g, t, 0, 2*pi)
%-second integral-%
g = @(r) R*I;
J = int(g, r, R, 1/2*pi)
Thanks in advance
  3 件のコメント
Ameer Hamza
Ameer Hamza 2018 年 5 月 17 日
編集済み: Ameer Hamza 2018 年 5 月 17 日
@Babacar, the integrand in your case is quite complex. It is very unlikely that you will be able to get an analytical solution. The best chance of solving this problem is to use a numerical optimization method.
Walter Roberson
Walter Roberson 2018 年 5 月 17 日
I am finding analytical solutions under some reasonable assumptions. The analytic solutions are inf or undefined except for narrow cases such as R=π/2, but the exact sign is rather messy to express. Like is it -inf or is it +inf+undefined*1i depends on details of the relationship between the variables.

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

カテゴリ

Help Center および File ExchangeCalculus についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by