Re: Define a function and its derivatives
- To: mathgroup at smc.vnet.net
- Subject: [mg43367] Re: Define a function and its derivatives
- From: Jens-Peer Kuska <kuska at informatik.uni-leipzig.de>
- Date: Tue, 26 Aug 2003 07:13:47 -0400 (EDT)
- Organization: Universitaet Leipzig
- References: <bi7mvh$p1h$1@smc.vnet.net>
- Reply-to: kuska at informatik.uni-leipzig.de
- Sender: owner-wri-mathgroup at wolfram.com
Hi,
in general you can't, because Mathematica evaluates
inner expressions first. In
D[expression,z]
the expression is evaluated first and when expression get a value
different from R[z] it will be used later and your definition
for Derivative[_]{R][_] is never found or searched.
You must hinder Mathematica
to evaluate R[z] for a symbolic argument and
Derivative[m_][R][z_] := D[E^(-z^4), {z, m - 1}]
R[z_?NumericQ] := (2 UnitStep[z] - 1) (Gamma[1 + 1/n] -
Gamma[1/n, Abs[z]^n]/n);
may work, if it fit to your computation.
Regards
Jens
Martin Manscher wrote:
>
> I wish to define a function and its derivatives. The function expression is
> complicated, but the derivatives are fairly simple (full cut-and-paste
> notebook expression below). The problem is that the definition of the
> function itself seems to shadow the definition of the derivatives. How can I
> make Mathematica prefer my definition of the derivative over the one derived
> from the definition of the funtion?
>
> In[1]:= n=4;
> In[2]:= Derivative[m_][R][z_] := D[E^(-z^4), {z, m - 1}]
> In[3]:= {R'[z],R''[z],R'''[z]}
> Out[3]= {E^(-z^4), -4 E^(-z^4) z^3, -12 E^(-z^4) z^2 + 16 E^(-z^4) z^6}
> In[4]:= R[z_] = (2 UnitStep[z] - 1) (Gamma[1 + 1/n] - Gamma[1/n,
> Abs[z]^n]/n);
> In[5]:= {R'[z],R''[z],R'''[z]}
> Out[3]= <long expressions involving UnitsStep, DiracDelta etc.>
>
> Sincerely,
>
> Martin Manscher