Sage: Ticket #21639: Implement derivative of gegenbauer(n,a,x) wrt to a
https://trac.sagemath.org/ticket/21639
<p>
Implement
</p>
<pre class="wiki">In [3]: gegenbauer(n,m,x)
Out[3]: gegenbauer(n, m, x)
In [4]: _.diff(m)
Out[4]:
n - 1
____
╲
╲ ⎛⎛ -k + n ⎞
╲ ⎜⎝2⋅(-1) + 2⎠⋅(k + m)⋅gegenbauer(k, m, x) ⎛ 2⋅k + 2
╱ ⎜────────────────────────────────────────────── + ⎜──────────────────────
╱ ⎝ (-k + n)⋅(k + 2⋅m + n) ⎝(k + 2⋅m)⋅(2⋅k + 2⋅m +
╱
‾‾‾‾
k = 0
⎞
2 ⎞ ⎟
─── + ───────────⎟⋅gegenbauer(n, m, x) ⎟
1) k + 2⋅m + n ⎠ ⎠
</pre><p>
Previous description was (now implemented):
</p>
<p>
I noticed that the derivative of the gegenbauer polynomial wrt x was not implemented, so I wrote a patch for it.
</p>
<p>
I used the formula C'(n,a,x) = 2*a*C(n-1,a+1,x)
</p>
<p>
With the patch applied I get, for example:
</p>
<pre class="wiki">sage: var('a');
sage: derivative(gegenbauer(2,a,x),x)
4*(a + 1)*a*x
</pre>en-usSagehttps://trac.sagemath.org/chrome/site/logo_sagemath_trac.png
https://trac.sagemath.org/ticket/21639
Trac 1.1.6mafraTue, 04 Oct 2016 17:05:11 GMTattachment set
https://trac.sagemath.org/ticket/21639
https://trac.sagemath.org/ticket/21639
<ul>
<li><strong>attachment</strong>
set to <em>0001-Implement-derivative-of-gegenbauer-n-a-x-w.r.t-x.patch</em>
</li>
</ul>
<p>
Patch implementing the derivative of gegenbauer(n,a,x) wrt x
</p>
TicketmafraTue, 04 Oct 2016 17:06:51 GMTdescription changed
https://trac.sagemath.org/ticket/21639#comment:1
https://trac.sagemath.org/ticket/21639#comment:1
<ul>
<li><strong>description</strong>
modified (<a href="/ticket/21639?action=diff&version=1">diff</a>)
</li>
</ul>
TicketkcrismanTue, 04 Oct 2016 17:07:35 GMTcc set
https://trac.sagemath.org/ticket/21639#comment:2
https://trac.sagemath.org/ticket/21639#comment:2
<ul>
<li><strong>cc</strong>
<em>rws</em> added
</li>
</ul>
TicketmafraTue, 04 Oct 2016 17:09:08 GMTauthor set
https://trac.sagemath.org/ticket/21639#comment:3
https://trac.sagemath.org/ticket/21639#comment:3
<ul>
<li><strong>author</strong>
set to <em>Carlos R. Mafra</em>
</li>
</ul>
TicketrwsWed, 05 Oct 2016 06:37:10 GMT
https://trac.sagemath.org/ticket/21639#comment:4
https://trac.sagemath.org/ticket/21639#comment:4
<p>
Thanks. I would like to extend this ticket with derivatives on the second index:
</p>
<pre class="wiki">In [3]: gegenbauer(n,m,x)
Out[3]: gegenbauer(n, m, x)
In [4]: _.diff(m)
Out[4]:
n - 1
____
╲
╲ ⎛⎛ -k + n ⎞
╲ ⎜⎝2⋅(-1) + 2⎠⋅(k + m)⋅gegenbauer(k, m, x) ⎛ 2⋅k + 2
╱ ⎜────────────────────────────────────────────── + ⎜──────────────────────
╱ ⎝ (-k + n)⋅(k + 2⋅m + n) ⎝(k + 2⋅m)⋅(2⋅k + 2⋅m +
╱
‾‾‾‾
k = 0
⎞
2 ⎞ ⎟
─── + ───────────⎟⋅gegenbauer(n, m, x) ⎟
1) k + 2⋅m + n ⎠ ⎠
</pre><p>
I'll both implement in Pynac directly. See also <a class="closed ticket" href="https://trac.sagemath.org/ticket/21644" title="defect: Bug in derivatives of some functions to the index var (closed: fixed)">#21644</a>.
</p>
TicketrwsWed, 05 Oct 2016 07:31:06 GMT
https://trac.sagemath.org/ticket/21639#comment:5
https://trac.sagemath.org/ticket/21639#comment:5
<p>
The second case would depend on <a class="closed ticket" href="https://trac.sagemath.org/ticket/21645" title="defect: Full symbolic sum function (closed: fixed)">#21645</a>.
</p>
TicketrwsWed, 05 Oct 2016 07:47:35 GMT
https://trac.sagemath.org/ticket/21639#comment:6
https://trac.sagemath.org/ticket/21639#comment:6
<p>
The first case is <a class="ext-link" href="https://github.com/pynac/pynac/commit/6587fdc83ef1b002b583339bca70bcf94e50535c"><span class="icon"></span>https://github.com/pynac/pynac/commit/6587fdc83ef1b002b583339bca70bcf94e50535c</a>
</p>
<p>
Doctests will be in the Pynac upgrade ticket, can be already seen at <a class="ext-link" href="https://github.com/pynac/sage/commit/85726b14a96eb91c8fd70c1e76e729230e606a15"><span class="icon"></span>https://github.com/pynac/sage/commit/85726b14a96eb91c8fd70c1e76e729230e606a15</a>
</p>
TicketmafraWed, 05 Oct 2016 16:32:08 GMT
https://trac.sagemath.org/ticket/21639#comment:7
https://trac.sagemath.org/ticket/21639#comment:7
<p>
Thanks for adding the derivative wrt m, I wasn't aware of this identity (where did you get it?).
</p>
<p>
Btw, what is the guiding principle to decide if things should go into pynac or pure sage?
</p>
<p>
I was under the impression that 'performance' was the primary factor to move things to pynac. Is this the case here?
</p>
TicketrwsThu, 06 Oct 2016 06:12:17 GMT
https://trac.sagemath.org/ticket/21639#comment:8
https://trac.sagemath.org/ticket/21639#comment:8
<p>
Replying to <a class="ticket" href="https://trac.sagemath.org/ticket/21639#comment:7" title="Comment 7">mafra</a>:
</p>
<blockquote class="citation">
<p>
Thanks for adding the derivative wrt m, I wasn't aware of this identity (where did you get it?).
</p>
</blockquote>
<p>
This is from SymPy.
</p>
<blockquote class="citation">
<p>
Btw, what is the guiding principle to decide if things should go into pynac or pure sage?
</p>
<p>
I was under the impression that 'performance' was the primary factor to move things to pynac. Is this the case here?
</p>
</blockquote>
<p>
You are right, in many cases this is the reason. One other reason can be that when all the function code is already in Pynac then for clarity add the new functionality there.
</p>
TicketmafraThu, 06 Oct 2016 08:09:36 GMT
https://trac.sagemath.org/ticket/21639#comment:9
https://trac.sagemath.org/ticket/21639#comment:9
<p>
Replying to <a class="ticket" href="https://trac.sagemath.org/ticket/21639#comment:8" title="Comment 8">rws</a>:
</p>
<blockquote class="citation">
<p>
Replying to <a class="ticket" href="https://trac.sagemath.org/ticket/21639#comment:7" title="Comment 7">mafra</a>:
</p>
<blockquote class="citation">
<p>
Btw, what is the guiding principle to decide if things should go into pynac or pure sage?
</p>
<p>
I was under the impression that 'performance' was the primary factor to move things to pynac. Is this the case here?
</p>
</blockquote>
<p>
You are right, in many cases this is the reason. One other reason can be that when all the function code is already in Pynac then for clarity add the new functionality there.
</p>
</blockquote>
<p>
IMHO, Pynac should be reserved for performance reasons only.
</p>
<p>
Adding the derivative functions to Pynac only complicates the situation here as we lose a unified handling of the derivatives within the Python file, like in this case with 'hermite' needing a fix in Pynac and gen_laguerre in Sage. I don't think this adds to 'clarity'.
</p>
<p>
So I disagree with moving the derivative of gegenbauer to Pynac, as it is not performance motivated and could be easily done in Sage.
</p>
TicketrwsThu, 06 Oct 2016 09:11:58 GMT
https://trac.sagemath.org/ticket/21639#comment:10
https://trac.sagemath.org/ticket/21639#comment:10
<p>
You would not believe how much slower any Python (and Cython) code is versus C/C++. That's for example why SymPy has extraordinary performance problems for even simple computations, and why they urgently push the SymEngine project. I therefore feel justified to replace *any Python/Cython code with C++, and contrarily to SymPy we are in the fortunate position that Pynac is already integrated in Sage. While the time when to do this transcription may certainly be a matter of debate, the necessity itself is not.
</p>
TicketmafraThu, 06 Oct 2016 09:41:28 GMT
https://trac.sagemath.org/ticket/21639#comment:11
https://trac.sagemath.org/ticket/21639#comment:11
<p>
Replying to <a class="ticket" href="https://trac.sagemath.org/ticket/21639#comment:10" title="Comment 10">rws</a>:
</p>
<blockquote class="citation">
<p>
You would not believe how much slower any Python (and Cython) code is versus C/C++. That's for example why SymPy has extraordinary performance problems for even simple computations, and why they urgently push the SymEngine project. I therefore feel justified to replace *any Python/Cython code with C++, and contrarily to SymPy we are in the fortunate position that Pynac is already integrated in Sage. While the time when to do this transcription may certainly be a matter of debate, the necessity itself is not.
</p>
</blockquote>
<p>
Fair enough, thanks!
</p>
TicketrwsSat, 29 Oct 2016 08:33:36 GMTdescription, summary changed; dependencies set
https://trac.sagemath.org/ticket/21639#comment:12
https://trac.sagemath.org/ticket/21639#comment:12
<ul>
<li><strong>dependencies</strong>
set to <em>#21645</em>
</li>
<li><strong>description</strong>
modified (<a href="/ticket/21639?action=diff&version=12">diff</a>)
</li>
<li><strong>summary</strong>
changed from <em>[PATCH] Implement derivative of gegenbauer(n,a,x) wrt to x</em> to <em>Implement derivative of gegenbauer(n,a,x) wrt to a</em>
</li>
</ul>
Ticket