Function solve cannot find explicit solution with 'ReturnConditions'=true but it finds when it is false

3 views (last 30 days)
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)

Answers (1)

Paul
Paul on 15 Jun 2022
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
Warning: Solutions are only valid under certain conditions. To include parameters and conditions in the solution, specify the 'ReturnConditions' value as 'true'.
sol = struct with fields:
x: -(at*b^2 - N*at*b2 + N*ab*bt - a*b*bt + a*b2*t - ab*b*t)/(a^2*bt + N*ab*at - N*a2*bt - a*at*b - a*ab*t + a2*b*t) T: (b2*a^2 - 2*a*ab*b + N*ab^2 + a2*b^2 - N*a2*b2)/(k*(a^2*bt + N*ab*at - N*a2*bt - a*at*b - a*ab*t + a2*b*t)) T0: -(ab^2*t + a*at*b2 - a*ab*bt - ab*at*b + a2*b*bt - a2*b2*t)/(a^2*bt*k - a*ab*k*t + a2*b*k*t + N*ab*at*k - N*a2*bt*k - a*at*b*k)
sol = solve([eq1, eq2, eq3], [x, T, T0], 'ReturnConditions', true)
Warning: Unable to find explicit solution. For options, see help.
sol = struct with fields:
x: [0×1 sym] T: [0×1 sym] T0: [0×1 sym] parameters: [1×0 sym] conditions: [0×1 sym]
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)
sol = struct with fields:
x: -(at*b^2 - N*at*b2 + N*ab*bt - a*b*bt + a*b2*t - ab*b*t)/(a^2*bt + N*ab*at - N*a2*bt - a*at*b - a*ab*t + a2*b*t) T: (b2*a^2 - 2*a*ab*b + N*ab^2 + a2*b^2 - N*a2*b2)/(k*(a^2*bt + N*ab*at - N*a2*bt - a*at*b - a*ab*t + a2*b*t)) T0: -(ab^2*t + a*at*b2 - a*ab*bt - ab*at*b + a2*b*bt - a2*b2*t)/(a^2*bt*k - a*ab*k*t + a2*b*k*t + N*ab*at*k - N*a2*bt*k - a*at*b*k) parameters: [1×0 sym] conditions: b2*a^2 + N*ab^2 + a2*b^2 ~= N*a2*b2 + 2*a*ab*b
  1 Comment
Walter Roberson
Walter Roberson on 16 Jun 2022
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.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!