On Tue, 05 Dec 2006 09:53:37 -0800, Bobby Moretti <[EMAIL PROTECTED]>
wrote:
> William, I know you're busy right now, but when you get a chance could
> you give an example of what a SAGE session with this type of
> substitution would look like?
Here's an example. It actually works today if you change one line
of interfaces/maxima.py, and it gives a flavor of what we want if
you ignore the top line involving maxima:
# ignore the following two lines
sage: sin = maxima('sin'); cos=maxima('cos'); exp=maxima('exp');
tan=maxima('tan')
sage: R.<x,y,z> = QQ[]
# what I basically want (and which already works today with the setup
above):
sage: f = sin(x) + cos(x*y) + exp(2*x*y); f
cos(x*y) + %e^(2*x*y) + sin(x)
sage: g = f.ev('z=sqrt(2)', 'y=2/3'); g # substitutions
sin(x) + cos(2*x/3) + %e^(4*x/3)
sage: h = g.integrate(x); h
-cos(x) + 3*sin(2*x/3)/2 + 3*%e^(4*x/3)/4
sage: k = h.diff(x); k
sin(x) + cos(2*x/3) + %e^(4*x/3)
sage: tan(10)
tan(10)
sage: float(tan(10))
0.64836082745908663
-------------
Substitutions would have to work differently in SAGE though, e.g., as
in the following *fantasy* session:
sage: f = sin(x) + cos(x*y) + exp(2*x*y); f
cos(x*y) + exp(2*x*y) + sin(x)
sage: g = f.subs( (z,sqrt(2)), (y,2/3)); g # substitutions
sin(x) + cos(2*x/3) + e^(4*x/3)
sage: h = g.integrate(x); h
-cos(x) + 3*sin(2*x/3)/2 + 3*exp(4*x/3)/4
sage: k = h.diff(x); k
sin(x) + cos(2*x/3) + exp(4*x/3)
sage: tan(10)
tan(10)
sage: float(tan(10))
0.64836082745908663
Non one-letter vars:
sage: theta = var('theta')
sage: g = sin(theta) + cos(theta) + x^2 + y
sage: g.subs(theta, 3)
sin(3) + cos(3) + x^2 + y
sage: g.subs((theta, 3), (x,5))
sin(3) + cos(3) + 25 + y
Subscripts could be via a dot notation or square brackets, which would
fit well with the current impelmentation:
sage: f = cos(x.0 + 7*x.1 + 3*x.2)
or alternatively,
sage: f = cos(x[0] + 7*x[1] + 3*x[2])
The second version requires no preparsing. The first does, but it's
already
done -- x.[number] alread gets preparsed to x.gen(number).
Anybody who seriously wants to get into this calculus discussion for SAGE
definitely *MUST* take a good look through the maxima documentation, since
Maxima is, for Calculus, an amazingly powerful program, which already does
everything -- and which will be doing all the heavily lifting. The problem
is just that we need to do much more than we have to make Maxima's really
amazing power very easy to use in SAGE. I.e., basically I'd like
something
that feels like the best of Maple/Mathematica but is implemented mostly
behind the scenes using Maxima. This is exactly the analogue of
what Alex Clemesha has been doing with graphics for SAGE, but for calculus.
-- William
--~--~---------~--~----~------------~-------~--~----~
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-devel
URLs: http://sage.scipy.org/sage/ and http://modular.math.washington.edu/sage/
-~----------~----~----~----~------~----~------~--~---