Skip to content

Commit

Permalink
Special case of besselY
Browse files Browse the repository at this point in the history
  • Loading branch information
paulmasson committed May 28, 2022
1 parent ec1346b commit d994dda
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
8 changes: 8 additions & 0 deletions build/math.js
Original file line number Diff line number Diff line change
Expand Up @@ -589,6 +589,11 @@ function besselY( n, x ) {

if ( isComplex(n) || isComplex(x) ) {

if ( isZero(x) ) {
if ( !isComplex(n) ) n = complex(n);
if ( fractionalPart(n.re) === -.5 && n.im === 0 ) return complex(0);
}

// dlmf.nist.gov/10.2.3
if ( isInteger(n) )
return div( add( diff( n => besselJ(n,x), n ),
Expand All @@ -601,6 +606,9 @@ function besselY( n, x ) {

if ( x < 0 ) return besselY( n, complex(x) );

if ( x === 0 )
if ( fractionalPart(n) === -.5 ) return 0;

// dlmf.nist.gov/10.2.3
if ( Number.isInteger(n) )
return ( diff( n => besselJ(n,x), n ) + (-1)**n * diff( n => besselJ(n,x), -n ) ) / pi;
Expand Down
8 changes: 8 additions & 0 deletions src/functions/bessel.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ function besselY( n, x ) {

if ( isComplex(n) || isComplex(x) ) {

if ( isZero(x) ) {
if ( !isComplex(n) ) n = complex(n);
if ( fractionalPart(n.re) === -.5 && n.im === 0 ) return complex(0);
}

// dlmf.nist.gov/10.2.3
if ( isInteger(n) )
return div( add( diff( n => besselJ(n,x), n ),
Expand All @@ -70,6 +75,9 @@ function besselY( n, x ) {

if ( x < 0 ) return besselY( n, complex(x) );

if ( x === 0 )
if ( fractionalPart(n) === -.5 ) return 0;

// dlmf.nist.gov/10.2.3
if ( Number.isInteger(n) )
return ( diff( n => besselJ(n,x), n ) + (-1)**n * diff( n => besselJ(n,x), -n ) ) / pi;
Expand Down

0 comments on commit d994dda

Please sign in to comment.