Hi Regina,
On Sunday, 2009-06-28 20:20:17 +0200, Regina Henschel wrote:
> Searching around I come across an iterative solution from Peter
> Deuflhard [1] (German). My tests as Basic macro results in an accuracy
> of at least 12 digits. But it needs approximately order+x*1.1+30
> iterations.
> [1]
http://www.mathematik.uni-dortmund.de/ieem/BzMU/BzMU2007/Deuflhard.pdf>
> So the question is, how much iterations are acceptable?
Depends of course on the cost per iteration. Hard to say. How much time
is a user willing to wait for an accurate result? Which still doesn't
say anything about a series of values to be calculated. But, since
a non-accurate solution wouldn't help much, I guess having to wait
a little isn't too much.. so I just throw a number and say 10000. Does
that help anything?
> For example BESSELJ(3000;200) results in -7,79235815417491E-003 with the
> current implementation with asymptotic formula, but the true value is
> -1.186524260848996e-2. Gnumeric results -1.186524260848841E-002, my
> Basic version of Deuflhard's algorithm results -1,18652426084901E-002.
> But calculating this needs 3147 iterations. For order 200 you would need
> x>520000 to result in at least 1 digit accuracy with the asymptotic
> formula.
> Second problem: The current implementation restricts the order to
> integer values. In mathematic the order need not to be integer. ODF1.2
> also allows non-integer order. Are there plans to implement a solution
> in OOo with non-integer orders? I personally have no idea how to do it.
No plans. Is there any practical benefit in calculating non-integer
orders? Does any spreadsheet application do it?
> So the question is, shall I implement Deuflhard's algorithm nevertheless?
>
> Perhaps warn the user in the help, that large input values results in
> long lasting calculations?
What is "large" and what is "long lasting"?
> Or return an error, if neither asymptotic
> formula results at least 2 digits (How tell the user, that the result is
> not accurate?)
A few functions set errNoConvergence if a function can't determine
a result.
> nor Deuflhard's algorithm calculates in reasonable time
> (where to cut?)?
"reasonable time" depends on user perspective and intention. I don't
think there is a general reasonable timeout.
Btw, newer g++ compilers (>= 4.3) have some bessel functions built-in,
as part of the TR1 extensions, see
http://en.wikipedia.org/wiki/C%2B%2B_Technical_Report_1, it appears that
MSVC does not have them though. Also the Boost library provides bessel
functions, I don't know off-hand which library version introduced them
and if it is in the one OOo uses. Maybe time to finally upgrade ;-)
Eike
--
OOo/SO Calc core developer. Number formatter stricken i18n transpositionizer.
SunSign 0x87F8D412 : 2F58 5236 DB02 F335 8304 7D6C 65C9 F9B5 87F8 D412
OpenOffice.org Engineering at Sun:
http://blogs.sun.com/GullFOSS Please don't send personal mail to the
erl@... account, which I use for
mailing lists only and don't read from outside Sun. Use
erack@... Thanks.