# Revision history [back]

You should get rid of symbolic computations, and use floating-point arithmetic instead, using RDF where needed. Be careful that the coercion goes toward the symbolic ring, so each time you use it, the follogin computations use it as well. I did not run your code, but you can start with the following and tell if this solves your problem and if you need more hints:

1. First step remove the x,y,u,v = var('x y u v') at the beginning, and see for which function there is a problem, then replace those symbolic functions to PYthon function.

2. replace c(r) = 2/3*(4**(r+1)-4) which defines a symbolic function with the following Python function : c = lambda r : 2/3*(4**(r+1)-4)

3. Do not use pi, use pi_approx = RDF(pi)

4. note that vectors have a .norm() method already defined (note also that you can specify the base ring of the vector),

for example:

sage: v = vector([1,2])
sage: v.norm()

sage: v = vector(RDF, [3,4])
sage: v.norm()
5.0


I think you get the idea.

You should get rid of symbolic computations, and use floating-point arithmetic instead, using RDF where needed. Be careful that the coercion goes toward the symbolic ring, so each time you use it, the follogin computations use it as well. I did not run your code, but you can start with the following and tell if this solves your problem and if you need more hints:

1. First step remove the x,y,u,v = var('x y u v') at the beginning, and see for which function there is a problem, then replace those symbolic functions to PYthon function.

2. replace ep = 0.1 with ep = RDF(0.1) (Real Double Field is faster than Real Field with 53 bits of precision|, and the coercion goes from the first to the second).

3. replace c(r) = 2/3*(4**(r+1)-4) which defines a symbolic function with the following Python function : c = lambda r : 2/3*(4**(r+1)-4)

4. Do not use pi, use pi_approx = RDF(pi)

5. note that vectors have a .norm() method already defined (note also that you can specify the base ring of the vector),

for example:

sage: v = vector([1,2])
sage: v.norm()

sage: v = vector(RDF, [3,4])
sage: v.norm()
5.0


I think you get the idea.

You I am not sure if you spend more time in just drawing pictures or in the computations. If the plot is guilty, you should look for another Python library that wil be faster, but i am not specialist about pictures and animations.

If computations take too much time, you should get rid of symbolic computations, and use floating-point arithmetic instead, using RDF where needed. Be careful that the coercion goes toward the symbolic ring, so each time you use it, the follogin computations use it as well. I did not run your code, but you can start with the following and tell if this solves your problem and if you need more hints:

1. First step remove the x,y,u,v = var('x y u v') at the beginning, and see for which function there is a problem, then replace those symbolic functions to PYthon function.

2. replace ep = 0.1 with ep = RDF(0.1) (Real Double Field is faster than Real Real Field with 53 bits of precision|, precision, and the coercion goes from the first to the second).

3. replace c(r) = 2/3*(4**(r+1)-4) which defines a symbolic function with the following Python function : c = lambda r : 2/3*(4**(r+1)-4)

4. Do not use pi, use pi_approx = RDF(pi)

5. note that vectors have a .norm() method already defined (note also that you can specify the base ring of the vector),

for example:

sage: v = vector([1,2])
sage: v.norm()

sage: v = vector(RDF, [3,4])
sage: v.norm()
5.0


I think you get the idea.

I am not sure if you spend more time in just drawing pictures or in the computations. If the plot is guilty, you should look for another Python library that wil be faster, but i am not specialist about pictures and animations.animations. You can user %timeit to see which part of the program takes the most time.

If the computations take too much time, you should get rid of symbolic computations, and use floating-point arithmetic instead, using RDF where needed. Be careful that the coercion goes toward the symbolic ring, so each time you use it, the follogin computations use it as well. I did not run your code, but you can start with the following and tell if this solves your problem and if you need more hints:

1. First step remove the x,y,u,v = var('x y u v') at the beginning, and see for which function there is a problem, then replace those symbolic functions to PYthon function.

2. replace ep = 0.1 with ep = RDF(0.1) (Real Double Field is faster than Real Field with 53 bits of precision, and the coercion goes from the first to the second).

3. replace c(r) = 2/3*(4**(r+1)-4) which defines a symbolic function with the following Python function : c = lambda r : 2/3*(4**(r+1)-4)

4. Do not use pi, use pi_approx = RDF(pi)

5. note that vectors have a .norm() method already defined (note also that you can specify the base ring of the vector),

for example:

sage: v = vector([1,2])
sage: v.norm()

sage: v = vector(RDF, [3,4])
sage: v.norm()
5.0


I think you get the idea.

I am not sure if you spend more time in just drawing pictures or in the computations. If the plot is guilty, you should look for another Python library that wil will be faster, but i am not specialist about pictures and animations. You can user use %timeit to see which part of the program takes the most time.

If the computations take too much time, you should get rid of symbolic computations, and use floating-point arithmetic instead, using RDF where needed. Be careful that the coercion goes toward the symbolic ring, so each time you use it, the follogin computations use it as well. I did not run your code, but you can start with the following and tell if this solves your problem and if you need more hints:

1. First step remove the x,y,u,v = var('x y u v') at the beginning, and see for which function there is a problem, then replace those symbolic functions to PYthon function.

2. replace ep = 0.1 with ep = RDF(0.1) (Real Double Field is faster than Real Field with 53 bits of precision, and the coercion goes from the first to the second).

3. replace c(r) = 2/3*(4**(r+1)-4) which defines a symbolic function with the following Python function : c = lambda r : 2/3*(4**(r+1)-4)

4. Do not use pi, use pi_approx = RDF(pi)

5. note that vectors have a .norm() method already defined (note also that you can specify the base ring of the vector),

for example:

sage: v = vector([1,2])
sage: v.norm()

sage: v = vector(RDF, [3,4])
sage: v.norm()
5.0


I think you get the idea.