Use matplotlib to plot the functions $y = x^3 + 3x^2 - x + 0.3 $ and $y = sin x$ [closed] The 2019 Stack Overflow Developer Survey Results Are InHow to plot logarithm functions on Google search graphing toolShape of graph and plotHow to plot bivariate function involving modulus and floor functions?How to make a good “infinity plot”?Help finding turning points to plot quartic and cubic functionsWhat free tools can I use to plot complex functions on the complex plane?How to plot these functions? (Utility functions)Verify the Riemann Hypothesis for first 1000 zeros.Plot Products of Airy FunctionsPlot 2 or more parametric functions MAXIMA
What is the most effective way of iterating a std::vector and why?
Did Scotland spend $250,000 for the slogan "Welcome to Scotland"?
Does coating your armor in silver add any effects?
How to notate time signature switching consistently every measure
Pokemon Turn Based battle (Python)
What could be the right powersource for 15 seconds lifespan disposable giant chainsaw?
FPGA - DIY Programming
Why do UK politicians seemingly ignore opinion polls on Brexit?
What is the meaning of Triage in Cybersec world?
Why not take a picture of a closer black hole?
Should I use my personal e-mail address, or my workplace one, when registering to external websites for work purposes?
Identify boardgame from Big movie
One word riddle: Vowel in the middle
Why can Shazam fly?
Looking for Correct Greek Translation for Heraclitus
Is there a symbol for a right arrow with a square in the middle?
Why do we hear so much about the Trump administration deciding to impose and then remove tariffs?
Loose spokes after only a few rides
Is flight data recorder erased after every flight?
Is "plugging out" electronic devices an American expression?
"as much details as you can remember"
Aging parents with no investments
What do the Banks children have against barley water?
Are there incongruent pythagorean triangles with the same perimeter and same area?
Use matplotlib to plot the functions $y = x^3 + 3x^2 - x + 0.3 $ and $y = sin x$ [closed]
The 2019 Stack Overflow Developer Survey Results Are InHow to plot logarithm functions on Google search graphing toolShape of graph and plotHow to plot bivariate function involving modulus and floor functions?How to make a good “infinity plot”?Help finding turning points to plot quartic and cubic functionsWhat free tools can I use to plot complex functions on the complex plane?How to plot these functions? (Utility functions)Verify the Riemann Hypothesis for first 1000 zeros.Plot Products of Airy FunctionsPlot 2 or more parametric functions MAXIMA
$begingroup$
I'm new to Python coding and wondered if someone could give me the coding to plot these two graphs on the same program.
This is what I have so far, exactly as typed on Python, however I know that parts are incorrect.
from matplotlib import pyplot as plt
x = [float(i)/100 for i in range(0,101)]
y = [sin(x)]
plt.plot(x,y)
graphing-functions math-software python
$endgroup$
closed as unclear what you're asking by Somos, Javi, Leucippus, YiFan, Alex Provost Mar 24 at 14:15
Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.
add a comment |
$begingroup$
I'm new to Python coding and wondered if someone could give me the coding to plot these two graphs on the same program.
This is what I have so far, exactly as typed on Python, however I know that parts are incorrect.
from matplotlib import pyplot as plt
x = [float(i)/100 for i in range(0,101)]
y = [sin(x)]
plt.plot(x,y)
graphing-functions math-software python
$endgroup$
closed as unclear what you're asking by Somos, Javi, Leucippus, YiFan, Alex Provost Mar 24 at 14:15
Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.
add a comment |
$begingroup$
I'm new to Python coding and wondered if someone could give me the coding to plot these two graphs on the same program.
This is what I have so far, exactly as typed on Python, however I know that parts are incorrect.
from matplotlib import pyplot as plt
x = [float(i)/100 for i in range(0,101)]
y = [sin(x)]
plt.plot(x,y)
graphing-functions math-software python
$endgroup$
I'm new to Python coding and wondered if someone could give me the coding to plot these two graphs on the same program.
This is what I have so far, exactly as typed on Python, however I know that parts are incorrect.
from matplotlib import pyplot as plt
x = [float(i)/100 for i in range(0,101)]
y = [sin(x)]
plt.plot(x,y)
graphing-functions math-software python
graphing-functions math-software python
edited Mar 24 at 3:05
Lee David Chung Lin
4,47841242
4,47841242
asked Mar 23 at 18:55
BrookeBrooke
63
63
closed as unclear what you're asking by Somos, Javi, Leucippus, YiFan, Alex Provost Mar 24 at 14:15
Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.
closed as unclear what you're asking by Somos, Javi, Leucippus, YiFan, Alex Provost Mar 24 at 14:15
Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
$begingroup$
First, you need a larger range for $x$ to see a nice sinusoid, say from $0$ to $2pi$.
Second, specify $y$ as a list comprehension, too:
from matplotlib import pyplot as plt
import math
x = [float(i)/100 for i in range(0, 628)]
y = [math.sin(z) for z in x]
plt.plot(x,y)
If you want to plot both graphs one over the other (what isn't generally a good idea because those 2 function are so different, that in the default settings the sine function will appear as to coincide with the x-axis), the code may be as follows (I extended the range for $x$, and set limits for $y$-axes):
from matplotlib import pyplot as plt
import math
BOUND = 1000
x = [float(i)/100 for i in range(-BOUND, +BOUND)]
y = [math.sin(z) for z in x]
w = [z**3 + 3*z**2 - z + 0.3 for z in x]
plt.ylim(-7,+7)
plt.plot(x, y)
plt.plot(x, w)
$endgroup$
$begingroup$
Ah I see, so how would I add the second y graph onto this?
$endgroup$
– Brooke
Mar 23 at 19:16
$begingroup$
Do you mean to overlay this graph, or to create other one (in the other window)?
$endgroup$
– MarianD
Mar 23 at 19:30
$begingroup$
They will both be on the same axis so it will over lay it and show both
$endgroup$
– Brooke
Mar 23 at 19:38
$begingroup$
It's not a good idea, because there is such difference between the 2 functions that the sine function will appear to coincident with x axis. See: $sin(5pi /2) = 1$, while $x^3 + 3x^2 - x + 0.3$ will be for the same $x =5pi /2$ approximately $662$.
$endgroup$
– MarianD
Mar 23 at 20:01
$begingroup$
That what the assignment question is asking me to do as I am to find the real solutions of the graphs.
$endgroup$
– Brooke
Mar 23 at 20:10
|
show 2 more comments
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
$begingroup$
First, you need a larger range for $x$ to see a nice sinusoid, say from $0$ to $2pi$.
Second, specify $y$ as a list comprehension, too:
from matplotlib import pyplot as plt
import math
x = [float(i)/100 for i in range(0, 628)]
y = [math.sin(z) for z in x]
plt.plot(x,y)
If you want to plot both graphs one over the other (what isn't generally a good idea because those 2 function are so different, that in the default settings the sine function will appear as to coincide with the x-axis), the code may be as follows (I extended the range for $x$, and set limits for $y$-axes):
from matplotlib import pyplot as plt
import math
BOUND = 1000
x = [float(i)/100 for i in range(-BOUND, +BOUND)]
y = [math.sin(z) for z in x]
w = [z**3 + 3*z**2 - z + 0.3 for z in x]
plt.ylim(-7,+7)
plt.plot(x, y)
plt.plot(x, w)
$endgroup$
$begingroup$
Ah I see, so how would I add the second y graph onto this?
$endgroup$
– Brooke
Mar 23 at 19:16
$begingroup$
Do you mean to overlay this graph, or to create other one (in the other window)?
$endgroup$
– MarianD
Mar 23 at 19:30
$begingroup$
They will both be on the same axis so it will over lay it and show both
$endgroup$
– Brooke
Mar 23 at 19:38
$begingroup$
It's not a good idea, because there is such difference between the 2 functions that the sine function will appear to coincident with x axis. See: $sin(5pi /2) = 1$, while $x^3 + 3x^2 - x + 0.3$ will be for the same $x =5pi /2$ approximately $662$.
$endgroup$
– MarianD
Mar 23 at 20:01
$begingroup$
That what the assignment question is asking me to do as I am to find the real solutions of the graphs.
$endgroup$
– Brooke
Mar 23 at 20:10
|
show 2 more comments
$begingroup$
First, you need a larger range for $x$ to see a nice sinusoid, say from $0$ to $2pi$.
Second, specify $y$ as a list comprehension, too:
from matplotlib import pyplot as plt
import math
x = [float(i)/100 for i in range(0, 628)]
y = [math.sin(z) for z in x]
plt.plot(x,y)
If you want to plot both graphs one over the other (what isn't generally a good idea because those 2 function are so different, that in the default settings the sine function will appear as to coincide with the x-axis), the code may be as follows (I extended the range for $x$, and set limits for $y$-axes):
from matplotlib import pyplot as plt
import math
BOUND = 1000
x = [float(i)/100 for i in range(-BOUND, +BOUND)]
y = [math.sin(z) for z in x]
w = [z**3 + 3*z**2 - z + 0.3 for z in x]
plt.ylim(-7,+7)
plt.plot(x, y)
plt.plot(x, w)
$endgroup$
$begingroup$
Ah I see, so how would I add the second y graph onto this?
$endgroup$
– Brooke
Mar 23 at 19:16
$begingroup$
Do you mean to overlay this graph, or to create other one (in the other window)?
$endgroup$
– MarianD
Mar 23 at 19:30
$begingroup$
They will both be on the same axis so it will over lay it and show both
$endgroup$
– Brooke
Mar 23 at 19:38
$begingroup$
It's not a good idea, because there is such difference between the 2 functions that the sine function will appear to coincident with x axis. See: $sin(5pi /2) = 1$, while $x^3 + 3x^2 - x + 0.3$ will be for the same $x =5pi /2$ approximately $662$.
$endgroup$
– MarianD
Mar 23 at 20:01
$begingroup$
That what the assignment question is asking me to do as I am to find the real solutions of the graphs.
$endgroup$
– Brooke
Mar 23 at 20:10
|
show 2 more comments
$begingroup$
First, you need a larger range for $x$ to see a nice sinusoid, say from $0$ to $2pi$.
Second, specify $y$ as a list comprehension, too:
from matplotlib import pyplot as plt
import math
x = [float(i)/100 for i in range(0, 628)]
y = [math.sin(z) for z in x]
plt.plot(x,y)
If you want to plot both graphs one over the other (what isn't generally a good idea because those 2 function are so different, that in the default settings the sine function will appear as to coincide with the x-axis), the code may be as follows (I extended the range for $x$, and set limits for $y$-axes):
from matplotlib import pyplot as plt
import math
BOUND = 1000
x = [float(i)/100 for i in range(-BOUND, +BOUND)]
y = [math.sin(z) for z in x]
w = [z**3 + 3*z**2 - z + 0.3 for z in x]
plt.ylim(-7,+7)
plt.plot(x, y)
plt.plot(x, w)
$endgroup$
First, you need a larger range for $x$ to see a nice sinusoid, say from $0$ to $2pi$.
Second, specify $y$ as a list comprehension, too:
from matplotlib import pyplot as plt
import math
x = [float(i)/100 for i in range(0, 628)]
y = [math.sin(z) for z in x]
plt.plot(x,y)
If you want to plot both graphs one over the other (what isn't generally a good idea because those 2 function are so different, that in the default settings the sine function will appear as to coincide with the x-axis), the code may be as follows (I extended the range for $x$, and set limits for $y$-axes):
from matplotlib import pyplot as plt
import math
BOUND = 1000
x = [float(i)/100 for i in range(-BOUND, +BOUND)]
y = [math.sin(z) for z in x]
w = [z**3 + 3*z**2 - z + 0.3 for z in x]
plt.ylim(-7,+7)
plt.plot(x, y)
plt.plot(x, w)
edited Mar 23 at 21:22
answered Mar 23 at 19:15
MarianDMarianD
2,2611618
2,2611618
$begingroup$
Ah I see, so how would I add the second y graph onto this?
$endgroup$
– Brooke
Mar 23 at 19:16
$begingroup$
Do you mean to overlay this graph, or to create other one (in the other window)?
$endgroup$
– MarianD
Mar 23 at 19:30
$begingroup$
They will both be on the same axis so it will over lay it and show both
$endgroup$
– Brooke
Mar 23 at 19:38
$begingroup$
It's not a good idea, because there is such difference between the 2 functions that the sine function will appear to coincident with x axis. See: $sin(5pi /2) = 1$, while $x^3 + 3x^2 - x + 0.3$ will be for the same $x =5pi /2$ approximately $662$.
$endgroup$
– MarianD
Mar 23 at 20:01
$begingroup$
That what the assignment question is asking me to do as I am to find the real solutions of the graphs.
$endgroup$
– Brooke
Mar 23 at 20:10
|
show 2 more comments
$begingroup$
Ah I see, so how would I add the second y graph onto this?
$endgroup$
– Brooke
Mar 23 at 19:16
$begingroup$
Do you mean to overlay this graph, or to create other one (in the other window)?
$endgroup$
– MarianD
Mar 23 at 19:30
$begingroup$
They will both be on the same axis so it will over lay it and show both
$endgroup$
– Brooke
Mar 23 at 19:38
$begingroup$
It's not a good idea, because there is such difference between the 2 functions that the sine function will appear to coincident with x axis. See: $sin(5pi /2) = 1$, while $x^3 + 3x^2 - x + 0.3$ will be for the same $x =5pi /2$ approximately $662$.
$endgroup$
– MarianD
Mar 23 at 20:01
$begingroup$
That what the assignment question is asking me to do as I am to find the real solutions of the graphs.
$endgroup$
– Brooke
Mar 23 at 20:10
$begingroup$
Ah I see, so how would I add the second y graph onto this?
$endgroup$
– Brooke
Mar 23 at 19:16
$begingroup$
Ah I see, so how would I add the second y graph onto this?
$endgroup$
– Brooke
Mar 23 at 19:16
$begingroup$
Do you mean to overlay this graph, or to create other one (in the other window)?
$endgroup$
– MarianD
Mar 23 at 19:30
$begingroup$
Do you mean to overlay this graph, or to create other one (in the other window)?
$endgroup$
– MarianD
Mar 23 at 19:30
$begingroup$
They will both be on the same axis so it will over lay it and show both
$endgroup$
– Brooke
Mar 23 at 19:38
$begingroup$
They will both be on the same axis so it will over lay it and show both
$endgroup$
– Brooke
Mar 23 at 19:38
$begingroup$
It's not a good idea, because there is such difference between the 2 functions that the sine function will appear to coincident with x axis. See: $sin(5pi /2) = 1$, while $x^3 + 3x^2 - x + 0.3$ will be for the same $x =5pi /2$ approximately $662$.
$endgroup$
– MarianD
Mar 23 at 20:01
$begingroup$
It's not a good idea, because there is such difference between the 2 functions that the sine function will appear to coincident with x axis. See: $sin(5pi /2) = 1$, while $x^3 + 3x^2 - x + 0.3$ will be for the same $x =5pi /2$ approximately $662$.
$endgroup$
– MarianD
Mar 23 at 20:01
$begingroup$
That what the assignment question is asking me to do as I am to find the real solutions of the graphs.
$endgroup$
– Brooke
Mar 23 at 20:10
$begingroup$
That what the assignment question is asking me to do as I am to find the real solutions of the graphs.
$endgroup$
– Brooke
Mar 23 at 20:10
|
show 2 more comments