Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

vector_field.apply_map before and after vector.display (weird behaviour)

Hello,

Recently, I have come a cross a very weird behaviour with vector_field.apply_map function. Here is the case:

Consider the following code:

E.<r,th,ph>=EuclideanSpace(coordinates="spherical",start_index=0)

cart.<x,y,z>=E.cartesian_coordinates()
cartf=E.cartesian_frame()

spherf=E.spherical_frame()

E.set_default_frame(cartf)

Now, if I create a vector field, substitute ph with ph_1 and th with th_1, and then display the resultant vector as

var("r_1 th_1 ph_1")
v=E.vector_field([r_1,0,0], frame=spherf, chart=cart);
v.apply_map(lambda c:c.subs(ph==ph_1, th==th_1));show(v.display())

I get 0 printed

However,

If I do the same, but this time if I add show(v.display()) before calling apply_map function as

var("r_1 th_1 ph_1")
v=E.vector_field([r_1,0,0], frame=spherf, chart=cart); show(v.display())
v.apply_map(lambda c:c.subs(ph==ph_1, th==th_1));show(v.display())

I get

 r_1 cos(ph)sin(th) e_x + r_1 sin(ph)sin(th) e_y + r_1 cos(th) e_z
 r_1 cos(ph_1)sin(th_1) e_x + r_1 sin(ph_1)sin(th_1) e_y + r_1 cos(th_1) e_z

printed.

Why does the display function affect the substitution?

vector_field.apply_map before and after vector.display (weird behaviour)

Hello,

Recently, I have come a cross a very weird behaviour with vector_field.apply_map function. Here is the case:

Consider the following code:

E.<r,th,ph>=EuclideanSpace(coordinates="spherical",start_index=0)

cart.<x,y,z>=E.cartesian_coordinates()
cartf=E.cartesian_frame()

spherf=E.spherical_frame()

E.set_default_frame(cartf)

Now, if I create a vector field, substitute ph with ph_1 and th with th_1, and then display the resultant vector as

var("r_1 th_1 ph_1")
v=E.vector_field([r_1,0,0], frame=spherf, chart=cart);
v.apply_map(lambda c:c.subs(ph==ph_1, th==th_1));show(v.display())

I get 0 printed

However,

If I do the same, but this time if I add show(v.display()) before calling apply_map function as

var("r_1 th_1 ph_1")
v=E.vector_field([r_1,0,0], frame=spherf, chart=cart); show(v.display())
v.apply_map(lambda c:c.subs(ph==ph_1, th==th_1));show(v.display())

I get

 r_1 cos(ph)sin(th) e_x + r_1 sin(ph)sin(th) e_y + r_1 cos(th) e_z
 r_1 cos(ph_1)sin(th_1) e_x + r_1 sin(ph_1)sin(th_1) e_y + r_1 cos(th_1) e_z

printed.printed (as expected).

Why does the display function affect the substitution? substitution?