|
[Date Index]
[Thread Index]
[Author Index]
Re: Two related question. Question 1
- To: mathgroup at smc.vnet.net
- Subject: [mg57541] Re: Two related question. Question 1
- From: dh <dh at metrohm.ch>
- Date: Wed, 1 Jun 2005 06:01:27 -0400 (EDT)
- References: <d7dp2r$qam$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Hi Kazimir,
a function is not the same as a variable. A function has input slots
that you must take care of. There is a samll pitfall here, "Function"
has the attribute HoldAll, therefore you must use Evaluate to do some
calculation inside a function definition. Therefore, if
f = #1^2 + #2 &
the the square is obtained by:
c= Evaluate[f[#1,#2]^2]&
this gives:(#1^2 + #2^2)^2 &
Sincerely, Daniel
Kazimir 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
>
Prev by Date:
Re: reducing the time of constructing a List
Next by Date:
Re: opposite of partition
Previous by thread:
Re: Related quastions. Question 2
Next by thread:
Re: Two related question. Question 1
|