Symbolic math solve numeric approximation

38 views (last 30 days)
Thomas Ligon
Thomas Ligon on 18 Sep 2017
Commented: Thomas Ligon on 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 Comments
Thomas Ligon
Thomas Ligon on 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 on 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.

Sign in to comment.

Answers (1)

Karan Gill
Karan Gill on 18 Sep 2017
Edited: Karan Gill on 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 Comment
Thomas Ligon
Thomas Ligon on 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.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!