Graph tan and arctan with python

  • Context: Python 
  • Thread starter Thread starter ver_mathstats
  • Start date Start date
  • Tags Tags
    Graph Python Tan
Join the discussion
Registration is free. Ask a follow-up in this thread, or start your own.
8 replies · 4K views
ver_mathstats
Messages
258
Reaction score
21
Code:
import numpy as np
import matplotlib.pyplot as plt

x=np.arange(-5*np.pi, 5*np.pi, step = 0.02)
plt.ylim(-1, 1)
tan=np.tan(x)
arctan=np.arctan(x)
plt.plot(x,tan)
plt.plot(x,arctan)

Here is the code I came up with using the guide my teacher gave me, is this correct the way I have done it? Thank you.
 
Physics news on Phys.org
phyzguy said:
Can't you run it and see?
Yeah I did, and it went fine I think, I just wanted to make sure it was okay. Thanks for the response though.
 
It looks good to me. I just wanted you to test it for yourself.
 
  • Like
Likes   Reactions: ver_mathstats and sysprog
You showed that you understand that arctan is the inverse of tan, but if you want us to evaluate your code, maybe you could show some of its output.
 
  • Like
Likes   Reactions: ver_mathstats
sysprog said:
You showed that you understand that arctan is the inverse of tan, but if you want us to evaluate your code, maybe you could show some of its output.
Oh okay, like attaching a photo of the results I obtained?
 
ver_mathstats said:
Oh okay, like attaching a photo of the results I obtained?
Maybe a text copy would be better than a screenshot, but the point is that for diagnostic purposes, we're better informed if we can see all of the components -- input, code, and output.
 
ver_mathstats said:
Oh okay, like attaching a photo of the results I obtained?
If you add a line that says:
Python:
plt.savefig("myplot.png")
it will save the plot as a png file which you can then attach to your post using the "Attach Files" button.
 
  • Like
Likes   Reactions: ver_mathstats and sysprog
phyzguy said:
If you add a line that says:
Python:
plt.savefig("myplot.png")
it will save the plot as a png file which you can then attach to your post using the "Attach Files" button.
nice
 
  • Like
Likes   Reactions: ver_mathstats