“Unable to prove `expr` literally…” error when trying to compare a symbol inside a function

那年仲夏 提交于 2019-12-11 13:09:28

问题


I just started learning MATLAB and I'm trying to normalize a bump function given by

function b = bump(x)
region1 = abs(x) < 1
b(region1) = (exp(-1./(1 - x(region1).^2)))
region2 = abs(x) >= 1
b(region2) = 0
end

To do this, I need to divide by the definite integral from -1 to 1. However, when I input

syms x;
int(bump(x), -1, 1)

I get a long error message, which says

Error using symengine (line 58)
Unable to prove 'abs(x) < 1' literally. To test the statement mathematically, use isAlways.

Error in sym/subsindex (line 1554)
X = find(mupadmex('symobj::logical',A.s,9)) - 1;

Error in sym>privformat (line 2357)
x = subsindex(x)+1;

Error in sym/subsref (line 1578)
[inds{k},refs{k}] = privformat(inds{k});

Error in bump (line 3)
b(region1) = (exp(-1./(1 - x(region1).^2)))

I tried replacing abs(x)<1 with what I think is the suggested isAlways(abs(x)<1), and that removes the error, although it gives the wrong answer (it says the integral is zero).

I don't understand what does the error message means.


回答1:


syms x defines x as a symbolic variable, invoking symbolic computation on x. This probably isn't what you want.

Instead, define x as some kind of input matrix, e.g. x = zeros(3);. Or, to do numeric integration, use the integral function:

integral(@bump, -1, 1)


来源:https://stackoverflow.com/questions/18966576/unable-to-prove-expr-literally-error-when-trying-to-compare-a-symbol-insi

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!