On Sat, May 3, 2008 at 10:27 PM, William Stein <[EMAIL PROTECTED]> wrote:
>
>  On Sat, May 3, 2008 at 6:53 PM, dvase <[EMAIL PROTECTED]> wrote:
>  >
>  >  Hello,
>  >  It seems as though I am missing something obvious, but I can not
>  >  figure out how to use complex number manipulations on symbolic
>  >  variables in sage.
>  >
>  >  A trivial example would be to have a function that returns the
>  >  imaginary portion of a given complex value:
>  >
>  >  sage: f(x) = imag(x)
>  >  sage: f(i*1)
>  >  I
>  >
>  >  However, the result of this currently gives me zero, as it seems the
>  >  imag() function is not captured by the function declaration.  Any
>  >  insights on this quandary?
>
>
>  At present, depending on what you're doing your best bet in this case
>  is probably just to define a Python function instead of a formal symbolic
>  function.   For example, paste in this:
>
>  def f(x):
>      return imag(x) + 5
>
>  Then
>
>  sage: f(3+I)
>  6
>
>
>  The rest of this email has some details about what is going on.
>  Since symbolic calculus in Sage is currently being massively
>  rewritten by Bill Furnish, I don't recommend people worry
>  too much about making changes to the current system to
>  address this problem.
>
>  Complex number support for Sage's current symbolics is not very good.
>  It wasn't a high priority in the initial implementation.
>
>  In particular, imag is just a Python function:
>
>  sage: type(imag)
>  <type 'function'>
>
>  whereas for something like the above to work well it should be a
>  symbolic function.
>
>  Second, even if imag were symbolic  Maxima (which does expression 
> simplification
>  of Sage symbolic expressions behind the scenes) would view x by default
>  as real, and imag(x) = 0.

I wonder if Bill Furnish is also planning on adding the sgn function
to this class?

>
>  sage: sage.calculus.calculus.maxima('imagpart(x)')  # imagpart = imag in 
> maxima
>  0
>  sage: sage.calculus.calculus.maxima('realpart(x)')
>  x
>
>  This behavior can be changed as follows:
>
>  sage: sage.calculus.calculus.maxima('declare(x, complex)')
>  done
>  sage: sage.calculus.calculus.maxima('imagpart(x)')  # imagpart = imag in 
> maxima
>  ?%imagpart(x)
>
>
>
>  >
>

--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---

Reply via email to