Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

Let $a$ represent some real irrational number. I am trying to perform computations with an automorphism $f:\mathbb{Q}(i,a)\to\mathbb{Q}(i,a)$ which fixes $\mathbb{Q}(i)$ pointwise and maps $a$ to $i a$.

What's the best way to represent $f$?

My approach below didn't work, since f@f performs a replacement on the symbol f:

f[x_] := x /. a -> I a
f[a]

(* I a *)

f@f[a]

(* -a *)

(f@f)[a]

(* I a (* Not the same as f@f[a] ?! *) *)

What's the best way to define f so that this does not happen?

share|improve this question
1  
Look at result of f@f. MM is doing exactly what you ask it to. –  rasher Apr 21 at 21:00
    
Thanks, I see now. How can I represent my automorphism f? –  tba Apr 21 at 21:04
    
What is $\mathbb Q(i,a)$? –  celtschk Apr 21 at 22:00
    
The smallest field containing the rationals, i, and a. We can think of an element of $\mathbb{Q}(i,a)$ as a complex polynomial in a. –  tba Apr 21 at 23:47

1 Answer 1

up vote 2 down vote accepted

You can define f to operate on f however you would like:

ClearAll[f]

f@f := f@f@# &;

f[x_] := x /. a -> I a

{f[a], f@f[a], (f@f)[a]}
{I a, -a, -a}

However if you expect this to extend to e.g. (f@f@f)[a] you may want something like:

ClearAll[f]
f[f] = Superscript[f, 2];
f[Superscript[f, n_]] := Superscript[f, n + 1]
Superscript[f, n_][x_] := Nest[f, x, n]
f[x_] := x /. a -> I a

Now:

(f@f@f)[a]
-I a
share|improve this answer
    
One can also use \[CircleDot] = Composition for example. –  Kuba Jul 9 at 7:10
    
@Kuba I'm afraid I don't understand what you're implying; could you give an example? Also, at least in v7, \[CircleDot] = Composition is not valid syntax, but I assume you meant CircleDot = Composition. –  Mr.Wizard Jul 9 at 7:32
    
Oh, yes, I don't know why I've written this :) ofc CircleDot :) –  Kuba Jul 9 at 7:34

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.