Why can Matlab not determine the sign of the square root of a positive expression?
5 Comments
- To clear all objects in the MATLAB workspace and close the Symbolic Math Toolbox™ engine associated with the MATLAB workspace resetting all its assumptions, use this command.
Answers (1)
Hi @MaggieD,
In MATLAB's Symbolic Toolbox, assumptions play a crucial role in how expressions are evaluated. They help define the domain and properties of symbolic variables, influencing the results of operations performed on them. The behavior you are observing stems from how MATLAB interprets these assumptions in relation to real numbers and divisions. When you declare a variable as real (e.g., syms b real), MATLAB restricts its analysis to real values only. This means that any expressions involving these variables must also adhere to real number properties. In your case, when b is included in a multiplication scenario, it does not pose any ambiguity since multiplying two positive expressions will yield a positive result. However, when you divide by b, even under the assumption that b > 0, MATLAB cannot automatically deduce that the resultant expression remains positive without further information about how other terms behave—especially since division can introduce complexities not present in multiplication. The change from multiplication to division alters the nature of how expressions are evaluated:
Multiplication Example:
d=(1 + (1/beta - c*f2/sigma)*b)^2 - 4*(1/beta + c*f1/sigma)*b;
Here, if d > 0, it can be inferred that sqrt(d)>0 under your assumption.
Division Example:
d=(1 + (1/beta - c*f2/sigma)/b)^2 - 4*(1/beta + c*f1/sigma)/b;
This introduces potential for d to approach zero or even become negative depending on values of other variables, thus complicating the determination of sqrt(d).
Why Removing b Affects Behavior
When you remove b from your expression and still assume all variables are real, it can lead to undefined or ambiguous conditions in certain mathematical contexts, the expression:
d=(1 + (1/beta - c*f2/sigma))^2 - 4*(1/beta + c*f1/sigma);
may still yield conditions where positivity isn't guaranteed because the absence of b removes a multiplicative factor that could ensure positivity under certain conditions. Thus, without additional constraints or specific values for your parameters, MATLAB cannot conclude definitively about the sign.
In my opinion, the inherent complexity when dealing with symbolic expressions highlights a limitation in automatic reasoning within MATLAB's symbolic engine. It’s often beneficial to manually analyze critical points or ranges for parameters involved. My suggestion would be that you might consider breaking down your expressions into simpler components and using isAlways with specific assumptions on individual components rather than relying solely on global assumptions. As you continue experimenting, try gradually building up your expressions and assumptions, checking results at each step. This can help pinpoint where ambiguity arises.
In nutshell, understanding how symbolic assumptions interact with different operations is key in leveraging MATLAB’s capabilities effectively.
Hope, this helps.
If further clarification or assistance is needed with specific examples or additional concepts, feel free to ask!
0 Comments
See Also
Categories
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!