Gamma =
No results are showing in the symbolic math computation
You are now following this question
- You will see updates in your followed content feed.
- You may receive emails, depending on your communication preferences.
An Error Occurred
Unable to complete the action because of changes made to the page. Reload the page to see its updated state.
Show older comments
0 votes
Share a link to this question
%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)
Accepted Answer
John D'Errico
on 7 May 2025
Edited: John D'Errico
on 7 May 2025
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
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 Comments
Walter Roberson
on 7 May 2025
rewrite() does not help.
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 =

rw = ["exp", "log", "sincos", "sinhcosh", "asin", "acos", "atan", "acot", "asinh", "acosh", "atanh", "acoth", "sqrt", "heaviside", "piecewise"];
for K = 1 : length(rw)
rw(K) == rewrite(I, rw(K))
end
ans =

ans =

ans =

ans =

ans =

ans =

ans =

ans =

ans =

ans =

ans =

ans =

ans =

ans =

ans =

Samuel Suakye
on 7 May 2025
What about a standard integral which already has an answer
Walter Roberson
on 7 May 2025
What about a standard integral which already has an answer
What about it?
If you are asking about rewriting your current expression in terms of other functions such that the rewritten version is something that can be integrated by MATLAB... well, then doing that is not easy and would require a fair bit of mathematical knowledge to transform the expressions "by hand"... if it can be done at all.
If you are asking about how MATLAB handles cases that can be readily integrated, then for example,
syms k_x k_y T d t real
Gamma = cos(k_x)+cos(k_y)
Gamma = 
Integrand = exp(Gamma)
Integrand = 
I = int(int(Integrand, k_x, 0, pi), k_y, 0, pi)
I = 

●
simplify(I)
ans = 

I had to pare your existing expressions down quite a bit to find something that could be integrated.
Samuel Suakye
on 7 May 2025
Wow... thank you. Some standard integral already have an answer in text book (e.g is the second part of the codes) but MATLAB doesn't return the results. In such cases, how do you go about it?
Walter Roberson
on 7 May 2025
Sometimes using rewrite() requesting "exp" or "sincos" can help. If you have a piecewise() expression then rewrite() requesting "heaviside" can help.
Other than that... there is no general rule. Integration is difficult in general. Maplesoft's "Maple" product for one contains extensive integration tables and integration rules, but even so sometimes needs substituation hints and sometimes needs hints about which rules to apply, and sometimes just doesn't contain enough knowledge to be able to handle some integrals known in textbooks. There are large books containing lists of integrals because integration is just hard to do.
Steven Lord
on 7 May 2025
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
on 7 May 2025
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 =
More Answers (0)
Categories
Find more on Assumptions in Help Center and File Exchange
Tags
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)