eqn =
Would a General Hold/Release Functionality be a Good Feature for the Symbolic Toolbox?
Paul
on 12 Dec 2024
Latest activity Reply by Walter Roberson
on 15 Dec 2024
The int function in the Symbolic Toolbox has a hold/release functionality wherein the expression can be held to delay evaluation
syms x I
eqn = I == int(x,x,'Hold',true)
which allows one to show the integral, and then use release to show the result
release(eqn)
Maybe it would be nice to be able to hold/release any symbolic expression to delay the engine from doing evaluations/simplifications that it typically does. For example:
x*(x+1)/x, sin(sym(pi)/3)
If I'm trying to show a sequence of steps to develop a result, maybe I want to explicitly keep the x/x in the first case and then say "now the x in the numerator and denominator cancel and the result is ..." followed by the release command to get the final result.
Perhaps held expressions could even be nested to show a sequence of results upon subsequent releases.
Held expressions might be subject to other limitations, like maybe they can't be fplotted.
Seems like such a capability might not be useful for problem solving, but might be useful for exposition, instruction, etc.
3 Comments
x*(x+1)/x
When passed that expression as a parameter, the first thing MATLAB is going to do is evaluate that expression. Evaluation of the expression inside the symbolic toolbox is going to result in the x in the numerator and denominator canceling out. This is going to happen before any function being called gets control. For example, a hypothetical
hold(x*(x+1)/x)
is going to evaluate x*(x+1)/x first and pass the result to hold() . By which time it would be too late.
What could potentially work is something along the lines of
hold(x*(x+1))/x