# Solving symbolic equation using vpasolve

4 views (last 30 days)

Show older comments

syms Del theta

assume(Del,'real')

% assume(theta == 0);

% assume(theta>0 & theta<2*pi)

alpha = 1;

rho_0 = 0.5;

rho = 0.75;

q = 2;

s = 0;

kappa_0 = 1;

kappa_p = 0;

kappa = kappa_0+kappa_p*(rho-rho_0);

kappa_t = kappa+rho*kappa_p;

delta_0 = 0;

delta_p = 0;

delta = delta_0+delta_p*(rho-rho_0);

delta_t = delta+rho*delta_p;

R_0 = 3;

Del_shift = Del*(rho-rho_0);

R = R_0 - Del_shift + rho*(cos(theta)-delta*sin(theta)^2);

eps = rho_0/R_0;

D = kappa*rho*(cos(theta)*(cos(theta)-Del-delta_t*sin(theta)^2)+kappa_t/kappa*sin(theta)*(sin(theta)+delta*sin(2*theta)));

D_t = (cos(theta)*(cos(theta)-Del-delta_t*sin(theta)^2)+kappa_t/kappa*sin(theta)*(sin(theta)+delta*sin(2*theta)));

C = (sin(theta)+delta*sin(2*theta))*(cos(theta)-Del-delta_t*sin(theta)^2)-kappa*kappa_t*sin(theta)*cos(theta);

A_0 = kappa_0^2*cos(theta)^2+(sin(theta)+delta_0*sin(2*theta))^2;

%dRdrho = diff(R, rho);

dRdrho = cos(theta)-delta_0*sin(theta)^2-2*rho*delta_p*sin(theta)^2-rho_0*delta_p*sin(theta)^2;

E = 1/(pi)* int(-D*dRdrho*R_0/R^2, theta, 0, 2*pi);

F = 1/(2*pi)* int(D^3/(R*rho_0^2*A_0), theta, 0, 2*pi);

G_1 = 1/(2*pi)* int(D^3*R/(R_0^2*rho_0^2*A_0), theta, 0, 2*pi);

CBd = diff(C/(D*R), theta);

CB = CBd * (D*R/rho_0/A_0) + 2*(1/rho_0+(kappa_0*kappa_p*cos(theta)^2+(sin(theta)+delta_0*sin(2*theta))*sin(2*theta*delta_p))/A_0);

G_2 = 1/(2*pi)* int(D*rho_0/R*CB, theta, 0, 2*pi);

H = 1/(2*pi)* int(D_t*R_0/R, theta, 0, 2*pi);

L = kappa_0*eps*H;

SB = -alpha/(2*L) + (s*L/eps-E-G_2/eps+alpha*G_1/(2*L^2))/(L^2/q^2+F/L);

Sol = vpasolve(2*Del*(SB) -alpha*eps/L*(Del*eps-1-Del^2) -(2*delta_0-Del)/kappa_0*H +(1+eps*Del)/(1-eps^2)*L == 0, Del);

I need to solve a symbolic equation (last line of my code), but my code just runs forever. This equation must be solved for one variable only (Del).

However, this equation requires that I first derive some quantities: these contain the symbolic variable theta. I am not sure how to handle this and why my code fails.

My hypotheses are:

- The symbolic solutions I want to obtain before putting together the final equation are too complicated for Matlab;
- I am not setting theta to any value so the equation cannot be solved (how can I do this before solving but after integrating?);
- There is just something completely wrong in how I wrote my code.

Any ideas?

Edit: I debugged my code and found that the lines where I integrate to compute E, F, G1... return very weird solutions. I do not know what the problem may be though.

##### 3 Comments

Walter Roberson
on 21 Apr 2021

Walter Roberson
on 21 Apr 2021

for G_2,

Del = 9 exactly to Del = 15 (not included) is -infinity, but Del = 15 exactly is +infinity

It looks like it might be finite outside those bounds.

### Answers (1)

Divija Aleti
on 21 Apr 2021

Hi Alessandro,

The "int" function cannot solve all integrals since symbolic integration is such a complicated task. It is also possible that no analytic or elementary closed-form solution exists.

In this case, the lines where you have to integrate to compute E,F,G1 etc., are returning unresolved integrals as no closed form solution exists. You can try approximating these integrals using numeric approximations.

For more information, have a look at the 'Tips' section of the following link:

Regards,

Divija

##### 0 Comments

### See Also

### Categories

### Community Treasure Hunt

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

Start Hunting!