Skip to content

Commit eeebcff

Browse files
committed
lesson 4: unpack state, and use raw strings in figures
1 parent 4c8a97e commit eeebcff

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

notebooks_en/4_Birdseye_Vibrations.ipynb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@
300300
"pyplot.xlabel('Time [s]')\n",
301301
"pyplot.ylabel('Position, $x$ [m]')\n",
302302
"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));"
304304
]
305305
},
306306
{
@@ -406,8 +406,8 @@
406406
" -------\n",
407407
" derivs: derivatives of the state vector\n",
408408
" '''\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",
411411
" return derivs"
412412
]
413413
},
@@ -457,7 +457,7 @@
457457
"pyplot.xlabel('Time [s]')\n",
458458
"pyplot.ylabel('Position, $x$ [m]')\n",
459459
"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,ω));"
461461
]
462462
},
463463
{
@@ -534,7 +534,7 @@
534534
"pyplot.xlabel('Time [s]')\n",
535535
"pyplot.ylabel('Position, $x$ [m]')\n",
536536
"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,ω));"
538538
]
539539
},
540540
{

0 commit comments

Comments
 (0)