ubsuny / 23-Homework6G1

MIT License
2 stars 7 forks source link

Cos function #24

Open poojashresthacode opened 1 year ago

poojashresthacode commented 1 year ago

@WildJimmy ipython-input-8-fe2d73df47d6>:5: RuntimeWarning: divide by zero encountered in divide return np.cos(1 / x)

:5: RuntimeWarning: invalid value encountered in cos return np.cos(1 / x) :5: RuntimeWarning: divide by zero encountered in double_scalars return np.cos(1 / x) Trapezoidal rule result for cos(1/x): nan Simpson's rule result for cos(1/x): nan N = 2, Integral = 1.0806046117362795 N = 2.0, Integral = nan Adaptive trapezoidal rule result for cos(1/x): nan I have got these things in cos(1/x) function, Can you elaborate what it mean? My graph for this function appears like this, is it correct? ![image](https://github.com/ubsuny/23-Homework6G1/assets/143756553/db3c9a05-7d42-4ba3-927b-c07f1cd0d46b)
pratibha77118 commented 1 year ago

I get the graph of cos(1/x) defined from [0,4*pi] as : Cos1:x image I doubt whether the graph I got is correct. I would appreciate if any one share the nature of graph for cos(1/x). @poojashresthacode You got different one.

WildJimmy commented 1 year ago

Your graph looks correct to me, I think the error comes from the fact that your program is trying to divide by zero at x = 0

poojashresthacode commented 1 year ago

@pratibha77118 I got the same graph too, I think it is correct.

Pranjal-Srivastava-2023 commented 1 year ago

It is Division by 0 warning. The code is encountering 1/0 at x=0 which is undefined.