Help with simplifying a complex symbolic expression

5 views (last 30 days)
There is a symbolic expression, and one of the variable "U_j0" can be cancled out.
But when I use "simplify()" command, "U_j0" is still in the expression. Can anyone help me out to further simplify the expression below?
syms dIm Im dKm Km alpha1 omega1 S U1 delta c1 m
syms omega Omega R0 R Uinf U_j0
% The following is the symbolic expression waiting to be simplified. ^ O ^
% Thank you!
term1=((2*log(-(U_j0*(alpha1 - alpha1*c1 + S*delta*m))/delta)*(S^2*m^2 + 2*S*alpha1*c1*m - 2*S*alpha1*m - alpha1^2*c1^2 + 2*alpha1^2*c1 - alpha1^2))/(m^2*(alpha1 + S*m - alpha1*c1)^2) - (log(R)*(m^2 - 2))/m^2 + (Im*alpha1^2*((R*dIm*delta*((2*S*(S*m - alpha1 + alpha1*c1))/(m*(alpha1 + S*m - alpha1*c1)^2) - (log(-R*(delta - 1))*(m^2 - 2))/m^2 + (2*log(-(U_j0*alpha1*(c1 - 1)*(delta - 1))/delta)*(S^2*m^2 + 2*S*alpha1*c1*m - 2*S*alpha1*m - alpha1^2*c1^2 + 2*alpha1^2*c1 - alpha1^2))/(m^2*(alpha1 + S*m - alpha1*c1)^2)))/(Im*alpha1) - (R^2*delta^2*((U_j0*alpha1*(c1 - 1))/(R^2*delta*(delta - 1)) + (S*U_j0*m*((2*S*(S*m - alpha1 + alpha1*c1))/(m*(alpha1 + S*m - alpha1*c1)^2) - (log(-R*(delta - 1))*(m^2 - 2))/m^2 + (2*log(-(U_j0*alpha1*(c1 - 1)*(delta - 1))/delta)* (S^2*m^2 + 2*S*alpha1*c1*m - 2*S*alpha1*m - alpha1^2*c1^2 + 2*alpha1^2*c1 - alpha1^2))/(m^2*(alpha1 + S*m - alpha1*c1)^2)))/(R^2*delta*(delta - 1))))/(U_j0*alpha1^2*(c1 - 1)))*(c1 - 1)*(delta - 1))/(delta*(Im*S*m - R*alpha1*dIm + R*alpha1*c1*dIm + R*alpha1*dIm*delta - R*alpha1*c1*dIm*delta)) + (2*S*alpha1*(c1 - 1)*(delta - 1)*(S*m - alpha1 + alpha1*c1))/(m*(alpha1 + S*m - alpha1*c1)^2*(alpha1 - alpha1*c1 + S*delta*m)));
I tried to combine "log()" terms by hand and simplified the above expression to get a new one shown below (cancel variable "U_j0") , but the expression I got is not correct. I wondered anyone could help me to use MATLAB program to simplify this expression and cancel variable "U_j0"?

Accepted Answer

Paul
Paul on 26 Mar 2021
This code eliminates U_j0:
[num,den]=numden(term1);
newnum = combine(num,'log','IgnoreAnalyticConstraints',true);
newterm1 = newnum/den;
  4 Comments
Paul
Paul on 26 Mar 2021
Im and dIm are left over in Y3 - Y1. Substitute values in for those too:
>> Y1 = subs(term1,[alpha1,c1,S,delta,m, R, Im, dIm, U_j0],[1,0.1,1,0.1,1,1,3,2,1]);
>> Y3 = subs(newterm1,[alpha1,c1,S,delta,m, R, Im , dIm],[1,0.1,1,0.1,1,1,3,2]);
>> simplify(Y1-Y3,500)
ans =
0
Here is the code I used to show that num and newnum are identical (ignoring the Analytic Constraints):
>> syms dIm Im dKm Km alpha1 omega1 S U1 delta c1 m
syms omega Omega R0 R Uinf U_j0
% The following is the symbolic expression waiting to be simplified. ^ O ^
% Thank you!
term1=((2*log(-(U_j0*(alpha1 - alpha1*c1 + S*delta*m))/delta)*(S^2*m^2 + 2*S*alpha1*c1*m - 2*S*alpha1*m - alpha1^2*c1^2 + 2*alpha1^2*c1 - alpha1^2))/(m^2*(alpha1 + S*m - alpha1*c1)^2) - (log(R)*(m^2 - 2))/m^2 + (Im*alpha1^2*((R*dIm*delta*((2*S*(S*m - alpha1 + alpha1*c1))/(m*(alpha1 + S*m - alpha1*c1)^2) - (log(-R*(delta - 1))*(m^2 - 2))/m^2 + (2*log(-(U_j0*alpha1*(c1 - 1)*(delta - 1))/delta)*(S^2*m^2 + 2*S*alpha1*c1*m - 2*S*alpha1*m - alpha1^2*c1^2 + 2*alpha1^2*c1 - alpha1^2))/(m^2*(alpha1 + S*m - alpha1*c1)^2)))/(Im*alpha1) - (R^2*delta^2*((U_j0*alpha1*(c1 - 1))/(R^2*delta*(delta - 1)) + (S*U_j0*m*((2*S*(S*m - alpha1 + alpha1*c1))/(m*(alpha1 + S*m - alpha1*c1)^2) - (log(-R*(delta - 1))*(m^2 - 2))/m^2 + (2*log(-(U_j0*alpha1*(c1 - 1)*(delta - 1))/delta)* (S^2*m^2 + 2*S*alpha1*c1*m - 2*S*alpha1*m - alpha1^2*c1^2 + 2*alpha1^2*c1 - alpha1^2))/(m^2*(alpha1 + S*m - alpha1*c1)^2)))/(R^2*delta*(delta - 1))))/(U_j0*alpha1^2*(c1 - 1)))*(c1 - 1)*(delta - 1))/(delta*(Im*S*m - R*alpha1*dIm + R*alpha1*c1*dIm + R*alpha1*dIm*delta - R*alpha1*c1*dIm*delta)) + (2*S*alpha1*(c1 - 1)*(delta - 1)*(S*m - alpha1 + alpha1*c1))/(m*(alpha1 + S*m - alpha1*c1)^2*(alpha1 - alpha1*c1 + S*delta*m)));
[num,den]=numden(term1);
newnum = combine(num,'log','IgnoreAnalyticConstraints',true);
>> simplify(combine(newnum-num,'log','IgnoreAnalyticConstraints',true),500)
ans =
0
It may be possible to get simpler expressions by putting appropriate assumptions (e.g., real, positive, etc.) on the variables if appropriate.
Lu Zhao
Lu Zhao on 29 Mar 2021
That is great! I learned a lot from it. Than you. I really appreciate it. : D

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!