how to do symbolic type negation ?

조회 수: 2 (최근 30일)
Walter Roberson
Walter Roberson 2021년 7월 12일
댓글: Walter Roberson 2021년 7월 12일
How can one do symbolic type negation ? (Advanced methods permitted!!)
For example
syms x n m
y = symsum(1/(x-n),n,1,m)
y = 
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')
S1 = 
S2 = evalin(symengine, '~(x in integer)')
S2 = 
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 ?

채택된 답변

Paul
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개)

태그

제품


릴리스

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by