Ask Your Question

curios_mind's profile - activity

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)


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

Consider the following code:





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


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


I tried to calculate the divergence of 1/r^2e_r, but I got zero, where it should have been 4pidirac_delta(re_r)


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


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.

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?


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


Oversimplified version of my question is "How can I multiply a vector with a matrix?"

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
# nor this works

The only work around I could think of is,2,1)))

or directly on the vector field

v=vector([v[0].expr(), v[1].expr(), v[2].expr()])

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


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




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:

givememaxlen=lambda x: max([len(i) for i in x]);
2020-07-04 12:48:23 +0200 asked a question plot_vector_field3d in spherical coordinates


How can I draw a vector field in spherical coordinates?

For example


f_spher=E.frames()[2] # frame in spherical coordinates

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<oo

Thanks for the clarification. I think it is an important point of view.

2020-06-22 18:52:47 +0200 marked best answer solve: Possible bug?


This question is relevant to Question #2 in the topic "desolve: wrong solution?!". If desolve is using solve internally when initial conditions are invoked to find the constants after obtaining the general solution, perhaps this is where the problem lies.

Consider the following expression

f=-1/2*(I*sqrt(3)*2^(1/3) - 2^(1/3))/(-2*a - 1)^(1/3)

sol is [a == (-5/8)]

Now, if we plug that back in f,


this gives 1.00000000000000 - 1.73205080756888*I, where it ought to give -2 (if there is a solution)

And I tried this with Mathematica also

Solve[-1/2 (I Sqrt[3] 2^(1/3) - 2^(1/3))/(-2 a - 1)^(1/3) == -2, a]

It returns an empty list {} for this, indicating that there is no solution.

What is wrong with Sage's solve function here?

Update: I tried solve with "sympy" agorithm. It agreed with Mathematica. It looks like there is a problem with Maxima

2020-06-21 18:42:01 +0200 asked a question assume gives false for a<oo


print(bool(a<+Infinity)) # or print(bool(a<oo))

Why does this code print False.

2020-06-21 03:57:16 +0200 received badge  Commentator
2020-06-21 03:57:16 +0200 commented question Another: dirac_delta integration: possible bug?

I looked at the code and tried to fix it to accomodate this problem but I wasn't very successful (though I learned a lot!) I tried the following with your version, but I am getting 0.


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


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


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


When I tried to integrate the following


I get 1 (as expected)

But when I integrate


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:


returns 1 where it should return 1/|a|



returns 1/|a|, where it should be 1/(2|a|)