Explicit solution could not be found, using solve()

2 Ansichten (letzte 30 Tage)
Trevor Gates
Trevor Gates am 9 Jul. 2017
Bearbeitet: Walter Roberson am 9 Jul. 2017
Hello,
I have a relatively simple problem that I am able to solve by hand (i.e. solution should be a_sol = s/2). However, when I try to solve it using the solve() function, I get the warning that an explicit solution could not be found. Below is the source code. Any advice would be greatly appreciated.
syms a s lambda1 lambda2;
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);

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 9 Jul. 2017
This appears to be the same bug as https://www.mathworks.com/support/bugreports/677110 except no trig is involved.
Workaround:
Call the MuPAD symbolic engine directly. For example,
>> S = evalin(symengine,'solve([p1-y1,p2-y2,p3-sin(y3)],[y1,y2,y3])')

Weitere Antworten (0)

Kategorien

Mehr zu Get Started with MuPAD finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by