Function solve cannot find explicit solution with 'ReturnConditions'=true but it finds when it is false
4 次查看(过去 30 天)
显示 更早的评论
I have three equations, which depend on several variables. I need to find the solutions on the variables x, T and T0 (expressed in terms of the rest of the variables).
When I call 'solve' with 'ReturnConditions'=false, it returns the solution, but gives a warning with the conditions under which it is valid. However, when I call it again with 'ReturnConditions'=true to get these conditions, it returns empty sym, with a warning "Cannot find explicit solution". How can I get the solution and the conditions with 'ReturnConditions'=true?
Thank you for your help. I am using R2016b. Here's the code:
syms t2 t a b ab at bt a2 b2 N x T T0 k
assume(N ~= 0 & T ~= 0 & k ~= 0)
eq1 = ab == a2*x + T0*a*k + T*at*k;
eq2 = N*T0^2*k^2 + T*t*T0*k^2 + 2*a*T0*k*x + T*at*k*x + a2*x^2 + b2 == 2*ab*x + 2*T0*b*k + T*bt*k;
eq3 = b == a*x + N*T0*k + T*k*t;
sol = solve([eq1, eq2, eq3], [x, T, T0]) % By default, 'ReturnConditions'=false
sol = solve([eq1, eq2, eq3], [x, T, T0], 'ReturnConditions', true)
0 个评论
回答(1 个)
Paul
2022-6-15
Verifying same behavior in 2022a
syms t2 t a b ab at bt a2 b2 N x T T0 k
assume(N ~= 0 & T ~= 0 & k ~= 0)
eq1 = ab == a2*x + T0*a*k + T*at*k;
eq2 = N*T0^2*k^2 + T*t*T0*k^2 + 2*a*T0*k*x + T*at*k*x + a2*x^2 + b2 == 2*ab*x + 2*T0*b*k + T*bt*k;
eq3 = b == a*x + N*T0*k + T*k*t;
sol = solve([eq1, eq2, eq3], [x, T, T0]) % By default, 'ReturnConditions'=false
sol = solve([eq1, eq2, eq3], [x, T, T0], 'ReturnConditions', true)
That is odd.
Maybe solve() can get further if any additional assumptions are placed on the variables. For example, are they all real? Are any strictly positive (or negative)? Etc.
Sometimes ignoring analytic constraints helps, but one neven knows exactly what contraints are being ignored
sol = solve([eq1, eq2, eq3], [x, T, T0], 'ReturnConditions', true, 'IgnoreAnalyticConstraints', true)
1 个评论
Walter Roberson
2022-6-16
if you back substitute the version with no return conditions and simplify() you will get a list of three inequalities rather than symtrue
What happens there is that after substitution there are divisions on the left and right side. The left and right sides are equal so if you subtract the two you get 0 divided by something, and that gets automatically simplified to 0. But if the denominators just happen to equal 0 then you have something of the form A/0 == A/0 and that is not solvable.
So if you ask to solve lhs - rhs it will happily do that, but in the form of equations there are potential values that do not work out.
I do not know why it cannot generate conditions in this case.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Equation Solving 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!