On 9/6/10 1:58 PM, Michael Beeson wrote:
I want to create a vector space of dimension three, over the field
whose elements are symbolic expressions. (The reason is that then I
can do vector calculus on such objects, which represent surfaces in 3-
space if the expressions depend on 2 parameters.) How can I do
this? The following, for example, doesn't work:
One way to easily create such objects is to use the syntax for creating
functions:
sage: f(u,v)=(cos(u), sin(v), u*v)
sage: f
(u, v) |--> (cos(u), sin(v), u*v)
sage: f(1,2)
(cos(1), sin(2), 2)
sage: f(1,x)
(cos(1), sin(x), x)
sage: f.parent()
Vector space of dimension 3 over Callable function ring with arguments
(u, v)
sage: f.diff() # matrix derivative
[(u, v) |--> -sin(u) (u, v) |--> 0]
[ (u, v) |--> 0 (u, v) |--> cos(v)]
[ (u, v) |--> v (u, v) |--> u]
sage: f.diff()(u=1,v=2)
[-sin(1) 0]
[ 0 cos(2)]
[ 2 1]
sage: f.diff(u) # partial derivative wrt u
(u, v) |--> (-sin(u), 0, v)
sage: f.diff(v) # partial derivative wrt v
(u, v) |--> (0, cos(v), u)
sage: f.norm()
(u, v) |--> sqrt(abs(u*v)^2 + abs(sin(v))^2 + abs(cos(u))^2)
Thanks,
Jason
--
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-support
URL: http://www.sagemath.org