|
300 | 300 | "pyplot.xlabel('Time [s]')\n", |
301 | 301 | "pyplot.ylabel('Position, $x$ [m]')\n", |
302 | 302 | "pyplot.title('Damped spring-mass system with Euler-Cromer method.\\n')\n", |
303 | | - "pyplot.figtext(0.1,-0.1,'$m={:.1f}$, $k={:.1f}$, $b={:.1f}$'.format(m,k,b));" |
| 303 | + "pyplot.figtext(0.1,-0.1, r'$m={:.1f}$, $k={:.1f}$, $b={:.1f}$'.format(m,k,b));" |
304 | 304 | ] |
305 | 305 | }, |
306 | 306 | { |
|
406 | 406 | " -------\n", |
407 | 407 | " derivs: derivatives of the state vector\n", |
408 | 408 | " '''\n", |
409 | | - " \n", |
410 | | - " derivs = numpy.array([state[1], 1/m*(F(time)-k*state[0]-b*state[1])])\n", |
| 409 | + " x, v = state \n", |
| 410 | + " derivs = numpy.array([v, 1/m*(F(time)-k*x -b*v)])\n", |
411 | 411 | " return derivs" |
412 | 412 | ] |
413 | 413 | }, |
|
457 | 457 | "pyplot.xlabel('Time [s]')\n", |
458 | 458 | "pyplot.ylabel('Position, $x$ [m]')\n", |
459 | 459 | "pyplot.title('Driven spring-mass system with Euler-Cromer method.\\n')\n", |
460 | | - "pyplot.figtext(0.1,-0.1,'$m={:.1f}$, $k={:.1f}$, $b={:.1f}$, $A={:.1f}$, $\\omega={:.1f}$'.format(m,k,b,A,ω));" |
| 460 | + "pyplot.figtext(0.1,-0.1,r'$m={:.1f}$, $k={:.1f}$, $b={:.1f}$, $A={:.1f}$, $\\omega={:.1f}$'.format(m,k,b,A,ω));" |
461 | 461 | ] |
462 | 462 | }, |
463 | 463 | { |
|
534 | 534 | "pyplot.xlabel('Time [s]')\n", |
535 | 535 | "pyplot.ylabel('Position, $x$ [m]')\n", |
536 | 536 | "pyplot.title('Driven spring-mass system with Euler-Cromer method.\\n')\n", |
537 | | - "pyplot.figtext(0.1,-0.1,'$m={:.1f}$, $k={:.1f}$, $b={:.1f}$, $A={:.1f}$, $\\omega={:.1f}$'.format(m,k,b,A,ω));" |
| 537 | + "pyplot.figtext(0.1,-0.1, r'$m={:.1f}$, $k={:.1f}$, $b={:.1f}$, $A={:.1f}$, $\\omega={:.1f}$'.format(m,k,b,A,ω));" |
538 | 538 | ] |
539 | 539 | }, |
540 | 540 | { |
|
0 commit comments