<a href="https://colab.research.google.com/github/Jun-629/20MA573/blob/master/src/Hw2_pdf.ipynb" target="_parent"></a>

__Problem 1__

__Proof:__
By Taylor's Formula, we have

\begin{equation}
\begin{aligned}
f(x + 2h) &= f(x) + f'(x) \cdot 2h + f''(x) \cdot \frac{(2h)^2}{2} + f'''(x) \cdot \frac{(2h)^3}{6} + f^{(4)}(x) \cdot \frac{(2h)^4}{24} + O(h^5) \\
&= f(x) + f'(x) \cdot 2h + f''(x) \cdot 2h^2 + f'''(x) \cdot \frac{4h^3}{3} + f^{(4)}(x) \cdot \frac{2h^4}{3} + O(h^5) \\
f(x + h) &= f(x) + f'(x) \cdot h + f''(x) \cdot \frac{h^2}{2} + f'''(x) \cdot \frac{h^3}{6} + f^{(4)}(x) \cdot \frac{h^4}{24} + O(h^5) \\
f(x - h) &= f(x) - f'(x) \cdot h + f''(x) \cdot \frac{h^2}{2} - f'''(x) \cdot \frac{h^3}{6} + f^{(4)}(x) \cdot \frac{h^4}{24} + O(h^5) \\
f(x - 2h) &= f(x) - f'(x) \cdot 2h + f''(x) \cdot 2h^2 - f'''(x) \cdot \frac{4h^3}{3} + f^{(4)}(x) \cdot \frac{2h^4}{3} + O(h^5) \\
\end{aligned}
\end{equation}

To approximate the ﬁrst derivative $u'(x)$ of a very smooth function with an error of only $O(h^4)$, we need to show that there exists a linear combination of $f(x + 2h),f(x + h),f(x - h),f(x - 2h),$ which eliminates the terms: $f''(x),f'''(x),f^{(4)}(x)$ as well as making the coefficient of the term: $f'(x)$ equals to $1$.

Thus we need to solve the following quaternion equations:

\begin{equation}  
\left\{
  \begin{array}{**lr**}  
  a - b + 2c - 2d = 1, \\  
  \frac{1}{2}a + \frac{1}{2}b + 2c + 2d = 0, \\  
  \frac{1}{6}a - \frac{1}{6}b + \frac{4}{3}c - \frac{4}{3}d = 0, \\
  \frac{1}{24}a + \frac{1}{24}b + \frac{2}{3}c + \frac{2}{3}d = 0   .
  \end{array}  
\right.
\end{equation} 

After calculation, we have :
$$[a,b,c,d] = [\frac{2}{3},-\frac{2}{3},-\frac{1}{12},\frac{1}{12}]$$
Thus, we have:
\begin{eqnarray}
|\frac{2}{3}f(x + h) - \frac{2}{3}f(x - h) - \frac{1}{12}f(x + 2h) + \frac{1}{12}f(x - 2h)| = f'(x) \cdot h + O(h^5) \\
|\frac{\frac{2}{3}f(x + h) - \frac{2}{3}f(x - h) - \frac{1}{12}f(x + 2h) + \frac{1}{12}f(x - 2h) - f'(x)}{h}| = O(h^4) \\
\end{eqnarray}



 



```
import numpy as np
from scipy.linalg import solve
a = np.array([[1,-1,2,-2],[1/2,1/2,2,2],[1/6,-1/6,4/3,-4/3],[1/24,1/24,2/3,2/3]])
b = np.array([1,0,0,0])
x = solve(a, b)
print(x)

```

    [ 0.66666667 -0.66666667 -0.08333333  0.08333333]


__Problem 2__

- __Pf:__
Since $f(x)$ is a smooth even function, we have $$f(x) = f(-x).$$

Then we have $$f'(x) = f'(-x) = (-x)' \cdot f'(-x) = -f'(-x),$$

thus $$f'(x) + f'(-x) = 0,$$

when $x = 0,$ we have $$f'(0) = 0.$$

__Q.E.D__

- __Pf:__
As similar to the previous proof, we have $f'''(x) = 0,$

By Taylor's Formula, we have 
\begin{equation}
\begin{split}
f(h) &= f(0) + f'(0) \cdot h + f''(0) \cdot \frac{h^2}{2} + f'''(0) \cdot \frac{h^3}{6} + O(h^4) \\
&= f''(0) \cdot \frac{h^2}{2} + O(h^4). \\
\end{split}
\end{equation}
Thus, we will have $$|a_h - f''(0)| = |\frac{2f(h)}{h^2} - f''(0)| = O(h^2).$$
__Q.E.D__

- __Soln:__
As similar to the previous proof, we have $f^{(5)}(x) = 0,$

By Taylor's Formula, we have 
\begin{equation}
\begin{split}
f(h) &= f''(0) \cdot \frac{h^2}{2} + f^{(4)} \cdot \frac{h^4}{24} + O(h^6). \\
f(2h) &= f''(0) \cdot \frac{(2h)^2}{2} + f^{(4)} \cdot \frac{(2h)^4}{24} + O(h^6) \\
&= f''(0) \cdot 2h^2 + f^{(4)} \cdot \frac{2h^4}{3} + O(h^6). \\
\end{split}
\end{equation}

To let $$|b_h - f''(x)| = |\frac{c_1 \cdot f(h) + c_2 \cdot f(2h)}{h^2} - f''(x)| = O(h^2),$$

we have the following binary linear equations：

\begin{equation}  
\left\{
  \begin{array}{**lr**}  
  \frac{c_1}{2} +2c_2 = 1, \\
  \frac{c_1}{24} + \frac{2}{3}c_2 = 0   .
  \end{array}  
\right.
\end{equation} 

thus $c_1 = \frac{8}{3}, c_2 = -\frac{1}{6}$.

- __Soln:__
Since $f(x)$ is a smooth odd function, we have $$f(x) = -f(-x).$$

Then we have $$f'(x) = (-f(-x))' = (-x)' \cdot -f'(-x) = f'(-x),$$

then taking this step again, we have $$f''(x) = (f'(-x))' = (-x)' \cdot (f''(-x)) = -f''(x),$$

thus $$f''(x) + f''(-x) = 0,$$

when $x = 0,$ we have $$f''(0) = 0.$$



```
import numpy as np
from scipy.linalg import solve
a = np.array([[1/2,2],[1/24,2/3]])
b = np.array([1,0])
x = solve(a, b)
print(x)
```

    [ 2.66666667 -0.16666667]


fcbae029b00c08326c6bf8f351399ddc20094a9c
ipynb
Jupyter Notebook
src/Hw2_pdf.ipynb
Jun-629/20MA573
addad663d2dede0422ae690e49b230815aea4c70
MIT
src/Hw2_pdf.ipynb
Jun-629/20MA573
addad663d2dede0422ae690e49b230815aea4c70
MIT
src/Hw2_pdf.ipynb
Jun-629/20MA573
addad663d2dede0422ae690e49b230815aea4c70
MIT
2020-02-05T21:42:08.000Z
2020-02-05T21:42:08.000Z
Qwen/Qwen-72B
1. YES
2. YES