The function cosh(x) is defined as (exp(x)+exp(-x))/2 and therefore as x increases in size, the value of cosh(x) increases exponentially. I see that your values of Ln(n) are increasing up to approximately 1224 as n reaches nmax. This will make cosh(x) have +inf in the matlab "double" format. Since you are dividing by cosh(x), you will get zeros in Bn(n) for these larger values of n and very small values for many of the other values of n.
In other words, I am saying the behavior you are seeing is inherent in the numbers you are using. There is presumably nothing wrong with matlab's cosh(x) function - it is giving the values it is supposed to give. You can check it by substituting (exp(x)+exp(-x))/2 in place of cosh(x) and seeing if you get the same results.
By the way, you should be looking at your results with "format long", not the default "format short".
Best Answer