No results are showing in the symbolic math computation

3 次查看(过去 30 天)

%I run these symbolic math expressions but %still return same equations

 syms k_x k_y T d t real 
 Gamma = 1 + 4*cos(k_x)*cos(k_y/sqrt(3)) + 4*cos(k_y/sqrt(3))^2
 Integrand = exp(- sqrt(d^2 + t^2*Gamma)/T)
 I = int(int(integrand, k_x, 0, pi), k_y, 0, pi)
 Simplify(I)
%%
Syms u a b c real
assumeAlso([a, b, c], 'positive')
D = exp(- a*sqrt(b + c*u))/sqrt(1 - u^2)       
II = int(D, u, -1, 1)
Simplify(II)

采纳的回答

John D'Errico
John D'Errico 2025-5-7
编辑:John D'Errico 2025-5-7
First, you need to recognize MATLAB is case sensitive. Your code does not run, instead, it fails in several places. I fixed it, to at least attempt to run.
If you define the variable Integrand, then tryign to use integrand will be an issue. And the MATLAB function simplify needs to be called simplify. Simplify just gets MATLAB confused.
syms k_x k_y T d t real
Gamma = 1 + 4*cos(k_x)*cos(k_y/sqrt(3)) + 4*cos(k_y/sqrt(3))^2
Gamma = 
Integrand = exp(- sqrt(d^2 + t^2*Gamma)/T)
Integrand = 
I = int(int(Integrand, k_x, 0, pi), k_y, 0, pi)
I = 
simplify(I)
ans = 
Next, when MATLAB just returns an integral, shown like this, it means it was unable to resolve the integration.
Not every expression you decide to integrate will have an analytical solution, and even if one exist does not mean MATLAB will always find it. In at least the first case, MATLAB failed to return a solution. In fact, the vast majority of things you can write down will have no solution, since you can write down things that are arbitrarily complicated. Anyway, I'm not at all surprised that int failed here.
In some cases, you may be able to do a substitiution or other operation to make the problem more tractable. The human brain can often see things a computer does not, even though the computer is a stubborn beast and will try anything.
When all else fails, you can substitute numerical values for those parameters, and perform a numerical integration, though this is often unsatisfactory to those who want a nice pretty closed form solution. Or you can try other tricks, for example a series approximation to the integrand, etc.
  7 个评论
Steven Lord
Steven Lord 2025-5-7
How does the textbook answer handle the case where T is 0? Does it? You've told MATLAB (in your syms call) that T is real, but 0 is real.
Are you perhaps missing an assumption or two on some of your variables? See the assume and assumeAlso functions.
Walter Roberson
Walter Roberson 2025-5-7
If we simplify out nearly everything, we still end up with at least one integral that MATLAB does not handle.
The syms ... real is equivalent to syms ... followed by assume(k_x, 'real') and assume(k_y, 'real')
syms k_x k_y real
Gamma = cos(k_x)*cos(k_y);
Integrand = exp(Gamma);
I = int(int(Integrand, k_x, 0, pi), k_y, 0, pi)
I = 

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Symbolic Math Toolbox 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by