Symbolic expression bounds
显示 更早的评论
I have a symbolic expression (the real expression can be anything the Symbolic Toolbox supports) but for example we can use the following:
expr = sym('a + b')
Also, I know that a and b are integers and that their "legal" values go from 1 to 7.
I would like to figure out what are the bounds of expr. In this case, the min value would be 2 and the max value would be 14.
Is there any way to do this type of analysis?
Thanks Joan
3 个评论
Andrew Newell
2011-6-1
Judging by your response below, this isn't a complete statement of your real problem. Try editing your question to provide more detail. For example, is the user only allowed certain variable names? Do you know in advance what the allowed variables are?
Walter Roberson
2011-6-1
Would it not also be necessary to prove that the output was integral?
Joan Puig
2011-6-2
采纳的回答
更多回答(2 个)
Andrew Newell
2011-6-1
It makes little sense to use the Symbolic Toolbox for such an operation because comparisons like max and min are not allowed on symbolic objects and it is trivial to do in MATLAB:
a = 1:7;
b = 1:7;
min(a+b), max(a+b)
5 个评论
Joan Puig
2011-6-1
Walter Roberson
2011-6-1
What operations are the user permitted to use in the expression?
Joan Puig
2011-6-2
Walter Roberson
2011-6-2
If the user is allowed to type in "any symbolic expression they want" then they could, for example, put 1/(a^d + b^d - c^d) as one of the sub-terms. This is a rational number for all a, b, c, d positive integers, d>=3, if and only if Fermat's Last Theorem holds, and otherwise could become 1/0 . Is your formal verification system prepared to prove Fermat's Last Theorem?
Likewise a similar technique could be used to express the Riemann Zeta function and make assertions about its values.
You have to restrict operations and functions called by quite a bit in order to hope to be able to reliably do formal verification.
Joan Puig
2011-6-2
Andrew Newell
2011-6-2
0 个投票
If you have a pre-determined set of variables and a finite number of possible values for them, you might be able to use an approach like this:
- Create a function out of the expression using matlabfunction.
- Feed all possible values of the variables into your function and find the min and max.
类别
在 帮助中心 和 File Exchange 中查找有关 Assumptions 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!