Ask Your Question
0

functions with vector inputs

asked 2012-10-01 08:48:52 -0500

mirk gravatar image

updated 2012-10-01 10:40:09 -0500

Are vector functions supported in sage?

as in:

f1(r,phi,theta) = 1/r
f2(r,phi,theta) = 1
f3(r,phi,theta) = 1
F = vector([f1, f2, f3])
G=rot(F) # vector function

An ancient post seems to suggest that rot has to be defined with a positional python-argument like rot(*F).

Is there a way for "rot" to take the vector symbolically as an argument?

edit retag flag offensive close merge delete

Comments

1

I think I know what you mean now. `sage: rot(r,phi,theta) = F` could in theory make a vector function, but it doesn't currently know what to do.

kcrisman gravatar imagekcrisman ( 2012-10-01 13:02:19 -0500 )edit

2 answers

Sort by ยป oldest newest most voted
2

answered 2012-10-02 16:58:31 -0500

benjaminfjones gravatar image

I don't understand the question. Are you asking if it's possible to use the special notation like f(x) = x^2 for the creation of vector valued functions? If so, the answer is currently no, but it could probably be added to the Sage preparser without much problem. Of course you can always define the function rot the ordinary way to take a vector and return a vector:

sage: rot = lambda v: vector([1/v[0],1,1]) 
sage: rot(vector([2,1,1]))
(1/2, 1, 1)
edit flag offensive delete link more
0

answered 2012-10-01 09:16:46 -0500

kcrisman gravatar image

I usually think of a gradient as being a property of a single-variable function... but anyway, is this what you want?

sage: F.diff()
[(r, phi, theta) |--> -1/r^2      (r, phi, theta) |--> 0      (r, phi, theta) |--> 0]
[     (r, phi, theta) |--> 0      (r, phi, theta) |--> 0      (r, phi, theta) |--> 0]
[     (r, phi, theta) |--> 0      (r, phi, theta) |--> 0      (r, phi, theta) |--> 0]
sage: diff(F)
[(r, phi, theta) |--> -1/r^2      (r, phi, theta) |--> 0      (r, phi, theta) |--> 0]
[     (r, phi, theta) |--> 0      (r, phi, theta) |--> 0      (r, phi, theta) |--> 0]
[     (r, phi, theta) |--> 0      (r, phi, theta) |--> 0      (r, phi, theta) |--> 0]
edit flag offensive delete link more

Comments

My mistake: the problem arises while calculating the divergence. It was a copy/paste failure. I will edit the question. I don't think this is the answer I was looking for.

mirk gravatar imagemirk ( 2012-10-01 10:39:11 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2012-10-01 08:48:52 -0500

Seen: 759 times

Last updated: Oct 02 '12