Skip to content

Commit

Permalink
Avoid power singularity
Browse files Browse the repository at this point in the history
  • Loading branch information
paulmasson committed Jan 18, 2024
1 parent cc2cca1 commit bc0c3ec
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
2 changes: 2 additions & 0 deletions build/math.js
Original file line number Diff line number Diff line change
Expand Up @@ -1321,6 +1321,8 @@ function weierstrassRoots( g2, g3 ) {

// p, q both negative in defining cubic

if ( isZero(p) ) return mul( root(q,3), exp( complex(0,2*pi*n/3) ) )

return mul( 2/sqrt(3), sqrt(p),
cos( sub( div( arccos( mul( 3*sqrt(3)/2, q, pow(p,-3/2) ) ), 3 ),
2*pi*n/3 ) ) );
Expand Down
2 changes: 2 additions & 0 deletions src/functions/elliptic-functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,8 @@ function weierstrassRoots( g2, g3 ) {

// p, q both negative in defining cubic

if ( isZero(p) ) return mul( root(q,3), exp( complex(0,2*pi*n/3) ) )

return mul( 2/sqrt(3), sqrt(p),
cos( sub( div( arccos( mul( 3*sqrt(3)/2, q, pow(p,-3/2) ) ), 3 ),
2*pi*n/3 ) ) );
Expand Down

0 comments on commit bc0c3ec

Please sign in to comment.