Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

I would like to approximate a function containing terms of the form $\tanh( B\sqrt{A})$ for small $A$. I have tried doing a Taylor series, but I consistently find that it is not only $A$ that has to be small, but rather $B$ should as well in order to have an accurate approximation.

I can see that this is related to the fact that $\tanh(x)$ asymptotes to 1 for large $x$, so I understand where the issue originates, but I was wondering whether there is any way of getting around this? For example by determining a correction factor that takes the asymptote into account? Can this be done?

share|improve this question
    
About how large is $B \sqrt{A}$? –  Antonio Vargas Dec 4 '13 at 18:19
    
Strictly it can be anywhere between 0 and $\infty$, but the range I am interested in is roughly 0 to 50. –  Michiel Dec 4 '13 at 19:07
    
So essentially you're asking how to approximate $\tanh x$ on the interval $x \in [0,50]$? Would something like $\tanh x \approx 1 - e^{-1.48x}$ suffice? If not, could you give a little more information about the constraints of your calculation (why you can't just use $\tanh$ itself)? –  Antonio Vargas Dec 4 '13 at 19:37
    
How did you come up with $\tanh x \approx 1 - e^{-1.48x}$? If there is some strategy to that which I can also apply to the complete function which contains the $\tanh$ that would be perfect. Using the $\tanh$ itself is not an option because I need to solve an equation of the type $A + \tanh(B \sqrt{A})=1$ explicitly for $A$. –  Michiel Dec 4 '13 at 19:42
    
I just found this question, I think that could be helpful for this particular case: math.stackexchange.com/questions/107292/… –  Michiel Dec 4 '13 at 19:55

1 Answer 1

up vote 1 down vote accepted

By definition

$$ \tanh x = \frac{1 - e^{-2x}}{1 + e^{-2x}}, $$

so for $x \gg 1$ (something like $x > 4$) we have

$$ \tanh x \approx 1 - e^{-2x}. $$

Since you're interested in an approximation over a large interval we'll need $\tanh x \approx 1$ for most of it. Additionally, we at least want the approximation to be $0$ at $x = 0$. This suggests we shouldn't modify any of the factors of the terms of $1 - e^{-2x}$, so we'll consider an approximation like

$$ \tanh x \approx 1 - e^{-ax}. $$

Since $\tanh'(0) = 1$ and

$$ \left.\frac{d}{dx}\right|_{x=0} (1-e^{-ax}) = a $$

we'll want $1 < a < 2$. A first guess of $a = 3/2$ is pretty decent in the "eyeball norm" (looking at the plot of the approximation against $\tanh x$), but it looks like a smaller $a$ might be an improvement.

To get an idea of the error for all $x$ we could look at the $L_1$ and $L_2$ error of the approximation over some large interval, say

$$ \int_0^{20} \left|\tanh x - 1 + e^{-ax}\right|\,dx \quad \text{and} \quad \sqrt{\int_0^{20} \left(\tanh x - 1 + e^{-ax}\right)^2\,dx}. $$

Below is a plot of the $L_1$ error in blue and the $L_2$ error in red for $1.35 < a < 1.5$.

enter image description here

The $L_1$ error has a minimum at $a \approx 1.48$ and the $L_2$ error has one at $a \approx 1.4$, so any $a$ between these two values could be a pretty decent choice.

Splitting the difference, here's a plot of $\tanh x$ in blue and $1 - e^{-1.44 x}$ in red.

enter image description here

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.