MathGroup Archive 2005

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

Search the Archive

Re: Two related question. Question 1

  • To: mathgroup at smc.vnet.net
  • Subject: [mg57606] Re: Two related question. Question 1
  • From: Maxim <ab_def at prontomail.com>
  • Date: Wed, 1 Jun 2005 06:05:10 -0400 (EDT)
  • References: <d7dp2r$qam$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

On Mon, 30 May 2005 01:08:43 +0000 (UTC), Kazimir <kazimir04 at yahoo.co.uk>  
wrote:

> I have two related question. Let me introduce a pure function
>
> f = #1^2 + #2 &
>
> Now. I want to make an operation over the function, for example to
> find its square and to call the result (the expected function f = (#1^2
> + #2)^2 & ) c:
>
> c=f^2
>
> However, I do not obtain this, as
>
> c[a,b]
>
> does not evaluate to (a+b)^2. Can anybody advise me how to obtain
> such a function without long substitutions. I would like to obtain
> something which is made for derivatives :
>
> In[11]:=
> Derivative[1][f]
>
> Out[11]=
> 2 #1&
>
> In[12]:=
> Derivative[2][f]
>
> Out[12]=
> 2&
>
> Regards
>
> Vlad
>

In principle it should have been possible to do it in a Lisp-like style:

In[1]:= square2 = Function[f, Function[{x, y}, f[x, y]^2]]

square2 works as an operator, taking a binary function f and returning  
another binary function. However, this will work only for functions with  
named parameters (or functions defined as f[x_, y_] = ...); if we use Slot  
arguments, then the result is correct for Derivative[2, 0] and  
Derivative[0, 2], but not for mixed partial derivatives:

In[2]:= Derivative[1, 1][square2[Function[{x, y}, x^2 + y]]][a, b]

Out[2]= 4*a

In[3]:= Derivative[1, 1][square2[#^2 + #2&]][a, b]

Out[3]= 4*a + 2*(a^2 + b)*((0 & )*Derivative[1][Derivative[1, 0]][#1^2  
+ #2 & ])[a, b]

Also for some reason Derivative can handle SlotSequence only inside  
Composition:

In[4]:= Derivative[1, 0][Composition[#&, g[##]&]]

Out[4]= Derivative[1, 0][g][#1, #2] &

In[5]:= Derivative[1, 0][g[##]&]

Out[5]= 0 &

Maxim Rytin
m.r at inbox.ru


  • Prev by Date: Re: What is causing this error message?
  • Next by Date: Re: Re: Complex Oddity
  • Previous by thread: Re: Two related question. Question 1
  • Next by thread: Re: Two related question. Question 1