Explicit solution could not be found, using solve()

1 回表示 (過去 30 日間)
Trevor Gates
Trevor Gates 2017 年 7 月 9 日
編集済み: Walter Roberson 2017 年 7 月 9 日
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);

採用された回答

Walter Roberson
Walter Roberson 2017 年 7 月 9 日
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])')
  1 件のコメント
Trevor Gates
Trevor Gates 2017 年 7 月 9 日
Thank-you, that solved the problem!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeGet Started with MuPAD についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by