g.fun.Rd
Calculates the invariants g2 and g3 using any of a number of methods
g.fun(b, ...)
g2.fun(b, use.first=TRUE, ...)
g3.fun(b, use.first=TRUE, ...)
g2.fun.lambert(b, nmax=50, tol=1e-10, strict=TRUE)
g3.fun.lambert(b, nmax=50, tol=1e-10, strict=TRUE)
g2.fun.direct(b, nmax=50, tol=1e-10)
g3.fun.direct(b, nmax=50, tol=1e-10)
g2.fun.fixed(b, nmax=50, tol=1e-10, give=FALSE)
g3.fun.fixed(b, nmax=50, tol=1e-10, give=FALSE)
g2.fun.vectorized(b, nmax=50, tol=1e-10, give=FALSE)
g3.fun.vectorized(b, nmax=50, tol=1e-10, give=FALSE)
Half periods. NB: the arguments
are the half periods as per AMS55!
In these functions, argument b
is interpreted as per
p1.tau()
Maximum number of terms to sum. See details section for more discussion
Numerical tolerance for stopping: summation stops when adding an additional term makes less
Boolean, with default (where taken) TRUE
meaning to
stop()
if convergence is not achieved in nmax
terms.
Setting to FALSE
returns the partial sum and a warning.
Boolean, with default (where taken) TRUE
meaning to
return the partial sums. See examples section for an example of this
argument in use
In functions g.fun()
, g2.fun()
and
g3.fun()
, extra arguments passed to theta1()
and friends
In function g2.fun()
and g3.fun()
,
Boolean with default TRUE
meaning to use Wolfram's first formula
(remember to cite this) and FALSE
meaning to use the second
Functions g2.fun()
and g3.fun()
use theta functions
which converge very quickly. These functions are the best in most
circumstances. The theta functions include a loop that continues to add
terms until the partial sum is unaltered by addition
of the next term. Note that summation continues until all
elements of the argument are properly summed, so performance is
limited by the single worst-case element.
The following functions are provided for interest only, although there is a remote possibility that some weird circumstances may exist in which they are faster than the theta function approach.
Functions g2.fun.divisor()
and g3.fun.divisor()
use
Chandrasekharan's formula on page 83. This is generally slower than
the theta function approach
Functions g2.fun.lambert()
and g3.fun.lambert()
use a
Lambert series to accelerate Chandrasekharan's formula. In general,
it is a little better than the divisor form.
Functions g2.fun.fixed()
and g2.fun.fixed()
also use
Lambert series. These functions are vectorized in the sense that
the function body uses only vector operations. These functions do
not take a vector argument. They are called “fixed” because
the number of terms used is fixed in advance (unlike g2.fun()
and g3.fun()
).
Functions g2.fun.vectorized()
and g3.fun.vectorized()
also use Lambert series. They are fully vectorized in that they take
a vector of periods or period ratios, unlike the previous two
functions. However, this can lead to loss of precision in some
cases (specifically when the periods give rise to widely varying
values of g2 and g3).
Functions g2.fun.direct()
and g3.fun.direct()
use a
direct summation. These functions are absurdly slow. In general,
the Lambert series functions converge much faster; and the
“default” functions g2.fun()
and g3.fun()
,
which use theta functions, converge faster still.
Mathematica website
g.fun(half.periods(g=c(8,4+1i))) ## should be c(8,4+1i)
#> g2 g3
#> 8-1.887379e-15i 4+1.000000e+00i
## Example 4, p664, LHS:
omega <- c(10,11i)
(g2 <- g2.fun(omega))
#> [1] 0.001007577+0i
(g3 <- g3.fun(omega))
#> [1] 2.14201e-06+0i
e1e2e3(Re(c(g2,g3)))
#> e1 e2 e3
#> 0.016843041 -0.002166258 -0.014676784
## Example 4, p664, RHS:
omega2 <- 10
omega2dash <- 11i
omega1 <- (omega2-omega2dash)/2 ## From figure 18.1, p630
(g2 <- g2.fun(c(omega1,omega2)))
#> [1] -0.003748749+7.589415e-19i
(g3 <- g3.fun(c(omega1,omega2)))
#> [1] 1.656681e-05-8.470329e-22i
e1e2e3(Re(c(g2,g3)))
#> e1 e2 e3
#> -0.002166258+0.03084259i 0.004332515+0.00000000i -0.002166258-0.03084259i