# MyOpenMath/Solutions/Big-O

An excellent introduction to this subject can be found at this document from web.mit.edu:

In this introduction to Big O notation, we solve two problems: one simple and the other so tricky I got a bit lost. The advantage of Big-O notation is that you can quickly "see" an answer without doing elaborate perturbation theory. Instead you just learn a few low order approximations for small ${\displaystyle \epsilon }$. A few examples are ${\displaystyle \sin(\epsilon )\approx \epsilon }$, ${\displaystyle \cos \epsilon \approx 1-{\tfrac {1}{2}}\epsilon ^{2}}$. All we need for this discussion is the first order approximation for ${\displaystyle (1+\epsilon )^{p}}$.

## Ruler misalignment

You want ${\displaystyle h}$  but measure ${\displaystyle y}$ .

Have you ever pondered the fact that you can measure your height without carefully verifying that the ruler is perfectly vertical? In the language of Big O notation, if the actual height is ${\displaystyle h}$ , the error is second order in the distance, ${\displaystyle x}$ , between the actual and proper locations of the bottom of the ruler (see figure). To understand how this all works, begin with the Pythagorean theorem and express the erroneously measured height as:

${\displaystyle y={\sqrt {h^{2}+x^{2}}}=h\;\left(1+{\frac {x^{2}}{h^{2}}}\right)^{1/2}}$

Advanced mathematics with numbers that have dimensions is best done by creating dimensionless variables, and this is especially true when analyzing approximations. A handy approximation is that whenever ${\displaystyle \epsilon <<1}$ , we can write:

${\displaystyle (1+\epsilon )^{p}=1+p\epsilon +{\mathcal {O}}\epsilon ^{2}+...}$ .

Here the "big-O" informs us that the next term is proportion to ${\displaystyle \epsilon ^{2}}$ . The ${\displaystyle {\mathcal {O}}}$ -symbol allows us to avoid consideration of this term, while at the same time, preserve the location of these higher order terms, in case the calculation needs to be improved. We define, ${\displaystyle \Delta y=y-h}$ , to be the error that arises from ruler misalignment. We presume that this error will be small ... but small compared with what? This problem has two large terms, ${\displaystyle (h,y)}$ , and two small ones ${\displaystyle (x,\Delta y)}$ . The big-O notation will help us sort things out. From the two equations displayed above:

${\displaystyle {\frac {y}{h}}=1+{\frac {\Delta y}{h}}=1+{\frac {1}{2}}\left({\frac {x}{y}}\right)^{2}+{\mathcal {O}}\left({\frac {x}{y}}\right)^{4}}$

#### Example

${\displaystyle x=0.1y}$ , then ${\displaystyle \Delta y/h=.005}$ , which implies that:

A horizontal displacement of one end of ruler's length by ten percent will increase the measured height by approximately half of one percent.

This calculation is only an estimate that lacks a proper proof because higher order terms have been neglected. On the other hand, it is likely to be correct, since the next term in the expansion is of order ${\displaystyle (x/y)^{4}\approx 10^{-4}=0.01\%}$ .

#### Defining the small parameter

This section might seem unnecessary, but the next calculation is so weird that it might help to discuss it here: Whether something is "first" or "second" order depends on you choose to define things. Here we have chosen,

${\displaystyle \epsilon ={\frac {x^{2}}{y^{2}}}}$ ,

and we are working to "first order" in ${\displaystyle \epsilon }$ , even though it is "second" order in ${\displaystyle x/y}$ .

Note the approximation that the two paths to the screen are parallel

Two slit diffraction when screen is close

A better way to visualize ${\displaystyle \Delta r}$  as the base of a triangle for nearly parallel paths. Click for explanation

## Two slit diffraction with narrow slits

### When the screen is far from the slits

Problem: Two narrow slits are separated by 0.8 mm. The 15-th fringe appears 89 mm from the center of the diffraction pattern, and the screen is 9 m from the slits. What is the wavelength?

The standard textbook solution to this problem uses the formula, ${\displaystyle n\lambda =d\sin \theta }$ , where :

${\displaystyle 15\lambda ={\frac {0.8{\text{ mm}}\times 89{\text{ mm}}}{{\sqrt {9000^{2}+89^{2}}}{\text{ mm}}}}}$ ${\displaystyle \Rightarrow \lambda \approx 527.4{\text{ nm}}}$ .

This solution is only valid when the distance to the screen, ${\displaystyle L}$  is much greater than the distance between the slits, ${\displaystyle d}$ . In the next section we will derive an exact equation, and then use big-O notation to recover the standard formula in the limit that ${\displaystyle d/L}$  is small.

• To learn about two slit diffraction visit:
OpenStax College Physics Chapter 27-3
wikibooks:Waves/Double_slit_Diffraction
• To see a hand written solution on MyOpenMath visit:
https://myopenmaths3.s3.amazonaws.com/ufiles/2556987/interference_question_ID_420941.pdf

