<jupyter_start><jupyter_text>Problem 1 **Part (b)** - The problem is of a particle moving in potential $V(x) =  \alpha x^2/2 + \beta x^4/4$<jupyter_code>def V(alpha,beta,x):
    x = np.asarray(x)
    return alpha*x**2 + beta*x**4

params = [[3,-1],[-3,1],[0.25,0.25],[-0.25,-0.25]]
x = np.linspace(-2,2,1000)

#plt.figure(figsize=(4,4))

for parameter in params:
    alpha, beta = parameter
    plt.plot(x,V(alpha,beta,x),label=r'$\alpha = %s, \beta = %s$'%(alpha,beta))
plt.xlabel('$x$')
plt.ylabel('$V(x)$')
plt.legend()
plt.savefig('1.png')<jupyter_output><empty_output><jupyter_text>As is clearly evident from the plots (and the equation for $V(x)$),the function will have an extremum as $x=0$, irrespective of the value of $\alpha$ and $\beta$.* For $(\alpha,\beta)=(3,-1)$, the potential is bounded from above. * For $(\alpha,\beta)=(-3,1)$, the potential is bounded from below* For $(\alpha,\beta)=(0.25,0.25)$, the potential is bounded from below* For $(\alpha,\beta)=(-0.25,-0.25)$, the potential is bounded from below **Part (c)** -When $\delta = 0$, the energy can be written as $E = m\dot{x}^2/2 + \alpha x^2/2 + \beta x^4/4$. In the phase space, a constant value of energy will give a closed curve for all values of $\alpha$ and $\beta$, except for the case when $\alpha < 0$ and $\beta < 0$.<jupyter_code>params = [[3,-1],[-3,1],[0.25,0.25]]

def xdot(E,m,alpha,beta,x):
    x = np.asarray(x)
    return np.sqrt((2./m)*(E - V(alpha,beta,x)))

m = 1.0
E = 1.0
for parameter in params:
    alpha, beta = parameter
    xd = xdot(E,m,alpha,beta,x)
    plt.plot(np.append(x,x),np.append(xd,-xd),label=r'$\alpha = %s, \beta = %s$'%(alpha,beta))
plt.xlabel('$x$')
plt.ylabel('$\dot{x}$')
plt.legend()<jupyter_output><empty_output><jupyter_text>We also solve the equations of motion numerically for the same set of parameter values.<jupyter_code>params = [[3,-1],[-3,1],[0.25,0.25]]
for alpha, beta in params:
    def f(t,y):
        x = y[0]
        xd = y[1]
        return np.array([xd, -alpha*x - beta*x**3])
    ini = [0,1]
    sol = scipy.integrate.solve_ivp(f,[0,10],[ini[0],ini[1]],
                                        t_eval=np.linspace(0,10,100))
    plt.plot(sol.y[0],sol.y[1],label=r'$\alpha = %s, \beta = %s$'%(alpha,beta))
plt.xlabel('$x$')
plt.ylabel('$\dot{x}$')
plt.legend()
plt.show()<jupyter_output><empty_output><jupyter_text>**Part (e)**When $\delta \ne 0$, there is dissipation in the system, and hence the phase space plots will differ. We now solve the resultant equation of motion $m \ddot{x} + \delta \dot{x} + \alpha x + \beta x^3 = 0$ numerically (taking $m=1)$.<jupyter_code>params =  [[3,-1,0.25],[-3,1,0.25],[0.25,0.25,0.25]]
for alpha, beta, delta in params:
    def f(t,y):
        x = y[0]
        xd = y[1]
        return np.array([xd, -delta*xd -alpha*x - beta*x**3])
    ini = [0,1]
    sol = scipy.integrate.solve_ivp(f,[0,100],[ini[0],ini[1]],
                                        t_eval=np.linspace(0,50,10000))
    plt.plot(sol.y[0],sol.y[1],label=r'$\alpha = %s, \beta = %s$'%(alpha,beta))
plt.xlabel('$x$')
plt.ylabel('$\dot{x}$')
plt.legend()
plt.show()<jupyter_output><empty_output><jupyter_text>**Part(h)** - Poincare Plot<jupyter_code>params = [[-3,1]]
for alpha, beta in params:
    def f(t,y):
        x = y[0]
        xd = y[1]
        return np.array([xd, -alpha*x - beta*x**3 + np.cos(4.*t)])
    ini = [0,1]
    sol = scipy.integrate.solve_ivp(f,[0,10000],[ini[0],ini[1]],rtol=1e-7,atol=1e-7)
    #plt.plot(sol.y[0],sol.y[1])
    q_arr = sol.y[0]
    qdot_arr = sol.y[1]
    time = sol.t
    q = interp1d(time,q_arr)
    qdot = interp1d(time,qdot_arr)
    tm = np.arange(1,10000,np.pi/4.)
    tm_1 = np.linspace(0,10,10000)
    plt.plot(q(tm_1),qdot(tm_1))
    plt.xlabel('$x$')
    plt.ylabel('$\dot{x}$')
    
    plt.figure()
    plt.scatter(q(tm),qdot(tm),s=1)
    plt.xlabel('$x$')
    plt.ylabel('$\dot{x}$')
    plt.title('Poincare Plot')
plt.show()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.21938259109311742, 'fraction_numerical': 0.04807692307692308, 'mean_word_length': 3.522883295194508, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '514002', 'license': 'MIT', 'n_tokens_mistral': 1743, 'n_tokens_neox': 1635, 'n_words': 338, 'path': 'sem1/cmech/assign_1/Problem 1.ipynb', 'repo_name': 'adivijaykumar/courses', 'size': '3952'}