mirror of
https://github.com/vale981/phys512
synced 2025-03-04 09:11:37 -05:00
Updates HW2
This commit is contained in:
parent
afe773d3a0
commit
445a4bc18d
2 changed files with 28 additions and 5 deletions
12
hw2.md
12
hw2.md
|
@ -18,11 +18,13 @@ $$\epsilon_1\approx {I_1-I_2\over 15}$$
|
|||
|
||||
for Simpson's rule. [*Hint*: write the true value of the integral as $I=I_1+\epsilon_1=I_2+\epsilon_2$ and use the fact that you know how the errors scale with $\Delta x$.]
|
||||
|
||||
(c) The file `hw2_data.txt` has 21 samples of a function $f(x)$ between $x=1$ and $x=2$. Column 1 in the file gives the $x$ values and column 2 the corresponding $f(x)$ values. Write a code that reads in the data from the file, integrates the function from $x=1$ to $x=2$, and then carries out the procedure above to estimate the error in the integration. [*Hint*: One option to read in the data is to use [`numpy.loadtxt`](https://numpy.org/doc/stable/reference/generated/numpy.loadtxt.html) which can read the data straight into numpy arrays.]
|
||||
(c) The file [`hw2_data.txt`](https://github.com/andrewcumming/phys512/blob/main/hw2_data.txt) has 21 samples of a function $f(x)$ between $x=1$ and $x=2$. Column 1 in the file gives the $x$ values and column 2 the corresponding $f(x)$ values. Write a code that reads in the data from the file, integrates the function from $x=1$ to $x=2$, and then carries out the procedure above to estimate the error in the integration. [*Hint*: One option to read in the data is to use [`numpy.loadtxt`](https://numpy.org/doc/stable/reference/generated/numpy.loadtxt.html) which can read the data straight into numpy arrays.]
|
||||
|
||||
Do this for both the trapezoidal and Simpson's rules. Is the answer you get for the error what you would expect in each case?
|
||||
Do this for both the trapezoidal and Simpson's rules. Discuss whether the answer you get for the error makes sense given what you know about the accuracy of the trapezoidal rule and Simpson's rule.
|
||||
|
||||
(d) *Optional*: An extension of this question is to use this idea to write an adaptive integrator that takes a function $f(x)$ and iteratively increases the number of integration points until a specified precision is reached.
|
||||
(d) Because I generated the data points in the file, I know the true underlying function and its integral -- the true value of the integral is `1.482974344768713` (as obtained by `scipy.integrate.quad`). Use this value to calculate the true error of the trapezoidal and Simpson's rule integrals and compare with your estimate from part (c). Does our estimate procedure from part (b) do a good job at estimating the error?
|
||||
|
||||
(e) *Optional*: An extension of this question is to use this idea to write an adaptive integrator that takes a function $f(x)$ and iteratively increases the number of integration points until a specified precision is reached.
|
||||
|
||||
|
||||
2. **Chemical potential of a Fermi gas**
|
||||
|
@ -36,9 +38,9 @@ where you can assume that the particles are non-relativistic so $p = \sqrt{2m\ep
|
|||
(a) Numerically evaluate the integral for different values of $\mu/k_BT$ (from large and negative to large and positive) and set up an interpolating function that returns $\mu/k_BT$ as a function of $N/n_QV$ where
|
||||
$n_Q=(m k_BT/2\pi\hbar^2)^{3/2}$. [You may find it helpful to simplify the integral first, for example to write the integration variable as $x=\epsilon/k_BT$.]
|
||||
|
||||
(b) Assess the errors in your calculation: describe the different sources of error and estimate the accuracy of your final value of $\mu(N, T)$.
|
||||
(b) Assess the errors in your calculation: describe the sources of error and estimate the accuracy of your final value of $\mu(N, T)$.
|
||||
|
||||
(c) Compare your results with the analytic limits of non-degenerate $\mu = k_BT \ln (n/n_Q)$ and degenerate $\mu=E_F$ fermions (where $E_F = p_F^2/2m$ with $p_F=\hbar(3\pi^2 n)^{1/3}$ is the Fermi energy). Determine the region of parameter space where each of these limits is accurate to 0.1\%.
|
||||
(c) Compare your results with the analytic limits of non-degenerate $\mu = k_BT \ln (n/2n_Q)$ and degenerate $\mu=E_F$ fermions (where $E_F = p_F^2/2m$ with $p_F=\hbar(3\pi^2 n)^{1/3}$ is the Fermi energy). Determine the region of parameter space where each of these limits is accurate to 1\%.
|
||||
|
||||
|
||||
3. **Sampling the Maxwell-Boltzmann distribution**
|
||||
|
|
21
hw2_data.txt
Normal file
21
hw2_data.txt
Normal file
|
@ -0,0 +1,21 @@
|
|||
1.000000000000000000e+00 3.833049951722714010e-01
|
||||
1.050000000000000044e+00 4.236132045922697542e-01
|
||||
1.100000000000000089e+00 4.938416668738566662e-01
|
||||
1.149999999999999911e+00 6.015298748818670438e-01
|
||||
1.199999999999999956e+00 7.562256275428551611e-01
|
||||
1.250000000000000000e+00 9.673651762058040893e-01
|
||||
1.300000000000000044e+00 1.240010674549824499e+00
|
||||
1.350000000000000089e+00 1.568381308460616186e+00
|
||||
1.399999999999999911e+00 1.928970804410876205e+00
|
||||
1.449999999999999956e+00 2.277505759484860004e+00
|
||||
1.500000000000000000e+00 2.554866512706404524e+00
|
||||
1.550000000000000044e+00 2.703639367046938080e+00
|
||||
1.600000000000000089e+00 2.689507917609784027e+00
|
||||
1.649999999999999911e+00 2.515833625946386043e+00
|
||||
1.700000000000000178e+00 2.222176481372354129e+00
|
||||
1.750000000000000000e+00 1.867730306324478784e+00
|
||||
1.800000000000000044e+00 1.510013340025460282e+00
|
||||
1.850000000000000089e+00 1.189924054549335919e+00
|
||||
1.899999999999999911e+00 9.276032958975465315e-01
|
||||
1.950000000000000178e+00 7.264982581090186908e-01
|
||||
2.000000000000000000e+00 5.804096620472413148e-01
|
Loading…
Add table
Reference in a new issue