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
Can a rogue use sneak attack with weapons that have the thrown property even if they are not thrown?
Why isn't airport relocation done gradually?
Ubuntu Server install with full GUI
Looking for Correct Greek Translation for Heraclitus
Is "plugging out" electronic devices an American expression?
How to support a colleague who finds meetings extremely tiring?
Why do we hear so much about the Trump administration deciding to impose and then remove tariffs?
Multiply Two Integer Polynomials
How technical should a Scrum Master be to effectively remove impediments?
Why was M87 targetted for the Event Horizon Telescope instead of Sagittarius A*?
Who coined the term "madman theory"?
Is a "Democratic" Oligarchy-Style System Possible?
How to deal with fear of taking dependencies
Can one be advised by a professor who is very far away?
How to answer pointed "are you quitting" questioning when I don't want them to suspect
If I score a critical hit on an 18 or higher, what are my chances of getting a critical hit if I roll 3d20?
What do the Banks children have against barley water?
Can a flute soloist sit?
Am I thawing this London Broil safely?
Is there a symbol for a right arrow with a square in the middle?
Protecting Dualbooting Windows from dangerous code (like rm -rf)
Worn-tile Scrabble
A poker game description that does not feel gimmicky
FPGA - DIY Programming
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