OK, thanks for this. It works! Where would I have found this distinction in the documentation?
Thanks Robin On Mon, Jan 21, 2013 at 10:37 PM, P Purkayastha <ppu...@gmail.com> wrote: > On 01/21/2013 05:01 PM, robin hankin wrote: >> >> Hello. kubuntu linux, sage 5.5 >> >> I want to define a function that takes argument 'x' and returns 'x^2'. >> But I cannot make this idea work when 'x' is an element of a >> permutation group. As per the snippet below, 'u^2' is perfectly well >> defined, but f(u) returns an error. >> >> How do I define a function f() such that f(x) returns x^2 even when x >> is a peculiar object such as an element of a permutation group? >> >> >> >> sage: f(x) = x^2 > > > This defines a symbolic expression. > > sage: preparse('f(x) = x^2') > '__tmp__=var("x"); f = symbolic_expression(x**Integer(2)).function(x)' > > >> sage: f(3) >> 9 >> sage: u = CubeGroup().U() >> sage: u^2 >> (1,8)(2,7)(3,6)(4,5)(9,25)(10,26)(11,27)(17,33)(18,34)(19,35) >> sage: f(u) >> >> --------------------------------------------------------------------------- >> TypeError > > > Use a python function instead: > > sage: def f(u): return u^2 > ....: > sage: f(u) > (1,8)(2,7)(3,6)(4,5)(9,25)(10,26)(11,27)(17,33)(18,34)(19,35) > > -- > You received this message because you are subscribed to the Google Groups > "sage-support" group. > To post to this group, send email to sage-support@googlegroups.com. > To unsubscribe from this group, send email to > sage-support+unsubscr...@googlegroups.com. > Visit this group at http://groups.google.com/group/sage-support?hl=en. > > -- Robin Hankin Uncertainty Analyst hankin.ro...@gmail.com -- You received this message because you are subscribed to the Google Groups "sage-support" group. To post to this group, send email to sage-support@googlegroups.com. To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com. Visit this group at http://groups.google.com/group/sage-support?hl=en.