Exercises on differential equation ================================== The pendulum equation --------------------- We consider the equation .. math:: \theta^{\prime\prime} = -\sin{\theta} Write a function that returns an array containing the position and the angular velocity of the pendulum for :math:`N` instants :math:`t_i` between 0 and :math:`T`. The initial position is :math:`\theta=0`. Plot the phase space trajectory for different values of the initial velocity. Angle will be represented between -π and π. Solving the Schrödinger equation using the finite element method ---------------------------------------------------------------- Let us consider the Schrödinger equation with hbar = m = 1 .. math:: \frac{d\psi}{dt} =-i\left( -\frac12 \frac{d^2\psi}{dx^2} + V(x)\psi\right) The potential is :math:`V(x) = \frac12 k x^2` with :math:`\kappa=.5`. To solve the equation, we will truncate the x-axis to values between :math:`x_\mathrm{min}` and :math:`x_\mathrm{max}`. We will also discretize the x-axis with small steps (:math:`\Delta x`). The term :math:`\frac{d^2\psi}{dx^2}` will be approximated using :math:`\frac{\psi(x+\Delta x) - 2\psi(x) + \psi(x-\Delta x)}{\Delta x^2}`. For the initial state, we will take a Gaussian distribution :math:`e^{-\alpha(x-x_0)^2}`. We will use :math:`\alpha = \frac 12` and :math:`x_0=1`. Calculate and plot :math:`|{\psi(x,t)}|^2` as a function of :math:`x` for :math:`t=1` using the ``zvode`` solver with an absolute precision of :math:`10{^-3}`.