0

Let $f(x) = arctan (x)$. Use the derivative approximation: $f'(x) = \frac{8f(x+h) - 8f(x-h) - f(x+2h) +f(x-2h)}{12h} $ to approximate $f'(\frac14\pi)$ using $h^-1$ = 2, 4, 8 . Try to take h small enough that the rounding error effect begins to dominate the mathematical error. For what value of h does this begin to occur? (You may have to restrict yourself to working in single precision.)

I have no idea how to even begin...

steve
  • 141
  • 1
  • 1
  • 11
  • What program is used ? Which is the machine precision, if "single precision" is chosen ? – Peter Jan 22 '17 at 21:17
  • You did not have difficulties with part $1$, did you ? – Peter Jan 22 '17 at 21:18
  • What part 1? I'm not sure what the precision would be in this case. I'm allowed to use any language, C++, Java, Matlab, etc – steve Jan 22 '17 at 21:20
  • The approximations of $f'(\frac{\pi}{4})$ can be calculated by simply plugging $x=\frac{\pi}{4}$ and the values $h=1/2,1/4,1/8$ into the given approximation-formula. You get $3$ approximations. – Peter Jan 22 '17 at 21:22
  • The point for which the rounding error is as big as the mathematical error depends on how precise we calculate the approximation. – Peter Jan 22 '17 at 21:24
  • but how would this relate to f(x+h) and its calculation. And what does it mean when it says to take " h small enough that the rounding error effect begins to dominate the mathematical error"? – steve Jan 22 '17 at 21:25
  • The "mathematical error" is the distance between the correct derivate and the approximation we get if we calculate the derivate with the formula. We assume that we do not make any rounding errors. If $h$ is very small, and we round to , say $6$ digits, we will get an error in the calculation using the formula (here we do not care about the "mathematical error"). If $h$ gets smaller and smaller, the "mathematical error" tends to $0$, but the rounding error will increase. Therefore, at some point, they will meet. – Peter Jan 22 '17 at 21:27

1 Answers1

0

Partial answer

To get an idea how good the approximation is, you can calculate the result for the special functions $f(x)=1,x,x^2,x^3\cdots$. Here, we get the exact result for $f(x)=1,x,x^2,x^3,x^4$, so the formula is exact upto degree $4$ (Polynomials upto degree $4$ are differentiated exactly by the formula)

For $f(x)=x^5$, you get $f'(x)=5x^4-4h^4$, so you have an error of $4h^4$

Peter
  • 84,454
  • You lost me from " Here, we get the ...." forward. Why does it work for up to $x^4$ and not for $x^5$? Also, it the question asking to pick random values for h, such that $4h^4$ is greater than $5x^4$? if so, would I plug for $x=\frac{\pi}4$? – steve Jan 22 '17 at 21:44
  • In the case of $f(x)=x^4$ we have $f'(x)=\frac{8(x+h)^4-8(x-h)^4-(x+2h)^4+(x-2h)^4}{12h}=4x^3$. Calculate $f'(x)$ for $f(x)=x^5$ analogue. – Peter Jan 22 '17 at 21:48
  • If you want the approximation at some position, you plug in this position for $x$ (In the example $x=\frac{\pi}{4}$) – Peter Jan 22 '17 at 21:50