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

3 views (last 30 days)
Nieves Lopez on 18 Apr 2022
Commented: Walter Roberson on 16 Jun 2022
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)

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
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.
{"ft_lang_label":"__label__en","ft_lang_prob":0.7776476,"math_prob":0.9985781,"size":2918,"snap":"2022-27-2022-33","text_gpt3_token_len":886,"char_repetition_ratio":0.12216884,"word_repetition_ratio":0.32264152,"special_character_ratio":0.32042494,"punctuation_ratio":0.114420064,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9987474,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2022-08-16T14:13:31Z\",\"WARC-Record-ID\":\"<urn:uuid:de625005-4da7-4c43-8bb6-b3ba6940f1bd>\",\"Content-Length\":\"129687\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:4d76cc27-1947-489b-9c30-f965cb37d71a>\",\"WARC-Concurrent-To\":\"<urn:uuid:4ade4488-eda1-4b54-a638-368cc6efb25a>\",\"WARC-IP-Address\":\"23.1.9.244\",\"WARC-Target-URI\":\"https://in.mathworks.com/matlabcentral/answers/1699065-function-solve-cannot-find-explicit-solution-with-returnconditions-true-but-it-finds-when-it-is-fa\",\"WARC-Payload-Digest\":\"sha1:5IUCAV33HGG4NGF4XEXZBYQJ25YKQKHN\",\"WARC-Block-Digest\":\"sha1:WBUPHP35FY3P5I24UVCG5CN7P4FQNZVU\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2022/CC-MAIN-2022-33/CC-MAIN-2022-33_segments_1659882572304.13_warc_CC-MAIN-20220816120802-20220816150802-00382.warc.gz\"}"}