Message Boards Message Boards

0
|
8895 Views
|
7 Replies
|
1 Total Likes
View groups...
Share
Share this post:

How to define a homogeneous function?

Posted 12 years ago
Does anybody have any idea on how to define a linearly homogeneous function?

The only solution I have come up with involves using rules and 'ReplaceAll'. This solution is not adequate, as it requires a lot of fine tuning.

An example:

Evaluating the following code, for a suitably defined function f (linearly homogeneous) should return 'True'
f[tau x,tau y]==tau f[x,y]

Alternatively, evaluating
In[1]:= f[mu x1,mu x2]

should return
Out[1]:= mu f[x1,x2]


Optionaly, it would really be an added bonus if somehow the definitions would persist, in the following sense:

The derivative of a linearly homogeneous function should be a homogeneous function of degree 0, i.e.

evaluating
In[2]:= Derivative[1,0][f][k x,k y]

should return
Out[2]:= Derivative[1,0][f][x,y]


I would be really gratefull if someone could offer a hint towards the right direction
POSTED BY: jarque
7 Replies
 IN:
 ClearAll[f]
 f[\[Tau]_ x_, \[Tau]_ y_]:=\[Tau] f[x,y]
 
 f[a,b]
 f[3a,3b]
 f[e t,e r]
 f[tau x,tau y]==tau f[x,y]
 
OUT:
f[a,b]
3 f[a,b]
e f[t,r]
True
This definition simplifies any definition to a simpeler one.
POSTED BY: Sander Huisman
Posted 12 years ago
Thank you Sander Huisman for the reply!

The proposed solution does not work 'all the way' i.e.
f[X, a Y] /. {X -> x a W/z, Y -> W/z}

would produce
a f[x W, W]/z

which is not the required result.

Also, this solution does not 'propagate' to the derivatives of the function i.e.

assuming f is a linearly homogeneous function, then evaluating
f'[x W, W]

(deriv. wrt x) should evaluate to
W f'[x,1] (I think...)

which doesn't, in this case.
POSTED BY: jarque
In the case of 
f[X, a Y] /. {X -> x a W/z, Y -> W/z}
or
f[x a W/z , a W/z]
What should be the outcome?
Do you want it to return: 
(a W f[1, x])/z
?
If so try:
ClearAll[f]
SetAttributes[f, Orderless]
f[\[Tau]_ x_, \[Tau]_ y_] := \[Tau] f[x, y]
f[\[Tau]_, \[Tau]_ y_] := \[Tau] f[1, y]
f[X, a Y] /. {X -> x a W/z, Y -> W/z}

Returns:
(a W f[1, x])/z
POSTED BY: Sander Huisman
Posted 12 years ago
Thanks Sander Huisman

It seems it produces the expected output for this set of inputs emoticon

I think the part(s)
SetAttributes[f, Orderless]
(*...*)
f[?_, ?_ y_] := ? f[1, y]

did the trick, or so it seems...

I'll try to verify it with some more diverse input... but it looks promisning

It even seems to 'propagate' the required behaviour to the derivatives

thanks for taking the time!
POSTED BY: jarque
What should happen with 
f[x,x]
?
Should it return x f[1,1] ?
if so, than add another rule:
f[\[Tau]_, \[Tau]_ ] := \[Tau] f[1, 1]
Regards.
POSTED BY: Sander Huisman
Posted 12 years ago
yes,evaluating
In[1]:= f[x,x]

should produce
Out[1]:= x f[1,1]

so I did make use of your later suggestion (i.e.
f[t_,t_]:= t f[1,1]
)

I also replaced the 'Orderless' attribute with the definition
f[t_ x_,t_]:= t f[x,1]

because, for the context which these definitions are made,
f[a,1] == f[1,a]

does not hold always.

So far and for a limited but sensible range of inputs it seems to be working as it should


*Unfortunately, the behavior for the derivatives so far seems not the desired one (which makes perfect sense since no defitions involve the derivatives).
D[f[x , y], x] /. {x -> a x, y -> a y}

evaluates to
Derivative[1,0][f][a x,a y]

when it would be desirable to evaluate to
Derivative[1,0][f][x,y]
POSTED BY: jarque
Posted 12 years ago
Hi Jarque,

I think the problem with the derivate ist just that 
D[f[x , y], x] /. {x -> a x, y -> a y}
expands to the somewhat strange expression: 
D[f[a x , a y], a x]

What you probably really want is:
D[f[a x , a y], x]
So use instead:
D[f[x, y] /. {x -> a x, y -> a y}, x]
and you get 
a*Derivative[1,0][f][x,y]
as expected.
POSTED BY: Markus Schopfer
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract