Graph tan and arctan with python

  • Context: Python 
  • Thread starter Thread starter ver_mathstats
  • Start date Start date
  • Tags Tags
    Graph Python Tan
Click For Summary

Discussion Overview

The discussion revolves around a Python code snippet for graphing the tangent and arctangent functions using NumPy and Matplotlib. Participants explore the correctness of the code and seek feedback on its output and presentation.

Discussion Character

  • Homework-related
  • Technical explanation

Main Points Raised

  • One participant shares a code snippet for plotting tan and arctan functions and asks for feedback on its correctness.
  • Several participants suggest running the code to verify its functionality.
  • There is a suggestion to provide output from the code for better evaluation.
  • Participants discuss the merits of attaching a screenshot versus a text copy of the output.
  • A suggestion is made to include a line of code to save the plot as a PNG file for easier sharing.

Areas of Agreement / Disagreement

Participants generally agree on the need for output to evaluate the code, but there is no consensus on the best method for sharing that output.

Contextual Notes

Some participants express uncertainty about the effectiveness of different methods for sharing results, and there are no specific details provided about the output of the code.

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.
 
Technology news on Phys.org
Can't you run it and see?
 
  • Like
Likes   Reactions: ver_mathstats and sysprog
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

Similar threads

  • · Replies 6 ·
Replies
6
Views
3K
  • · Replies 1 ·
Replies
1
Views
1K
Replies
1
Views
2K
  • · Replies 21 ·
Replies
21
Views
6K
  • · Replies 15 ·
Replies
15
Views
2K
  • · Replies 2 ·
Replies
2
Views
3K
Replies
4
Views
5K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 1 ·
Replies
1
Views
3K