Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2004
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2004

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

Search the Archive

Derivatives of user-defined control-flow functions

  • To: mathgroup at smc.vnet.net
  • Subject: [mg51057] Derivatives of user-defined control-flow functions
  • From: "Maxim A. Dubinnyi" <maxim at nmr.ru>
  • Date: Sun, 3 Oct 2004 05:47:24 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

Can anyone correctly define derivatives of
user-defined control-flow functions?

The derivative of build-in control function 'If' is evaluated as:

In[]=  D[If[f[x], g[x], h[x]], x]
Out[]= If[f[x],g'[x],h'[x]]

Which is perfectly correct answer. I wish to introduce my own
control flow function MyIf and define it's derivatives with
properties identical to ones in build-in If function.
Usually derivatives are defined via properties of
symbol 'Derivative' by setting

Derivative[order...][function_name]:= (derivative definition)

but this method fails in case of control-flow expressions.
The problem origin is in the rule for derivatives of
composite functions:

In[]=  D[f[g[x]], x]
Out[]= f'[g[x]]g'[x]

This rule should not be applied if 'f' is control-flow function such
as 'If', 'Which', etc, and it is really so for build-in control-flow
expressions. But how can I suppress this deepely build-in rule for
some user-defined symbols?

I am experienced user of Mathematica, and I use widely symbolic
and functional programming in my applications,
but can't find any solution of this problem.

Is it the task which can't be solved by means of Mathematica
symbolic programming language?


Maxim A. Dubinnyi


  • Prev by Date: Re: Write long table into file problem
  • Next by Date: Re: Thichness of Plot does not change Solved
  • Previous by thread: Re: How to explain functions' linearity to Mathematica 5 ?
  • Next by thread: Re: Derivatives of user-defined control-flow functions