how to do symbolic type negation ?

2 Ansichten (letzte 30 Tage)
Walter Roberson
Walter Roberson am 12 Jul. 2021
Kommentiert: Walter Roberson am 12 Jul. 2021
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 ?

Akzeptierte Antwort

Paul
Paul am 12 Jul. 2021
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.

Weitere Antworten (0)

Produkte


Version

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by