2021-02-08 15:05:08 +0200 commented answer vector_field.apply_map before and after vector.display (weird behaviour) Your explanation makes sense, though I thought when the vector_field is called, as in the question, the corresponding representation of the field in spherical chart is updated. 2021-02-08 14:54:22 +0200 commented answer Divergence of inverse square It would have been great, if it had given the dirac solution. 2021-02-07 04:27:55 +0200 asked a question 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.=EuclideanSpace(coordinates="spherical",start_index=0) cart.=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 (as expected). Why does the display function affect the substitution? 2021-02-07 00:15:43 +0200 asked a question Divergence of inverse square Hello, I tried to calculate the divergence of 1/r^2e_r, but I got zero, where it should have been 4pidirac_delta(re_r) E.=EuclideanSpace(coordinates="spherical") v=E.vector_field([1/r^2,0,0]) v.div().display()  Results is E^3 --> R (r, th, ph) |--> 0  Can this be considered as a bug? 2021-02-02 01:01:18 +0200 received badge ● Good Question (source) 2021-02-01 14:26:50 +0200 received badge ● Nice Question (source) 2021-02-01 12:30:45 +0200 commented answer subs in vector field 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? 2021-02-01 04:11:15 +0200 asked a question subs in vector field Hello, var('a') E.=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. 2021-01-30 23:43:42 +0200 commented answer 2 sets of coordinates in EuclideanSpace? Thank you so much! this is really awesome. I love the way sagemath handle these things. 2021-01-30 23:42:57 +0200 received badge ● Supporter (source) 2021-01-29 21:28:08 +0200 asked a question 2 sets of coordinates in EuclideanSpace? Hello, I would like to work with 2 vectors in EuclideanSpace each having x1,y1,z1 and x2,y2,z2 coordinates. I will be needing to switch back and forth between cartesian and spherical coordinates as well. As an example, say, (r1,0,0) -> (x1,y1,z1) while (r2,0,0)->(x2,y2,z2) in the same EuclideanSpace. How would one work with multiple vectors (with independent coordinates) in EuclideanSpace? Should one define 2 chart for spherical coordinates and 2 for cartesian coordinates? Or should one create 2 different EuclideanSpace and combine them (if possible)? 2021-01-29 14:26:30 +0200 commented answer Matrix multiplication with a vector in EuclideanSpace Thank you very much. This really helped and saved me from a lot of trouble. 2021-01-29 01:25:10 +0200 asked a question Matrix multiplication with a vector in EuclideanSpace Hello Oversimplified version of my question is "How can I multiply a vector with a matrix?" E.=EuclideanSpace(start_index=0) vf=E.vector_field([x*y,x^2,z**2]) # the components are for testing purposes M=Matrix(RR,3,3);M[:]=1 # this is just a test # Neither this M*vf # nor this works M*vf.at(E((3,2,1)))  The only work around I could think of is v=vf.at(E((3,2,1))) q=vector([v[0],v[1],v[2]]) M*q  or directly on the vector field v=vector([v[0].expr(), v[1].expr(), v[2].expr()]) M*q  With this approach I have to put the transformed components back in the vector field defined within EuclideanSpace. I would like to use EuclideanSpace to work with vectors. Is there an easy way to handle this? Basically I am looking for an easy way to transform a vector field defined in EuclideanSpace? Thanks in advance for your help. 2020-07-06 20:18:16 +0200 commented answer plot_vector_field3d in spherical coordinates Is there a way to increase density of the vectors? It is also very slow. Is there a way to speed it up? 2020-07-05 23:00:12 +0200 answered a question How do I solve cos(2*t)==sin(t) You could try var('t') solve(cos(2*t)==sin(t),t,to_poly_solve='force')  which gives [t == -1/2*pi - 2*pi*z24, t == 1/6*pi + 2/3*pi*z25] Z's are integers. 2020-07-05 22:47:56 +0200 asked a question Metric of EuclideanSpace(3) in spherical frame I may have some conceptual misunderstandings, but here is the code E=EuclideanSpace(3) c_spher.=E.spherical_coordinates() f_spher=E.spherical_frame() E.set_default_chart(c_spher) E.set_default_frame(f_spher) g=E.metric() show(g[:])  I was expecting the diagonal elements of the metric to be [1,r^2,r^4*sin(th)^2], but I get [1,1,1] What I am doing wrong? 2020-07-05 22:29:52 +0200 commented answer plot_vector_field3d in spherical coordinates Thank you so much. Yep, I made typos. Sorry for that. The code was on another computer, I was typing it it. 2020-07-04 19:02:31 +0200 answered a question How to find all maximum length lists with a nested and display? As the other contributors have said, you can simply use python. Just another version: a=[[1,3],[4,5,6],[2,3,4,6,7],[1,3]] givememaxlen=lambda x: max([len(i) for i in x]); print(givememaxlen(a))  2020-07-04 12:48:23 +0200 asked a question plot_vector_field3d in spherical coordinates Hello, How can I draw a vector field in spherical coordinates? For example E=EuclideanSpace(3) c_cart.=E.cartesian_coordinates() c_spher.=E.spherical_coordinates() f_spher=E.frames()[2] # frame in spherical coordinates E.set_default_chart(c_spher) E.set_default_frame(f_spher) vf=E.vectorfield((r,0,0), frame=f_spher,cart=c_spher,name="vf");show(vf.display())  This beutifully gives me a vector field as r e_r Now, I would like to plot this field in spherical coordinates plot_vector_field3d([c.expr() for c in vf[:]], (r,2,10),(th,0,pi),(ph,0,2*pi))  I also tried out the transformation keyword as it is in plot3d function, but it still plots r as x. How can I plot the vector field in spherical coordinates? I was expecting to see outgoing arrows in all directions from r=2 to 10? 2020-06-23 00:14:23 +0200 received badge ● Nice Question (source) 2020-06-22 23:19:56 +0200 commented answer assume gives false for a-2) assume(a<2) integrate_delta(dirac_delta(x^2-a),x,-100,100)  am I using it wrong? (especially the assumptions?) 2020-06-20 14:54:11 +0200 commented answer find the root of tan(x) I was looking for that too :) Thank you. Similarly, I came across tan(x)._maxima_().to_poly_solve(x).sage()  which I think does the same. 2020-06-20 14:39:59 +0200 answered a question find the root of tan(x) It would simply be solve(tan(x)==0,x)  and this returns [x == 0] as expected. However, if you need something more general like C*Pi where C is an integer, I don't know. 2020-06-20 00:05:19 +0200 marked best answer Integration of dirac_delta Hello, When I tried to integrate the following (dirac_delta(x)).integrate(x,-pi,pi)  I get 1 (as expected) But when I integrate (dirac_delta(cos(x))).integrate(x,-pi,pi)  I get integrate(dirac_delta(cos(x)), x, -pi, pi) back. I would expect to get 2 since there are two points which are zero between the upper and lower bounds of the integral. So by any means of approaching these points with limit during the integration, the integral of dirac_delta should have returned 1 for each point which adds up to 2 If I try the same with Mathematica, Integrate[DiracDelta[x], {x, -Pi, Pi}]  I get 1 and when I try Integrate[DiracDelta[Cos[x]], {x, -Pi, Pi}]  I get 2 as I would expect. What is the reason of this behaviour of Sage? 2020-06-20 00:05:19 +0200 commented answer Integration of dirac_delta Unfortunately, I think there are more bugs in Sage's integral with dirac_delta. I opened up a new thread for them. Another: dirac_delta integration: possible bug? 2020-06-20 00:00:09 +0200 edited question Another: dirac_delta integration: possible bug? I think there is another problem with the integration of the dirac_delta in Sage: (previous problem is discussed in the thread Integration of dirac_delta) Here is the problem: var('a',"real") f=integral(dirac_delta(a*x),x,-oo,oo);show(f)  returns 1 where it should return 1/|a| and var('a',"real") f=integral(dirac_delta(x^2-a^2),x,-oo,oo);show(f)  returns 1/|a|, where it should be 1/(2|a|)