0
$\begingroup$

If I define P[x]=D[#,x]& (derivative operator) How can I define another operator $Q$ such that $Q(f(x))=Pf(x)+a$ (for example)? Thanks.

$\endgroup$
1
  • 1
    $\begingroup$ P = D[#, x] &; Q = a + P[#] & $\endgroup$
    – march
    Commented Apr 17 at 23:15

1 Answer 1

-1
$\begingroup$

A direct nesting of function seems not to be part of Mathematica, because of the central aim to shield functions from evaluations.

So one has to introduce lots of local variables, evaluating and refunctionalize.

To avoid the overhead of symbols, copy math use of 'x' (not Mathematicas x=#, still to be used in the inner machine)

FChain[f_List] := Block[{x},
     Function @@ {{x}, Fold[( #2[#1] &), x , Reverse@f]}]

 d=FChain[{(1/Sqrt[2 \[Pi] t] #&) ,Exp,( (-#^2)/(2 t)&)}]

$$\{x\}\mapsto \frac{e^{-\frac{x^2}{2 t}}}{\sqrt{2 \pi } \sqrt{t}}$$

For practical purposes, one may include an option with simplifying or representing goals, eg. Simpify, Expand etc, to be applied before the expression is converted into a sealed function body again.

$\endgroup$
5
  • $\begingroup$ What is direct nesting of function? $\endgroup$
    – yarchik
    Commented Apr 19 at 13:35
  • $\begingroup$ The standard notation $$ f \circ g = f @ g$$ $\endgroup$
    – Roland F
    Commented Apr 19 at 17:07
  • $\begingroup$ Why not? See reference.wolfram.com/language/ref/Composition.html $\endgroup$
    – yarchik
    Commented Apr 19 at 19:47
  • $\begingroup$ The Mathematica chain '@' symbol in a@b is the prefix form of a[b], but is executed only as the transport of values through fixed function bodies as expressions, a very slow numerical construct in contrast to the speed available by a construction of the optimized combination of two function bodies. Any function call implies argument streamlining, standard simplification, domain checking and known result searches. Workin by chains of functions inside a pure function goes blind. $\endgroup$
    – Roland F
    Commented Apr 19 at 20:11
  • $\begingroup$ @yarchik Composition does not construct the composed function. It's merely a container of @a@.., that evaluates only with an argument supplied. Of course the argument can be #, and then a function can be defined by e.g. Function@@{Compose[a,b][#]} $\endgroup$
    – Roland F
    Commented Apr 20 at 10:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.