MathGroup Archive 1998

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

Search the Archive

Re: Simple question



hi Anderson,

since you do not define the function and it's argument, I suppose you
want (wisely) to operate on a functional level : in that case, here is
something to play with:

diff[f_,n_:1]:=Function[dum,Evaluate@D[f[dum],{dum,n}] ] intover[f_]:=
Function[d,Evaluate@Integrate[f[d],d]]  intover[f_,n_:1]:=
Nest[intover,f,n] 

here is a demonstration on a "pure" or "anonymous" function
(E^-#-E^#)^10& (where you could call "#" a dummy-variable: In[10]:=
diff[(E^-#-E^#)^10&,3 ]
Out[10]=Function[dum$, 720*(-E^(-dum$) - E^dum$)^3*
    (E^(-dum$) - E^dum$)^7 + 
   280*(-E^(-dum$) - E^dum$)*(E^(-dum$) - E^dum$)^9]

as you can see, it returns a pure function too, still without argument.
You can give it an argument :
In[11]:= diff[(E^-#-E^#)^10&,3 ] [z]

Out[11]=720*(-E^(-z) - E^z)^3*(E^(-z) - E^z)^7 + 
  280*(-E^(-z) - E^z)*(E^(-z) - E^z)^9

Needless to say, once you "grok" the technique, anything goes :

In[12]:=Nest[intover ,1+#^2&,2]
Out[12]=Function[d$, d$^2/2 + d$^4/12]

In[15]:=Nest[intover ,1+#^2&,2][x]
Out[15]=x^2/2 + x^4/12

In[16]:=intover[(1+#)^2 &,4][z]
Out[16]=z^4/24 + z^5/60 + z^6/360

In[17]:=Function[z,Evaluate@%]
Out[17]=Function[z, z^4/24 + z^5/60 + z^6/360]

In[18]:=diff[%,4][x]
Out[18]=1 + 2*x + x^2

enjoy,

wouter.

At 23:11 2-03-98 -0500, Anderson Brasil da Silva wrote:
>Hi!
>
>  I am a new user of Mathematica and I am having troubles trying to
>create a function FUNC[f,n,p] that returns the value of the n-th
>derivative of f in the point p. My main problem is that I have no idea
>about how to create a function that takes other functions as
>parameters. Besides this problem, when I use Dt[f,{x,n}] I can get the
>derivative, but I can't get the value of this in any specific point (if
>I try something like (Dt[f,{x,n}])[0] it doesn't work).
>   Can somebody help me, please?
>
>   Thanks in advance,
>
>   Anderson Brasil
>   anderbrasil@ax.ibase.org.br
>
>
>------------------------------------------------------------------------
>"The whole problem with the world is that fools and fanatics are always
>so certain of themselves, but wiser people so full of doubts."
>(Bertrand Russell)
>------------------------------------------------------------------------
>
>
>  
>
>
Dr. Wouter L. J. MEEUSSEN
w.meeussen.vdmcc@vandemoortele.be
eu000949@pophost.eunet.be




  • Prev by Date: Re: Mathematica bug when resolving Contex-names
  • Next by Date: Extract a contour from a 3-D plot.
  • Prev by thread: Re: Simple question
  • Next by thread: Re: Simple question