On Sun, 15 Oct 2006 04:20:55 -0700, Tang Hai Tuan Minh  
<[EMAIL PROTECTED]> wrote:

> Hello,
>
> I am having a little trouble finding out why the following code segment
> doesn't work as expected
>
> f = maxima.function('x', 'sin(x)')
> g = f.integrate('x')
> h = f*g                               // Here sage return different answers 
> on different executions
>
> If I define h as
>
> def h(n):
>       return f(n)*g(n)
>
> then everything seems to work fine.
>
> I have attached a hopefully small (42.8 KB) png image showing the above
> mentioned code executed inside a sage notebook.

What's happening is that f and g both wrap maxima objects and
when you multipy you get something that wraps a maxima object.
You can get the names of them and see that multiplying just gives
the name of the product.    The solution is for somebody (e.g., me)
to define arithmetic operations on maxima.function objects, i.e.,
adding to the MaximaFunction class in devel/sage/sage/interfaces/maxima.py.
Your problem is a NotImplementedError.  I've added this to the trac server
as enhancement # 132.

The reason the answer is different at different times is that the
variables in maxima that SAGE uses are named consecutively.

sage: f = maxima.function('x','sin(x)')
sage: g = f.integrate('x')
sage: f.name()
'sage0'
sage: g.name()
'sage2'
sage: f*g
sage0*sage2
sage: f
sin(x)
sage: g
-cos(x)
sage: f(10)
sin(10)
sage: f(10.)
-.5440211108893698
sage: (f*g)(10.0)
(sage0*sage2)[10.0]
sage: h = f*g
sage: h(10.0)
(sage0*sage2)[10.0]

--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/sage-forum
URLs: http://sage.math.washington.edu/sage/ and http://sage.scipy.org/sage/
-~----------~----~----~----~------~----~------~--~---

Reply via email to