Jun-10-2018, 10:05 PM
You are mixing pure python operations (float and lists) with vector-oriented ones using numpy. Although there is nothing wrong with this normally it is better to stick to one of them... in this cae I think the proper one is numpy, but is up to you.
Numerically your code has many small details that I think you shall take into account:
- Your f function has singularities around theta=-2*pi, 0, 2*pi... it will be good idea to either filter them or prpare your code to deal with inf and -inf.
- In your somme function (and later) you use
- For the plot you are creating a mesh in the range of [-150, 150] and your i, j variable vary from 0 to 300. Then you call f(i, j, k) so at least for j you are using a range of values between 0 and 300 radians (~47 complete revolutions) so I think there there is a mixture of indexes, degrees and radians.
Numerically your code has many small details that I think you shall take into account:
- Your f function has singularities around theta=-2*pi, 0, 2*pi... it will be good idea to either filter them or prpare your code to deal with inf and -inf.
- In your somme function (and later) you use
if teta//(pi/2)==0
I imagine to exclude this singularities... but notice that that is true for teta in the range [0.0 to 1.57..] that I think is not really what you whant to exclude- For the plot you are creating a mesh in the range of [-150, 150] and your i, j variable vary from 0 to 300. Then you call f(i, j, k) so at least for j you are using a range of values between 0 and 300 radians (~47 complete revolutions) so I think there there is a mixture of indexes, degrees and radians.