Ask Your Question

subs in vector field

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

curios_mind gravatar image


vf=E.vector_field([a**2,a*x,a*x*y]) # arbitrary vector field

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

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

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


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 +0200 )edit

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 +0200 )edit

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 for this.

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



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

Seen: 61 times

Last updated: Feb 01