Learn R Programming

elliptic (version 1.4-0)

congruence: Solves mx+by=1 for x and y

Description

Solves the Diophantine equation \(mx+by=1\) for \(x\) and \(y\). The function is named for equation 57 in Hardy and Wright.

Usage

congruence(a, l = 1)

Arguments

a

Two element vector with a=c(m,n)

l

Right hand side with default 1

Value

In the usual case of \((m,n)=1\), returns a square matrix whose rows are a and c(x,y). This matrix is a unimodular transformation that takes a pair of basic periods to another pair of basic periods.

If \((m,n)\neq 1\) then more than one solution is available (for example congruence(c(4,6),2)). In this case, extra rows are added and the matrix is no longer square.

References

G. H. Hardy and E. M. Wright 1985. An introduction to the theory of numbers, Oxford University Press (fifth edition)

See Also

unimodular

Examples

Run this code
# NOT RUN {
M <- congruence(c(4,9))
det(M)

o <- c(1,1i)
g2.fun(o) - g2.fun(o,maxiter=840)  #should be zero

# }

Run the code above in your browser using DataLab