Problem when using "solve" command

Hi,
I have a problem using the command "solve", I want to solve a 3rd order equation as shown below:
syms V R gamma r Qi
eqn = (1+R*0.5*(1-gamma))*V^3 - R*V^2 - R*0.25*gamma*r*V + R*r^(2/3)*gamma*1/(8*Qi) == 0;
V_solve = solve(eqn,V)
when I run the code, everything gets stuck and I have to close Matlab and re-open it. What is the problem??

Answers (1)

Stephan
Stephan on 17 Jul 2018
Edited: Stephan on 17 Jul 2018
Hi,
in your code there is a closing parenthesis missing at the end of the equation - use this:
syms V R gamma r Qi
eqn = (1+R*0.5*(1-gamma)*V^3 - R*V^2 - R*0.25*gamma*r*V + R*r^(2/3)*gamma*1/(8*Qi) == 0);
V_solve = solve(eqn,V)
But this mistake usually will not lead to this kind of problem. Do you use R2017b or R2018a? Then i recommend to update your matlab since there are known problems by using syms in these releases, which are fixed in the updates..
You find it here:
HOME-TAB / Add-Ons (little arrow) / Check for Updates / Products
If you updated your release and fix the syntax error it should be done.
Best regards
Stephan

4 Comments

Hi Stephan,
thank you for your answer. The closing parentehsis is actually not missing in my original code in matlab (so I have made a mistake when typing it here - I have changed it now). However, I have the R2018a version and by checking for updates it turned out that my version is the lastest one. Do you have other suggestions? Thank you!
Hi,
since you have an actual release you could use matlab online to calculate your equation. But this is not a solution to your problem... I did this and it works so far without problems.
I also tried your code on my netbook (2x 1,5 GHz @ 4GB RAM @Win10 64 Bit) and it also worked - also with newest update: MATLAB Version: 9.4.0.902940 (R2018a) Update 4:
>> syms V R gamma r Qi
eqn = (1+R*0.5*(1-gamma)*V^3 - R*V^2 - R*0.25*gamma*r*V + R*r^(2/3)*gamma*1/(8*Qi) == 0);
tic
V_solve = solve(eqn,V)
toc
V_solve =
root(- 8*Qi + 8*Qi*R*z^2 - 4*Qi*R*z^3 - R*gamma*r^(2/3) + 4*Qi*R*gamma*z^3 + 2*Qi*R*gamma*r*z, z, 1)
root(- 8*Qi + 8*Qi*R*z^2 - 4*Qi*R*z^3 - R*gamma*r^(2/3) + 4*Qi*R*gamma*z^3 + 2*Qi*R*gamma*r*z, z, 2)
root(- 8*Qi + 8*Qi*R*z^2 - 4*Qi*R*z^3 - R*gamma*r^(2/3) + 4*Qi*R*gamma*z^3 + 2*Qi*R*gamma*r*z, z, 3)
Elapsed time is 2.927402 seconds.
>>
So my suggestion would be to reinstall matlab and/or the symbolic toolbox and if it wont work it should be a case for the support i guess.
Best regards
Stephan
thank you very much! I have a question: why are the roots in function of "z"? Is it possible to get a solution with the parameters involved only (for example like the expression below)?
-(b + (b^2 - 4*a*c)^(1/2))/(2*a)
Sorry - in this question i can not help. It seems that symbolic toolbox did a z-transform to solve the problem. But i have really no idea how to deal with this - i think this is worth a new question.
Best regards
Stephan

Sign in to comment.

Asked:

on 17 Jul 2018

Commented:

on 17 Jul 2018

Community Treasure Hunt

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

Start Hunting!