Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Convolving two functions doesn't work as expected

Hi all, I'm trying to convolve two functions as follows:

forget()
x = PolynomialRing(QQ, 'x').gen()
f1 = Piecewise([[(-1 ,1), 1*x^0]])
f2 = Piecewise([[(0, 1), x], [(1, 2), -x + 2]])
g = f2.convolution(f1)
Q = g.plot(rgbcolor=(1,1,0), figsize = 4);
g

I get that g is given by:

Piecewise defined function with 4 parts, [[(-1, 0), 1/2*x^2 + x +1/2], [(0, 1), -1/2*x^2 + 3*x], [(1, 2), -1/2*x^2 - x + 4], [(2, 3), 1/2*x^2 - 3*x + 9/2]].

Whereas, if computed manually, g is given by:

Piecewise defined function with 3 parts, [[(-1, 0), 0.5*x^2 + x + 0.5], [(0, 2), -0.5*x^2 + x + 0.5], [(2, 3), 0.5*x^2 - 3*x + 4.5]

Convolving two functions doesn't work as expected

Hi all, I'm trying to convolve two functions as follows:

forget()
x = PolynomialRing(QQ, 'x').gen()
f1 = Piecewise([[(-1 ,1), 1*x^0]])
f2 = Piecewise([[(0, 1), x], [(1, 2), -x + 2]])
g = f2.convolution(f1)
Q = g.plot(rgbcolor=(1,1,0), figsize = 4);
g

I get that g is given by:

Piecewise defined function with 4 parts, [[(-1, 0), 1/2*x^2 + x +1/2], [(0, 1), -1/2*x^2 + 3*x], [(1, 2), -1/2*x^2 - x + 4], [(2, 3), 1/2*x^2 - 3*x + 9/2]].

Whereas, if computed manually, g is given by:

Piecewise defined function with 3 parts, [[(-1, 0), 0.5*x^2 + x + 0.5], [(0, 2), -0.5*x^2 + x + 0.5], [(2, 3), 0.5*x^2 - 3*x + 4.5]

Why doesn't the one computed by sage match the correct function?

Convolving two functions doesn't work as expected

Hi all, I'm trying to convolve two functions as follows:

forget()
x = PolynomialRing(QQ, 'x').gen()
f1 = Piecewise([[(-1 ,1), Piecewise([[(-1, 1), 1*x^0]])
f2 = Piecewise([[(0, 1), x], [(1, 2), -x + 2]])
g = f2.convolution(f1)
Q = g.plot(rgbcolor=(1,1,0), figsize = 4);
g

I get that g is given by:

Piecewise defined function with 4 parts, [[(-1, 0), 1/2*x^2 + x +1/2], [(0, 1), -1/2*x^2 + 3*x], [(1, 2), -1/2*x^2 - x + 4], [(2, 3), 1/2*x^2 - 3*x + 9/2]].

Whereas, if computed manually, g is given by:

Piecewise defined function with 3 parts, [[(-1, 0), 0.5*x^2 + x + 0.5], [(0, 2), -0.5*x^2 + x + 0.5], [(2, 3), 0.5*x^2 - 3*x + 4.5]

Why doesn't the one computed by sage match the correct function?