Hi,

I think that the expected behaviour would be for pow(x,2) to return
x^2, as opposed to a general function. Otherwise, it would be
inconsistent with how 'sin' and 'exp' are handled (for example).

Cheers

Colin

On May 1, 7:02 pm, Ondrej Certik <ond...@certik.cz> wrote:
> On Fri, May 1, 2009 at 10:45 AM, Colin Gillespie <c.gilles...@ncl.ac.uk> 
> wrote:
>
> > Hi Ondrej,
>
> > I've tried to figure out exactly where the errors lies, but don't have
> > anything concrete. Here's what I have come up with:
>
> >> >> y=Symbol("pow(A,2)")
> >> >> Poly(y,y)
> > Poly(pow(A,2), pow(A,2))
>
> > Seems OK.
>
> >> >> x=sympify("pow1(PZPZ)")
> >> >> help(x)
> > Help on pow1 in module sympy.core.function object:
>
> > class pow1(Function)
> > |  Base class for applied functions.
> > |  Constructor of undefined classes.
> > | |  Method resolution order:
> > |      pow1
> > |      Function
> > |      sympy.core.basic.Basic
> > |      sympy.core.assumptions.AssumeMeths
> > |      __builtin__.object
> > <snip>
> >> >> Poly(x,x)
> > Traceback (most recent call last):
> >  File "<stdin>", line 1, in <module>
> >  File "/data/ncsg3/pythonModules/lib/python2.5/site-packages/
> > sympy-0.6.4-py2.5.egg/sympy/polys/polynomial.py", line 310, in __new__
> >   raise SymbolsError("Invalid symbols: %s" % (symbols,))
> > sympy.polys.polynomial.SymbolsError: Invalid symbols: (pow1(PZPZ),)
>
> > Notice that I've used 'pow1' not 'pow'. I think that sympify creates a
> > function 'pow1' that Poly doesn't know what to do with. When we change
> > pow1 -> pow we get the same error, so essentially I think that pow
> > isn't being associated with power.
>
> Yes, you have figured that out, thanks!
>
> Indeed, sympify just creates functions for what it thinks are functions.
>
> So now the question is --- do you want sympify to recognize pow() as a power?
>
> Ondrej
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To post to this group, send email to sympy@googlegroups.com
To unsubscribe from this group, send email to sympy+unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sympy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to