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

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 commentaires

Walter Roberson
Walter Roberson le 28 Fév 2022
In terms of t, you would have
But 1 = 1 is true in any logic system in which = represents equality and the symbol 1 exists, so is always false, and the set of t such that false is true is empty. So the second part is the empty set, and so the solution is the set of all t . There is no t such that 1=1 is false so all t are included in the solution.
Stephen23
Stephen23 le 28 Fév 2022
Modifié(e) : Stephen23 le 28 Fév 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 le 28 Fév 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.

Connectez-vous pour commenter.

 Réponse acceptée

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

Plus de réponses (0)

Produits

Version

R2021a

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by