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: [mg57513] Re: [mg57498] Two related question. Question 1
  • From: Andrzej Kozlowski <andrzej at akikoz.net>
  • Date: Tue, 31 May 2005 04:59:04 -0400 (EDT)
  • References: <200505300100.VAA26808@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

On 30 May 2005, at 10:00, Kazimir wrote:

> *This message was transferred with a trial version of CommuniGate 
> (tm) Pro*
> 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
>
>
Just evaluate:

Unprotect[Times, Plus, Power];
(a_?NumericQ*f_.)[x__] := a f[x];
(f_ + g_)[x__] := f[x] + g[x];
(f_*g_)[x__] := f[x]*g[x];
(f_^n_?NumericQ)[x__] := f[x]^n
Protect[Times, Plus, Power];

and then proceed as in your message. Everything will work the way you  
expect.

Andrzej Kozlowski


  • Prev by Date: Re: a dangerous feature of Module[]?
  • Next by Date: Re: Complex Oddity
  • Previous by thread: Two related question. Question 1
  • Next by thread: Re: Two related question. Question 1