### When the screen is not far from the slits

The wavelength and dimensions of the device in the previous section were chosen so that the simple formula would yield the correct answer. But how we solve the problem when the spacing between the slits is close to the distance to the screen. The geometry is shown in the figure to the right. It helps to define,

${\displaystyle R={\sqrt {L^{2}+y^{2}}},}$  so that:

${\displaystyle r_{1}={\sqrt {L^{2}+(y-d/2)^{2}}}={\sqrt {R^{2}-yd+d^{2}/4}}}$

${\displaystyle r_{2}={\sqrt {L^{2}+(y+d/2)^{2}}}={\sqrt {R^{2}+yd+d^{2}/4}}}$

Note from the figure that ${\displaystyle y/R=\sin \theta }$ , and that the two paths are effectively parallel when ${\displaystyle d< . The exact formula for the path difference is:

${\displaystyle \Delta r=r_{2}-r_{1}={\sqrt {T^{2}+yd}}-{\sqrt {T^{2}+yd}},}$

where,

${\displaystyle T={\sqrt {L^{2}+y^{2}+{\frac {d^{2}}{4}}}}={\sqrt {R^{2}+{\frac {d^{2}}{4}}}}}$

From the formulas stated without proof in the previous section, we are looking to show that:

${\displaystyle \Delta r\approx {\frac {yd}{R}}=d\sin \theta }$ .

We also seek insight into the nature of higher order correction terms in order to estimate when this simple formula is likely to be valid. The standard approach would be to perform a Taylor series expansion of the function ${\displaystyle f(d)=\Delta r}$ , using ${\displaystyle d}$  as the variable. But in order to highlight big-O notation, we employ the aforementioned expansion:

${\displaystyle (1+\epsilon )^{1/2}=1+{\frac {\epsilon }{2}}+{\mathcal {O}}\epsilon ^{2}}$ .

Wright this expression with ${\displaystyle \epsilon }$  replaced by ${\displaystyle -\epsilon }$ , and subtract the two:

${\displaystyle (1+\epsilon )^{1/2}-(1-\epsilon )^{1/2}=}$ ${\displaystyle \left[1+{\frac {\epsilon }{2}}+{\mathcal {O}}\epsilon ^{2}\right]}$ ${\displaystyle -\left[1-{\frac {\epsilon }{2}}+{\mathcal {O}}\epsilon ^{2}\right]}$

When subtracting in the big-O notation, it is essential to realize that in general,

${\displaystyle {\mathcal {O}}\epsilon ^{2}-{\mathcal {O}}\epsilon ^{2}={\mathcal {O}}\epsilon ^{2}\neq {\mathcal {O}}\epsilon ^{2}}$

This is because ${\displaystyle {\mathcal {O}}\epsilon ^{2}}$  stands for ${\displaystyle C\epsilon ^{2}}$ , where ${\displaystyle C}$  is some unknown constant. The difference between unknown constants is not usually zero. However in this case the exact cancellation of all even terms leaves us with an expression containing only terms that are odd in ${\displaystyle \epsilon }$ :

${\displaystyle (1+\epsilon )^{1/2}-(1-\epsilon )^{1/2}=\epsilon +{\mathcal {O}}\epsilon ^{3}+...}$

The absence of a second order term suggests that the first order term is likely to be sufficient for reasonably small values of ${\displaystyle \epsilon }$ . The physics of this problem informs us that, ${\displaystyle \Delta r=n\lambda ,}$  so that we seek and expression for,

${\displaystyle \Delta r={\sqrt {T^{2}+yd}}-{\sqrt {T^{2}+yd}}=T\cdot \left[\,{\sqrt {1+\epsilon }}+{\sqrt {1-\epsilon }}\;\right]}$ ,

We see here that our small parameter is,

${\displaystyle \epsilon ={\frac {yd}{T^{2}}}}$

${\displaystyle \Delta r=\epsilon \cdot T+{\mathcal {O}}\epsilon ^{3}\cdot T={\frac {yd}{T}}+T\cdot {\mathcal {O}}\epsilon ^{3}}$

One final task remains: Since since ${\displaystyle y/R=\sin \theta ,}$  we need to replace ${\displaystyle yd/T}$  = ${\displaystyle yd/R}$  (...plus small terms.) It is left as an exercise for the reader to show that:

${\displaystyle {\frac {1}{T}}={\frac {1}{R}}\left\{1-{\mathcal {O}}\left({\frac {d^{2}}{4R^{2}}}\right)\right\}}$

In other words, ${\displaystyle T}$  and ${\displaystyle R}$  are very close to each other, differing only at second order in our small parameter. Unless ${\displaystyle \theta {\text{ is very close to }}\pi /2,}$  the three lengths ${\displaystyle T,R,{\text{and }}L}$  are all of the same order and are not small:

${\displaystyle {\mathcal {O}}T={\mathcal {O}}R={\mathcal {O}}L={\mathcal {O}}\epsilon ^{0}}$

We also note that ${\displaystyle yd/T={\mathcal {O}}\epsilon }$ , so that up to but not including third order, the difference in path length is:

${\displaystyle \Delta r={\frac {yd}{R}}\left[1+{\mathcal {O}}\epsilon ^{2}\right]\approx yd\sin \theta +...}$ ,

which agrees with the formula found in most physics books.

${\displaystyle n\lambda \approx d\sin \theta }$  is a good approximation even with the screen this close to the slits.

If your small parameters have small parameters, you need analysis.

#### Example

While not exact, the familiar formula for fringes when the screen is far away, the approximate formula, ${\displaystyle n\lambda =d\sin \theta }$ , works surprisingly well for the screen close to the slits. Here, ${\displaystyle [d,y,L]=[321,274,404]].}$  The fringe number was ${\displaystyle n=1}$  (first maximum.)

