Why does solve(1 == 1, t) return 0 as an answer?

2 views (last 30 days)
I understand that the solution of the equation 1=1 in terms of t is all t. Now, when I ask MATLAB to solve(1 == 1, t) it returns 0. This problem arose from a vector valued function who's derivative imposed to equal 1 had more than one solution and MATLAB wasn't giving them.
  3 Comments
Stephen23
Stephen23 on 28 Feb 2022
Edited: Stephen23 on 28 Feb 2022
Then I repeat my question: does anyone have a reference to the MATLAB documenation, where it explains what to expect in this situation? Surely this behavior should be in some way predictable based on TMW documentation.
Walter Roberson
Walter Roberson on 28 Feb 2022
Tips
If the solution contains parameters and ReturnConditions is true, solve returns the parameters in the solution and the conditions under which the solutions are true. If ReturnConditions is false, the solve function either chooses values of the parameters and returns the corresponding results, or returns parameterized solutions without choosing particular values. In the latter case, solve also issues a warning indicating the values of parameters in the returned solutions
So, solve() sometimes chooses values for the parameters, so choosing 0 in this case is not contrary to the documentation.

Sign in to comment.

Accepted Answer

Walter Roberson
Walter Roberson on 28 Feb 2022
When MATLAB detects that there a range of solutions, then historically MATLAB has chosen what I refer to as a "representative" solution. There is a whole logic about which representative solution will be chosen; 0 is the most common choice, but the "magic" values also include 1 and pi, and left boundaries in case of constrained ranges.
At some point in the past I posted an analysis of how the representative solution is chosen.
Choosing a representative solution is an artifact of the output interface. The internal computation tool, MuPAD, returns structured information about the range information, but MATLAB translates that into a representative solution.
If you ask to ReturnConditions then you might get more information
syms t
sol = solve(1==1, t, 'returnconditions', true)
sol = struct with fields:
t: z parameters: z conditions: symtrue
sol.t
ans = 
z
sol.conditions
ans = 
symtrue
This says that the solution for t is all of the z such that the condition symtrue holds -- so t is the set of all numbers.
You can see for example,
sol = solve((t-2)^2 > 5, t)
sol = 
sol = solve((t - 2)^2 > 5, t, 'returnconditions', true), sol.t, sol.conditions
sol = struct with fields:
t: [2×1 sym] parameters: x conditions: [2×1 sym]
ans = 
ans = 
solve() without 'returnconditions' returned a "representative solution", but with 'returnconditions' return the inequalities

More Answers (0)

Tags

Products


Release

R2021a

Community Treasure Hunt

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

Start Hunting!