ubsuny / 23-Homework6G2

Apache License 2.0
0 stars 9 forks source link

Cos function #21

Closed poojashresthacode closed 9 months ago

poojashresthacode commented 9 months ago

@LinxuanHu @AhmedCode99 @tirthbha 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

tirthbha commented 9 months ago

@poojashresthacode I got the same runtime error, and which is due to singularly about x=0. You have to handle the singularly at x=0.

tirthbha commented 9 months ago

@poojashresthacode As you can see the function has indeterminate form at x=0, it will encounters errors or warning unless you resolve this singularity issue.

tirthbha commented 9 months ago

@poojashresthacode I have resolved this issue, you can see here: https://github.com/ubsuny/23-Homework6G5/pull/19

reshnashrestha commented 9 months ago

https://github.com/ubsuny/23-Homework6G2/issues/16 This can be of some help.

AhmedCode99 commented 9 months ago

This is a possible way of dealing with a singularity: (https://github.com/ubsuny/23-Homework6G2/issues/47)