Yet, the "small parameter" is not very small:

${\displaystyle yd/R^{2}\approx 0.37}$ .

The approximate formula for the first fringe is depicted in the figure as ${\displaystyle \lambda _{1}}$ , which equals the length of the line segment, ${\displaystyle {\overline {CD}}}$ .

The actual wavelength is ${\displaystyle \lambda ={\overline {CE}}}$ . The point ${\displaystyle E}$  was by creating the (dotted) arc of length ${\displaystyle r_{1}}$ , which intersect with line ${\displaystyle {\overline {CP}}}$ , which has length ${\displaystyle r_{2}}$ . The approximation,

${\displaystyle n\lambda _{1}=d\sin \theta }$  .

yields,

${\displaystyle \lambda _{1}=180.18...=\lambda \times 1.037...}$ ,

where,

${\displaystyle \lambda =173.66...}$ ,

is the exact wavelength, calculated from:

${\displaystyle n\lambda ={\sqrt {{\sqrt {L^{2}+y^{2}+{\frac {d^{2}}{4}}}}+yd}}-{\sqrt {{\sqrt {R^{2}L^{2}+y^{2}+{\frac {d^{2}}{4}}}}+yd}},}$

### Another approach

The big-O approach led us initially to a rather awkward small parameter,

${\displaystyle \epsilon ={\frac {yx}{T^{2}}}={\frac {yx}{R^{2}+x^{2}/4}}\approx {\frac {yx}{R^{2}}}+{\mathcal {O}}{\frac {x^{3}y}{R^{4}}}}$

In other words, the convenient small parameter differs from the useful small parameter by a small parameter. Weird, huh?

We could also solve this problem with a Taylor series. In anticipation of doing differential calculus, we replace ${\displaystyle d}$  by ${\displaystyle x}$  as the variable to represent the distance between the slits. Now define the path length difference ${\displaystyle \Delta r}$  by the function ${\displaystyle F}$ , where:

${\displaystyle F(x)={\sqrt {{\sqrt {R^{2}+{\frac {x^{2}}{4}}}}+yx}}-{\sqrt {{\sqrt {R^{2}+{\frac {x^{2}}{4}}}}-yx}}}$

This looks like a lot of trouble, but symbolic software is available that can make this almost effortless. This expression also shows us why the big-O approach got into trouble. There are really two small dimensionless parameters lurking in this problem, and we can distinguish between them with subscripts:

${\displaystyle \epsilon _{R}={\frac {x^{2}}{4R^{2}}}{\text{, and }}\epsilon _{y}={\frac {yx}{R^{2}}}}$ ,

so that

${\displaystyle {\frac {\Delta r}{R}}={\sqrt {{\sqrt {1+\epsilon _{R}}}+\epsilon _{y}}}-{\sqrt {{\sqrt {1+\epsilon _{R}}}-\epsilon _{y}}}}$

In other words we need to understand the function,

${\displaystyle f(x,y)={\sqrt {{\sqrt {1+x}}+y}}-{\sqrt {{\sqrt {1+x}}-y}}}$ ,

when ${\displaystyle x}$  and ${\displaystyle y}$  are small. What I would do here is a two-dimensional expansion:

${\displaystyle f(x,y)=f_{0}+\left.{\frac {\partial f}{\partial x}}\right|_{0}x+\left.{\frac {\partial f}{\partial y}}\right|_{0}y+{\frac {1}{2}}\left.{\frac {\partial ^{2}f}{\partial x^{2}}}\right|_{0}x^{2}+{\frac {1}{2}}\left.{\frac {\partial ^{2}f}{\partial y^{2}}}\right|_{0}y^{2}+\left.{\frac {\partial ^{2}f}{\partial x\partial y}}\right|_{0}xy+...}$