1 | initial version |
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:
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.
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)
Do not use pi
, use pi_approx = RDF(pi)
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()
sqrt(5) # bad
sage: v = vector(RDF, [3,4])
sage: v.norm()
5.0
I think you get the idea.
2 | No.2 Revision |
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:
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.
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).
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)
Do not use pi
, use pi_approx = RDF(pi)
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()
sqrt(5) # bad
sage: v = vector(RDF, [3,4])
sage: v.norm()
5.0
I think you get the idea.
3 | No.3 Revision |
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:
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.
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).
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)
Do not use pi
, use pi_approx = RDF(pi)
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()
sqrt(5) # bad
sage: v = vector(RDF, [3,4])
sage: v.norm()
5.0
I think you get the idea.
4 | No.4 Revision |
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:
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.
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).
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)
Do not use pi
, use pi_approx = RDF(pi)
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()
sqrt(5) # bad
sage: v = vector(RDF, [3,4])
sage: v.norm()
5.0
I think you get the idea.
5 | No.5 Revision |
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:
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.
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).
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)
Do not use pi
, use pi_approx = RDF(pi)
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()
sqrt(5) # bad
sage: v = vector(RDF, [3,4])
sage: v.norm()
5.0
I think you get the idea.