/*! This file is auto-generated */ .wp-block-button__link{color:#fff;background-color:#32373c;border-radius:9999px;box-shadow:none;text-decoration:none;padding:calc(.667em + 2px) calc(1.333em + 2px);font-size:1.125em}.wp-block-file__button{background:#32373c;color:#fff;text-decoration:none} Problem 18 Rearranging Eq. (5.19) into a sl... [FREE SOLUTION] | 91Ó°ÊÓ

91Ó°ÊÓ

Rearranging Eq. (5.19) into a slightly more conventional form, we have: $$ \int_{a}^{b} f(x) \mathrm{d} x=h\left[\frac{1}{2} f(a)+\frac{1}{2} f(b)+\sum_{k=1}^{N-1} f(a+k h)\right]+\frac{1}{12} h^{2}\left[f^{\prime}(a)-f^{\prime}(b)\right]+\mathrm{O}\left(h^{4}\right) . $$ This result gives a value for the integral on the left which has an error of order \(h^{4}-a\) factor of \(h^{2}\) better than the error on the trapezoidal rule and as good as Simpson's rule. We can use this formula as a new rule for evaluating integrals, distinct from any of the others we have seen in this chapter. We might call it the "Euler-Maclaurin rule." a) Write a program to calculate the value of the integral \(\int_{0}^{2}\left(x^{4}-2 x+1\right) \mathrm{d} x\) using this formula. (This is the same integral that we studied in Example 5.1, whose true value is \(4.4\).) The order- \(h\) term in the formula is just the ordinary trapezoidal rule; the \(h^{2}\) term involves the derivatives \(f^{\prime}(a)\) and \(f^{\prime}(b)\), which you should evaluate using central differences, centered on \(a\) and \(b\) respectively. Note that the size of the interval you use for calculating the central differences does not have to equal the value of \(h\) used in the trapezoidal rule part of the calculation. An interval of about \(10^{-5}\) gives good values for the central differences. Use your program to evaluate the integral with \(N=10\) slices and compare the accuracy of the result with that obtained from the trapezoidal rule alone with the same number of slices. b) Good though it is, this integration method is not much used in practice. Suggest a reason why not.

Short Answer

Expert verified
Calculate the integral using the Euler-Maclaurin rule, compare with the trapezoidal rule, and discuss why this method is not commonly used.

Step by step solution

01

- Define the function and its derivative

Define the function to be integrated as \( f(x) = x^4 - 2x + 1 \) and its derivative \( f'(x) \). The derivative can be found using the central difference method: \[ f'(a) = \frac{f(a + \epsilon) - f(a - \epsilon)}{2\epsilon} \] \[ f'(b) = \frac{f(b + \epsilon) - f(b - \epsilon)}{2\epsilon} \] Use \( \epsilon = 10^{-5} \) as suggested.
02

- Discretize the interval

Divide the interval \([0,2]\) into \(N=10\) slices. The step size \( h \) is given by: \[ h = \frac{b - a}{N} = \frac{2 - 0}{10} = 0.2 \].
03

- Evaluate the main sum

Calculate the sum of function values at the slice points other than the endpoints, weighted by \( h \): \[ \sum_{k=1}^{N-1} f(a+kh) = f(0.2) + f(0.4) + ... + f(1.8) \].
04

- Compute the Euler-Maclaurin formula

Combine the components to evaluate the integral using the Euler-Maclaurin rule: \[ I = h \left[ \frac{1}{2} f(a) + \frac{1}{2} f(b) + \sum_{k=1}^{N-1} f(a+kh) \right] + \frac{1}{12} h^2 \left[f'(a) - f'(b)\right] + O(h^4) \].
05

- Compute the trapezoidal rule

Evaluate the integral using the trapezoidal rule for comparison: \[ I_{trap} = h \left[ \frac{1}{2} f(a) + \frac{1}{2} f(b) + \sum_{k=1}^{N-1} f(a+kh) \right] \].
06

- Compare results

Compare the results obtained from both the Euler-Maclaurin rule and the trapezoidal rule to the true value of the integral.
07

- Discuss reason for limited use

Discuss why this method is rarely used in practice, despite its accuracy. The reason is primarily its complexity and the availability of simpler and equally effective methods like Simpson's rule.

Unlock Step-by-Step Solutions & Ace Your Exams!

  • Full Textbook Solutions

    Get detailed explanations and key concepts

  • Unlimited Al creation

    Al flashcards, explanations, exams and more...

  • Ads-free access

    To over 500 millions flashcards

  • Money-back guarantee

    We refund you if you fail your exam.

Over 30 million students worldwide already upgrade their learning with 91Ó°ÊÓ!

Key Concepts

These are the key concepts you need to understand to accurately answer the question.

Euler-Maclaurin formula
The Euler-Maclaurin formula bridges the gap between discrete sums and continuous integrals. This formula is invaluable in numerical integration because it considerably improves the accuracy of simple methods like the trapezoidal rule. The Euler-Maclaurin formula takes a sum and adds correction terms involving derivatives to approximate an integral more precisely.
For example, in the exercise, the Euler-Maclaurin formula is given by: \[ \int_{a}^{b} f(x) \, \text{d} x = h \left[ \frac{1}{2} f(a) + \frac{1}{2} f(b) + \sum_{k=1}^{N-1} f(a+kh) \right] + \frac{1}{12} h^2 \[ f^{\prime}(a) - f^{\prime}(b) \] + \mathcal{O}(h^4) \]
Here, the first part is simply the trapezoidal rule, but the formula also includes a term with the second derivative \(f^{\prime}(a)-f^{\prime}(b)\). This term significantly reduces the error, making the integration much more accurate. However, in practice, it's not widely used due to its complexity and the need for computing the derivatives accurately.
Trapezoidal rule
The trapezoidal rule is a simple yet powerful method for approximating the definite integral of a function. The idea behind it is straightforward: you approximate the region under the curve as a series of trapezoids rather than rectangles.
Mathematically, for a function \(f\) over an interval \[a, b\], the trapezoidal rule is expressed as: \[ \int_{a}^{b} f(x) \, dx \approx \frac{h}{2} [ f(a) + 2f(a+h) + 2f(a+2h) + ... + 2f(b-h) + f(b) ] \]
Here, \(h \) is the width of each slice. In the exercise, it breaks down into: \[ h = \frac{b - a}{N} \] \[ I_{trap} = h \left[ \frac{1}{2} f(a) + \frac{1}{2} f(b) + \sum_{k=1}^{N-1} f(a+kh) \right] \]
Although the trapezoidal rule is straightforward and easy to apply, its accuracy is limited. This is why methods like the Euler-Maclaurin formula and Simpson's rule, which provide higher accuracy at similar computational costs, are often preferred.
Central difference method
The central difference method is essential when calculating derivatives, especially in numerical settings. It gives an approximation for the derivative of a function, and it's particularly useful in methods like the Euler-Maclaurin formula.
The central difference formula for the first derivative of a function \(f\) is given by: \[ f^{\prime}(x) \approx \frac{f(x + \epsilon) - f(x - \epsilon)}{2\epsilon} \]
In this formula, \(\epsilon\) is a small number used to calculate the difference. In the exercise, \(\epsilon = 10^{-5}\) is used to ensure a good approximation. This method is simple yet effective as it reduces truncation errors, making it suitable for high-accuracy numerical differentiation. By using \`centered differences\` around points \(a\) and \(b\), we can accurately compute the necessary derivatives for the Euler-Maclaurin formula.

One App. One Place for Learning.

All the tools & learning materials you need for study success - in one app.

Get started for free

Most popular questions from this chapter

Electric tield of a charge distribution: Suppose we have a distribution of charges and we want to calculate the resulting electric field. One way to do this is to first calculate the electric potential \(\phi\) and then take its gradient. For a point charge \(q\) at the origin, the electric potential at a distance \(r\) from the origin is \(\phi=q / 4 \pi \epsilon_{0} r\) and the electric field is \(\mathbf{E}=-\nabla \phi\). a) You have two charges, of \(\pm 1 \mathrm{C}, 10 \mathrm{~cm}\) apart. Calculate the resulting electric potential on a \(1 \mathrm{~m} \times 1 \mathrm{~m}\) square plane surrounding the charges and passing through them. Calculate the potential at \(1 \mathrm{~cm}\) spaced points in a grid and make a visualization on the screen of the potential using a density plot. b) Now calculate the partial derivatives of the potential with respect to \(x\) and \(y\) and hence find the electric field in the \(x y\) plane. Make a visualization of the field also. This is a little trickier than visualizing the potential, because the electric field has both magnitude and direction. One way to do it might be to make two density plots, one for the magnitude, and one for the direction, the latter using the "hsv"

The diffraction limit of a telescope Our ability to resolve detail in astronomical observation is limited by the diffraction of light in our telescopes. Light from stars can be treated effectively as coming from a point source at infinity. When such light, with wavelength \(\lambda\), passes through the circular aperture of a telescope (which we'll assume to have unit radius) and is focused by the telescope in the focal plane, it produces not a single dot, but a circular diffraction pattern consisting of central spot surrounded by a series of concentric rings. The intensity of the light in this diffraction pattern is given by $$ I(r)=\left(\frac{J_{1}(k r)}{k r}\right)^{2} $$ where \(r\) is the distance in the focal plane from the center of the diffraction pattern, \(k=2 \pi / \lambda\), and \(J_{1}(x)\) is a Bessel function. The Bessel functions \(J_{m}(x)\) are given by $$ J_{m}(x)=\frac{1}{\pi} \int_{0}^{\pi} \cos (m \theta-x \sin \theta) \mathrm{d} \theta, $$ where \(m\) is a nonnegative integer and \(x \geq 0\). a) Write a Python function \(J(m, x)\) that calculates the value of \(J_{m}(x)\) using Simpson's rule with \(N=1000\) points. Use your function in a program to make a plot, on a single graph, of the Bessel functions \(J_{0}, J_{1}\) and \(J_{2}\) as a function of \(x\) from \(x=0\) to \(x=20\). b) Make a second program that makes a density plot of the intensity of the circular diffraction pattern of a point light source with \(\lambda=500 \mathrm{~nm}\), in a square region of the focal plane, using the formula given above. Your picture should cover values of \(r\) from zero up to about \(1 \mu \mathrm{m}\).

Quantum uncertainty in the harmonic oscillator In units where all the constants are 1 , the wavefunction of the \(n\)th energy level of the one-dimensional quantum harmonic oscillator-i.e., a spinless point particle in a quadratic potential well-is given by $$ \psi_{n}(x)=\frac{1}{\sqrt{2^{11} n ! \sqrt{\pi}}} \mathrm{e}^{-x^{2} / 2} H_{n}(x), $$ for \(n=0 \ldots \infty\), where \(H_{n}(x)\) is the \(n\)th Hermite polynomial. Hermite polynomials satisfy a relation somewhat similar to that for the Fibonacci numbers, although more complex: $$ H_{n+1}(x)=2 x H_{n}(x)-2 n H_{n-1}(x) . $$ The first two Hermite polynomials are \(H_{0}(x)=1\) and \(H_{1}(x)=2 x\). a) Write a user-defined function \(\mathrm{H}(\mathrm{n}, \mathrm{x})\) that calculates \(H_{n}(x)\) for given \(x\) and any integer \(n \geq 0\). Use your function to make a plot that shows the harmonic oscillator wavefunctions for \(n=0,1,2\), and 3, all on the same graph, in the range \(x=-4\) to \(x=4\). Hint: There is a function factorial in the ath package that calculates the factorial of an integer. b) Make a separate plot of the wavefunction for \(n=30\) from \(x=-10\) to \(x=10\). Hint If your program takes too long to run in this case, then you're doing the calculation wrong-the program should take only a second or so to run. c) The quantum uncertainty in the position of a particle in the \(n\)th level of a harmonic oscillator can be quantified by its root-mean-square position \(\sqrt{\left\langle x^{2}\right\rangle}\), where $$ \left\langle x^{2}\right\rangle=\int_{-\infty}^{\infty} x^{2}\left|\psi_{n}(x)\right|^{2} \mathrm{~d} x . $$ Write a program that evaluates this integral using Gaussian quadrature on 100 points, then calculates the uncertainty (i.e., the root-mean-square position of the particle) for a given value of \(n\). Use your program to calculate the uncertainty for \(n=5\). You should get an answer in the vicinity of \(\sqrt{\left\langle x^{2}\right\rangle}=2.3 .\)

Diffraction gratings: Light with wavelength \(\lambda\) is incident on a diffraction grating of total width \(w\), gets diffracted, is focused with a lens of focal length \(f\), and falls on a screen: Theory tells us that the intensity of the diffraction pattern on the screen, a distance \(x\) from the central axis of the system, is given by $$ I(x)=\left|\int_{-w / 2}^{w / 2} \sqrt{q(u)} \mathrm{e}^{i 2 \pi x u / \lambda f} \mathrm{~d} u\right|^{2} $$ where \(q(u)\) is the intensity transmission function of the diffraction grating at a distance \(u\) from the central axis, i.e., the fraction of the incident light that the grating lets through. a) Consider a grating with transmission function \(q(u)=\sin ^{2} \alpha u\). What is the separation of the "slits" in this grating, expressed in terms of \(\alpha\) ? b) Write a Python function \(q(u)\) that returns the transmission function \(q(u)=\sin ^{2} \alpha u\) as above at position \(u\) for a grating whose slits have separation \(20 \mu \mathrm{m}\). c) Use your function in a program to calculate and graph the intensity of the diffraction pattern produced by such a grating having ten slits in total, if the incident light has wavelength \(\lambda=500 \mathrm{~nm}\). Assume the lens has a focal length of 1 meter and the screen is \(10 \mathrm{~cm}\) wide. You can use whatever method you think appropriate for doing the integral. Once you've made your choice you'll also need to decide the number of sample points you'll use. What criteria play into this decision? Notice that the integrand in the equation for \(I(x)\) is complex, so you will have to use complex variables in your program. As mentioned in Section 2.2.5, there is a version of the math package for use with complex variables called cmath. In particular you may find the exp function from cmath useful because it can calculate the exponentials of complex arguments. d) Create a visualization of how the diffraction pattern would look on the screen using a density plot (see Section 3.3). Your plot should look something like this: e) Modify your program further to make pictures of the diffraction patterns produced by gratings with the following profiles: i) A transmission profile that obeys \(q(u)=\sin ^{2} \alpha d \sin ^{2} \beta u\), with \(\alpha\) as before and the same total grating width \(w\), and \(\beta=\frac{1}{2} \alpha\). ii) Two "square" slits, meaning slits with \(100 \%\) transmission through the slit and \(0 \%\) transmission everywhere else. Calculate the diffraction pattern for non-identical slits, one \(10 \mu \mathrm{m}\) wide and the other \(20 \mu \mathrm{m}\) wide, with a \(60 \mu \mathrm{m}\) gap between the two.

Gravitational pull of a uniform sheet A uniform square sheet of metal is floating motionless in space: The sheet is \(10 \mathrm{~m}\) on a side and of negligible thickness, and it has a mass of 10 metric tonnes. a) Consider the gravitational force due to the plate felt by a point mass of \(1 \mathrm{~kg}\) a distance \(z\) from the center of the square, in the direction perpendicular to the sheet, as shown above. Show that the component of the force along the \(z\)-axis is $$ F_{z}=G \sigma z \iint_{-L / 2}^{L / 2} \frac{\mathrm{d} x \mathrm{~d} y}{\left(x^{2}+y^{2}+z_{2}^{2}\right)^{3 / 2}}, $$ where \(G=6.674 \times 10^{-11} \mathrm{~m}^{3} \mathrm{~kg}^{-1} \mathrm{~s}^{-2}\) is Newton's gravitational constant and \(\sigma\) is the mass per unit area of the sheet. b) Write a program to calculate and plot the force as a function of \(z\) from \(z=0\) to \(z=10 \mathrm{~m}\). For the double integral use (double) Gaussian quadrature, as in Eq. (5.82), with 100 sample points along each axis. c) You should see a smooth curve, except at very small values of \(z\), where the force should drop off suddenly to zero. This drop is not a real effect, but an artifact of the way we have done the calculation. Explain briefly where this artifact comes from and suggest a strategy to remove it, or at least to decrease its size. This calculation can thought of as a model for the gravitational pull of a galaxy. Most of the mass in a spiral galaxy (such as our own Milky Way) lies in a thin plane or disk passing through the galactic center, and the gravitational pull exerted by that plane on bodies outside the galaxy can be calculated by just the methods we have employed here.

See all solutions

Recommended explanations on Physics Textbooks

View all explanations

What do you think about this solution?

We value your feedback to improve our textbook solutions.

Study anywhere. Anytime. Across all devices.