# how to do symbolic type negation ?

조회 수: 8(최근 30일)
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 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.
##### 댓글 수: 1표시숨기기 없음
Walter Roberson 2021년 7월 12일
Oh, well done!

댓글을 달려면 로그인하십시오.

R2021a

### Community Treasure Hunt

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

Start Hunting!

Translated by