Why does solve ignore if a variable is assumed real or positive?

3 ビュー (過去 30 日間)
Prabhakar
Prabhakar 2011 年 1 月 18 日
When I use 'solve' on a complicated equation with variables assumed to be real or positive, these assumptions are sometimes ignored.
syms a positive;
solve('5*ln(a) - 32*exp(a/16) + 8*a^2 + 4*a^4=0','a')
ans = 0.22609034746836648974751899999113*i - 1.3900380484673922332261785846175

回答 (1 件)

Prabhakar
Prabhakar 2011 年 1 月 18 日
This behaviour occurs because the solver cannot find an analytical solution, and switches to the numeric solver. The numeric solver ignores any assumptions made on variables. There are a couple of workarounds to this issue:
1. You can force the result to follow the desired assumption, for example:
abs(solve('5*ln(abs(a)) - 32*exp(abs(a)/16) + 8*abs(a)^2 + 4*abs(a)^4=0','a') )
2. You can access the numeric solver directly, giving the input it requires to find the desired result:
evalin(symengine, 'numeric::fsolve(5*ln(a) - 32*exp(a/16) + 8*a^2 + 4*a^4=0,a=0..infinity)')
  2 件のコメント
Walter Roberson
Walter Roberson 2011 年 1 月 20 日
Interestingly, Maple's solve() is not able to find a symbolic solution for the version with abs().
Christopher Creutzig
Christopher Creutzig 2011 年 1 月 24 日
Note that with the assumption that a be positive, your abs(a) is automatically simplified to a and your first command returns an incorrect solution (try subs('5*ln(a) ... 4*a^4', 'a', ans), I get -1.63.)

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

カテゴリ

Help Center および File ExchangeCalculus についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by