Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Substitute piecewise function variable

I have the following piecewise function:

phi   = piecewise([([-1,1], (1-abs(x))*(1-abs(x))*(1+2*abs(x)))]);
phi   = phi.extension(0);

It appears to be a valid function since I can obtain/plot its values for any 'x'. But whenever I try to substitute the variable, it does not work. For example,

phi(2)
0

but if I declare another variable 'h' and try to input that variable into the piecewise function, it does not appear to work:

h=pi/2
phi(h)
TypeError: self must be a numeric expression

At first I thought that 'h' was not a 'numeric' or 'real' value, but when I test it, it is a real value:

h.is_real()
True

How can I overcome this? How can I successfully operate a variable substitution in my piecewise function?