Programm freezes in solve

In my programm I repeatedly call a function that uses solve to calculate its return value. After some iterations the programm freezes and when I stop the execution, I see that the problem occurs in solve:
Warning: Attempt to stop MuPAD failed.
In mupadengine/evalin (line 102)
In mupadengine/feval (line 158)
In solve (line 292)
...
Weirdly, when I call the function directly from the console with the exact same arguments it runs just fine, so in principle solve is able to calculate the solutions of the equation. I have no idea what is going on. It seems that there have been similar issues in versions 2017b and 2018a (see here), but I use 2016b.
It seems to me that the fault does not lie with my programm, so for simplicity's sake I'll only post the basic structure:
while someCondition
// changes to someVector
myFunction(someVector)
end
y = myFunction(v)
// construct somePolynomial
solve(somePolynomial == 0)
// ...
end
As said above the call
myFunction(someVector)
gives a result. The problem does not occur for vectors with relatively few entries.
Do you have any suggestions how I could fix the problem or any alternatives to solve? I already tried
roots(coeffs(somePolynomial))
but with that even calling myFunction directly led Matlab to freeze. Thanks in advance.

2 Comments

Walter Roberson
Walter Roberson on 17 Sep 2018
Edited: Walter Roberson on 17 Sep 2018
I wonder if you are running out of memory inside the MuPAD engine?
I suspect that as MuPAD calculates, it tends to remember results, as a cache so that it does not need to recalculate results (as much) if it happens to be presented with the same problem. I do not know anything about how MuPAD manages that cache. For user-level cache see https://www.mathworks.com/help/symbolic/mupad_ug/remember-mechanism.html . Maple has procedure options "system" and "cache" to control amount of memory used for remember tables, but there does not appear to be any MuPAD equivalent.
You might find yourself needing to use reset(symengine) -- see https://www.mathworks.com/help/symbolic/reset.html
Thanks for your comment. That seems a very plausible explanation to me, but unfortunately neither clear nor reset(symengine) did the trick.

Sign in to comment.

Answers (0)

Asked:

on 17 Sep 2018

Commented:

on 20 Sep 2018

Community Treasure Hunt

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

Start Hunting!