ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Mon, 15 Apr 2013 18:44:38 +0200Convolving two functions doesn't work as expectedhttps://ask.sagemath.org/question/10019/convolving-two-functions-doesnt-work-as-expected/Hi all, I'm trying to convolve two functions as follows:
`forget()` <br>
`x = PolynomialRing(QQ, 'x').gen()` <br>
`f1 = Piecewise([[(-1, 1), 1*x^0]])` <br>
`f2 = Piecewise([[(0, 1), x], [(1, 2), -x + 2]])` <br>
`g = f2.convolution(f1)` <br>
`Q = g.plot(rgbcolor=(1,1,0), figsize = 4);` <br>
`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?
Sat, 13 Apr 2013 18:31:30 +0200https://ask.sagemath.org/question/10019/convolving-two-functions-doesnt-work-as-expected/Comment by rickhg12hs for <p>Hi all, I'm trying to convolve two functions as follows:</p>
<p><code>forget()</code> <br/>
<code>x = PolynomialRing(QQ, 'x').gen()</code> <br/>
<code>f1 = Piecewise([[(-1, 1), 1*x^0]])</code> <br/>
<code>f2 = Piecewise([[(0, 1), x], [(1, 2), -x + 2]])</code> <br/>
<code>g = f2.convolution(f1)</code> <br/>
<code>Q = g.plot(rgbcolor=(1,1,0), figsize = 4);</code> <br/>
<code>g</code></p>
<p>I get that g is given by:</p>
<blockquote>
<p>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]].</p>
</blockquote>
<p>Whereas, if computed manually, g is given by:</p>
<blockquote>
<p>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]</p>
</blockquote>
<p>Why doesn't the one computed by sage match the correct function?</p>
https://ask.sagemath.org/question/10019/convolving-two-functions-doesnt-work-as-expected/?comment=17888#post-id-17888Are the examples given in the documentation even right? E.g., see last example of "f1.convolution?". How/why are 5 parts given as the convolution when one function is 1 part and the other 2 parts?Mon, 15 Apr 2013 18:44:38 +0200https://ask.sagemath.org/question/10019/convolving-two-functions-doesnt-work-as-expected/?comment=17888#post-id-17888