"Steven Lord" <
Steve...@mathworks.com> wrote in message <lmhv94$m0$
1...@newscl01ah.mathworks.com>...
As Steve points out, this function returns NaN at zero.
fun = @(x) coth(x) - 1./x;
fun(0)
ans =
NaN
Of course, for small arguments, the function has numerical
problems. You should expect this.
format long g
fun(1000*eps)
ans =
0
fun(1000000*eps)
ans =
0
fun(10000000000*eps)
ans =
7.40168616175652e-07
We can get a limit for fun at zero of course. I'll use my
limit tool (as always, found on the file exchange.)
[lim,limerr] = limest(fun,0)
lim =
6.0737e-13
limerr =
1.3371e-12
ezplot sees no problem, plotting a smooth curve.
Regardless, I'd suggest you choose a functional form that
lacks singularities of this sort in curve fitting, at least if
you have data that is at or near zero.
Even better is to use a spline form for your curve fit. If
your only issue is a monotonic fit, my SLM tools allow that
quite nicely. (Also on the file exchange.)
John