Ask Your Question
4

subs in vector field

asked 2021-02-01 04:11:15 +0100

curios_mind gravatar image

Hello,

var('a')
E.<x,y,z>=EuclideanSpace()
vf=E.vector_field([a**2,a*x,a*x*y]) # arbitrary vector field
vf.subs(a==1).display()

gives back the vector field without substituting the value of a

a^2 e_x + a*x e_y + a*x*y e_z

How does the funciton subs work with vector fields?

Thanks alot for your help.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2021-02-01 08:07:05 +0100

eric_g gravatar image

You have to use the method apply_map() in order to perform the substitution on each component of the vector field:

sage: vf.apply_map(lambda cmp: cmp.subs(a==1))                                                      
sage: vf.display()                                                                                  
e_x + x e_y + x*y e_z

See the documentation of apply_map() for more details.

edit flag offensive delete link more

Comments

Just curious: Couldn't OP's code be made to work? The fact that subs exists while not doing the expected thing is likely to confuse/frustrate users. I've also run into this.

rburing gravatar imagerburing ( 2021-02-01 09:45:51 +0100 )edit
1

I had the same confusion. There is the subs function, but doesn't do the job. Don't you guys think that this is a bug?

curios_mind gravatar imagecurios_mind ( 2021-02-01 12:30:45 +0100 )edit
1

Yes this is a bug! I was not aware that the method subs() (silently) exists for vector fields! It is actually inherited from Sage's base class Element. I've opened https://trac.sagemath.org/ticket/31316 for this.

eric_g gravatar imageeric_g ( 2021-02-01 15:41:48 +0100 )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

2 followers

Stats

Asked: 2021-02-01 04:11:15 +0100

Seen: 702 times

Last updated: Feb 01 '21