Home > other >  Divide by zero and adjust sample rate of sin(1/x)
Divide by zero and adjust sample rate of sin(1/x)

Time:12-14

I want to create the function f(x)=sin(30/x) in Manim. However, I get an error because I'm dividing by zero. So I adjusted the definition set. The sample rate is also too low, how can I increase the number of sample rates so that the graph is displayed better?

curve_2 = ax.plot( lambda x: np.sin(30/(x)), x_range=[0.0000001, 4], color=GREEN_B, ) 

My graph looks like this: enter image description here

But the graph should look like this: enter image description here

CodePudding user response:

You can add a third parameter, the step size, to the list passed to the x_range argument: x_range=[0.001, 4, 0.01]. Using a very small value for the step range might substantially increase the time required to render your scene, though.

  • Related