Re: Re: Way to evaluate D[(1-x^2)y''[x],{x,n
- To: mathgroup at smc.vnet.net
- Subject: [mg14996] Re: [mg14961] Re: [mg14914] Way to evaluate D[(1-x^2)y''[x],{x,n
- From: Jurgen Tischer <jtischer at col2.telecom.com.co>
- Date: Wed, 2 Dec 1998 03:59:15 -0500
- Organization: Universidad del Valle
- References: <9097585452@wiskunde_1.win.tue.nl>
- Sender: owner-wri-mathgroup at wolfram.com
Fred,
I apologize for my stupid question. Your solution is nice. The thing is
I used your formula with n changed for k, and it didn't work:
In[1]:= D[(1 - x^2) y''[x], {x, k}][[2]]
Out[1]= -2 y''[x] - 2x y''[x] + (1 - x^2) y''[x]
I should have realized that this was just a minor bug. What do you think
about the following version:
D[p_ f_, {x_Symbol, n_Symbol}] /; PolynomialQ[p, x] :=
Module[{k}, Sum[Binomial[n, k] D[p, {x, k}]
D[f, {x, n - k}], {k, 0, Exponent[p, x]}]]
It avoids the error above, avoids strange answers like
In[2]:= D[(1 - x^2)y''[x], {x, -1}]
$IterationLimit::"itlim":"Iteration limit of \!\(4096\) exceeded."
Out[2]= Hold[D[(1 - x^2)*Derivative[2][y][x], {x, -1}]]
doesn't try to solve a problem Mathematica solves by it's own, and even
allows things like
In[3]:= D[(1 - x^2) y''[x] z[x], {x, k}]
Out[3]= -((-1 + k) k D[z[x] y''[x], {x, -2 + k}]) -
2 k x D[z[x] y''[x], {x, -1 + k}] +
(1 - x^2) D[z[x] y''[x], {x, k}]
The formula for n < Exponent[p] doesn't bother me too much, the way
Mathematica works (and many mathematicians think), Binomial takes care
of that.
Jurgen
Fred Simons wrote:
>
> Jurgen,
>
> I do not completely understand your question, so if this reply is not
> an answer to your question, please ask again.
>
> I think Phillips question was to find the three terms formula for the
> n-th derivative of (1-x^2)y''[x] automatically, and Mathematica can
> not do that. So I extended the Mathematica D-function in such a way
> that the desired result wil be produced. First Unprotect[D], enter
> the line and Protect[D] again.
>
> Now this formula hold only for integer values of n at least equal to
> the degree of the polynomial. So I used an If-statement with this
> condition, to make sure that the extension of D does not have an
> undesired impact on other computations.
>
> The formula Phillips was looking for is now obtained in the following
> way:
>
> D[ (1-x^2) y''[x] , {x, n} ] [[2]]
>
> One of my colleagues remarked that the implementation is not
> complete; in the situation with y''[x] replaced with y[x] it does not
> work. So the following line is better:
>
> D[p_ f_[x_], {x_Symbol, n_} ] /;PolynomialQ[p, x]:=
> If[ Floor[n]==n&& n>=Exponent[p,x],
> Sum[ Binomial[n,k]D[p, {x,k}] Derivative[n-k][f][x], {k, 0,
> Exponent[p, x]}] // Evaluate, D[p f[x], {x,
> n} ] ]
>
> Please ask again if I did not reply your question satisfactory.
>
> Fred Simons
> Eindhoven University of Technology