how to do symbolic type negation ?
2 次查看(过去 30 天)
显示 更早的评论
How can one do symbolic type negation ? (Advanced methods permitted!!)
For example
syms x n m
y = symsum(1/(x-n),n,1,m)
Notice the -- that is, if x is an integer. That leads to the question: how can you set an assumption such that x is known to be a non-integer ?
You can use assume() to set x to be integer, but assume() does not support negation. It is not obvious to me that the internal MuPAD routine assume does either; you can read the code for it by using
regexprep(char(evalin(symengine, 'expose(assume)')),'\\n','\n')
You can appear to construct an appropriate type at the MuPAD level:
S1 = evalin(symengine, 'Dom::Real and not Dom::Integer')
S2 = evalin(symengine, '~(x in integer)')
but how could you associate that type with a symbolic variable?
I know that in this particular case you could use children() to extract the third branch of the piecewise() and proceed from there, skipping around the problem: but what if you wanted MATLAB to be able to reason about the fact that a variable is a non-integer ?
0 个评论
采纳的回答
Paul
2021-7-12
Accoding to the doc page for assume(), maybe
assume(~in(x,'integer'))
will do what you want? I couldn't test it because my version (2019a) only returns
psi(1 - x) - psi(m - x + 1)
as the ouput of that symsum, without any conditions.
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!