Matlab says "Cannot find explicit solution", although I can solve it manually.
The initial equation is below:
And the explicit solution is below:
What is wrong with my code, below?
----------------------------------
>> syms x n b r a
eqn = x*(1+n)==(b/(b+1))*r*(1-a)*x^a ;
solx = solve(eqn, x)
Warning: Cannot find explicit solution.
> In solve (line 318)
solx =
Empty sym: 0-by-1
------------------------------------

2 Kommentare

Walter Roberson
Walter Roberson am 20 Jul. 2015
Which MATLAB version are you using?
Check to see if eqns is already a logical value even before the solve() call; that happened in older MATLAB releases.
P J
P J am 20 Jul. 2015
Bearbeitet: Walter Roberson am 9 Jul. 2017
Thank you so much for your help.
The version is R2015a (8.5.0.197613) 32 bit (win32) February 12, 2015.
When I put a more simpler equation, such as below, it worked well.
Also, I cleared all of the previous variables in the workspace, using the function "clear all."
---------------------------------------
syms x y z
eqn = x*y+x*z==z^3+y^4+15 ;
solx = solve(eqn, x)
solx =
(y^4 + z^3 + 15)/(y + z)
---------------------------------------

Melden Sie sich an, um zu kommentieren.

 Akzeptierte Antwort

Star Strider
Star Strider am 20 Jul. 2015

4 Stimmen

Sometimes, you have to lead it gently by the hand:
syms x n b r a
eqn = x*(1+n)==(b/(b+1))*r*(1-a)*x^a ;
eqn = rewrite(eqn,'log');
solx = solve(eqn, x, 'IgnoreAnalyticConstraints',1)
pretty(solx)
solx =
(-((b + 1)*(n + 1))/(b*r*(a - 1)))^(1/(a - 1))
1
-----
/ (b + 1) (n + 1) \a - 1
| - --------------- |
\ b r (a - 1) /

4 Kommentare

P J
P J am 20 Jul. 2015
Your answer is great help for me !! It worked, when I pasted it to Matlab.
Interestingly, removing the line below also yield the same answer.
eqn = rewrite(eqn,'log');
With your answer, I am able to study Matlab further by searching at Mathworks webpage: http://www.mathworks.com/help/.
Star Strider
Star Strider am 20 Jul. 2015
My pleasure.
Your second result (after removing the rewrite call) is interesting. I got the same results you did before adding the rewrite call. After adding it, I got the correct result. I didn’t experiment with removing it again.
Trevor Gates
Trevor Gates am 9 Jul. 2017
Bearbeitet: Walter Roberson am 13 Jul. 2018
Hello,
I am having the same problem (i.e. unable to find explicit solution), except that in my case, there are 7 equations (with some being inequalities). Again, I am able to find an explicit solution for 'a' by hand. Is there a similar trick that I can use to help the solve() function to find it? Below is my source code. I am using the Student Version R2010a.
syms a s lambda1 lamdbda2;
obj = log(a);
cons1 = a;
cons2 = s/2 - a;
Lagrange = obj + lambda1*cons1 + lambda2*cons2;
eq1 = [char(diff(Lagrange, a)), '=0'];
eq3 = [char(diff(Lagrange, lambda1)), '>=0'];
eq4 = [char(diff(Lagrange, lambda2)), '>=0'];
eq3a = [char(diff(Lagrange, lambda1)*lambda1), '=0'];
eq4a = [char(diff(Lagrange, lambda2)*lambda2), '=0'];
eq6a = 'lambda1>=0';
eq6b = 'lambda2>=0';
[a_sol] = solve(eq1, eq3, eq4, eq3a, eq4a, eq6a, eq6b, a);
Walter Roberson
Walter Roberson am 9 Jul. 2017
Trevor, your situation has to do with a MATLAB bug in the old release you are using. The workaround is to call into MuPAD directly.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

Shashank kumar
Shashank kumar am 13 Jul. 2018
Bearbeitet: Walter Roberson am 13 Jul. 2018

0 Stimmen

Hello i am also having the same problem. The above explain code is not able to solve my problem. If possible please look into it.
syms y k p b c;
eqn= k*p^(1-a)==b*p^(-a)+c;
eqn=rewrite(eqn,'log');
sol=solve(eqn, p, 'IgnoreAnalyticConstraints',1)
pretty(sol)

1 Kommentar

Walter Roberson
Walter Roberson am 13 Jul. 2018
There is no analytic solution to that equation.

Melden Sie sich an, um zu kommentieren.

Community Treasure Hunt

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

Start Hunting!

Translated by