In :%matplotlib inline import matplotlib.pyplot as plt import numpy as np import scipy.optimize as opt
The following potential is often used in Physics and other fields to describe symmetry breaking and is often known as the "hat potential":$$ V(x) = -a x^2 + b x^4 $$
Write a function
hat(x,a,b) that returns the value of this function:
In :def hat(x,a,b): v = (-a*(x**2))+(b*(x**4)) return v
In :assert hat(0.0, 1.0, 1.0)==0.0 assert hat(0.0, 1.0, 1.0)==0.0 assert hat(1.0, 10.0, 1.0)==-9.0
Plot this function over the range $x\in\left[-3,3\right]$ with $b=1.0$ and $a=5.0$:
In :a = 5.0 b = 1.0
In :x = np.linspace(-3, 3) plt.plot(x,hat(x,a,b)) plt.xlabel('X') plt.ylabel('V') plt.title('Hat Potential');
In [ ]:assert True # leave this to grade the plot
Write code that finds the two local minima of this function for $b=1.0$ and $a=5.0$.
scipy.optimize.minimizeto find the minima. You will have to think carefully about how to get this function to find both minima.
In [ ]:# YOUR CODE HERE raise NotImplementedError()
In [ ]:assert True # leave this for grading the plot
To check your numerical results, find the locations of the minima analytically. Show and describe the steps in your derivation using LaTeX equations. Evaluate the location of the minima using the above parameters.
YOUR ANSWER HERE