Properties of exponentials - symbolic algebra

조회 수: 3 (최근 30일)
Luca Lazzizzera
Luca Lazzizzera . 2021년 4월 16일
편집: John D'Errico . 2023년 7월 29일
Hello all,
I am experiencing problems with the properties of exponentials, in particular when the exponent is a symbolic variable.
For example, if I set
syms x y
and I want to evaluate
is there a way of having the result the exponential with the sum of exponents
instead of the uncomfortable exp(x)*exp(y)?
Notice that it does work for one variable only, i.e. exp(x)*exp(x)=exp(2*x)
Thank you very much!

답변 (3개)

Mischa Kim
Mischa Kim 2021년 4월 16일
Hi Luca, use
syms x y
z = simplify(exp(x)*exp(y))
z = 
  댓글 수: 1
Luca Lazzizzera
Luca Lazzizzera 2021년 4월 18일
편집: Luca Lazzizzera 님. 2021년 4월 18일
Hello, thank you for answering.
It works as long as the variables are just "x" and "y", but it does not always work, in particular if the product of exponentials is a term in a sum with other terms like exp(x)
for example 6*exp(x) + 5*exp(-x)*exp(y) + 4*exp(-2*y)*exp(x)
does not get simplified for some reason (I have to compute partition functions with many summed terms like this, many more than 3).
Up to 2 added terms, it seems to work instead.
Is there any other more powerful/reliable way?
Thank you again

댓글을 달려면 로그인하십시오.

VBBV 2023년 7월 29일
You can of course use simplify as @Mischa Kim mentioned. However, if you want to obtain the simplified expression as you wanted, you need to apply that function for those terms which involve mixed variables as shown below. This will simplify the overall expression ,
syms x y
p = 6*exp(x) + 5*exp(-x)*exp(y) + 4*exp(-2*y)*exp(x)
p = 
p = 6*exp(x) + simplify(5*exp(-x)*exp(y)) + simplify(4*exp(-2*y)*exp(x))
p = 

John D'Errico
John D'Errico 2023년 7월 29일
편집: John D'Errico 님. 2023년 7월 29일
syms x y
V = exp(x)*exp(y)
V = 
ans = 
So simplify does work. On more complicated problems though, what seems simple to me may not seem simple to you, and to a computer, it may well be confused.
U = 6*exp(x) + 5*exp(-x)*exp(y) + 4*exp(-2*y)*exp(x)
U = 
ans = 
But simplify has some additional capabilities.
Usimp = simplify(U,'all',true,'steps',100)
Usimp = 
And all of those options may be what you are looking to find. The first one is just the original expression.
ans = 
But the second may be more in line with what you were hoping to see.
ans = 
But maybe you might be looking for one of the others. How can simplify know? Maybe there is a common factor that can be removed?
ans = 
And there are many other possibilities, all of which might be of interest. But a computer simply does not have the judgment to know what you personally think is most simple, especially for a complicated expression.

Community Treasure Hunt

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

Start Hunting!

Translated by