Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2008

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Defining derivatives

  • To: mathgroup at smc.vnet.net
  • Subject: [mg87879] Re: Defining derivatives
  • From: Szabolcs Horvát <szhorvat at gmail.com>
  • Date: Sat, 19 Apr 2008 03:34:40 -0400 (EDT)
  • Organization: University of Bergen
  • References: <fu9vnl$igu$1@smc.vnet.net>

dh wrote:
> Hello All,
> 
> does anybody know how to define symbolic derivatives. E.g.:
> 
> f[x_]:=f1[x];
> 
> f'[x_]:=f2[x];
> 
> this does not work because f on the lefthand side is evaluated. To 
> 
> prevent this (do not forget to remove f before redefining it):
> 
> f[x_]:=f1[x];
> 
> HoldPattern[f'[x_]]:=f2[x];
> 
> this gives no message, but f'[x] returns f1[x] instead of f2[x].
> 
> The same thinhg happens when you change the sequence of definitions:
> 
> f'[x_]:=f2[x];
> 
> f[x_]:=f1[x];


Hi Daniel,

It seems that Mathematica is not prepared to accept that the derivative 
of f[x] is f2[x] unless you also tell it that f1'[x] is f2[x].

A workaround is to use

f' = f2

instead of

f'[x_] := f2[x]

This appears to work in simple cases.

> 
> Further, where is the information about derivatives stored?
> 

It is stored as a SubValue of Derivative.

Try

f'[x_] := g[2 x]
SubValues[f]

or just remove the ReadProtected attrbute of Derivative and use

?? Derivative

(There are quite a few *Values functions, e.g. NValues.  Just try 
Names["*Values"].  Unfortunately these functions are not very well 
documented.)

I hope this helps,
Szabolcs


  • Prev by Date: Re: Scaling Plot inside Row
  • Next by Date: Re: Re: Abs[x] function
  • Previous by thread: Re: Defining derivatives
  • Next by thread: Re: Defining derivatives