title: Python: Fourth Order Runge-Kutta Method
body: <pre><code>from math import sin
  from numpy import arange
  from pylab import plot,xlabel,ylabel,show
  def answer():
      print('Part a:')
      print(low(x,t))
      print('First Graph')
      print('')
  
  
  def low(x,t):
      return 1/RC * (V_in - V_out)
  
  a = 0.0
  b = 10.0
  N = 1000
  h = (b-a)/N
  RC = 0.01
  V_out = 0.0
  
  tpoints = arange(a,b,h)
  xpoints = []
  x = 0.0
  
  for t in tpoints:
      xpoints.append(x)
      k1 = h*f(x,t)
      k2 = h*f(x+0.5*k1,t+0.5*h)
      k3 = h*f(x+0.5*k2,t+0.5*h)
      k4 = h*f(x+k3,t+h)
      x += (k1+2*k2+2*k3+k4)/6
  
  plot(tpoints,xpoints)
  xlabel("t")
  ylabel("x(t)")
  show()
  </code></pre>
  
  <p>So I have the fourth order runge kutta method coded but the part I'm trying to fit in is where the problem say V_in(t) = 1   if [2t] is even or -1   if [2t] is odd.</p>
  
  <p>Also the I'm not sure if I'm suppose to return this equation:
  return 1/RC * (V_in - V_out)</p>
  
  <p>Here is the problem: </p>
  
  <p><a href="http://i.stack.imgur.com/59ouu.png" rel="nofollow">Problem 8.1</a></p>
  
  <p>It would be greatly appreciated if you help me out! </p>