Symbolic math solve numeric approximation

15 vues (au cours des 30 derniers jours)
Thomas Ligon
Thomas Ligon le 18 Sep 2017
Commenté : Thomas Ligon le 17 Oct 2017
Question: When does the Symbolic Math "solve" statement try to find a numeric approximation?
I have 2 versions of the same complex logic. In version 2, my colleague made a lot of changes over the weekend, but the results should be exactly the same. Now, when one specific "solve" statement runs, version 1 produces the following:
Warning: Solutions might be lost
Version 2 produces this:
Warning: Cannot solve symbolically. Returning a numeric approximation instead
Q: Why does "solve" in version 2 try to find a numeric approximation, when "solve" in version 1 does not?
I looked at the input to "solve" and couldn't find any differences. In both cases, we are passing cell arrays containing 1x1 sym expressions. They look the same to me. I didn't find any options for "solve" like we have for fmincon.
Q: Are the any default or global options for "solve" or Symbolic Math in general?
  3 commentaires
Thomas Ligon
Thomas Ligon le 19 Sep 2017
Thanks Karan and Walter. This is good information. However, the problem seems to be more subtle than it looks, so I created a test program and submitted a service request, number 02754965.
Thomas Ligon
Thomas Ligon le 20 Sep 2017
This issue is completely resolved, thanks to great information from support. Our software was in fact supplying the same data to "solve" but, when it was called the first time, it took 10-15 minutes to determine that the relations couldn't be solved symbolically, and then ran a numerical solution in a few seconds. If "solve" was called again sometime later, it had cached some information and immediately did the quick numerical solution. So there was no difference to be found in the code, but it was a matter of what had run since MATLAB was last started.

Connectez-vous pour commenter.

Réponses (1)

Karan Gill
Karan Gill le 18 Sep 2017
Modifié(e) : Karan Gill le 17 Oct 2017
Question: When does the Symbolic Math "solve" statement try to find a numeric approximation?
"solve" tries to find a symbolic (closed form) solution. If one doesn't exist, then a numeric solution could still be possible. A numeric solution is always an approximation of an exact symbolic solution. The numeric answer is the result of vpasolve. See https://www.mathworks.com/help/symbolic/solve.html#bue1gjw-1.
Q: Why does "solve" in version 2 try to find a numeric approximation, when "solve" in version 1 does not?
As Walter said, that's undocumented behavior. I assume your input changed so that the solver's approach worked differently in the two cases. "solve" only falls back to a numeric solutions when a symbolic solution cannot be found.
Q: Are the any default or global options for "solve" or Symbolic Math in general?
All options for a function are documented in the "Arguments" section of the respective function reference page.
  1 commentaire
Thomas Ligon
Thomas Ligon le 17 Oct 2017
Dear Karan, thanks for your efforts. However, the answer to this question was already supplied by Mathworks support, and I explained the situation in my comment on 20 September 2017.

Connectez-vous pour commenter.

Community Treasure Hunt

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

Start Hunting!

Translated by