| |
 |
|
|
Science Forum Index » Math - Numerical Analysis Forum » bessel functions
Page 1 of 2 Goto page 1, 2 Next
|
| Author |
Message |
| Lane Straatman |
Posted: Thu Mar 08, 2007 10:31 pm |
|
|
|
Guest
|
I've been attempting to calculate Bessel's functions to work up a new syntax
(fortran95), believing that when I had a good guess, I would simply be able
to find some table out there on the net to compare it to. Notation varies
widely. The reference I am using calls this a Bessel function of the first
kind and order p. I hard coded the values for p and x and the number of
iterations:
program bessel4
IMPLICIT NONE
integer, external :: factorial
integer :: iterations, i, p, x
real :: total, term
iterations = 8
total = 0
x = 7
p = 5
do i = 0, iterations - 1
term = ((-1)**i)*((x/2.0)**(2*i+p))/factorial(i)/factorial(i+p)
write (*, '(i2,f8.5)') i, term
total = total + term
end do
write (*, '(a, i2)') 'x is ', x
write (*, '(a, i2)') 'p is ', p
write (*, '(a, f8.5)') 'total = ', total
end program bessel4
integer function factorial(ii)
integer :: i, ii, fact
fact=1
do i = 1,ii
fact=fact*i
end do
factorial = fact
end function factorial
! end source begin output
0 4.37682
1-8.93601
2 7.81901
3-3.99095
4 1.35803
5-0.33272
6 0.06175
7-0.00901
x is 7
p is 5
total = 0.34693
Is .35 J(7) of the fifth order?
--
LS |
|
|
| Back to top |
|
| Timo Nieminen |
Posted: Thu Mar 08, 2007 11:01 pm |
|
|
|
Guest
|
On Thu, 8 Mar 2007, Lane Straatman wrote:
Quote: I've been attempting to calculate Bessel's functions to work up a new syntax
(fortran95), believing that when I had a good guess, I would simply be able
to find some table out there on the net to compare it to.
[cut]
total = 0.34693
Is .35 J(7) of the fifth order?
Approximately, but not exactly. J5(7) = 0.34790 is the correct value to 5
sig figs. Abramowitz and Stegun (which you can find online) gives tables
of Bessel functions; this particular value is on page 398 (10th printing).
--
Timo |
|
|
| Back to top |
|
| user923005 |
Posted: Thu Mar 08, 2007 11:08 pm |
|
|
|
Guest
|
You will find that Bessel functions generally are categorized by type
and order.
This is the interface to the Cephes library (C routines) for Bessel
functions:
extern double i0(double x);
extern double i0e(double x);
extern double i1(double x);
extern double i1e(double x);
extern double iv(double v,double x);
extern double j0(double x);
extern double j1(double x);
extern double jn(int n,double x);
extern double jv(double n,double x);
extern double k0(double x);
extern double k0e(double x);
extern double k1(double x);
extern double k1e(double x);
extern double kn(int nn,double x);
extern double y0(double x);
extern double y1(double x);
extern double yn(int n,double x);
I guess that most Fortran libraries will be very similar. |
|
|
| Back to top |
|
| Lane Straatman |
Posted: Fri Mar 09, 2007 3:17 am |
|
|
|
Guest
|
"Timo Nieminen" <timo@physics.uq.edu.au> wrote in message
news:Pine.LNX.4.50.0703091258120.6428-100000@localhost...
Quote: On Thu, 8 Mar 2007, Lane Straatman wrote:
I've been attempting to calculate Bessel's functions to work up a new
syntax
(fortran95), believing that when I had a good guess, I would simply be
able
to find some table out there on the net to compare it to.
[cut]
total = 0.34693
Is .35 J(7) of the fifth order?
Approximately, but not exactly. J5(7) = 0.34790 is the correct value to 5
sig figs. Abramowitz and Stegun (which you can find online) gives tables
of Bessel functions; this particular value is on page 398 (10th printing).
Well that's exciting as all get out. I usually have to get a few offensive
rebounds before I score. I've got to figure out how to calculate the
higher-order terms without busting datatypes, and then I think I've got it.
Thanks.
--
LS |
|
|
| Back to top |
|
| Lane Straatman |
Posted: Fri Mar 09, 2007 6:43 pm |
|
|
|
Guest
|
"user923005" <dcorbit@connx.com> wrote in message
news:1173409680.294558.240520@s48g2000cws.googlegroups.com...
Quote: You will find that Bessel functions generally are categorized by type
and order.
This is the interface to the Cephes library (C routines) for Bessel
functions:
extern double i0(double x);
extern double i0e(double x);
extern double i1(double x);
extern double i1e(double x);
extern double iv(double v,double x);
extern double j0(double x);
extern double j1(double x);
extern double jn(int n,double x);
extern double jv(double n,double x);
extern double k0(double x);
extern double k0e(double x);
extern double k1(double x);
extern double k1e(double x);
extern double kn(int nn,double x);
extern double y0(double x);
extern double y1(double x);
extern double yn(int n,double x);
I guess that most Fortran libraries will be very similar.
I was going to do this in C, but decided that my knowledge of types was
lacking. Here's what I got now:
program bessel7
IMPLICIT NONE
real, external :: factorial
integer :: iterations, i, p, x
real :: total, term
iterations = 20
total = 0
x = 7
p = 5
do i = 0, iterations - 1 ! i is maxed at iterations
term = ((-1)**i)*((x/2.0)**(2*i+p))
term = term /factorial(i)
term = term /factorial(i+p)
write (*, '(i2,f20.16)') i, term
total = total + term
end do
write (*, '(a, i2)') 'x is ', x
write (*, '(a, i2)') 'p is ', p
write (*, '(a, f20.16)') 'total = ', total
end program bessel7
real function factorial(ii)
integer :: ii
real :: i, fact
fact=1
do i = 1,ii
fact=fact*i
end do
factorial = fact
end function factorial
! end source begin output:
0 4.3768229484558106
1 -8.9360132217407227
2 7.8190121650695801
3 -3.9909539222717285
4 1.3580329418182373
5 -0.3327180743217468
6 0.0617544874548912
7 -0.0090058622881770
8 0.0010607867734507
9 -0.0001031320425682
10 0.0000084224511738
11 -0.0000005862217449
12 0.0000000352020386
13 -0.0000000018428419
14 0.0000000000848677
15 -0.0000000000034654
16 0.0000000000001263
17 -0.0000000000000041
18 0.0000000000000001
19 0.0000000000000000
x is 7
p is 5
total = 0.3478969633579254
This agrees with Timo's five sig figs, and I wouldn't be surprised if there
are 15 sig figs there. Finding these things on the net is killing me.
Everywhere looks like this:
http://www.math.sfu.ca/~cbm/aands/frameindex.htm
Is there a .pdf out there of these data so I can see it without it looking
like trying to read a technical journal with a telescope?
--
LS |
|
|
| Back to top |
|
| Badger |
Posted: Fri Mar 09, 2007 7:46 pm |
|
|
|
Guest
|
On Fri, 9 Mar 2007 17:43:36 -0500, "Lane Straatman"
<invalid@invalid.net> wrote:
[snip]
Quote: total = 0.3478969633579254
This agrees with Timo's five sig figs, and I wouldn't be surprised if there
are 15 sig figs there. Finding these things on the net is killing me.
Everywhere looks like this:
http://www.math.sfu.ca/~cbm/aands/frameindex.htm
Is there a .pdf out there of these data so I can see it without it looking
like trying to read a technical journal with a telescope?
You can at least spot-check values using Mathematica at the Wolfram
Functions Site,
<http://functions.wolfram.com/>
For BesselJ, link here then click Evaluation.
<http://functions.wolfram.com/BesselAiryStruveFunctions/BesselJ/>
J5(7), to 20D, gives 0.34789632475118328514
HTH |
|
|
| Back to top |
|
| jim bunch |
Posted: Sat Mar 10, 2007 12:49 am |
|
|
|
Guest
|
Badger wrote:
Quote: On Fri, 9 Mar 2007 17:43:36 -0500, "Lane Straatman"
invalid@invalid.net> wrote:
[snip]
total = 0.3478969633579254
This agrees with Timo's five sig figs, and I wouldn't be surprised if there
are 15 sig figs there. Finding these things on the net is killing me.
Everywhere looks like this:
http://www.math.sfu.ca/~cbm/aands/frameindex.htm
Is there a .pdf out there of these data so I can see it without it looking
like trying to read a technical journal with a telescope?
You can at least spot-check values using Mathematica at the Wolfram
Functions Site,
http://functions.wolfram.com/
For BesselJ, link here then click Evaluation.
http://functions.wolfram.com/BesselAiryStruveFunctions/BesselJ/
J5(7), to 20D, gives 0.34789632475118328514
HTH
If you do it in double precision you can match the number above to 15
significant digits
i.e. dbl precision version-
program bessel7
IMPLICIT NONE
real( , external :: factorial
integer :: iterations, i, p, x
real( :: total, term
iterations = 20
total = 0
x = 7
p = 5
do i = 0, iterations - 1 ! i is maxed at iterations
term = ((-1)**i)*((x/2.0)**(2*i+p))
term = term /factorial(i)
term = term /factorial(i+p)
write (*, '(i2,f20.16)') i, term
total = total + term
end do
write (*, '(a, i2)') 'x is ', x
write (*, '(a, i2)') 'p is ', p
write (*, '(a, f20.16)') 'total = ', total
end program bessel7
real( function factorial(ii)
integer :: ii, i
real( :: fact
fact=1.
do i = 1,ii
fact=fact*float(i)
end do
factorial = fact
end function factorial |
|
|
| Back to top |
|
| user923005 |
Posted: Sat Mar 10, 2007 1:33 am |
|
|
|
Guest
|
#include <math.h>
#include "specfunc/gsl_sf_gamma.h"
#include "specfunc/gsl_sf_hyperg.h"
/*
Bessel functions of the first kind, denoted as Ja(x),
are solutions of Bessel's differential equation that
are finite at the origin (x = 0) for non-negative
integer a, and diverge as x approaches zero for negative
non-integer a.
See:
http://en.wikipedia.org/wiki/Bessel_function
under "Relation to hypergeometric series"
*/
double jaz(double alpha, double zeta)
{
double half_z = zeta * 0.5;
double ap1 = alpha + 1.0;
return (pow(half_z, alpha) / gsl_sf_gamma(ap1)) *
gsl_sf_hyperg_0F1(ap1, -(half_z * half_z));
}
#ifdef UNIT_TEST
#include <stdio.h>
int main(void)
{
double alpha;
double zeta;
double result = 0;
unsigned a,
z;
for (a = 0; a < 10; a++)
for (z = 0; z < 10; z++) {
alpha = a;
zeta = z;
result = jaz(alpha, zeta);
printf("J%u(%u) = %25.18g\n", a, z, result);
}
return 0;
}
/*
J0(0) = 1
J0(1) = 0.76519768655796661
J0(2) = 0.22389077914123562
J0(3) = -0.26005195490193334
J0(4) = -0.3971498098638474
J0(5) = -0.17759677131433835
J0(6) = 0.15064525725099692
J0(7) = 0.30007927051955563
J0( = 0.17165080713755401
J0(9) = -0.090333611182876125
J1(0) = 0
J1(1) = 0.44005058574493355
J1(2) = 0.57672480775687363
J1(3) = 0.33905895852593648
J1(4) = -0.06604332802354923
J1(5) = -0.32757913759146523
J1(6) = -0.27668385812756546
J1(7) = -0.00468282348234583
J1( = 0.23463634685391457
J1(9) = 0.2453117865733252
J2(0) = 0
J2(1) = 0.1149034849319006
J2(2) = 0.35283402861563806
J2(3) = 0.48609126058589164
J2(4) = 0.36412814585207331
J2(5) = 0.046565116277752013
J2(6) = -0.2428732099601856
J2(7) = -0.30141722008594035
J2( = -0.11299172042407556
J2(9) = 0.14484734153250409
J3(0) = 0
J3(1) = 0.019563353982668445
J3(2) = 0.12894324947440233
J3(3) = 0.30906272225525233
J3(4) = 0.43017147387562293
J3(5) = 0.36483123061366762
J3(6) = 0.11476838482077538
J3(7) = -0.1675555879953346
J3( = -0.291132207065953
J3(9) = -0.18093519033665731
J4(0) = 0
J4(1) = 0.0024766389641099548
J4(2) = 0.033995719807568416
J4(3) = 0.13203418392461214
J4(4) = 0.28112906496135998
J4(5) = 0.39123236045864812
J4(6) = 0.35764159478096047
J4(7) = 0.1577981446613668
J4( = -0.10535743487538886
J4(9) = -0.2654708017569416
J5(0) = 0
J5(1) = 0.00024975773021123526
J5(2) = 0.0070396297558717015
J5(3) = 0.043028434877047675
J5(4) = 0.1320866560470986
J5(5) = 0.26114054612017068
J5(6) = 0.36208707488717318
J5(7) = 0.34789632475118454
J5( = 0.18577477219056387
J5(9) = -0.055038855669513782
J6(0) = 0
J6(1) = 2.0938338002389283e-005
J6(2) = 0.0012024289717899946
J6(3) = 0.011393932332213077
J6(4) = 0.049087575156385628
J6(5) = 0.13104873178169213
J6(6) = 0.24583686336432672
J6(7) = 0.33919660498317988
J6( = 0.33757590011359412
J6(9) = 0.20431651767970466
J7(0) = 0
J7(1) = 1.5023258174368123e-006
J7(2) = 0.00017494407486827487
J7(3) = 0.0025472944518047042
J7(4) = 0.015176069422058515
J7(5) = 0.053376410155890924
J7(6) = 0.12958665184148119
J7(7) = 0.23358356950569684
J7( = 0.3205890779798275
J7(9) = 0.32746087924245409
J8(0) = 0
J8(1) = 9.4223441726045283e-008
J8(2) = 2.2179552287925949e-005
J8(3) = 0.00049344177620883577
J8(4) = 0.004028667820819014
J8(5) = 0.018405216654802038
J8(6) = 0.056531990932461883
J8(7) = 0.12797053402821279
J8( = 0.22345498635110378
J8(9) = 0.30506707225300017
J9(0) = 0
J9(1) = 5.2492501799119129e-009
J9(2) = 2.4923434351330803e-006
J9(3) = 8.4395021309092397e-005
J9(4) = 0.0009386018612175703
J9(5) = 0.0055202831394757183
J9(6) = 0.0211653239784175
J9(7) = 0.058920508273075767
J9( = 0.12632089472238051
J9(9) = 0.21488058254065953
*/
#endif |
|
|
| Back to top |
|
| user923005 |
Posted: Sat Mar 10, 2007 1:52 am |
|
|
|
Guest
|
/*
It occurs to me that you may only want integer valued versions of
Jn(z).
If that is the case, then the GSL has an implementation ready made for
it.
*/
#include <math.h>
#include "specfunc/gsl_sf_gamma.h"
#include "specfunc/gsl_sf_hyperg.h"
#include "specfunc/gsl_sf_bessel.h"
/*
Bessel functions of the first kind, denoted as Ja(x),
are solutions of Bessel's differential equation that
are finite at the origin (x = 0) for non-negative
integer a, and diverge as x approaches zero for negative
non-integer a.
See:
http://en.wikipedia.org/wiki/Bessel_function
under "Relation to hypergeometric series"
*/
double jaz(double alpha, double zeta)
{
double half_z = zeta * 0.5;
double ap1 = alpha + 1.0;
return (pow(half_z, alpha) / gsl_sf_gamma(ap1)) *
gsl_sf_hyperg_0F1(ap1, -(half_z * half_z));
}
#ifdef UNIT_TEST
#include <stdio.h>
int main(void)
{
double alpha;
double zeta;
double result = 0;
unsigned a,
z;
for (a = 0; a < 10; a++)
for (z = 0; z < 10; z++) {
alpha = a;
zeta = z;
result = jaz(alpha, zeta);
printf("DRC real valued version: J%u(%u) = %25.18g\n",
a, z, result);
result = gsl_sf_bessel_Jn(a, zeta);
printf("GSL integer valued version: J%u(%u) = %25.18g\n",
a, z, result);
}
return 0;
}
/*
DRC real valued version: J0(0) = 1
GSL integer valued version: J0(0) = 1
DRC real valued version: J0(1) = 0.76519768655796661
GSL integer valued version: J0(1) = 0.76519768655796661
DRC real valued version: J0(2) = 0.22389077914123562
GSL integer valued version: J0(2) = 0.22389077914123562
DRC real valued version: J0(3) = -0.26005195490193334
GSL integer valued version: J0(3) = -0.26005195490193345
DRC real valued version: J0(4) = -0.3971498098638474
GSL integer valued version: J0(4) = -0.3971498098638474
DRC real valued version: J0(5) = -0.17759677131433835
GSL integer valued version: J0(5) = -0.17759677131433826
DRC real valued version: J0(6) = 0.15064525725099692
GSL integer valued version: J0(6) = 0.15064525725099692
DRC real valued version: J0(7) = 0.30007927051955563
GSL integer valued version: J0(7) = 0.30007927051955552
DRC real valued version: J0( = 0.17165080713755401
GSL integer valued version: J0( = 0.1716508071375539
DRC real valued version: J0(9) = -0.090333611182876125
GSL integer valued version: J0(9) = -0.090333611182876111
DRC real valued version: J1(0) = 0
GSL integer valued version: J1(0) = 0
DRC real valued version: J1(1) = 0.44005058574493355
GSL integer valued version: J1(1) = 0.4400505857449335
DRC real valued version: J1(2) = 0.57672480775687363
GSL integer valued version: J1(2) = 0.5767248077568734
DRC real valued version: J1(3) = 0.33905895852593648
GSL integer valued version: J1(3) = 0.33905895852593648
DRC real valued version: J1(4) = -0.06604332802354923
GSL integer valued version: J1(4) = -0.066043328023549105
DRC real valued version: J1(5) = -0.32757913759146523
GSL integer valued version: J1(5) = -0.32757913759146523
DRC real valued version: J1(6) = -0.27668385812756546
GSL integer valued version: J1(6) = -0.27668385812756557
DRC real valued version: J1(7) = -0.00468282348234583
GSL integer valued version: J1(7) = -0.0046828234823458291
DRC real valued version: J1( = 0.23463634685391457
GSL integer valued version: J1( = 0.23463634685391463
DRC real valued version: J1(9) = 0.2453117865733252
GSL integer valued version: J1(9) = 0.24531178657332528
DRC real valued version: J2(0) = 0
GSL integer valued version: J2(0) = 0
DRC real valued version: J2(1) = 0.1149034849319006
GSL integer valued version: J2(1) = 0.11490348493190049
DRC real valued version: J2(2) = 0.35283402861563806
GSL integer valued version: J2(2) = 0.35283402861563773
DRC real valued version: J2(3) = 0.48609126058589164
GSL integer valued version: J2(3) = 0.48609126058589125
DRC real valued version: J2(4) = 0.36412814585207331
GSL integer valued version: J2(4) = 0.36412814585207293
DRC real valued version: J2(5) = 0.046565116277752013
GSL integer valued version: J2(5) = 0.046565116277752193
DRC real valued version: J2(6) = -0.2428732099601856
GSL integer valued version: J2(6) = -0.24287320996018541
DRC real valued version: J2(7) = -0.30141722008594035
GSL integer valued version: J2(7) = -0.30141722008594002
DRC real valued version: J2( = -0.11299172042407556
GSL integer valued version: J2( = -0.11299172042407547
DRC real valued version: J2(9) = 0.14484734153250409
GSL integer valued version: J2(9) = 0.144847341532504
DRC real valued version: J3(0) = 0
GSL integer valued version: J3(0) = 0
DRC real valued version: J3(1) = 0.019563353982668445
GSL integer valued version: J3(1) = 0.019563353982668407
DRC real valued version: J3(2) = 0.12894324947440233
GSL integer valued version: J3(2) = 0.12894324947440206
DRC real valued version: J3(3) = 0.30906272225525233
GSL integer valued version: J3(3) = 0.30906272225525167
DRC real valued version: J3(4) = 0.43017147387562293
GSL integer valued version: J3(4) = 0.43017147387562199
DRC real valued version: J3(5) = 0.36483123061366762
GSL integer valued version: J3(5) = 0.3648312306136669
DRC real valued version: J3(6) = 0.11476838482077538
GSL integer valued version: J3(6) = 0.11476838482077532
DRC real valued version: J3(7) = -0.1675555879953346
GSL integer valued version: J3(7) = -0.16755558799533421
DRC real valued version: J3( = -0.291132207065953
GSL integer valued version: J3( = -0.29113220706595228
DRC real valued version: J3(9) = -0.18093519033665731
GSL integer valued version: J3(9) = -0.18093519033665686
DRC real valued version: J4(0) = 0
GSL integer valued version: J4(0) = 0
DRC real valued version: J4(1) = 0.0024766389641099548
GSL integer valued version: J4(1) = 0.0024766389641099557
DRC real valued version: J4(2) = 0.033995719807568416
GSL integer valued version: J4(2) = 0.033995719807568436
DRC real valued version: J4(3) = 0.13203418392461214
GSL integer valued version: J4(3) = 0.13203418392461222
DRC real valued version: J4(4) = 0.28112906496135998
GSL integer valued version: J4(4) = 0.28112906496136009
DRC real valued version: J4(5) = 0.39123236045864812
GSL integer valued version: J4(5) = 0.39123236045864812
DRC real valued version: J4(6) = 0.35764159478096047
GSL integer valued version: J4(6) = 0.35764159478096075
DRC real valued version: J4(7) = 0.1577981446613668
GSL integer valued version: J4(7) = 0.1577981446613678
DRC real valued version: J4( = -0.10535743487538886
GSL integer valued version: J4( = -0.10535743487538889
DRC real valued version: J4(9) = -0.2654708017569416
GSL integer valued version: J4(9) = -0.26547080175694188
DRC real valued version: J5(0) = 0
GSL integer valued version: J5(0) = 0
DRC real valued version: J5(1) = 0.00024975773021123526
GSL integer valued version: J5(1) = 0.00024975773021123444
DRC real valued version: J5(2) = 0.0070396297558717015
GSL integer valued version: J5(2) = 0.0070396297558716859
DRC real valued version: J5(3) = 0.043028434877047675
GSL integer valued version: J5(3) = 0.043028434877047599
DRC real valued version: J5(4) = 0.1320866560470986
GSL integer valued version: J5(4) = 0.13208665604709829
DRC real valued version: J5(5) = 0.26114054612017068
GSL integer valued version: J5(5) = 0.26114054612017013
DRC real valued version: J5(6) = 0.36208707488717318
GSL integer valued version: J5(6) = 0.36208707488717246
DRC real valued version: J5(7) = 0.34789632475118454
GSL integer valued version: J5(7) = 0.34789632475118321
DRC real valued version: J5( = 0.18577477219056387
GSL integer valued version: J5( = 0.18577477219056346
DRC real valued version: J5(9) = -0.055038855669513782
GSL integer valued version: J5(9) = -0.05503885566951372
DRC real valued version: J6(0) = 0
GSL integer valued version: J6(0) = 0
DRC real valued version: J6(1) = 2.0938338002389283e-005
GSL integer valued version: J6(1) = 2.0938338002389273e-005
DRC real valued version: J6(2) = 0.0012024289717899946
GSL integer valued version: J6(2) = 0.0012024289717899933
DRC real valued version: J6(3) = 0.011393932332213077
GSL integer valued version: J6(3) = 0.011393932332213072
DRC real valued version: J6(4) = 0.049087575156385628
GSL integer valued version: J6(4) = 0.049087575156385579
DRC real valued version: J6(5) = 0.13104873178169213
GSL integer valued version: J6(5) = 0.13104873178169202
DRC real valued version: J6(6) = 0.24583686336432672
GSL integer valued version: J6(6) = 0.24583686336432636
DRC real valued version: J6(7) = 0.33919660498317988
GSL integer valued version: J6(7) = 0.33919660498317955
DRC real valued version: J6( = 0.33757590011359412
GSL integer valued version: J6( = 0.33757590011359323
DRC real valued version: J6(9) = 0.20431651767970466
GSL integer valued version: J6(9) = 0.20431651767970443
DRC real valued version: J7(0) = 0
GSL integer valued version: J7(0) = 0
DRC real valued version: J7(1) = 1.5023258174368123e-006
GSL integer valued version: J7(1) = 1.5023258174368083e-006
DRC real valued version: J7(2) = 0.00017494407486827487
GSL integer valued version: J7(2) = 0.00017494407486827416
DRC real valued version: J7(3) = 0.0025472944518047042
GSL integer valued version: J7(3) = 0.0025472944518046946
DRC real valued version: J7(4) = 0.015176069422058515
GSL integer valued version: J7(4) = 0.015176069422058451
DRC real valued version: J7(5) = 0.053376410155890924
GSL integer valued version: J7(5) = 0.05337641015589073
DRC real valued version: J7(6) = 0.12958665184148119
GSL integer valued version: J7(6) = 0.12958665184148069
DRC real valued version: J7(7) = 0.23358356950569684
GSL integer valued version: J7(7) = 0.23358356950569606
DRC real valued version: J7( = 0.3205890779798275
GSL integer valued version: J7( = 0.32058907797982633
DRC real valued version: J7(9) = 0.32746087924245409
GSL integer valued version: J7(9) = 0.32746087924245287
DRC real valued version: J8(0) = 0
GSL integer valued version: J8(0) = 0
DRC real valued version: J8(1) = 9.4223441726045283e-008
GSL integer valued version: J8(1) = 9.4223441726045019e-008
DRC real valued version: J8(2) = 2.2179552287925949e-005
GSL integer valued version: J8(2) = 2.2179552287925912e-005
DRC real valued version: J8(3) = 0.00049344177620883577
GSL integer valued version: J8(3) = 0.00049344177620883468
DRC real valued version: J8(4) = 0.004028667820819014
GSL integer valued version: J8(4) = 0.0040286678208190044
DRC real valued version: J8(5) = 0.018405216654802038
GSL integer valued version: J8(5) = 0.018405216654802003
DRC real valued version: J8(6) = 0.056531990932461883
GSL integer valued version: J8(6) = 0.056531990932461779
DRC real valued version: J8(7) = 0.12797053402821279
GSL integer valued version: J8(7) = 0.12797053402821251
DRC real valued version: J8( = 0.22345498635110378
GSL integer valued version: J8( = 0.223454986351103
DRC real valued version: J8(9) = 0.30506707225300017
GSL integer valued version: J8(9) = 0.30506707225299995
DRC real valued version: J9(0) = 0
GSL integer valued version: J9(0) = 0
DRC real valued version: J9(1) = 5.2492501799119129e-009
GSL integer valued version: J9(1) = 5.2492501799118749e-009
DRC real valued version: J9(2) = 2.4923434351330803e-006
GSL integer valued version: J9(2) = 2.4923434351330642e-006
DRC real valued version: J9(3) = 8.4395021309092397e-005
GSL integer valued version: J9(3) = 8.4395021309091787e-005
DRC real valued version: J9(4) = 0.0009386018612175703
GSL integer valued version: J9(4) = 0.00093860186121756391
DRC real valued version: J9(5) = 0.0055202831394757183
GSL integer valued version: J9(5) = 0.0055202831394756888
DRC real valued version: J9(6) = 0.0211653239784175
GSL integer valued version: J9(6) = 0.021165323978417361
DRC real valued version: J9(7) = 0.058920508273075767
GSL integer valued version: J9(7) = 0.058920508273075406
DRC real valued version: J9( = 0.12632089472238051
GSL integer valued version: J9( = 0.12632089472237959
DRC real valued version: J9(9) = 0.21488058254065953
GSL integer valued version: J9(9) = 0.21488058254065848
*/
#endif |
|
|
| Back to top |
|
| Timo Nieminen |
Posted: Sun Mar 11, 2007 6:19 pm |
|
|
|
Guest
|
On Fri, 9 Mar 2007, Lane Straatman wrote:
Quote: "Timo Nieminen" <timo@physics.uq.edu.au> wrote:
On Thu, 8 Mar 2007, Lane Straatman wrote:
I've been attempting to calculate Bessel's functions to work up a new
syntax
(fortran95), believing that when I had a good guess, I would simply be
able
to find some table out there on the net to compare it to.
[cut]
total = 0.34693
Is .35 J(7) of the fifth order?
Approximately, but not exactly. J5(7) = 0.34790 is the correct value to 5
sig figs. Abramowitz and Stegun (which you can find online) gives tables
of Bessel functions; this particular value is on page 398 (10th printing).
Well that's exciting as all get out. I usually have to get a few offensive
rebounds before I score. I've got to figure out how to calculate the
higher-order terms without busting datatypes, and then I think I've got it.
Avoid factorials. Factorials will kill the algorithm, for large n. For
quite a few special functions, there are explicit formulae that involve
factorials. OK for small n, but useless in practice for large n. Use
recursion formulae instead. Alas, these can be unstable for certain
ranges.
For a nice example, see Brock's Sandia report
Sandia Report No. SAND2000-2217-Revised
and compare the explicit formula for Wigner 3j functions and the actual
useful algorithm.
--
Timo Nieminen - Home page: http://www.physics.uq.edu.au/people/nieminen/
E-prints: http://eprint.uq.edu.au/view/person/Nieminen,_Timo_A..html
Shrine to Spirits: http://www.users.bigpond.com/timo_nieminen/spirits.html |
|
|
| Back to top |
|
| Lane Straatman |
Posted: Sun Mar 11, 2007 7:20 pm |
|
|
|
Guest
|
"Timo Nieminen" <timo@physics.uq.edu.au> wrote in message
news:Pine.LNX.4.50.0703120914560.8368-100000@localhost...
Quote: On Fri, 9 Mar 2007, Lane Straatman wrote:
"Timo Nieminen" <timo@physics.uq.edu.au> wrote:
On Thu, 8 Mar 2007, Lane Straatman wrote:
I've been attempting to calculate Bessel's functions to work up a new
syntax
(fortran95), believing that when I had a good guess, I would simply be
able
to find some table out there on the net to compare it to.
[cut]
total = 0.34693
Is .35 J(7) of the fifth order?
Approximately, but not exactly. J5(7) = 0.34790 is the correct value to
5
sig figs. Abramowitz and Stegun (which you can find online) gives
tables
of Bessel functions; this particular value is on page 398 (10th
printing).
Well that's exciting as all get out. I usually have to get a few
offensive
rebounds before I score. I've got to figure out how to calculate the
higher-order terms without busting datatypes, and then I think I've got
it.
Avoid factorials. Factorials will kill the algorithm, for large n. For
quite a few special functions, there are explicit formulae that involve
factorials. OK for small n, but useless in practice for large n. Use
recursion formulae instead. Alas, these can be unstable for certain
ranges.
I'm using factorial instead of the gamma function. It occurs to me that I
might want to rewrite the above with gamma functions. I wouldn't be
surprised if fortran makes it easy.
--
LS |
|
|
| Back to top |
|
| Lane Straatman |
Posted: Sun Mar 11, 2007 8:54 pm |
|
|
|
Guest
|
"jim bunch" <bubbajeb@charter.net> wrote in message
news:2PqIh.108$8m3.95@newsfe05.lga...
Quote: If you do it in double precision you can match the number above to 15
significant digits
i.e. dbl precision version-
program bessel7
IMPLICIT NONE
real(  , external :: factorial
With small changes to what you wrote, I'm able to get fifteen places:
program numsci5
IMPLICIT NONE
integer, parameter :: DP = SELECTED_REAL_KIND(13,37)
integer :: iterations, i, p, x
real(KIND=DP) :: total, term
iterations = 25
total = 0
x = 12
p = 5
do i = 0, iterations - 1 ! i is maxed at iterations
term = ((-1_DP)**i)*((x/2.0_DP)**(2*i+p))
term = term /factorial(i)
term = term /factorial(i+p)
write (*, '(i2,f24.15)') i, term
total = total + term
end do
write (*, '(a, i2)') 'x is ', x
write (*, '(a, i2)') 'p is ', p
write (*, '(a, f24.20)') 'total = ', total
write (*, '(a)' ) 'sought: -0.073470963101658581266'
write (*, '(a)' ) 'sought: 0.123451234512345'
contains
real(KIND=DP) function factorial(ii)
IMPLICIT NONE
integer :: ii, i
real(KIND=DP):: fact
fact=1._DP
do i = 1,ii
fact=fact*real(i,DP)
end do
factorial = fact
end function factorial
end program numsci5
!end source begin output:
0 64.799999999999997
1 -388.800000000000012
2 999.771428571428601
3 -1499.657142857142844
4 1499.657142857142844
5 -1079.753142857142848
6 588.956259740259725
7 -252.409825602968482
8 87.372631939489082
9 -24.963609125568311
10 5.991266190136394
11 -1.225486266164262
12 0.216262282264282
13 -0.033271120348351
14 0.004502858393010
15 -0.000540343007161
16 0.000057893893624
17 -0.000005572674253
18 0.000000484580370
19 -0.000000038256345
20 0.000000002754457
21 -0.000000000181613
22 0.000000000011007
23 -0.000000000000615
24 0.000000000000032
x is 12
p is 5
total = -0.07347096310165797395
sought: -0.073470963101658581266
sought: 0.123451234512345
What surprises me is that nothing fouled up even though it had to calclulate
(p + iterations)! = 30!, which is a huge number. The link to mathematica
was a good one:
http://functions.wolfram.com/BesselAiryStruveFunctions
It gives Bessel functions where p=n and x=z in my code, and it does it to 20
digits without complaint.
The statement:
integer, parameter :: DP = SELECTED_REAL_KIND(13,37)
is considered more portable than real( . Thanks for your help.
--
LS |
|
|
| Back to top |
|
| Lane Straatman |
Posted: Sun Mar 11, 2007 9:25 pm |
|
|
|
Guest
|
"user923005" <dcorbit@connx.com> wrote in message
news:1173504818.565719.11700@h3g2000cwc.googlegroups.com...
Quote: #include <math.h
#include "specfunc/gsl_sf_gamma.h"
#include "specfunc/gsl_sf_hyperg.h"
What do these look like? I'm unusually interested in something that will
allow me to calculate a gamma function robustly.
Quote: double jaz(double alpha, double zeta)
{
double half_z = zeta * 0.5;
double ap1 = alpha + 1.0;
return (pow(half_z, alpha) / gsl_sf_gamma(ap1)) *
gsl_sf_hyperg_0F1(ap1, -(half_z * half_z));
}
#ifdef UNIT_TEST
#include <stdio.h
int main(void)
{
double alpha;
double zeta;
double result = 0;
unsigned a,
z;
for (a = 0; a < 10; a++)
for (z = 0; z < 10; z++) {
alpha = a;
zeta = z;
result = jaz(alpha, zeta);
printf("J%u(%u) = %25.18g\n", a, z, result);
}
return 0;
}
What happens to the above when your gamma function hands it something that
is 10^70 ? How much of the above is pre-packaged?
Quote: J0(0) = 1
One should be able to say why this is so a priori.
--
LS |
|
|
| Back to top |
|
| Noone |
Posted: Sun Mar 11, 2007 10:32 pm |
|
|
|
Guest
|
On Sun, 11 Mar 2007 22:25:28 -0400, "Lane Straatman"
<invalid@invalid.net> wrote:
Quote:
"user923005" <dcorbit@connx.com> wrote in message
news:1173504818.565719.11700@h3g2000cwc.googlegroups.com...
#include <math.h
#include "specfunc/gsl_sf_gamma.h"
#include "specfunc/gsl_sf_hyperg.h"
What do these look like? I'm unusually interested in something that will
allow me to calculate a gamma function robustly.
GSL - GNU Scientific Library
<http://www.gnu.org/software/gsl/>
For some Fortran code, including the various kinds of Bessel
functions, Gamma, test programs ...
<http://www.netlib.org/specfun/>
The Cephes library (more C code, choice of precision) is also
available at netlib.org, and from at the author's web site
<http://moshier.net/#Cephes>
Follow the links for the various documentation files.
One can also use Google to search for public source code via
<http://www.google.com/codesearch> |
|
|
| Back to top |
|
| Lane Straatman |
Posted: Sun Mar 11, 2007 10:43 pm |
|
|
|
Guest
|
"Noone" <x@x.invalid> wrote in message
news:j2h9v29minfou4uieshtfietuuth1efqou@4ax.com...
On Sun, 11 Mar 2007 22:25:28 -0400, "Lane Straatman"
<invalid@invalid.net> wrote:
Quote:
"user923005" <dcorbit@connx.com> wrote in message
news:1173504818.565719.11700@h3g2000cwc.googlegroups.com...
#include <math.h
#include "specfunc/gsl_sf_gamma.h"
#include "specfunc/gsl_sf_hyperg.h"
What do these look like? I'm unusually interested in something that will
allow me to calculate a gamma function robustly.
GSL - GNU Scientific Library
<http://www.gnu.org/software/gsl/>
For some Fortran code, including the various kinds of Bessel
functions, Gamma, test programs ...
<http://www.netlib.org/specfun/>
CS REAL FUNCTION ALGAMA(X)
CD DOUBLE PRECISION FUNCTION DLGAMA(X)
C----------------------------------------------------------------------
C
C This routine calculates the LOG(GAMMA) function for a positive real
C argument X. Computation is based on an algorithm outlined in
C references 1 and 2. The program uses rational functions that
C theoretically approximate LOG(GAMMA) to at least 18 significant
C decimal digits. The approximation for X > 12 is from reference
C 3, while approximations for X < 12.0 are similar to those in
C reference 1, but are unpublished. The accuracy achieved depends
C on the arithmetic system, the compiler, the intrinsic functions,
C and proper selection of the machine-dependent constants.
C
C
C*********************************************************************
C*********************************************************************
C
C Explanation of machine-dependent constants
C
C beta - radix for the floating-point representation
C maxexp - the smallest positive power of beta that overflows
C XBIG - largest argument for which LN(GAMMA(X)) is representable
C in the machine, i.e., the solution to the equation
C LN(GAMMA(XBIG)) = beta**maxexp
C XINF - largest machine representable floating-point number;
C approximately beta**maxexp.
C EPS - The smallest positive floating-point number such that
C 1.0+EPS .GT. 1.0
C FRTBIG - Rough estimate of the fourth root of XBIG
C
C
C Approximate values for some important machines are:
C
C beta maxexp XBIG
C
C CRAY-1 (S.P.) 2 8191 9.62E+2461
C Cyber 180/855
C under NOS (S.P.) 2 1070 1.72E+319
C IEEE (IBM/XT,
C SUN, etc.) (S.P.) 2 128 4.08E+36
C IEEE (IBM/XT,
C SUN, etc.) (D.P.) 2 1024 2.55D+305
C IBM 3033 (D.P.) 16 63 4.29D+73
C VAX D-Format (D.P.) 2 127 2.05D+36
C VAX G-Format (D.P.) 2 1023 1.28D+305
C
C
C XINF EPS FRTBIG
C
C CRAY-1 (S.P.) 5.45E+2465 7.11E-15 3.13E+615
C Cyber 180/855
C under NOS (S.P.) 1.26E+322 3.55E-15 6.44E+79
C IEEE (IBM/XT,
C SUN, etc.) (S.P.) 3.40E+38 1.19E-7 1.42E+9
C IEEE (IBM/XT,
C SUN, etc.) (D.P.) 1.79D+308 2.22D-16 2.25D+76
C IBM 3033 (D.P.) 7.23D+75 2.22D-16 2.56D+18
C VAX D-Format (D.P.) 1.70D+38 1.39D-17 1.20D+9
C VAX G-Format (D.P.) 8.98D+307 1.11D-16 1.89D+76
C
C**************************************************************
C**************************************************************
C
C Error returns
C
C The program returns the value XINF for X .LE. 0.0 or when
C overflow would occur. The computation is believed to
C be free of underflow and overflow.
C
C
C Intrinsic functions required are:
C
C LOG
C
C
C References:
C
C 1) W. J. Cody and K. E. Hillstrom, 'Chebyshev Approximations for
C the Natural Logarithm of the Gamma Function,' Math. Comp. 21,
C 1967, pp. 198-203.
C
C 2) K. E. Hillstrom, ANL/AMD Program ANLC366S, DGAMMA/DLGAMA, May,
C 1969.
C
C 3) Hart, Et. Al., Computer Approximations, Wiley and sons, New
C York, 1968.
C
C
C Authors: W. J. Cody and L. Stoltz
C Argonne National Laboratory
C
C Latest modification: June 16, 1988
C
C----------------------------------------------------------------------
INTEGER I
CS REAL
CD DOUBLE PRECISION
1 C,CORR,D1,D2,D4,EPS,FRTBIG,FOUR,HALF,ONE,PNT68,P1,P2,P4,
2 Q1,Q2,Q4,RES,SQRTPI,THRHAL,TWELVE,TWO,X,XBIG,XDEN,XINF,
3 XM1,XM2,XM4,XNUM,Y,YSQ,ZERO
DIMENSION C(7),P1( ,P2( ,P4( ,Q1( ,Q2( ,Q4(
C----------------------------------------------------------------------
C Mathematical constants
C----------------------------------------------------------------------
CS DATA ONE,HALF,TWELVE,ZERO/1.0E0,0.5E0,12.0E0,0.0E0/,
CS 1 FOUR,THRHAL,TWO,PNT68/4.0E0,1.5E0,2.0E0,0.6796875E0/,
CS 2 SQRTPI/0.9189385332046727417803297E0/
CD DATA ONE,HALF,TWELVE,ZERO/1.0D0,0.5D0,12.0D0,0.0D0/,
CD 1 FOUR,THRHAL,TWO,PNT68/4.0D0,1.5D0,2.0D0,0.6796875D0/,
CD 2 SQRTPI/0.9189385332046727417803297D0/
C----------------------------------------------------------------------
C Machine dependent parameters
C----------------------------------------------------------------------
CS DATA XBIG,XINF,EPS,FRTBIG/4.08E36,3.401E38,1.19E-7,1.42E9/
CD DATA XBIG,XINF,EPS,FRTBIG/2.55D305,1.79D308,2.22D-16,2.25D76/
C----------------------------------------------------------------------
C Numerator and denominator coefficients for rational minimax
C approximation over (0.5,1.5).
C----------------------------------------------------------------------
CS DATA D1/-5.772156649015328605195174E-1/
CS DATA P1/4.945235359296727046734888E0,2.018112620856775083915565E2,
CS 1 2.290838373831346393026739E3,1.131967205903380828685045E4,
CS 2 2.855724635671635335736389E4,3.848496228443793359990269E4,
CS 3 2.637748787624195437963534E4,7.225813979700288197698961E3/
CS DATA Q1/6.748212550303777196073036E1,1.113332393857199323513008E3,
CS 1 7.738757056935398733233834E3,2.763987074403340708898585E4,
CS 2 5.499310206226157329794414E4,6.161122180066002127833352E4,
CS 3 3.635127591501940507276287E4,8.785536302431013170870835E3/
CD DATA D1/-5.772156649015328605195174D-1/
CD DATA P1/4.945235359296727046734888D0,2.018112620856775083915565D2,
CD 1 2.290838373831346393026739D3,1.131967205903380828685045D4,
CD 2 2.855724635671635335736389D4,3.848496228443793359990269D4,
CD 3 2.637748787624195437963534D4,7.225813979700288197698961D3/
CD DATA Q1/6.748212550303777196073036D1,1.113332393857199323513008D3,
CD 1 7.738757056935398733233834D3,2.763987074403340708898585D4,
CD 2 5.499310206226157329794414D4,6.161122180066002127833352D4,
CD 3 3.635127591501940507276287D4,8.785536302431013170870835D3/
C----------------------------------------------------------------------
C Numerator and denominator coefficients for rational minimax
C Approximation over (1.5,4.0).
C----------------------------------------------------------------------
CS DATA D2/4.227843350984671393993777E-1/
CS DATA P2/4.974607845568932035012064E0,5.424138599891070494101986E2,
CS 1 1.550693864978364947665077E4,1.847932904445632425417223E5,
CS 2 1.088204769468828767498470E6,3.338152967987029735917223E6,
CS 3 5.106661678927352456275255E6,3.074109054850539556250927E6/
CS DATA Q2/1.830328399370592604055942E2,7.765049321445005871323047E3,
CS 1 1.331903827966074194402448E5,1.136705821321969608938755E6,
CS 2 5.267964117437946917577538E6,1.346701454311101692290052E7,
CS 3 1.782736530353274213975932E7,9.533095591844353613395747E6/
CD DATA D2/4.227843350984671393993777D-1/
CD DATA P2/4.974607845568932035012064D0,5.424138599891070494101986D2,
CD 1 1.550693864978364947665077D4,1.847932904445632425417223D5,
CD 2 1.088204769468828767498470D6,3.338152967987029735917223D6,
CD 3 5.106661678927352456275255D6,3.074109054850539556250927D6/
CD DATA Q2/1.830328399370592604055942D2,7.765049321445005871323047D3,
CD 1 1.331903827966074194402448D5,1.136705821321969608938755D6,
CD 2 5.267964117437946917577538D6,1.346701454311101692290052D7,
CD 3 1.782736530353274213975932D7,9.533095591844353613395747D6/
C----------------------------------------------------------------------
C Numerator and denominator coefficients for rational minimax
C Approximation over (4.0,12.0).
C----------------------------------------------------------------------
CS DATA D4/1.791759469228055000094023E0/
CS DATA P4/1.474502166059939948905062E4,2.426813369486704502836312E6,
CS 1 1.214755574045093227939592E8,2.663432449630976949898078E9,
CS 2 2.940378956634553899906876E10,1.702665737765398868392998E11,
CS 3 4.926125793377430887588120E11,5.606251856223951465078242E11/
CS DATA Q4/2.690530175870899333379843E3,6.393885654300092398984238E5,
CS 2 4.135599930241388052042842E7,1.120872109616147941376570E9,
CS 3 1.488613728678813811542398E10,1.016803586272438228077304E11,
CS 4 3.417476345507377132798597E11,4.463158187419713286462081E11/
CD DATA D4/1.791759469228055000094023D0/
CD DATA P4/1.474502166059939948905062D4,2.426813369486704502836312D6,
CD 1 1.214755574045093227939592D8,2.663432449630976949898078D9,
CD 2 2.940378956634553899906876D10,1.702665737765398868392998D11,
CD 3 4.926125793377430887588120D11,5.606251856223951465078242D11/
CD DATA Q4/2.690530175870899333379843D3,6.393885654300092398984238D5,
CD 2 4.135599930241388052042842D7,1.120872109616147941376570D9,
CD 3 1.488613728678813811542398D10,1.016803586272438228077304D11,
CD 4 3.417476345507377132798597D11,4.463158187419713286462081D11/
C----------------------------------------------------------------------
C Coefficients for minimax approximation over (12, INF).
C----------------------------------------------------------------------
CS DATA C/-1.910444077728E-03,8.4171387781295E-04,
CS 1 -5.952379913043012E-04,7.93650793500350248E-04,
CS 2 -2.777777777777681622553E-03,8.333333333333333331554247E-02,
CS 3 5.7083835261E-03/
CD DATA C/-1.910444077728D-03,8.4171387781295D-04,
CD 1 -5.952379913043012D-04,7.93650793500350248D-04,
CD 2 -2.777777777777681622553D-03,8.333333333333333331554247D-02,
CD 3 5.7083835261D-03/
C----------------------------------------------------------------------
Y = X
IF ((Y .GT. ZERO) .AND. (Y .LE. XBIG)) THEN
IF (Y .LE. EPS) THEN
RES = -LOG(Y)
ELSE IF (Y .LE. THRHAL) THEN
C----------------------------------------------------------------------
C EPS .LT. X .LE. 1.5
C----------------------------------------------------------------------
IF (Y .LT. PNT68) THEN
CORR = -LOG(Y)
XM1 = Y
ELSE
CORR = ZERO
XM1 = (Y - HALF) - HALF
END IF
IF ((Y .LE. HALF) .OR. (Y .GE. PNT68)) THEN
XDEN = ONE
XNUM = ZERO
DO 140 I = 1, 8
XNUM = XNUM*XM1 + P1(I)
XDEN = XDEN*XM1 + Q1(I)
140 CONTINUE
RES = CORR + (XM1 * (D1 + XM1*(XNUM/XDEN)))
ELSE
XM2 = (Y - HALF) - HALF
XDEN = ONE
XNUM = ZERO
DO 220 I = 1, 8
XNUM = XNUM*XM2 + P2(I)
XDEN = XDEN*XM2 + Q2(I)
220 CONTINUE
RES = CORR + XM2 * (D2 + XM2*(XNUM/XDEN))
END IF
ELSE IF (Y .LE. FOUR) THEN
C----------------------------------------------------------------------
C 1.5 .LT. X .LE. 4.0
C----------------------------------------------------------------------
XM2 = Y - TWO
XDEN = ONE
XNUM = ZERO
DO 240 I = 1, 8
XNUM = XNUM*XM2 + P2(I)
XDEN = XDEN*XM2 + Q2(I)
240 CONTINUE
RES = XM2 * (D2 + XM2*(XNUM/XDEN))
ELSE IF (Y .LE. TWELVE) THEN
C----------------------------------------------------------------------
C 4.0 .LT. X .LE. 12.0
C----------------------------------------------------------------------
XM4 = Y - FOUR
XDEN = -ONE
XNUM = ZERO
DO 340 I = 1, 8
XNUM = XNUM*XM4 + P4(I)
XDEN = XDEN*XM4 + Q4(I)
340 CONTINUE
RES = D4 + XM4*(XNUM/XDEN)
ELSE
C----------------------------------------------------------------------
C Evaluate for argument .GE. 12.0,
C----------------------------------------------------------------------
RES = ZERO
IF (Y .LE. FRTBIG) THEN
RES = C(7)
YSQ = Y * Y
DO 450 I = 1, 6
RES = RES / YSQ + C(I)
450 CONTINUE
END IF
RES = RES/Y
CORR = LOG(Y)
RES = RES + SQRTPI - HALF*CORR
RES = RES + Y*(CORR-ONE)
END IF
ELSE
C----------------------------------------------------------------------
C Return for bad arguments
C----------------------------------------------------------------------
RES = XINF
END IF
C----------------------------------------------------------------------
C Final adjustments and return
C----------------------------------------------------------------------
CS ALGAMA = RES
CD DLGAMA = RES
RETURN
C ---------- Last line of DLGAMA ----------
END
Golly Beav, it's huge.--LS |
|
|
| Back to top |
|
| |
Page 1 of 2 Goto page 1, 2 Next
All times are GMT - 5 Hours
The time now is Thu Jan 08, 2009 2:10 am
|
|