Python Forum
Thread Rating:
  • 1 Vote(s) - 2 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to plot a Graph
#1
Hello, I have an equation and need to plot a graph using the Euler method, the code looks like this:

h = 0.01
x = [0.0]
y = [0]
n = int(30/h)

def f(y,x):
    eq = #something
     return #something

for i in range (0,n):
    xn = (i+1)*h
    yn = y[i] + f(y[i],x[i])*h
    x.append(xn)
    y.append(yn)
    #print (x[i],y[i])
    
    
plt.plot(x,y)
plt.xlabel("Time(t)")
plt.ylabel("Concentration(Cs)")
plt.title("Concentration by Time")
plt.show()
But I have an equation, this one:

10(105 + log(900)) -5*t = S^2 /2 +20S +20log(S)

So when t = 0, S = 30. So I need to plot the values of S as the time increase.

Any help how to solve the equation?? In fact, I need anything that use the euler method that allows me to plot the graph.

Thanks in advance!
Reply


Messages In This Thread
How to plot a Graph - by Kamo - May-11-2017, 05:27 PM
RE: How to plot a Graph - by Larz60+ - May-11-2017, 10:04 PM
RE: How to plot a Graph - by zivoni - May-12-2017, 12:22 PM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020