0

I have a function $\frac{e^x - e^{-x}}{2x}$. In order to avoid loss of significance when calculating values of this function near $x=0$, I represent $e^x$ as Taylor series. The truncation error of $e^x$ is $\frac{x^5}{5!}*e^x$ (If i use 4 members of Taylor series for the approximation). But this is the error only for $e^x$, not for the whole function. How to compute truncation error for $\frac{e^x - e^{-x}}{2x}$ when $e^x$ is computed using Taylor series approximation?

This question continues this series here: Truncation error in approximation of $\frac{e^x - 1}{x}$ because I could not do the same manipulations with this formula as with the previous answer

John
  • 1,313
  • $$\dfrac{e^x-e^{-x}}{2x} = x + \dfrac16x^3 + \dfrac1{120}x^5 + \cdots = \displaystyle \sum_{n=0}^\infty \dfrac1{(2n+1)!} x^{2n+1}$$ – Kenny Lau Sep 16 '17 at 14:41
  • How did you come up with this result? I mean the original formula can be written ofc as $(e^{2x} - 1)/{e^x2x}$ but then...how did you expand it like that? – John Sep 16 '17 at 14:45
  • 2
    Correction: $$\dfrac{e^x-e^{-x}}{2x} = 1 + \dfrac16x^2 + \dfrac1{120}x^4 + \cdots = \displaystyle \sum_{n=0}^\infty \dfrac1{(2n+1)!} x^{2n}$$ obtained by expanding $e^x$ and $e^{-x}$ separately and then using term-by-term subtraction. – Kenny Lau Sep 16 '17 at 14:47

2 Answers2

1

$\dfrac{e^x-e^{-x}}{2x}=\dfrac{\sinh (x)}{x}= 1+\dfrac{x^2}{6}+\dfrac{x^4}{120}+\dfrac{x^6}{5040}+\dfrac{x^8}{362880}+O(x^9)$

The series is $$\frac{\sinh (x)}{x}=\sum _{n=0}^{\infty } \frac{x^{2 n}}{(2 n+1)!}$$

Raffaele
  • 26,371
1

Assuming you want to use up to the $x^4$ term,

Hint:

$$e^x=1+x+\frac12x^2+\frac16x^3+\frac1{24}x^4\pm\frac1{120}x^5e^{|x|}$$

where $\pm$ denotes maximum error. By setting $x\mapsto-x$, we get

$$e^{-x}=1-x+\frac12x^2-\frac16x^3+\frac1{24}x^4\pm\frac1{120}x^5e^{|x|}$$

What do you get when you subtract these and divide by $2x$?

  • Yep, I got the reasoning behind this, due to Kenny Lau's comment. Only 1 thing after your comment in the linked question - this problem is the same that you answered about $\frac{e^x - 1}{x}$ - what about the error term? should it be with x^4, or how to properly assess the error term? – John Sep 16 '17 at 17:54
  • @John To what terms are you expanding $e^x$? – Simply Beautiful Art Sep 16 '17 at 17:56
  • Note that the exact remainder is generally given by:$$e^x-\sum_{k=0}^n\frac{x^k}{k!}=\frac{x^{n+1}}{n!}\int_0^1(1-t)^ne^{xt}~\mathrm dt$$Upon which we usually simplify the integral:$$\left|\int_0^1(1-t)^ne^{xt}~\mathrm dt\right|\le e^{|x|}$$ – Simply Beautiful Art Sep 16 '17 at 18:02
  • I expand $e^x$ to four terms (1st term is 1), 5th term should be an error – John Sep 16 '17 at 18:24
  • I think I don't need the precise remainder as it seems like integral is hard to compute and it is sure not what is required from me. The whole task is - examine function (I gave) in the range of values 10^-7 to 10^-9, but due to loss of significance you are not allowed to use direct computation, so expand each $e^x$ term into Taylor with 4 members, -> and then suddenly the exercise says - now the error term is the fifth member of Taylor series. I do not think this is right for the whole formula (and we take the endpoint as just $x$, so no need for the integral - we take upper bound) – John Sep 16 '17 at 18:27
  • @John Well, you can probably figure out how to change my answer to four terms (just remove the last term pretty much) – Simply Beautiful Art Sep 16 '17 at 19:00
  • Usually, when texts say "now the error term is the fifth member of Taylor series" they usually mean to use the Lagrange Remainder, which is close, but not quite, to the fifth term in the expansion. Here, it says that$$e^x-\sum_{k=0}^n\frac{x^k}{k!}=\frac{x^{n+1}}{(n+1)!}e^\xi$$for some $|\xi|<x$. (The exact value of $\xi$ is not important, as you can, for your range, use $e^\xi<e^1<3$) – Simply Beautiful Art Sep 16 '17 at 19:04