rational

package module
v0.0.0-...-c5a6f46 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 4, 2016 License: MIT Imports: 5 Imported by: 0

README

rational

Package rational brings rational complex, split-complex, and dual numbers to Go. It borrows heavily from the math, math/cmplx, and math/big packages. Indeed, it is built on top of the big.Rat type.

Go Report Card GoDoc

This package contains three two-dimensional types (e.g. complex numbers), five four-dimensional types (e.g. quaternions), and seven eight-dimensional types (e.g. octonions). Each type is either an elliptic, a parabolic, or a hyperbolic Cayley-Dickson construct.

Cayley-Dickson Constructs

Given elements from what I will call a seed algebra, the Cayley-Dickson construction allows you to build elements of a higher-dimensional algebra with certain interesting properties. Let a, b, c, and d be elements in the seed algebra. Let p = (a, b) and q = (c, d) be elements in the construct algebra. Thus,

	Add(p, q) = (Add(a, c), Add(b, d))

That is, addition is element-wise. The multiplication operation can be any of three kinds. Before we look into these, we should mention that the seed algebra must also include two involutions, Conj and Neg, such that the construct algebra also has two involutions Conj and Neg given by:

	Neg(p) = (Neg(a), Neg(b))
	Conj(p) = (Conj(a), Neg(b))

With Neg you can define subtraction:

	Sub(p, q) = Add(p, Neg(q))

The three multiplication operations are named after conic sections. Each has the form

	Mul(p, q) = (F(a, b, c, d), G(a, b, c, d))

With F and G being a linear combination of bilinear terms.

Elliptic Multiplication

The elliptic multiplication operation is:

	F(a, b, c, d) = Sub(Mul(a, c), Mul(Conj(d), b))
	G(a, b, c, d) = Add(Mul(d, a), Mul(b, Conj(c)))

The order of the arguments in all Mul calls is very important.

Parabolic Multiplication

The parabolic multiplication operation is:

	F(a, b, c, d) = Mul(a, c)
	G(a, b, c, d) = Add(Mul(d, a), Mul(b, Conj(c)))

The order of the arguments in all Mul calls is very important. Note that if a and c are both zero, then Mul(p, q) = (0, 0) with p and q not necessarily being zero. That is, there are zero divisors with this multiplication operation.

Hyperbolic Multiplication

The hyperbolic multiplication operation is:

	F(a, b, c, d) = Add(Mul(a, c), Mul(Conj(d), b))
	G(a, b, c, d) = Add(Mul(d, a), Mul(b, Conj(c)))

The order of the arguments in all Mul calls is very important. Although it is not obvious, this multiplication operation also leads to zero divisors.

Non-Sesquilinear Multiplication

The three "conic" multiplication operations above all use the Conj involution of the seed algebra. One can also consider non-sesquilinear multiplication rules. If the seed algebra is commutative and associative, then the resulting construct algebra will also be commutative and associative.

The non-sesquilinear elliptic multiplication operation is:

	F(a, b, c, d) = Sub(Mul(a, c), Mul(b, d))
	G(a, b, c, d) = Add(Mul(a, d), Mul(b, c))

The non-sesquilinear parabolic multiplication operation is:

	F(a, b, c, d) = Mul(a, c)
	G(a, b, c, d) = Add(Mul(a, d), Mul(b, c))

The non-sesquilinear hyperbolic multiplication operation is:

	F(a, b, c, d) = Add(Mul(a, c), Mul(b, d))
	G(a, b, c, d) = Add(Mul(a, d), Mul(b, c))

Note the different ordering in some of the Mul calls. The resulting construct algebras are very different from the familiar Cayley-Dickson constructs.

Two-Dimensional Types

There are three two-dimensional types. The (binary) multiplication operation for all two-dimensional types is commutative and associative.

rational.Complex

The rational.Complex type represents a rational complex number. It corresponds to an elliptic Cayley-Dickson construct with big.Rat values. The imaginary unit element is denoted i. The multiplication rule is:

	Mul(i, i) = -1

This type can be used to study Gaussian integers.

rational.Perplex

The rational.Perplex type represents a rational perplex number. It corresponds to a hyperbolic Cayley-Dickson construct with big.Rat values. The split unit element is denoted s. The multiplication rule is:

	Mul(s, s) = +1

Perplex numbers are more commonly known as split-complex numbers, but "perplex" is used here for brevity and symmetry with "complex".

rational.Infra

The rational.Infra type represents a rational infra number. It corresponds to a parabolic Cayley-Dickson construct with big.Rat values. The dual unit element is denoted α. The multiplication rule is:

	Mul(α, α) = 0

Infra numbers are useful for computing numerical first-order derivatives. If z = a + 1α, and f is a function, then

	f(z) = f(a) + f'(a)α

Infra numbers are more commonly known as dual numbers, but "infra" is used here along with "supra" and "ultra" for the higher-dimensional analogs.

Four-Dimensional Types

There are five four-dimensional types. The (binary) multiplication operation for all four-dimensional types is noncommutative but associative.

rational.Hamilton

The rational.Hamilton type represents a rational Hamilton quaternion. It corresponds to an elliptic Cayley-Dickson construct with rational.Complex values. The imaginary unit elements are denoted i, j, and k. The multiplication rules are:

	Mul(i, i) = Mul(j, j) = Mul(k, k) = -1
	Mul(i, j) = -Mul(j, i) = k
	Mul(j, k) = -Mul(k, j) = i
	Mul(k, i) = -Mul(i, k) = j

Hamilton quaternions are traditional quaternions. The type is named after W.R. Hamilton, who discovered quaternions.

This type can be used to study Hurwitz and Lipschitz integers.

rational.Cockle

The rational.Cockle type represents a rational Cockle quaternion. It corresponds to a hyperbolic Cayley-Dickson construct with rational.Complex values. The imaginary unit element is denoted i, and the split unit elements are denoted t and u. The multiplication rules are:

	Mul(i, i) = -1
	Mul(t, t) = Mul(u, u) = +1
	Mul(i, t) = -Mul(t, i) = u
	Mul(u, t) = -Mul(t, u) = i
	Mul(u, i) = -Mul(i, u) = t

Cockle quaternions are more commonly known as split-quaternions. The type is named after J. Cockle, who discovered them.

Alternatively, you can obtain the Cockle quaternions from an elliptic Cayley-Dickson construct with rational.Perplex values; or from a hyperbolic Cayley-Dickson construct with rational.Perplex values.

rational.Supra

The rational.Supra type represents a rational supra number. It corresponds to a parabolic Cayley-Dickson construct with rational.Infra values. The dual unit elements are denoted α, β, and γ. The multiplication rules are:

	Mul(α, α) = Mul(β, β) = Mul(γ, γ) = 0
	Mul(α, β) = -Mul(β, α) = γ
	Mul(β, γ) = Mul(γ, β) = 0
	Mul(γ, α) = Mul(α, γ) = 0

Note that supra numbers are very different from hyper-dual numbers: the multiplication operation for supra numbers is noncommutative. In some ways, supra numbers are the dual analog of quaternions.

rational.InfraComplex

The rational.InfraComplex type represents a rational infra complex number. It corresponds to a parabolic Cayley-Dickson construct with rational.Complex values. The imaginary unit element is denoted i, and the dual unit elements are denoted β and γ. The multiplication rules are:

	Mul(i, i) = -1
	Mul(β, β) = Mul(γ, γ) = 0
	Mul(β, γ) = Mul(γ, β) = 0
	Mul(i, β) = -Mul(β, i) = γ
	Mul(γ, i) = -Mul(i, γ) = β

Note that i does not commute with either β or γ. This makes the infra complex numbers different from the more familiar dual complex numbers.

Alternatively, you can obtain the infra complex numbers from an elliptic Cayley-Dickson construct with rational.Infra values.

rational.InfraPerplex

The rational.InfraPerplex type represents a rational infra perplex number. It corresponds to a parabolic Cayley-Dickson construct with rational.Perplex values. The split unit element is denoted s, and the dual unit elements are denoted τ and υ. The multiplication rules are:

	Mul(s, s) = +1
	Mul(τ, τ) = Mul(υ, υ) = 0
	Mul(τ, υ) = Mul(υ, τ) = 0
	Mul(s, τ) = -Mul(τ, s) = υ
	Mul(s, υ) = -Mul(υ, s) = τ

Like i in the infra complex numbers, s does not commute with either τ or υ. This makes the infra perplex numbers different from the more familiar dual split-complex numbers.

Alternatively, you can obtain the infra perplex numbers from a hyperbolic Cayley-Dickson construct with rational.Infra values.

Eight-Dimensional Types

There are seven eight-dimensional types. The (binary) multiplication operation for all eight-dimensional types is noncommutative and nonassociative.

rational.Cayley

The rational.Cayley type represents a rational Cayley octonion. It corresponds to an elliptic Cayley-Dickson construct with rational.Hamilton values. The imaginary unit elements are denoted i, j, k, m, n, p, and q. The multiplication rules are:

	Mul(i, i) = Mul(j, j) = Mul(k, k) = -1
	Mul(m, m) = Mul(n, n) = Mul(p, p) = Mul(q, q) = -1
	Mul(i, j) = -Mul(j, i) = +k
	Mul(i, k) = -Mul(k, i) = -j
	Mul(i, m) = -Mul(m, i) = +n
	Mul(i, n) = -Mul(n, i) = -m
	Mul(i, p) = -Mul(p, i) = -q
	Mul(i, q) = -Mul(q, i) = +p
	Mul(j, k) = -Mul(k, j) = +i
	Mul(j, m) = -Mul(m, j) = +p
	Mul(j, n) = -Mul(n, j) = +q
	Mul(j, p) = -Mul(p, j) = -m
	Mul(j, q) = -Mul(q, j) = -n
	Mul(k, m) = -Mul(m, k) = +q
	Mul(k, n) = -Mul(n, k) = -p
	Mul(k, p) = -Mul(p, k) = +n
	Mul(k, q) = -Mul(q, k) = -m
	Mul(m, n) = -Mul(n, m) = +i
	Mul(m, p) = -Mul(p, m) = +j
	Mul(m, q) = -Mul(q, m) = +k
	Mul(n, p) = -Mul(p, n) = -k
	Mul(n, q) = -Mul(q, n) = +j
	Mul(p, q) = -Mul(q, p) = -i

Cayley octonions are traditional octonions. The type is named after A. Cayley, who was not the first person to discover octonions. The first person to discover octonions was J.T. Graves.

This type can be used to study Gravesian and Kleinian integers, as well as other integral octonions.

rational.Zorn

The rational.Zorn type represents a rational Zorn octonion. It corresponds to a hyperbolic Cayley-Dickson construct with rational.Hamilton values. The imaginary unit elements are denoted i, j, and k, and the split unit elements are r, s, t, and u. The multiplication rules are:

	Mul(i, i) = Mul(j, j) = Mul(k, k) = -1
	Mul(r, r) = Mul(s, s) = Mul(t, t) = Mul(u, u) = +1
	Mul(i, j) = -Mul(j, i) = +k
	Mul(i, k) = -Mul(k, i) = -j
	Mul(i, r) = -Mul(r, i) = +s
	Mul(i, s) = -Mul(s, i) = -r
	Mul(i, t) = -Mul(t, i) = -u
	Mul(i, u) = -Mul(u, i) = +t
	Mul(j, k) = -Mul(k, j) = +i
	Mul(j, r) = -Mul(r, j) = +t
	Mul(j, s) = -Mul(s, j) = +u
	Mul(j, t) = -Mul(t, j) = -r
	Mul(j, u) = -Mul(u, j) = -s
	Mul(k, r) = -Mul(r, k) = +u
	Mul(k, s) = -Mul(s, k) = -t
	Mul(k, t) = -Mul(t, k) = +s
	Mul(k, u) = -Mul(u, k) = -r
	Mul(r, s) = -Mul(s, r) = -i
	Mul(r, t) = -Mul(t, r) = -j
	Mul(r, u) = -Mul(u, r) = -k
	Mul(s, t) = -Mul(t, s) = +k
	Mul(s, u) = -Mul(u, s) = -j
	Mul(t, u) = -Mul(u, t) = +i

Zorn octonions are commonly known as split-octonions. The type is named after M.A. Zorn, who developed a vector-matrix algebra for working with split-octonions.

Alternatively, you can obtain the Zorn octonions from an elliptic Cayley-Dickson construct with rational.Cockle values; or from a hyperbolic Cayley-Dickson construct with rational.Cockle values.

rational.Ultra

The rational.Ultra type represents a rational ultra number. It corresponds to a parabolic Cayley-Dickson construct with rational.Supra values. The dual unit elements are denoted α, β, γ, δ, ε, ζ, and η. The multiplication rules are:

	Mul(α, α) = Mul(β, β) = Mul(γ, γ) = 0
	Mul(δ, δ) = Mul(ε, ε) = Mul(ζ, ζ) = Mul(η, η) = 0
	Mul(α, β) = -Mul(β, α) = +γ
	Mul(α, γ) = Mul(γ, α) = 0
	Mul(α, δ) = -Mul(δ, α) = +ε
	Mul(α, ε) = Mul(ε, α) = 0
	Mul(α, ζ) = -Mul(ζ, α) = -η
	Mul(α, η) = -Mul(η, α) = +ζ
	Mul(β, γ) = Mul(γ, β) = 0
	Mul(β, δ) = -Mul(δ, β) = +ζ
	Mul(β, ε) = -Mul(ε, β) = +η
	Mul(β, ζ) = Mul(ζ, β) = 0
	Mul(β, η) = Mul(η, β) = 0
	Mul(γ, δ) = -Mul(δ, γ) = +η
	Mul(γ, ε) = Mul(ε, γ) = 0
	Mul(γ, ζ) = Mul(ζ, γ) = 0
	Mul(γ, η) = Mul(η, γ) = 0
	Mul(δ, ε) = Mul(ε, δ) = 0
	Mul(δ, ζ) = Mul(ζ, δ) = 0
	Mul(δ, η) = Mul(η, δ) = 0
	Mul(ε, ζ) = Mul(ζ, ε) = 0
	Mul(ε, η) = Mul(η, ε) = 0
	Mul(ζ, η) = Mul(η, ζ) = 0

In some ways, ultra numbers are the dual analog of octonions.

rational.InfraHamilton

The rational.InfraHamilton type represents a rational infra Hamilton quaternion. It corresponds to a parabolic Cayley-Dickson construct with rational.Hamilton values. The imaginary unit elements are denoted i, j and k, and the dual unit elements are denoted α, β, γ, and δ. The multiplication rules are:

	Mul(i, i) = Mul(j, j) = Mul(k, k) = -1
	Mul(α, α) = Mul(β, β) = Mul(γ, γ) = Mul(δ, δ) = 0
	Mul(i, j) = -Mul(j, i) = +k
	Mul(i, k) = -Mul(k, i) = -j
	Mul(i, α) = -Mul(α, i) = +β
	Mul(i, β) = -Mul(β, i) = -α
	Mul(i, γ) = -Mul(γ, i) = -δ
	Mul(i, δ) = -Mul(δ, i) = +γ
	Mul(j, k) = -Mul(k, j) = +i
	Mul(j, α) = -Mul(α, j) = +γ
	Mul(j, β) = -Mul(β, j) = +δ
	Mul(j, γ) = -Mul(γ, j) = -α
	Mul(j, δ) = -Mul(δ, j) = -β
	Mul(k, α) = -Mul(α, k) = +δ
	Mul(k, β) = -Mul(β, k) = -γ
	Mul(k, γ) = -Mul(γ, k) = +β
	Mul(k, δ) = -Mul(δ, k) = -α
	Mul(α, β) = Mul(β, α) = 0
	Mul(α, γ) = Mul(γ, α) = 0
	Mul(α, δ) = Mul(δ, α) = 0
	Mul(β, γ) = Mul(γ, β) = 0
	Mul(β, δ) = Mul(δ, β) = 0
	Mul(γ, δ) = Mul(δ, γ) = 0

The infra Hamilton quaternions are different from the more familiar dual quaternions.

Alternatively, you can obtain the infra Hamilton quaternions from an elliptic Cayley-Dickson construct with rational.InfraComplex values.

rational.InfraCockle

The rational.InfraCockle type represents a rational infra Cockle quaternion. It corresponds to a parabolic Cayley-Dickson construct with rational.Cockle values. The imaginary unit element is denoted i, the split unit elements are denoted t and u, and the dual unit elements are denoted ρ, σ, τ, and υ. The multiplication rules are:

	Mul(i, i) = -1
	Mul(t, t) = Mul(u, u) = +1
	Mul(ρ, ρ) = Mul(σ, σ) = Mul(τ, τ) = Mul(υ, υ) = 0
	Mul(i, t) = -Mul(t, i) = +u
	Mul(i, u) = -Mul(u, i) = -t
	Mul(i, ρ) = -Mul(ρ, i) = +σ
	Mul(i, σ) = -Mul(σ, i) = -ρ
	Mul(i, τ) = -Mul(τ, i) = -υ
	Mul(i, υ) = -Mul(υ, i) = +τ
	Mul(t, u) = -Mul(u, t) = -i
	Mul(t, ρ) = -Mul(ρ, t) = +τ
	Mul(t, σ) = -Mul(σ, t) = +υ
	Mul(t, τ) = -Mul(τ, t) = +ρ
	Mul(t, υ) = -Mul(υ, t) = +σ
	Mul(u, ρ) = -Mul(ρ, u) = +υ
	Mul(u, σ) = -Mul(σ, u) = -τ
	Mul(u, τ) = -Mul(τ, u) = -σ
	Mul(u, υ) = -Mul(υ, u) = +ρ
	Mul(ρ, σ) = Mul(σ, ρ) = 0
	Mul(ρ, τ) = Mul(τ, ρ) = 0
	Mul(ρ, υ) = Mul(υ, ρ) = 0
	Mul(σ, τ) = Mul(τ, σ) = 0
	Mul(σ, υ) = Mul(υ, σ) = 0
	Mul(τ, υ) = Mul(υ, τ) = 0

The infra Cockle quaternions are different from the more familiar dual split-quaternions.

Alternatively, you can obtain the infra Cockle quaternions from a hyperbolic Cayley-Dickson construct with rational.InfraComplex values; an elliptic Cayley-Dickson construct with rational.InfraPerplex values; or a hyperbolic Cayley-Dickson construct with rational.InfraPerplex values.

rational.SupraComplex

The rational.SupraComplex type represents a rational supra complex number. It corresponds to a parabolic Cayley-Dickson construct with rational.InfraComplex values. The imaginary unit element is denoted i, and the dual unit elements are denoted α, β, γ, δ, ε, and ζ. The multiplication rules are:

	Mul(i, i) = -1
	Mul(α, α) = Mul(β, β) = Mul(γ, γ) = 0
	Mul(δ, δ) = Mul(ε, ε) = Mul(ζ, ζ) = 0
	Mul(i, α) = -Mul(α, i) = +β
	Mul(i, β) = -Mul(β, i) = -α
	Mul(i, γ) = -Mul(γ, i) = +δ
	Mul(i, δ) = -Mul(δ, i) = -γ
	Mul(i, ε) = -Mul(ε, i) = -ζ
	Mul(i, ζ) = -Mul(ζ, i) = +ε
	Mul(α, β) = Mul(β, α) = 0
	Mul(α, γ) = -Mul(γ, α) = +ε
	Mul(α, δ) = -Mul(δ, α) = +ζ
	Mul(α, ε) = Mul(ε, α) = 0
	Mul(α, ζ) = Mul(ζ, α) = 0
	Mul(β, γ) = -Mul(γ, β) = +ζ
	Mul(β, δ) = -Mul(δ, β) = -ε
	Mul(β, ε) = Mul(ε, β) = 0
	Mul(β, ζ) = Mul(ζ, β) = 0
	Mul(γ, δ) = Mul(δ, γ) = 0
	Mul(γ, ε) = Mul(ε, γ) = 0
	Mul(γ, ζ) = Mul(ζ, γ) = 0
	Mul(δ, ε) = Mul(ε, δ) = 0
	Mul(δ, ζ) = Mul(ζ, δ) = 0
	Mul(ε, ζ) = Mul(ζ, ε) = 0

Alternatively, you can obtain the supra complex numbers from an elliptic Cayley-Dickson construct with rational.Supra values.

rational.SupraPerplex

The rational.SupraPerplex type represents a rational supra perplex number. It corresponds to a parabolic Cayley-Dickson construct with rational.InfraPerplex values. The split unit element is denoted s, and the dual unit elements are denoted ρ, σ, τ, υ, φ, and ψ. The multiplication rules are:

	Mul(s, s) = +1
	Mul(ρ, ρ) = Mul(σ, σ) = Mul(τ, τ) = 0
	Mul(υ, υ) = Mul(φ, φ) = Mul(ψ, ψ) = 0
	Mul(s, ρ) = -Mul(ρ, s) = +σ
	Mul(s, σ) = -Mul(σ, s) = +ρ
	Mul(s, τ) = -Mul(τ, s) = +υ
	Mul(s, υ) = -Mul(υ, s) = +τ
	Mul(s, φ) = -Mul(φ, s) = -ψ
	Mul(s, ψ) = -Mul(ψ, s) = -φ
	Mul(ρ, σ) = Mul(σ, ρ) = 0
	Mul(ρ, τ) = -Mul(τ, ρ) = +φ
	Mul(ρ, υ) = -Mul(υ, ρ) = +ψ
	Mul(ρ, φ) = Mul(φ, ρ) = 0
	Mul(ρ, ψ) = Mul(ψ, ρ) = 0
	Mul(σ, τ) = -Mul(τ, σ) = +ψ
	Mul(σ, υ) = -Mul(υ, σ) = +φ
	Mul(σ, φ) = Mul(φ, σ) = 0
	Mul(σ, ψ) = Mul(ψ, σ) = 0
	Mul(τ, υ) = Mul(υ, τ) = 0
	Mul(τ, φ) = Mul(φ, τ) = 0
	Mul(τ, ψ) = Mul(ψ, τ) = 0
	Mul(υ, φ) = Mul(φ, υ) = 0
	Mul(υ, ψ) = Mul(ψ, υ) = 0
	Mul(φ, ψ) = Mul(ψ, φ) = 0

Alternatively, you can obtain the supra perplex numbers from a hyperbolic Cayley-Dickson construct with rational.Supra values.

And Beyond...

Using any of the Cayley-Dickson constructs on any of the eight-dimensional types would produce one of nine sixteen-dimensional types. These types include the sedenions, which are infamous for containing zero divisors.

Other Types

Besides all the types mentioned above, other types are included. These types have multiplication operations that do not involve conjugation.

rational.BiComplex

The rational.BiComplex type represents a bicomplex number. It corresponds to a non-sesquilinear elliptic construct with rational.Complex values. The imaginary units are denoted i and J. The multiplication rules are:

	Mul(i, i) = Mul(J, J) = -1
	Mul(i, J) = Mul(J, i)

Note that this multiplication operation is commutative and associative.

rational.BiPerplex

The rational.BiPerplex type represents a biperplex number. It corresponds to a non-sesquilinear hyperbolic construct with rational.Perplex values. The split units are denoted s and T. The multiplication rules are:

	Mul(s, s) = Mul(T, T) = +1
	Mul(s, T) = Mul(T, s)

Note that this multiplication operation is commutative and associative.

rational.Hyper

The rational.Hyper type represents a hyper-dual number. It corresponds to a non-sesquilinear parabolic construct with rational.Infra values. The dual units are denoted α and Γ. The multiplication rules are:

	Mul(α, α) = Mul(Γ, Γ) = 0
	Mul(α, Γ) = Mul(Γ, α)

Note that this multiplication operation is commutative and associative.

Hyper-dual numbers are useful for computing second-order derivatives. If z = a + 1α + 1Γ + 0αΓ, and f is a function, then

	f(z) = f(a) + f'(a)α + f'(a)Γ + f''(a)αΓ

Another name for the dual numbers could be the nilplex numbers. Thus, in analogy with the bicomplex numbers, another name for the hyper-dual numbers could be the binilplex numbers.

rational.DualComplex

The rational.DualComplex type represents a dual-complex number. It corresponds to a non-sesquilinear parabolic construct with rational.Complex values. The imaginary unit is denoted i, and the dual unit is denoted Γ. The multiplication rules are:

	Mul(i, i) = -1
	Mul(Γ, Γ) = 0
	Mul(i, Γ) = Mul(Γ, i)

Note that this multiplication operation is commutative and associative.

Dual-complex numbers are useful for evaluating two-dimensional vector derivatives. Let (x, y) be the coordinate vector in a two-dimensional space. Also, let f = (g, h) be a function vector. Then, the divergence and the curl of f are:

	Div(f) = (∂g / ∂x) + (∂h / ∂y)
	Curl(f) = (∂h / ∂x) - (∂g / ∂y)

A two-dimensional vector (x, y) can be associated with a complex number z = x + yi. Introduce the Wirtinger derivative

	(∂ / ∂z) = (1 / 2) * ((∂ / ∂x) - (∂ / ∂y)i)

The function vector (g, h) becomes the complex number f = g + hi. Then:

	2 * (∂f / ∂z) = Div(f) + (Curl(f))i

Thus, in analogy with the dual numbers, given a dual-complex number p = a + bi + 2Γ + 0iΓ, and a function f, then

	f(p) = f(a + bi) + (∂f / ∂z) * (2Γ + 0iΓ)
		 = f(a + bi) + (Div(f))Γ + (Curl(f))iΓ

In this manner, f, Div(f), and Curl(f) can be calculated at the point a + bi by just evaluating f(a + bi + 2Γ + 0iΓ). Note that this derivation assumes that f is holomorphic (i.e. that it only depends on a and b in the combination a + bi).

rational.DualPerplex

The rational.DualPerplex type represents a dual-perplex number. It corresponds to a non-sesquilinear parabolic construct with rational.Perplex values. The split unit is denoted s, and the dual unit is denoted Γ. The multiplication rules are:

	Mul(s, s) = +1
	Mul(Γ, Γ) = 0
	Mul(s, Γ) = Mul(Γ, s)

Note that this multiplication operation is commutative and associative.

Just like dual-complex numbers, the dual-perplex numbers can be used to evaluate certain vector derivatives. Let w = x + ys and f = g + hs. The Wirtinger derivative is now

	(∂ / ∂w) = (1 / 2) * ((∂ / ∂x) + (∂ / ∂y)s)

Then:

	2 * (∂f / ∂w) = ((∂g / ∂x) + (∂h / ∂y)) + ((∂h / ∂x) + (∂g / ∂y))s

This suggests the introduction of the hyperbolic version of the curl:

	Hurl(f) = (∂h / ∂x) + (∂g / ∂y)

Now let p = a + bs + 2Γ + 0sΓ. Thus,

	f(p) = f(a + bs) + (Div(f))Γ + (Hurl(f))sΓ

Again, f, Div(f), and now Hurl(f) can be calculated at the point a + bs by just evaluating f(a + bs + 2Γ + 0sΓ).

To Do

  1. Improve documentation
  2. Tests
  3. DualHamilton type
  4. DualCockle type
  5. Elementary and special functions via Padé approximants
  6. Simplify symbols for constructs from plexification
  7. Complexification, Nilplexification, Perplexification

Documentation

Overview

Package rational implements arithmetic for many elliptic, parabolic, and hyperbolic Cayley-Dickson constructs over the rational numbers and their plexifications.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BiCockle

type BiCockle struct {
	// contains filtered or unexported fields
}

A BiCockle represents a rational Cockle biquaternion.

func NewBiCockle

func NewBiCockle(a, b, c, d, e, f, g, h *big.Rat) *BiCockle

NewBiCockle returns a *BiCockle with value a+bi+ct+du+eH+fiH+gtH+huH.

func (*BiCockle) Add

func (z *BiCockle) Add(x, y *BiCockle) *BiCockle

Add sets z equal to x+y, and returns z.

func (*BiCockle) Commutator

func (z *BiCockle) Commutator(x, y *BiCockle) *BiCockle

Commutator sets z equal to the commutator of x and y:

Mul(x, y) - Mul(y, x)

Then it returns z.

func (*BiCockle) Conj

func (z *BiCockle) Conj(y *BiCockle) *BiCockle

Conj sets z equal to the conjugate of y, and returns z.

func (*BiCockle) CrossRatioL

func (z *BiCockle) CrossRatioL(v, w, x, y *BiCockle) *BiCockle

CrossRatioL sets z equal to the left cross-ratio of v, w, x, and y:

Inv(w - x) * (v - x) * Inv(v - y) * (w - y)

Then it returns z.

func (*BiCockle) CrossRatioR

func (z *BiCockle) CrossRatioR(v, w, x, y *BiCockle) *BiCockle

CrossRatioR sets z equal to the right cross-ratio of v, w, x, and y:

(v - x) * Inv(w - x) * (w - y) * Inv(v - y)

Then it returns z.

func (*BiCockle) Equals

func (z *BiCockle) Equals(y *BiCockle) bool

Equals returns true if y and z are equal.

func (*BiCockle) Generate

func (z *BiCockle) Generate(rand *rand.Rand, size int) reflect.Value

Generate returns a random BiCockle value for quick.Check testing.

func (*BiCockle) Inv

func (z *BiCockle) Inv(y *BiCockle) *BiCockle

Inv sets z equal to the inverse of y, and returns z. If y is a zero divisor, then Inv panics.

func (*BiCockle) IsZeroDivisor

func (z *BiCockle) IsZeroDivisor() bool

IsZeroDivisor returns true if z is a zero divisor.

func (*BiCockle) Mul

func (z *BiCockle) Mul(x, y *BiCockle) *BiCockle

Mul sets z equal to the product of x and y, and returns z.

The multiplication rules are:

Mul(i, i) = Mul(H, H) = -1
Mul(t, t) = Mul(u, u) = +1
Mul(i, t) = -Mul(t, i) = +u
Mul(i, u) = -Mul(u, i) = -t
Mul(i, H) = Mul(H, i)
Mul(t, u) = -Mul(u, t) = -i
Mul(t, H) = Mul(H, t)
Mul(u, H) = Mul(H, u)

This binary operation is noncommutative but associative.

func (*BiCockle) MöbiusL

func (z *BiCockle) MöbiusL(y, a, b, c, d *BiCockle) *BiCockle

MöbiusL sets z equal to the left Möbius (fractional linear) transform of y:

Inv(y*c + d) * (y*a + b)

Then it returns z.

func (*BiCockle) MöbiusR

func (z *BiCockle) MöbiusR(y, a, b, c, d *BiCockle) *BiCockle

MöbiusR sets z equal to the right Möbius (fractional linear) transform of y:

(a*y + b) * Inv(c*y + d)

Then it returns z.

func (*BiCockle) Neg

func (z *BiCockle) Neg(y *BiCockle) *BiCockle

Neg sets z equal to the negative of y, and returns z.

func (*BiCockle) Norm

func (z *BiCockle) Norm() *big.Rat

Norm returns the norm of z. If z = a+bi+ct+du+eH+fiH+gtH+huH, then the norm is

(a² + b² - c² - d² - e² - f² + g² + h²)² +
4(ae + bf - cg - dh)²

The norm is always non-negative.

func (*BiCockle) QuoL

func (z *BiCockle) QuoL(x, y *BiCockle) *BiCockle

QuoL sets z equal to the left quotient of x and y:

Mul(Inv(y), x)

Then it returns z. If y is zero, then QuoL panics.

func (*BiCockle) QuoR

func (z *BiCockle) QuoR(x, y *BiCockle) *BiCockle

QuoR sets z equal to the right quotient of x and y:

Mul(x, Inv(y))

Then it returns z. If y is zero, then QuoR panics.

func (*BiCockle) Rats

func (z *BiCockle) Rats() (*big.Rat, *big.Rat, *big.Rat, *big.Rat,
	*big.Rat, *big.Rat, *big.Rat, *big.Rat)

Rats returns the eight rational components of z.

func (*BiCockle) Real

func (z *BiCockle) Real() *big.Rat

Real returns the (rational) real part of z.

func (*BiCockle) Scal

func (z *BiCockle) Scal(y *BiCockle, a *big.Rat) *BiCockle

Scal sets z equal to y scaled by a, and returns z.

func (*BiCockle) Set

func (z *BiCockle) Set(y *BiCockle) *BiCockle

Set sets z equal to y, and returns z.

func (*BiCockle) String

func (z *BiCockle) String() string

String returns the string representation of a BiCockle value.

func (*BiCockle) Sub

func (z *BiCockle) Sub(x, y *BiCockle) *BiCockle

Sub sets z equal to x-y, and returns z.

type BiComplex

type BiComplex struct {
	// contains filtered or unexported fields
}

A BiComplex represents a rational bicomplex number.

func NewBiComplex

func NewBiComplex(a, b, c, d *big.Rat) *BiComplex

NewBiComplex returns a *BiComplex with value a+bi+cJ+diJ.

func (*BiComplex) Add

func (z *BiComplex) Add(x, y *BiComplex) *BiComplex

Add sets z equal to x+y, and returns z.

func (*BiComplex) Conj

func (z *BiComplex) Conj(y *BiComplex) *BiComplex

Conj sets z equal to the conjugate of y, and returns z. This operation changes the sign of all the components with J.

func (*BiComplex) CrossRatio

func (z *BiComplex) CrossRatio(v, w, x, y *BiComplex) *BiComplex

CrossRatio sets z equal to the cross-ratio of v, w, x, and y:

Inv(w - x) * (v - x) * Inv(v - y) * (w - y)

Then it returns z.

func (*BiComplex) Equals

func (z *BiComplex) Equals(y *BiComplex) bool

Equals returns true if y and z are equal.

func (*BiComplex) Generate

func (z *BiComplex) Generate(rand *rand.Rand, size int) reflect.Value

Generate returns a random BiComplex value for quick.Check testing.

func (*BiComplex) Inv

func (z *BiComplex) Inv(y *BiComplex) *BiComplex

Inv sets z equal to the inverse of y, and returns z. If y is a zero divisor, then Inv panics.

func (*BiComplex) IsZeroDivisor

func (z *BiComplex) IsZeroDivisor() bool

IsZeroDivisor returns true if z is a zero divisor.

func (*BiComplex) Mul

func (z *BiComplex) Mul(x, y *BiComplex) *BiComplex

Mul sets z equal to the product of x and y, and returns z.

The multiplication rules are:

Mul(i, i) = Mul(J, J) = -1
Mul(i, J) = Mul(J, i)

This binary operation is commutative and associative.

func (*BiComplex) Möbius

func (z *BiComplex) Möbius(y, a, b, c, d *BiComplex) *BiComplex

Möbius sets z equal to the Möbius (fractional linear) transform of y:

(a*y + b) * Inv(c*y + d)

Then it returns z.

func (*BiComplex) Neg

func (z *BiComplex) Neg(y *BiComplex) *BiComplex

Neg sets z equal to the negative of y, and returns z.

func (*BiComplex) Norm

func (z *BiComplex) Norm() *big.Rat

Norm returns the norm of z. If z = a+bi+cJ+diJ, then the norm is

(a² - b² + c² - d²)² + 4(ab + cd)²

There is another way to write the norm as a sum of two squares:

(a² + b² - c² - d²)² + 4(ac + bd)²

Alternatively, it can also be written as a difference of two squares:

(a² + b² + c² + d²)² - 4(ad - bc)²

Finally, you have the factorized form:

((a - d)² + (b + c)²)((a + d)² + (b - c)²)

In this form it is clear that the norm is always non-negative.

func (*BiComplex) Quad

func (z *BiComplex) Quad() *Complex

Quad returns the quadrance of z. If z = a+bi+cJ+diJ, then the quadrance is

a² - b² + c² - d² + 2(ab + cd)i

Note that this is a complex number.

func (*BiComplex) Quo

func (z *BiComplex) Quo(x, y *BiComplex) *BiComplex

Quo sets z equal to the quotient of x and y. If y is a zero divisor, then Quo panics.

func (*BiComplex) Rats

func (z *BiComplex) Rats() (*big.Rat, *big.Rat, *big.Rat, *big.Rat)

Rats returns the four rational components of z.

func (*BiComplex) Real

func (z *BiComplex) Real() *big.Rat

Real returns the (rational) real part of z.

func (*BiComplex) Scal

func (z *BiComplex) Scal(y *BiComplex, a *big.Rat) *BiComplex

Scal sets z equal to y scaled by a, and returns z.

func (*BiComplex) Set

func (z *BiComplex) Set(y *BiComplex) *BiComplex

Set sets z equal to y, and returns z.

func (*BiComplex) Star

func (z *BiComplex) Star(y *BiComplex) *BiComplex

Star sets z equal to the star conjugate of y, and returns z.

func (*BiComplex) String

func (z *BiComplex) String() string

String returns the string representation of a BiComplex value.

func (*BiComplex) Sub

func (z *BiComplex) Sub(x, y *BiComplex) *BiComplex

Sub sets z equal to x-y, and returns z.

type BiHamilton

type BiHamilton struct {
	// contains filtered or unexported fields
}

A BiHamilton represents a rational Hamilton biquaternion.

func NewBiHamilton

func NewBiHamilton(a, b, c, d, e, f, g, h *big.Rat) *BiHamilton

NewBiHamilton returns a *BiHamilton with value a+bi+cj+dk+eH+fiH+gjH+hkH.

func (*BiHamilton) Add

func (z *BiHamilton) Add(x, y *BiHamilton) *BiHamilton

Add sets z equal to x+y, and returns z.

func (*BiHamilton) Commutator

func (z *BiHamilton) Commutator(x, y *BiHamilton) *BiHamilton

Commutator sets z equal to the commutator of x and y:

Mul(x, y) - Mul(y, x)

Then it returns z.

func (*BiHamilton) Conj

func (z *BiHamilton) Conj(y *BiHamilton) *BiHamilton

Conj sets z equal to the conjugate of y, and returns z.

func (*BiHamilton) CrossRatioL

func (z *BiHamilton) CrossRatioL(v, w, x, y *BiHamilton) *BiHamilton

CrossRatioL sets z equal to the left cross-ratio of v, w, x, and y:

Inv(w - x) * (v - x) * Inv(v - y) * (w - y)

Then it returns z.

func (*BiHamilton) CrossRatioR

func (z *BiHamilton) CrossRatioR(v, w, x, y *BiHamilton) *BiHamilton

CrossRatioR sets z equal to the right cross-ratio of v, w, x, and y:

(v - x) * Inv(w - x) * (w - y) * Inv(v - y)

Then it returns z.

func (*BiHamilton) Equals

func (z *BiHamilton) Equals(y *BiHamilton) bool

Equals returns true if y and z are equal.

func (*BiHamilton) Generate

func (z *BiHamilton) Generate(rand *rand.Rand, size int) reflect.Value

Generate returns a random BiHamilton value for quick.Check testing.

func (*BiHamilton) Inv

func (z *BiHamilton) Inv(y *BiHamilton) *BiHamilton

Inv sets z equal to the inverse of y, and returns z. If y is a zero divisor, then Inv panics.

func (*BiHamilton) IsZeroDivisor

func (z *BiHamilton) IsZeroDivisor() bool

IsZeroDivisor returns true if z is a zero divisor.

func (*BiHamilton) Mul

func (z *BiHamilton) Mul(x, y *BiHamilton) *BiHamilton

Mul sets z equal to the product of x and y, and returns z.

The multiplication rules are:

Mul(i, i) = Mul(j, j) = Mul(k, k) = Mul(H, H) = -1
Mul(i, j) = -Mul(j, i) = +k
Mul(i, k) = -Mul(k, i) = -j
Mul(i, H) = Mul(H, i)
Mul(j, k) = -Mul(k, j) = +i
Mul(j, H) = Mul(H, j)
Mul(k, H) = Mul(H, k)

This binary operation is noncommutative but associative.

func (*BiHamilton) MöbiusL

func (z *BiHamilton) MöbiusL(y, a, b, c, d *BiHamilton) *BiHamilton

MöbiusL sets z equal to the left Möbius (fractional linear) transform of y:

Inv(y*c + d) * (y*a + b)

Then it returns z.

func (*BiHamilton) MöbiusR

func (z *BiHamilton) MöbiusR(y, a, b, c, d *BiHamilton) *BiHamilton

MöbiusR sets z equal to the right Möbius (fractional linear) transform of y:

(a*y + b) * Inv(c*y + d)

Then it returns z.

func (*BiHamilton) Neg

func (z *BiHamilton) Neg(y *BiHamilton) *BiHamilton

Neg sets z equal to the negative of y, and returns z.

func (*BiHamilton) Norm

func (z *BiHamilton) Norm() *big.Rat

Norm returns the norm of z. If z = a+bi+cj+dk+eH+fS+gT+hU, then the norm is

(a² + b² + c² + d² - e² - f² - g² - h²)² +
4(ae + bf + cg + dh)²

The norm is always non-negative.

func (*BiHamilton) QuoL

func (z *BiHamilton) QuoL(x, y *BiHamilton) *BiHamilton

QuoL sets z equal to the left quotient of x and y:

Mul(Inv(y), x)

Then it returns z. If y is zero, then QuoL panics.

func (*BiHamilton) QuoR

func (z *BiHamilton) QuoR(x, y *BiHamilton) *BiHamilton

QuoR sets z equal to the right quotient of x and y:

Mul(x, Inv(y))

Then it returns z. If y is zero, then QuoR panics.

func (*BiHamilton) Rats

func (z *BiHamilton) Rats() (*big.Rat, *big.Rat, *big.Rat, *big.Rat,
	*big.Rat, *big.Rat, *big.Rat, *big.Rat)

Rats returns the eight rational components of z.

func (*BiHamilton) Real

func (z *BiHamilton) Real() *big.Rat

Real returns the (rational) real part of z.

func (*BiHamilton) Scal

func (z *BiHamilton) Scal(y *BiHamilton, a *big.Rat) *BiHamilton

Scal sets z equal to y scaled by a, and returns z.

func (*BiHamilton) Set

func (z *BiHamilton) Set(y *BiHamilton) *BiHamilton

Set sets z equal to y, and returns z.

func (*BiHamilton) String

func (z *BiHamilton) String() string

String returns the string representation of a BiHamilton value.

If z corresponds to a + bi + cj + dk + eH + fiH + gjH + hkH, then the string is "(a+bi+cj+dk+eH+fiH+gjH+hkH)", similar to complex128 values.

func (*BiHamilton) Sub

func (z *BiHamilton) Sub(x, y *BiHamilton) *BiHamilton

Sub sets z equal to x-y, and returns z.

type BiPerplex

type BiPerplex struct {
	// contains filtered or unexported fields
}

A BiPerplex represents a rational biperplex number.

func NewBiPerplex

func NewBiPerplex(a, b, c, d *big.Rat) *BiPerplex

NewBiPerplex returns a *BiPerplex with value a+bs+cR+dsT.

func (*BiPerplex) Add

func (z *BiPerplex) Add(x, y *BiPerplex) *BiPerplex

Add sets z equal to x+y, and returns z.

func (*BiPerplex) Conj

func (z *BiPerplex) Conj(y *BiPerplex) *BiPerplex

Conj sets z equal to the conjugate of y, and returns z.

func (*BiPerplex) CrossRatio

func (z *BiPerplex) CrossRatio(v, w, x, y *BiPerplex) *BiPerplex

CrossRatio sets z equal to the cross-ratio of v, w, x, and y:

Inv(w - x) * (v - x) * Inv(v - y) * (w - y)

Then it returns z.

func (*BiPerplex) Equals

func (z *BiPerplex) Equals(y *BiPerplex) bool

Equals returns true if y and z are equal.

func (*BiPerplex) Generate

func (z *BiPerplex) Generate(rand *rand.Rand, size int) reflect.Value

Generate returns a random BiPerplex value for quick.Check testing.

func (*BiPerplex) Inv

func (z *BiPerplex) Inv(y *BiPerplex) *BiPerplex

Inv sets z equal to the inverse of y, and returns z. If y is a zero divisor, then Inv panics.

func (*BiPerplex) IsZeroDivisor

func (z *BiPerplex) IsZeroDivisor() bool

IsZeroDivisor returns true if z is a zero divisor.

func (*BiPerplex) Mul

func (z *BiPerplex) Mul(x, y *BiPerplex) *BiPerplex

Mul sets z equal to the product of x and y, and returns z.

The multiplication rules are:

Mul(s, s) = Mul(T, T) = +1
Mul(s, T) = Mul(T, s)

This binary operation is commutative and associative.

func (*BiPerplex) Möbius

func (z *BiPerplex) Möbius(y, a, b, c, d *BiPerplex) *BiPerplex

Möbius sets z equal to the Möbius (fractional linear) transform of y:

(a*y + b) * Inv(c*y + d)

Then it returns z.

func (*BiPerplex) Neg

func (z *BiPerplex) Neg(y *BiPerplex) *BiPerplex

Neg sets z equal to the negative of y, and returns z.

func (*BiPerplex) Norm

func (z *BiPerplex) Norm() *big.Rat

Norm returns the norm of z. If z = a+bs+cR+dsT, then the norm is

(a² + b² - c² - d²)² - 4(ab - cd)²

This can also be written as

((a + b)² - (c + d)²)((a - b)² - (c + d)²)

In this form, the norm looks similar to the norm of the BiComplex type. The norm can also be written as

(a + b + c + d)(a + b - c - d)(a - b + c - d)(a - b - c + d)

In this form the norm looks similar to Brahmagupta's formula for the area of a cyclic quadrilateral. The norm can be positive, negative, or zero.

func (*BiPerplex) Quad

func (z *BiPerplex) Quad() *Perplex

Quad returns the quadrance of z. If z = a+bs+cR+dsT, then the quadrance is

a² + b² - c² - d² + 2(ab - cd)s

Note that this is a perplex number.

func (*BiPerplex) Quo

func (z *BiPerplex) Quo(x, y *BiPerplex) *BiPerplex

Quo sets z equal to the quotient of x and y. If y is a zero divisor, then Quo panics.

func (*BiPerplex) Rats

func (z *BiPerplex) Rats() (*big.Rat, *big.Rat, *big.Rat, *big.Rat)

Rats returns the four rational components of z.

func (*BiPerplex) Real

func (z *BiPerplex) Real() *big.Rat

Real returns the (rational) real part of z.

func (*BiPerplex) Scal

func (z *BiPerplex) Scal(y *BiPerplex, a *big.Rat) *BiPerplex

Scal sets z equal to y scaled by a, and returns z.

func (*BiPerplex) Set

func (z *BiPerplex) Set(y *BiPerplex) *BiPerplex

Set sets z equal to y, and returns z.

func (*BiPerplex) Star

func (z *BiPerplex) Star(y *BiPerplex) *BiPerplex

Star sets z equal to the star conjugate of y, and returns z.

func (*BiPerplex) String

func (z *BiPerplex) String() string

String returns the string representation of a BiPerplex value.

func (*BiPerplex) Sub

func (z *BiPerplex) Sub(x, y *BiPerplex) *BiPerplex

Sub sets z equal to x-y, and returns z.

type Cayley

type Cayley struct {
	// contains filtered or unexported fields
}

A Cayley represents a rational Cayley octonion.

func NewCayley

func NewCayley(a, b, c, d, e, f, g, h *big.Rat) *Cayley

NewCayley returns a pointer to the Cayley value a+bi+cj+dk+em+fn+gp+hq.

func (*Cayley) Add

func (z *Cayley) Add(x, y *Cayley) *Cayley

Add sets z equal to x+y, and returns z.

func (*Cayley) Associator

func (z *Cayley) Associator(w, x, y *Cayley) *Cayley

Associator sets z equal to the associator of w, x, and y:

Mul(Mul(w, x), y) - Mul(w, Mul(x, y))

Then it returns z.

func (*Cayley) Commutator

func (z *Cayley) Commutator(x, y *Cayley) *Cayley

Commutator sets z equal to the commutator of x and y

Mul(x, y) - Mul(y, x)

Then it returns z.

func (*Cayley) Conj

func (z *Cayley) Conj(y *Cayley) *Cayley

Conj sets z equal to the conjugate of y, and returns z.

func (*Cayley) Equals

func (z *Cayley) Equals(y *Cayley) bool

Equals returns true if y and z are equal.

func (*Cayley) Generate

func (z *Cayley) Generate(rand *rand.Rand, size int) reflect.Value

Generate returns a random Cayley value for quick.Check testing.

func (*Cayley) Graves

func (z *Cayley) Graves(a, b, c, d, e, f, g, h *big.Int) *Cayley

Graves sets z equal to the Gravesian integer a+bi+cj+dk+em+fn+gp+hq, and returns z.

func (*Cayley) Inv

func (z *Cayley) Inv(y *Cayley) *Cayley

Inv sets z equal to the inverse of y, and returns z. If y is zero, then Inv panics.

func (*Cayley) Klein

func (z *Cayley) Klein(a, b, c, d, e, f, g, h *big.Int) *Cayley

Klein sets z equal to the Kleinian integer (a+½)+(b+½)i+(c+½)j+(d+½)k+(e+½)m+(f+½)n+(g+½)p+(h+½)q, and returns z.

func (*Cayley) Mul

func (z *Cayley) Mul(x, y *Cayley) *Cayley

Mul sets z equal to the product of x and y, and returns z.

The multiplication rules are:

Mul(i, i) = Mul(j, j) = Mul(k, k) = -1
Mul(m, m) = Mul(n, n) = Mul(p, p) = Mul(q, q) = -1
Mul(i, j) = -Mul(j, i) = +k
Mul(i, k) = -Mul(k, i) = -j
Mul(i, m) = -Mul(m, i) = +n
Mul(i, n) = -Mul(n, i) = -m
Mul(i, p) = -Mul(p, i) = -q
Mul(i, q) = -Mul(q, i) = +p
Mul(j, k) = -Mul(k, j) = +i
Mul(j, m) = -Mul(m, j) = +p
Mul(j, n) = -Mul(n, j) = +q
Mul(j, p) = -Mul(p, j) = -m
Mul(j, q) = -Mul(q, j) = -n
Mul(k, m) = -Mul(m, k) = +q
Mul(k, n) = -Mul(n, k) = -p
Mul(k, p) = -Mul(p, k) = +n
Mul(k, q) = -Mul(q, k) = -m
Mul(m, n) = -Mul(n, m) = +i
Mul(m, p) = -Mul(p, m) = +j
Mul(m, q) = -Mul(q, m) = +k
Mul(n, p) = -Mul(p, n) = -k
Mul(n, q) = -Mul(q, n) = +j
Mul(p, q) = -Mul(q, p) = -i

This binary operation is noncommutative and nonassociative.

func (*Cayley) Neg

func (z *Cayley) Neg(y *Cayley) *Cayley

Neg sets z equal to the negative of y, and returns z.

func (*Cayley) Quad

func (z *Cayley) Quad() *big.Rat

Quad returns the quadrance of z. If z = a+bi+cj+dk+em+fn+gp+hq, then the quadrance is

a² + b² + c² + d² + e² + f² + g² + h²

This is always non-negative.

func (*Cayley) QuoL

func (z *Cayley) QuoL(x, y *Cayley) *Cayley

QuoL sets z equal to the left quotient of x and y:

Mul(Inv(y), x)

Then it returns z. If y is zero, then QuoL panics.

func (*Cayley) QuoR

func (z *Cayley) QuoR(x, y *Cayley) *Cayley

QuoR sets z equal to the right quotient of x and y:

Mul(x, Inv(y))

Then it returns z. If y is zero, then QuoR panics.

func (*Cayley) Rats

func (z *Cayley) Rats() (*big.Rat, *big.Rat, *big.Rat, *big.Rat,
	*big.Rat, *big.Rat, *big.Rat, *big.Rat)

Rats returns the eight rational components of z.

func (*Cayley) Real

func (z *Cayley) Real() *big.Rat

Real returns the (rational) real part of z.

func (*Cayley) Scal

func (z *Cayley) Scal(y *Cayley, a *big.Rat) *Cayley

Scal sets z equal to y scaled by a, and returns z.

func (*Cayley) Set

func (z *Cayley) Set(y *Cayley) *Cayley

Set sets z equal to y, and returns z.

func (*Cayley) String

func (z *Cayley) String() string

String returns the string representation of a Cayley value.

If z corresponds to a + bi + cj + dk + em + fn + gp + hq, then the string is"(a+bi+cj+dk+em+fn+gp+hq)", similar to complex128 values.

func (*Cayley) Sub

func (z *Cayley) Sub(x, y *Cayley) *Cayley

Sub sets z equal to x-y, and returns z.

type Cockle

type Cockle struct {
	// contains filtered or unexported fields
}

A Cockle represents a rational Cockle quaternion.

func NewCockle

func NewCockle(a, b, c, d *big.Rat) *Cockle

NewCockle returns a pointer to the Cockle value a+bi+ct+du.

func (*Cockle) Add

func (z *Cockle) Add(x, y *Cockle) *Cockle

Add sets z equal to x+y, and returns z.

func (*Cockle) Commutator

func (z *Cockle) Commutator(x, y *Cockle) *Cockle

Commutator sets z equal to the commutator of x and y

Mul(x, y) - Mul(y, x)

Then it returns z.

func (*Cockle) Conj

func (z *Cockle) Conj(y *Cockle) *Cockle

Conj sets z equal to the conjugate of y, and returns z.

func (*Cockle) CrossRatioL

func (z *Cockle) CrossRatioL(v, w, x, y *Cockle) *Cockle

CrossRatioL sets z equal to the left cross-ratio of v, w, x, and y:

Inv(w - x) * (v - x) * Inv(v - y) * (w - y)

Then it returns z.

func (*Cockle) CrossRatioR

func (z *Cockle) CrossRatioR(v, w, x, y *Cockle) *Cockle

CrossRatioR sets z equal to the right cross-ratio of v, w, x, and y:

(v - x) * Inv(w - x) * (w - y) * Inv(v - y)

Then it returns z.

func (*Cockle) Dot

func (z *Cockle) Dot(y *Cockle) *big.Rat

Dot returns the (rational) dot product of z and y.

func (*Cockle) Equals

func (z *Cockle) Equals(y *Cockle) bool

Equals returns true if y and z are equal.

func (*Cockle) Generate

func (z *Cockle) Generate(rand *rand.Rand, size int) reflect.Value

Generate returns a random Cockle value for quick.Check testing.

func (*Cockle) Inv

func (z *Cockle) Inv(y *Cockle) *Cockle

Inv sets z equal to the inverse of y, and returns z. If y is a zero divisor, then Inv panics.

func (*Cockle) IsNilpotent

func (z *Cockle) IsNilpotent(n int) bool

IsNilpotent returns true if z raised to the n-th power vanishes.

func (*Cockle) IsZeroDivisor

func (z *Cockle) IsZeroDivisor() bool

IsZeroDivisor returns true if z is a zero divisor.

func (*Cockle) Mul

func (z *Cockle) Mul(x, y *Cockle) *Cockle

Mul sets z equal to the product of x and y, and returns z.

The multiplication rules are:

Mul(i, i) = -1
Mul(t, t) = Mul(u, u) = +1
Mul(i, t) = -Mul(t, i) = u
Mul(u, t) = -Mul(t, u) = i
Mul(u, i) = -Mul(i, u) = t

This binary operation is noncommutative but associative.

func (*Cockle) MöbiusL

func (z *Cockle) MöbiusL(y, a, b, c, d *Cockle) *Cockle

MöbiusL sets z equal to the left Möbius (fractional linear) transform of y:

Inv(y*c + d) * (y*a + b)

Then it returns z.

func (*Cockle) MöbiusR

func (z *Cockle) MöbiusR(y, a, b, c, d *Cockle) *Cockle

MöbiusR sets z equal to the right Möbius (fractional linear) transform of y:

(a*y + b) * Inv(c*y + d)

Then it returns z.

func (*Cockle) Neg

func (z *Cockle) Neg(y *Cockle) *Cockle

Neg sets z equal to the negative of y, and returns z.

func (*Cockle) Quad

func (z *Cockle) Quad() *big.Rat

Quad returns the quadrance of z. If z = a+bi+ct+du, then the quadrance is

a² + b² - c² - d²

This can be positive, negative, or zero.

func (*Cockle) QuoL

func (z *Cockle) QuoL(x, y *Cockle) *Cockle

QuoL sets z equal to the left quotient of x and y:

Mul(Inv(y), x)

Then it returns z. If y is a zero divisor, then QuoL panics.

func (*Cockle) QuoR

func (z *Cockle) QuoR(x, y *Cockle) *Cockle

QuoR sets z equal to the right quotient of x and y:

Mul(x, Inv(y))

Then it returns z. If y is a zero divisor, then QuoR panics.

func (*Cockle) Rats

func (z *Cockle) Rats() (*big.Rat, *big.Rat, *big.Rat, *big.Rat)

Rats returns the four rational components of z.

func (*Cockle) Real

func (z *Cockle) Real() *big.Rat

Real returns the (rational) real part of z.

func (*Cockle) Scal

func (z *Cockle) Scal(y *Cockle, a *big.Rat) *Cockle

Scal sets z equal to y scaled by a, and returns z.

func (*Cockle) Set

func (z *Cockle) Set(y *Cockle) *Cockle

Set sets z equal to y, and returns z.

func (*Cockle) String

func (z *Cockle) String() string

String returns the string representation of a Cockle value. If z corresponds to a + bi + ct + du, then the string is "(a+bi+ct+du)", similar to complex128 values.

func (*Cockle) Sub

func (z *Cockle) Sub(x, y *Cockle) *Cockle

Sub sets z equal to x-y, and returns z.

type Complex

type Complex struct {
	// contains filtered or unexported fields
}

A Complex represents a rational complex number.

func NewComplex

func NewComplex(a, b *big.Rat) *Complex

NewComplex returns a pointer to the Complex value a+bi.

func (*Complex) Add

func (z *Complex) Add(x, y *Complex) *Complex

Add sets z equal to x+y, and returns z.

func (*Complex) Conj

func (z *Complex) Conj(y *Complex) *Complex

Conj sets z equal to the conjugate of y, and returns z.

func (*Complex) CrossRatio

func (z *Complex) CrossRatio(v, w, x, y *Complex) *Complex

CrossRatio sets z equal to the cross-ratio of v, w, x, and y:

Inv(w - x) * (v - x) * Inv(v - y) * (w - y)

Then it returns z.

func (*Complex) Dot

func (z *Complex) Dot(y *Complex) *big.Rat

Dot returns the (rational) dot product of z and y.

func (*Complex) Equals

func (z *Complex) Equals(y *Complex) bool

Equals returns true if y and z are equal.

func (*Complex) Gauss

func (z *Complex) Gauss(a, b *big.Int) *Complex

Gauss sets z equal to the Gaussian integer a+bi, and returns z.

func (*Complex) Generate

func (z *Complex) Generate(rand *rand.Rand, size int) reflect.Value

Generate returns a random Complex value for quick.Check testing.

func (*Complex) Inv

func (z *Complex) Inv(y *Complex) *Complex

Inv sets z equal to the inverse of y, and returns z. If y is zero, then Inv panics.

func (*Complex) Mul

func (z *Complex) Mul(x, y *Complex) *Complex

Mul sets z equal to the product of x and y, and returns z.

The multiplication rule is:

Mul(i, i) = -1

This binary operation is commutative and associative.

func (*Complex) Möbius

func (z *Complex) Möbius(y, a, b, c, d *Complex) *Complex

Möbius sets z equal to the Möbius (fractional linear) transform of y:

(a*y + b) * Inv(c*y + d)

Then it returns z.

func (*Complex) Neg

func (z *Complex) Neg(y *Complex) *Complex

Neg sets z equal to the negative of y, and returns z.

func (*Complex) Plus

func (z *Complex) Plus(y *Complex, a *big.Rat) *Complex

Plus sets z equal to y shifted by the rational a, and returns z.

func (*Complex) PolyEval

func (z *Complex) PolyEval(y *Complex, poly Laurent) *Complex

PolyEval sets z equal to poly evaluated at y, and returns z.

func (*Complex) Quad

func (z *Complex) Quad() *big.Rat

Quad returns the quadrance of z. If z = a+bi, then the quadrance is

a² + b²

This is always non-negative.

func (*Complex) Quo

func (z *Complex) Quo(x, y *Complex) *Complex

Quo sets z equal to the quotient of x and y, and returns z. If y is zero, then Quo panics.

func (*Complex) Rats

func (z *Complex) Rats() (*big.Rat, *big.Rat)

Rats returns the two rational components of z.

func (*Complex) Real

func (z *Complex) Real() *big.Rat

Real returns the (rational) real part of z.

func (*Complex) Scal

func (z *Complex) Scal(y *Complex, a *big.Rat) *Complex

Scal sets z equal to y scaled by a, and returns z.

func (*Complex) Set

func (z *Complex) Set(y *Complex) *Complex

Set sets z equal to y, and returns z.

func (*Complex) String

func (z *Complex) String() string

String returns the string version of a Complex value.

If z corresponds to a + bi, then the string is "(a+bi)", similar to complex128 values.

func (*Complex) Sub

func (z *Complex) Sub(x, y *Complex) *Complex

Sub sets z equal to x-y, and returns z.

type DualComplex

type DualComplex struct {
	// contains filtered or unexported fields
}

A DualComplex represents a rational dual-complex number.

func NewDualComplex

func NewDualComplex(a, b, c, d *big.Rat) *DualComplex

NewDualComplex returns a *DualComplex with value a+bi+cΓ+diΓ.

func (*DualComplex) Add

func (z *DualComplex) Add(x, y *DualComplex) *DualComplex

Add sets z equal to x+y, and returns z.

func (*DualComplex) Conj

func (z *DualComplex) Conj(y *DualComplex) *DualComplex

Conj sets z equal to the conjugate of y, and returns z.

func (*DualComplex) CrossRatio

func (z *DualComplex) CrossRatio(v, w, x, y *DualComplex) *DualComplex

CrossRatio sets z equal to the cross-ratio of v, w, x, and y:

Inv(w - x) * (v - x) * Inv(v - y) * (w - y)

Then it returns z.

func (*DualComplex) Equals

func (z *DualComplex) Equals(y *DualComplex) bool

Equals returns true if y and z are equal.

func (*DualComplex) Generate

func (z *DualComplex) Generate(rand *rand.Rand, size int) reflect.Value

Generate returns a random DualComplex value for quick.Check testing.

func (*DualComplex) Inv

func (z *DualComplex) Inv(y *DualComplex) *DualComplex

Inv sets z equal to the inverse of y, and returns z. If y is a zero divisor, then Inv panics.

func (*DualComplex) IsZeroDivisor

func (z *DualComplex) IsZeroDivisor() bool

IsZeroDivisor returns true if z is a zero divisor.

func (*DualComplex) Mul

func (z *DualComplex) Mul(x, y *DualComplex) *DualComplex

Mul sets z equal to the product of x and y, and returns z.

The multiplication rules are:

Mul(i, i) = -1
Mul(Γ, Γ) = 0
Mul(i, Γ) = Mul(Γ, i)

This binary operation is commutative and associative.

func (*DualComplex) Möbius

func (z *DualComplex) Möbius(y, a, b, c, d *DualComplex) *DualComplex

Möbius sets z equal to the Möbius (fractional linear) transform of y:

(a*y + b) * Inv(c*y + d)

Then it returns z.

func (*DualComplex) Neg

func (z *DualComplex) Neg(y *DualComplex) *DualComplex

Neg sets z equal to the negative of y, and returns z.

func (*DualComplex) Norm

func (z *DualComplex) Norm() *big.Rat

Norm returns the norm of z. If z = a+bi+cΓ+diΓ, then the norm is

(a² + b²)²

This is always non-negative.

func (*DualComplex) Quad

func (z *DualComplex) Quad() *Complex

Quad returns the quadrance of z. If z = a+bi+cΓ+diΓ, then the quadrance is

a² - b² + 2abi

Note that this is a complex number.

func (*DualComplex) Quo

func (z *DualComplex) Quo(x, y *DualComplex) *DualComplex

Quo sets z equal to the quotient of x and y. If y is a zero divisor, then Quo panics.

func (*DualComplex) Rats

func (z *DualComplex) Rats() (*big.Rat, *big.Rat, *big.Rat, *big.Rat)

Rats returns the four rational components of z.

func (*DualComplex) Real

func (z *DualComplex) Real() *big.Rat

Real returns the (rational) real part of z.

func (*DualComplex) Scal

func (z *DualComplex) Scal(y *DualComplex, a *big.Rat) *DualComplex

Scal sets z equal to y scaled by a, and returns z.

func (*DualComplex) Set

func (z *DualComplex) Set(y *DualComplex) *DualComplex

Set sets z equal to y, and returns z.

func (*DualComplex) Star

func (z *DualComplex) Star(y *DualComplex) *DualComplex

Star sets z equal to the star conjugate of y, and returns z.

func (*DualComplex) String

func (z *DualComplex) String() string

String returns the string representation of a DualComplex value.

func (*DualComplex) Sub

func (z *DualComplex) Sub(x, y *DualComplex) *DualComplex

Sub sets z equal to x-y, and returns z.

type DualPerplex

type DualPerplex struct {
	// contains filtered or unexported fields
}

A DualPerplex represents a rational dual perplex number.

func NewDualPerplex

func NewDualPerplex(a, b, c, d *big.Rat) *DualPerplex

NewDualPerplex returns a *DualPerplex with value a+bs+cΓ+dsΓ.

func (*DualPerplex) Add

func (z *DualPerplex) Add(x, y *DualPerplex) *DualPerplex

Add sets z equal to x+y, and returns z.

func (*DualPerplex) Conj

func (z *DualPerplex) Conj(y *DualPerplex) *DualPerplex

Conj sets z equal to the conjugate of y, and returns z.

func (*DualPerplex) CrossRatio

func (z *DualPerplex) CrossRatio(v, w, x, y *DualPerplex) *DualPerplex

CrossRatio sets z equal to the cross-ratio of v, w, x, and y:

Inv(w - x) * (v - x) * Inv(v - y) * (w - y)

Then it returns z.

func (*DualPerplex) Equals

func (z *DualPerplex) Equals(y *DualPerplex) bool

Equals returns true if y and z are equal.

func (*DualPerplex) Generate

func (z *DualPerplex) Generate(rand *rand.Rand, size int) reflect.Value

Generate returns a random DualPerplex value for quick.Check testing.

func (*DualPerplex) Inv

func (z *DualPerplex) Inv(y *DualPerplex) *DualPerplex

Inv sets z equal to the inverse of y, and returns z. If y is a zero divisor, then Inv panics.

func (*DualPerplex) IsZeroDivisor

func (z *DualPerplex) IsZeroDivisor() bool

IsZeroDivisor returns true if z is a zero divisor.

func (*DualPerplex) Mul

func (z *DualPerplex) Mul(x, y *DualPerplex) *DualPerplex

Mul sets z equal to the product of x and y, and returns z.

The multiplication rules are:

Mul(s, s) = +1
Mul(Γ, Γ) = 0
Mul(s, Γ) = Mul(Γ, s)

This binary operation is commutative and associative.

func (*DualPerplex) Möbius

func (z *DualPerplex) Möbius(y, a, b, c, d *DualPerplex) *DualPerplex

Möbius sets z equal to the Möbius (fractional linear) transform of y:

(a*y + b) * Inv(c*y + d)

Then it returns z.

func (*DualPerplex) Neg

func (z *DualPerplex) Neg(y *DualPerplex) *DualPerplex

Neg sets z equal to the negative of y, and returns z.

func (*DualPerplex) Norm

func (z *DualPerplex) Norm() *big.Rat

Norm returns the norm of z. If z = a+bs+cΓ+dsΓ, then the norm is

(a² - b²)²

This is always non-negative.

func (*DualPerplex) Quad

func (z *DualPerplex) Quad() *Perplex

Quad returns the quadrance of z. If z = a+bs+cΓ+dsΓ, then the quadrance is

a² + b² + 2abs

Note that this is a perplex number.

func (*DualPerplex) Quo

func (z *DualPerplex) Quo(x, y *DualPerplex) *DualPerplex

Quo sets z equal to the quotient of x and y. If y is a zero divisor, then Quo panics.

func (*DualPerplex) Rats

func (z *DualPerplex) Rats() (*big.Rat, *big.Rat, *big.Rat, *big.Rat)

Rats returns the four rational components of z.

func (*DualPerplex) Real

func (z *DualPerplex) Real() *big.Rat

Real returns the (rational) real part of z.

func (*DualPerplex) Scal

func (z *DualPerplex) Scal(y *DualPerplex, a *big.Rat) *DualPerplex

Scal sets z equal to y scaled by a, and returns z.

func (*DualPerplex) Set

func (z *DualPerplex) Set(y *DualPerplex) *DualPerplex

Set sets z equal to y, and returns z.

func (*DualPerplex) Star

func (z *DualPerplex) Star(y *DualPerplex) *DualPerplex

Star sets z equal to the star conjugate of y, and returns z.

func (*DualPerplex) String

func (z *DualPerplex) String() string

String returns the string representation of a DualPerplex value.

func (*DualPerplex) Sub

func (z *DualPerplex) Sub(x, y *DualPerplex) *DualPerplex

Sub sets z equal to x-y, and returns z.

type Hamilton

type Hamilton struct {
	// contains filtered or unexported fields
}

A Hamilton represents a rational Hamilton quaternion.

func NewHamilton

func NewHamilton(a, b, c, d *big.Rat) *Hamilton

NewHamilton returns a pointer to the Hamilton value a+bi+cj+dk.

func (*Hamilton) Add

func (z *Hamilton) Add(x, y *Hamilton) *Hamilton

Add sets z equal to x+y, and returns z.

func (*Hamilton) Commutator

func (z *Hamilton) Commutator(x, y *Hamilton) *Hamilton

Commutator sets z equal to the commutator of x and y:

Mul(x, y) - Mul(y, x)

Then it returns z.

func (*Hamilton) Conj

func (z *Hamilton) Conj(y *Hamilton) *Hamilton

Conj sets z equal to the conjugate of y, and returns z.

func (*Hamilton) CrossRatioL

func (z *Hamilton) CrossRatioL(v, w, x, y *Hamilton) *Hamilton

CrossRatioL sets z equal to the left cross-ratio of v, w, x, and y:

Inv(w - x) * (v - x) * Inv(v - y) * (w - y)

Then it returns z.

func (*Hamilton) CrossRatioR

func (z *Hamilton) CrossRatioR(v, w, x, y *Hamilton) *Hamilton

CrossRatioR sets z equal to the right cross-ratio of v, w, x, and y:

(v - x) * Inv(w - x) * (w - y) * Inv(v - y)

Then it returns z.

func (*Hamilton) Dot

func (z *Hamilton) Dot(y *Hamilton) *big.Rat

Dot returns the (rational) dot product of z and y.

func (*Hamilton) Equals

func (z *Hamilton) Equals(y *Hamilton) bool

Equals returns true if y and z are equal.

func (*Hamilton) Generate

func (z *Hamilton) Generate(rand *rand.Rand, size int) reflect.Value

Generate returns a random Hamilton value for quick.Check testing.

func (*Hamilton) Hurwitz

func (z *Hamilton) Hurwitz(a, b, c, d *big.Int) *Hamilton

Hurwitz sets z equal to the Hurwitz integer (a+½)+(b+½)i+(c+½)j+(d+½)k, and returns z.

func (*Hamilton) Inv

func (z *Hamilton) Inv(y *Hamilton) *Hamilton

Inv sets z equal to the inverse of y, and returns z. If y is zero, then Inv panics.

func (*Hamilton) Lipschitz

func (z *Hamilton) Lipschitz(a, b, c, d *big.Int) *Hamilton

Lipschitz sets z equal to the Lipschitz integer a+bi+cj+dk, and returns z.

func (*Hamilton) Mul

func (z *Hamilton) Mul(x, y *Hamilton) *Hamilton

Mul sets z equal to the product of x and y, and returns z.

The multiplication rules are:

Mul(i, i) = Mul(j, j) = Mul(k, k) = -1
Mul(i, j) = -Mul(j, i) = k
Mul(j, k) = -Mul(k, j) = i
Mul(k, i) = -Mul(i, k) = j

This binary operation is noncommutative but associative.

func (*Hamilton) MöbiusL

func (z *Hamilton) MöbiusL(y, a, b, c, d *Hamilton) *Hamilton

MöbiusL sets z equal to the left Möbius (fractional linear) transform of y:

Inv(y*c + d) * (y*a + b)

Then it returns z.

func (*Hamilton) MöbiusR

func (z *Hamilton) MöbiusR(y, a, b, c, d *Hamilton) *Hamilton

MöbiusR sets z equal to the right Möbius (fractional linear) transform of y:

(a*y + b) * Inv(c*y + d)

Then it returns z.

func (*Hamilton) Neg

func (z *Hamilton) Neg(y *Hamilton) *Hamilton

Neg sets z equal to the negative of y, and returns z.

func (*Hamilton) Quad

func (z *Hamilton) Quad() *big.Rat

Quad returns the quadrance of z. If z = a+bi+cj+dk, then the quadrance is

a² + b² + c² + d²

This is always non-negative.

func (*Hamilton) QuoL

func (z *Hamilton) QuoL(x, y *Hamilton) *Hamilton

QuoL sets z equal to the left quotient of x and y:

Mul(Inv(y), x)

Then it returns z. If y is zero, then QuoL panics.

func (*Hamilton) QuoR

func (z *Hamilton) QuoR(x, y *Hamilton) *Hamilton

QuoR sets z equal to the right quotient of x and y:

Mul(x, Inv(y))

Then it returns z. If y is zero, then QuoR panics.

func (*Hamilton) Rats

func (z *Hamilton) Rats() (*big.Rat, *big.Rat, *big.Rat, *big.Rat)

Rats returns the four rational components of z.

func (*Hamilton) Real

func (z *Hamilton) Real() *big.Rat

Real returns the (rational) real part of z.

func (*Hamilton) Scal

func (z *Hamilton) Scal(y *Hamilton, a *big.Rat) *Hamilton

Scal sets z equal to y scaled by a, and returns z.

func (*Hamilton) Set

func (z *Hamilton) Set(y *Hamilton) *Hamilton

Set sets z equal to y, and returns z.

func (*Hamilton) String

func (z *Hamilton) String() string

String returns the string representation of a Hamilton value.

If z corresponds to a + bi + cj + dk, then the string is"(a+bi+cj+dk)", similar to complex128 values.

func (*Hamilton) Sub

func (z *Hamilton) Sub(x, y *Hamilton) *Hamilton

Sub sets z equal to x-y, and returns z.

type Hyper

type Hyper struct {
	// contains filtered or unexported fields
}

A Hyper represents a rational hyper-dual number.

func NewHyper

func NewHyper(a, b, c, d *big.Rat) *Hyper

NewHyper returns a *Hyper with value a+bα+cΓ+dαΓ.

func (*Hyper) Add

func (z *Hyper) Add(x, y *Hyper) *Hyper

Add sets z equal to x+y, and returns z.

func (*Hyper) Conj

func (z *Hyper) Conj(y *Hyper) *Hyper

Conj sets z equal to the conjugate of y, and returns z.

func (*Hyper) CrossRatio

func (z *Hyper) CrossRatio(v, w, x, y *Hyper) *Hyper

CrossRatio sets z equal to the cross-ratio of v, w, x, and y:

Inv(w - x) * (v - x) * Inv(v - y) * (w - y)

Then it returns z.

func (*Hyper) Equals

func (z *Hyper) Equals(y *Hyper) bool

Equals returns true if y and z are equal.

func (*Hyper) Generate

func (z *Hyper) Generate(rand *rand.Rand, size int) reflect.Value

Generate returns a random Hyper value for quick.Check testing.

func (*Hyper) Inv

func (z *Hyper) Inv(y *Hyper) *Hyper

Inv sets z equal to the inverse of y, and returns z. If y is a zero divisor, then Inv panics.

func (*Hyper) IsZeroDivisor

func (z *Hyper) IsZeroDivisor() bool

IsZeroDivisor returns true if z is a zero divisor.

func (*Hyper) Mul

func (z *Hyper) Mul(x, y *Hyper) *Hyper

Mul sets z equal to the product of x and y, and returns z.

The multiplication rules are:

Mul(α, α) = Mul(Γ, Γ) = 0
Mul(α, Γ) = Mul(Γ, α)

This binary operation is commutative and associative.

func (*Hyper) Möbius

func (z *Hyper) Möbius(y, a, b, c, d *Hyper) *Hyper

Möbius sets z equal to the Möbius (fractional linear) transform of y:

(a*y + b) * Inv(c*y + d)

Then it returns z.

func (*Hyper) Neg

func (z *Hyper) Neg(y *Hyper) *Hyper

Neg sets z equal to the negative of y, and returns z.

func (*Hyper) Norm

func (z *Hyper) Norm() *big.Rat

Norm returns the norm of z. If z = a+bα+cΓ+dαΓ, then the norm is

(a²)²

This is always non-negative.

func (*Hyper) Quad

func (z *Hyper) Quad() *Infra

Quad returns the quadrance of z. If z = a+bα+cΓ+dαΓ, then the quadrance is

a² + 2abα

Note that this is an infra number.

func (*Hyper) Quo

func (z *Hyper) Quo(x, y *Hyper) *Hyper

Quo sets z equal to the quotient of x and y. If y is a zero divisor, then Quo panics.

func (*Hyper) Rats

func (z *Hyper) Rats() (*big.Rat, *big.Rat, *big.Rat, *big.Rat)

Rats returns the four rational components of z.

func (*Hyper) Real

func (z *Hyper) Real() *big.Rat

Real returns the (rational) real part of z.

func (*Hyper) Scal

func (z *Hyper) Scal(y *Hyper, a *big.Rat) *Hyper

Scal sets z equal to y scaled by a, and returns z.

func (*Hyper) Set

func (z *Hyper) Set(y *Hyper) *Hyper

Set sets z equal to y, and returns z.

func (*Hyper) Star

func (z *Hyper) Star(y *Hyper) *Hyper

Star sets z equal to the star conjugate of y, and returns z.

func (*Hyper) String

func (z *Hyper) String() string

String returns the string representation of a Hyper value.

func (*Hyper) Sub

func (z *Hyper) Sub(x, y *Hyper) *Hyper

Sub sets z equal to x-y, and returns z.

type Infra

type Infra struct {
	// contains filtered or unexported fields
}

An Infra represents a rational infra number.

func NewInfra

func NewInfra(a, b *big.Rat) *Infra

NewInfra returns a pointer to the Infra value a+bα.

func (*Infra) Add

func (z *Infra) Add(x, y *Infra) *Infra

Add sets z equal to x+y, and returns z.

func (*Infra) Conj

func (z *Infra) Conj(y *Infra) *Infra

Conj sets z equal to the conjugate of y, and returns z.

func (*Infra) CrossRatio

func (z *Infra) CrossRatio(v, w, x, y *Infra) *Infra

CrossRatio sets z equal to the cross-ratio of v, w, x, and y:

Inv(w - x) * (v - x) * Inv(v - y) * (w - y)

Then it returns z.

func (*Infra) Dot

func (z *Infra) Dot(y *Infra) *big.Rat

Dot returns the (rational) dot product of z and y.

func (*Infra) Equals

func (z *Infra) Equals(y *Infra) bool

Equals returns true if y and z are equal.

func (*Infra) Generate

func (z *Infra) Generate(rand *rand.Rand, size int) reflect.Value

Generate returns a random Infra value for quick.Check testing.

func (*Infra) Inv

func (z *Infra) Inv(y *Infra) *Infra

Inv sets z equal to the inverse of y, and returns z. If y is a zero divisor, then Inv panics.

func (*Infra) IsZeroDivisor

func (z *Infra) IsZeroDivisor() bool

IsZeroDivisor returns true if z is a zero divisor. This is equivalent to z being nilpotent.

func (*Infra) Mul

func (z *Infra) Mul(x, y *Infra) *Infra

Mul sets z to the product of x and y, and returns z.

The multiplication rule is:

Mul(α, α) = 0

This binary operation is commutative and associative.

func (*Infra) Möbius

func (z *Infra) Möbius(y, a, b, c, d *Infra) *Infra

Möbius sets z equal to the Möbius (fractional linear) transform of y:

(a*y + b) * Inv(c*y + d)

Then it returns z.

func (*Infra) Neg

func (z *Infra) Neg(y *Infra) *Infra

Neg sets z equal to the negative of y, and returns z.

func (*Infra) Plus

func (z *Infra) Plus(y *Infra, a *big.Rat) *Infra

Plus sets z equal to y shifted by the rational a, and returns z.

func (*Infra) PolyEval

func (z *Infra) PolyEval(y *Infra, poly Laurent) *Infra

PolyEval sets z equal to poly evaluated at y, and returns z.

func (*Infra) Quad

func (z *Infra) Quad() *big.Rat

Quad returns the quadrance of z. If z = a+bα, then the quadrance is

This is always non-negative.

func (*Infra) Quo

func (z *Infra) Quo(x, y *Infra) *Infra

Quo sets z equal to the quotient of x and y, and returns z. If y is a zero divisor, then Quo panics.

func (*Infra) Rats

func (z *Infra) Rats() (*big.Rat, *big.Rat)

Rats returns the two rational components of z.

func (*Infra) Real

func (z *Infra) Real() *big.Rat

Real returns the (rational) real part of z.

func (*Infra) Scal

func (z *Infra) Scal(y *Infra, a *big.Rat) *Infra

Scal sets z equal to y scaled by a, and returns z.

func (*Infra) Set

func (z *Infra) Set(y *Infra) *Infra

Set sets z equal to y, and returns z.

func (*Infra) String

func (z *Infra) String() string

String returns the string version of a Infra value.

If z corresponds to a + bα, then the string is "(a+bα)", similar to complex128 values.

func (*Infra) Sub

func (z *Infra) Sub(x, y *Infra) *Infra

Sub sets z equal to x-y, and returns z.

type InfraCockle

type InfraCockle struct {
	// contains filtered or unexported fields
}

An InfraCockle represents a rational infra-Cockle quaternion.

func NewInfraCockle

func NewInfraCockle(a, b, c, d, e, f, g, h *big.Rat) *InfraCockle

NewInfraCockle returns a pointer to the InfraCockle value a+bi+ct+du+eρ+fσ+gτ+hυ.

func (*InfraCockle) Add

func (z *InfraCockle) Add(x, y *InfraCockle) *InfraCockle

Add sets z equal to x+y, and returns z.

func (*InfraCockle) Associator

func (z *InfraCockle) Associator(w, x, y *InfraCockle) *InfraCockle

Associator sets z equal to the associator of w, x, and y:

Mul(Mul(w, x), y) - Mul(w, Mul(x, y))

Then it returns z.

func (*InfraCockle) Commutator

func (z *InfraCockle) Commutator(x, y *InfraCockle) *InfraCockle

Commutator sets z equal to the commutator of x and y:

Mul(x, y) - Mul(y, x)

Then it returns z.

func (*InfraCockle) Conj

func (z *InfraCockle) Conj(y *InfraCockle) *InfraCockle

Conj sets z equal to the conjugate of y, and returns z.

func (*InfraCockle) Equals

func (z *InfraCockle) Equals(y *InfraCockle) bool

Equals returns true if y and z are equal.

func (*InfraCockle) Generate

func (z *InfraCockle) Generate(rand *rand.Rand, size int) reflect.Value

Generate returns a random InfraCockle value for quick.Check testing.

func (*InfraCockle) Inv

func (z *InfraCockle) Inv(y *InfraCockle) *InfraCockle

Inv sets z equal to the inverse of y, and returns z. If y is a zero divisor, then Inv panics.

func (*InfraCockle) IsZeroDivisor

func (z *InfraCockle) IsZeroDivisor() bool

IsZeroDivisor returns true if z is a zero divisor. This is equivalent to z being nilpotent.

func (*InfraCockle) Mul

func (z *InfraCockle) Mul(x, y *InfraCockle) *InfraCockle

Mul sets z equal to the product of x and y, and returns z.

The multiplication rules are:

Mul(i, i) = -1
Mul(t, t) = Mul(u, u) = +1
Mul(ρ, ρ) = Mul(σ, σ) = Mul(τ, τ) = Mul(υ, υ) = 0
Mul(i, t) = -Mul(t, i) = +u
Mul(i, u) = -Mul(u, i) = -t
Mul(i, ρ) = -Mul(ρ, i) = +σ
Mul(i, σ) = -Mul(σ, i) = -ρ
Mul(i, τ) = -Mul(τ, i) = -υ
Mul(i, υ) = -Mul(υ, i) = +τ
Mul(t, u) = -Mul(u, t) = -i
Mul(t, ρ) = -Mul(ρ, t) = +τ
Mul(t, σ) = -Mul(σ, t) = +υ
Mul(t, τ) = -Mul(τ, t) = +ρ
Mul(t, υ) = -Mul(υ, t) = +σ
Mul(u, ρ) = -Mul(ρ, u) = +υ
Mul(u, σ) = -Mul(σ, u) = -τ
Mul(u, τ) = -Mul(τ, u) = -σ
Mul(u, υ) = -Mul(υ, u) = +ρ
Mul(ρ, σ) = Mul(σ, ρ) = 0
Mul(ρ, τ) = Mul(τ, ρ) = 0
Mul(ρ, υ) = Mul(υ, ρ) = 0
Mul(σ, τ) = Mul(τ, σ) = 0
Mul(σ, υ) = Mul(υ, σ) = 0
Mul(τ, υ) = Mul(υ, τ) = 0

This binary operation is noncommutative and nonassociative.

func (*InfraCockle) Neg

func (z *InfraCockle) Neg(y *InfraCockle) *InfraCockle

Neg sets z equal to the negative of y, and returns z.

func (*InfraCockle) Quad

func (z *InfraCockle) Quad() *big.Rat

Quad returns the quadrance of z. If z = a+bi+ct+du+eρ+fσ+gτ+hυ, then the quadrance is

a² + b² - c² - d²

This can be positive, negative, or zero.

func (*InfraCockle) QuoL

func (z *InfraCockle) QuoL(x, y *InfraCockle) *InfraCockle

QuoL sets z equal to the left quotient of x and y:

Mul(Inv(y), x)

Then it returns z. If y is a zero divisor, then QuoL panics.

func (*InfraCockle) QuoR

func (z *InfraCockle) QuoR(x, y *InfraCockle) *InfraCockle

QuoR sets z equal to the right quotient of x and y:

Mul(x, Inv(y))

Then it returns z. If y is a zero divisor, then QuoR panics.

func (*InfraCockle) Rats

func (z *InfraCockle) Rats() (*big.Rat, *big.Rat, *big.Rat, *big.Rat,
	*big.Rat, *big.Rat, *big.Rat, *big.Rat)

Rats returns the eight rational components of z.

func (*InfraCockle) Real

func (z *InfraCockle) Real() *big.Rat

Real returns the (rational) real part of z.

func (*InfraCockle) Scal

func (z *InfraCockle) Scal(y *InfraCockle, a *big.Rat) *InfraCockle

Scal sets z equal to y scaled by a, and returns z.

func (*InfraCockle) Set

func (z *InfraCockle) Set(y *InfraCockle) *InfraCockle

Set sets z equal to y, and returns z.

func (*InfraCockle) String

func (z *InfraCockle) String() string

String returns the string representation of an InfraCockle value.

If z corresponds to a + bi + ct + du + eρ + fσ + gτ + hυ, then the string is"(a+bi+ct+du+eρ+fσ+gτ+hυ)", similar to complex128 values.

func (*InfraCockle) Sub

func (z *InfraCockle) Sub(x, y *InfraCockle) *InfraCockle

Sub sets z equal to x-y, and returns z.

type InfraComplex

type InfraComplex struct {
	// contains filtered or unexported fields
}

An InfraComplex represents a rational infra-complex number.

func NewInfraComplex

func NewInfraComplex(a, b, c, d *big.Rat) *InfraComplex

NewInfraComplex returns a pointer to the InfraComplex value a+bi+cβ+dγ.

func (*InfraComplex) Add

func (z *InfraComplex) Add(x, y *InfraComplex) *InfraComplex

Add sets z equal to x+y, and returns z.

func (*InfraComplex) Commutator

func (z *InfraComplex) Commutator(x, y *InfraComplex) *InfraComplex

Commutator sets z equal to the commutator of x and y:

Mul(x, y) - Mul(y, x)

Then it returns z.

func (*InfraComplex) Conj

func (z *InfraComplex) Conj(y *InfraComplex) *InfraComplex

Conj sets z equal to the conjugate of y, and returns z.

func (*InfraComplex) CrossRatioL

func (z *InfraComplex) CrossRatioL(v, w, x, y *InfraComplex) *InfraComplex

CrossRatioL sets z equal to the left cross-ratio of v, w, x, and y:

Inv(w - x) * (v - x) * Inv(v - y) * (w - y)

Then it returns z.

func (*InfraComplex) CrossRatioR

func (z *InfraComplex) CrossRatioR(v, w, x, y *InfraComplex) *InfraComplex

CrossRatioR sets z equal to the right cross-ratio of v, w, x, and y:

(v - x) * Inv(w - x) * (w - y) * Inv(v - y)

Then it returns z.

func (*InfraComplex) Dot

func (z *InfraComplex) Dot(y *InfraComplex) *big.Rat

Dot returns the (rational) dot product of z and y.

func (*InfraComplex) Equals

func (z *InfraComplex) Equals(y *InfraComplex) bool

Equals returns true if y and z are equal.

func (*InfraComplex) Generate

func (z *InfraComplex) Generate(rand *rand.Rand, size int) reflect.Value

Generate returns a random InfraComplex value for quick.Check testing.

func (*InfraComplex) Inv

Inv sets z equal to the inverse of y, and returns z. If y is a zero divisor, then Inv panics.

func (*InfraComplex) IsZeroDivisor

func (z *InfraComplex) IsZeroDivisor() bool

IsZeroDivisor returns true if z is a zero divisor. This is equivalent to z being nilpotent.

func (*InfraComplex) Mul

func (z *InfraComplex) Mul(x, y *InfraComplex) *InfraComplex

Mul sets z equal to the product of x and y, and returns z.

The multiplication rules are:

Mul(i, i) = -1
Mul(β, β) = Mul(γ, γ) = 0
Mul(β, γ) = Mul(γ, β) = 0
Mul(i, β) = -Mul(β, i) = γ
Mul(γ, i) = -Mul(i, γ) = β

This binary operation is noncommutative but associative.

func (*InfraComplex) MöbiusL

func (z *InfraComplex) MöbiusL(y, a, b, c, d *InfraComplex) *InfraComplex

MöbiusL sets z equal to the left Möbius (fractional linear) transform of y:

Inv(y*c + d) * (y*a + b)

Then it returns z.

func (*InfraComplex) MöbiusR

func (z *InfraComplex) MöbiusR(y, a, b, c, d *InfraComplex) *InfraComplex

MöbiusR sets z equal to the right Möbius (fractional linear) transform of y:

(a*y + b) * Inv(c*y + d)

Then it returns z.

func (*InfraComplex) Neg

Neg sets z equal to the negative of y, and returns z.

func (*InfraComplex) Quad

func (z *InfraComplex) Quad() *big.Rat

Quad returns the quadrance of z. If z = a+bi+cβ+dγ, then the quadrance is

a² + b²

This is always non-negative.

func (*InfraComplex) QuoL

func (z *InfraComplex) QuoL(x, y *InfraComplex) *InfraComplex

QuoL sets z equal to the left quotient of x and y:

Mul(Inv(y), x)

Then it returns z. If y is a zero divisor, then QuoL panics.

func (*InfraComplex) QuoR

func (z *InfraComplex) QuoR(x, y *InfraComplex) *InfraComplex

QuoR sets z equal to the right quotient of x and y:

Mul(x, Inv(y))

Then it returns z. If y is a zero divisor, then QuoR panics.

func (*InfraComplex) Rats

func (z *InfraComplex) Rats() (*big.Rat, *big.Rat, *big.Rat, *big.Rat)

Rats returns the four rational components of z.

func (*InfraComplex) Real

func (z *InfraComplex) Real() *big.Rat

Real returns the (rational) real part of z.

func (*InfraComplex) Scal

func (z *InfraComplex) Scal(y *InfraComplex, a *big.Rat) *InfraComplex

Scal sets z equal to y scaled by a, and returns z.

func (*InfraComplex) Set

Set sets z equal to y, and returns z.

func (*InfraComplex) String

func (z *InfraComplex) String() string

String returns the string representation of an InfraComplex value.

If z corresponds to a + bi + cβ + dγ, then the string is"(a+bi+cβ+dγ)", similar to complex128 values.

func (*InfraComplex) Sub

func (z *InfraComplex) Sub(x, y *InfraComplex) *InfraComplex

Sub sets z equal to x-y, and returns z.

type InfraHamilton

type InfraHamilton struct {
	// contains filtered or unexported fields
}

An InfraHamilton represents a rational infra-Hamilton quaternion.

func NewInfraHamilton

func NewInfraHamilton(a, b, c, d, e, f, g, h *big.Rat) *InfraHamilton

NewInfraHamilton returns a pointer to the InfraHamilton value a+bi+cj+dk+eα+fβ+gγ+hδ.

func (*InfraHamilton) Add

func (z *InfraHamilton) Add(x, y *InfraHamilton) *InfraHamilton

Add sets z equal to x+y, and returns z.

func (*InfraHamilton) Associator

func (z *InfraHamilton) Associator(w, x, y *InfraHamilton) *InfraHamilton

Associator sets z equal to the associator of w, x, and y:

Mul(Mul(w, x), y) - Mul(w, Mul(x, y))

Then it returns z.

func (*InfraHamilton) Commutator

func (z *InfraHamilton) Commutator(x, y *InfraHamilton) *InfraHamilton

Commutator sets z equal to the commutator of x and y:

Mul(x, y) - Mul(y, x)

Then it returns z.

func (*InfraHamilton) Conj

Conj sets z equal to the conjugate of y, and returns z.

func (*InfraHamilton) Equals

func (z *InfraHamilton) Equals(y *InfraHamilton) bool

Equals returns true if y and z are equal.

func (*InfraHamilton) Generate

func (z *InfraHamilton) Generate(rand *rand.Rand, size int) reflect.Value

Generate returns a random InfraHamilton value for quick.Check testing.

func (*InfraHamilton) Inv

Inv sets z equal to the inverse of y, and returns z. If y is a zero divisor, then Inv panics.

func (*InfraHamilton) IsZeroDivisor

func (z *InfraHamilton) IsZeroDivisor() bool

IsZeroDivisor returns true if z is a zero divisor. This is equivalent to z being nilpotent.

func (*InfraHamilton) Mul

func (z *InfraHamilton) Mul(x, y *InfraHamilton) *InfraHamilton

Mul sets z equal to the product of x and y, and returns z.

The multiplication rules are:

Mul(i, i) = Mul(j, j) = Mul(k, k) = -1
Mul(α, α) = Mul(β, β) = Mul(γ, γ) = Mul(δ, δ) = 0
Mul(i, j) = -Mul(j, i) = +k
Mul(i, k) = -Mul(k, i) = -j
Mul(i, α) = -Mul(α, i) = +β
Mul(i, β) = -Mul(β, i) = -α
Mul(i, γ) = -Mul(γ, i) = -δ
Mul(i, δ) = -Mul(δ, i) = +γ
Mul(j, k) = -Mul(k, j) = +i
Mul(j, α) = -Mul(α, j) = +γ
Mul(j, β) = -Mul(β, j) = +δ
Mul(j, γ) = -Mul(γ, j) = -α
Mul(j, δ) = -Mul(δ, j) = -β
Mul(k, α) = -Mul(α, k) = +δ
Mul(k, β) = -Mul(β, k) = -γ
Mul(k, γ) = -Mul(γ, k) = +β
Mul(k, δ) = -Mul(δ, k) = -α
Mul(α, β) = Mul(β, α) = 0
Mul(α, γ) = Mul(γ, α) = 0
Mul(α, δ) = Mul(δ, α) = 0
Mul(β, γ) = Mul(γ, β) = 0
Mul(β, δ) = Mul(δ, β) = 0
Mul(γ, δ) = Mul(δ, γ) = 0

This binary operation is noncommutative and nonassociative.

func (*InfraHamilton) Neg

Neg sets z equal to the negative of y, and returns z.

func (*InfraHamilton) Quad

func (z *InfraHamilton) Quad() *big.Rat

Quad returns the quadrance of z. If z = a+bi+cj+dk+eα+fβ+gγ+hδ, then the quadrance is

a² + b² + c² + d²

This is always non-negative.

func (*InfraHamilton) QuoL

func (z *InfraHamilton) QuoL(x, y *InfraHamilton) *InfraHamilton

QuoL sets z equal to the left quotient of x and y:

Mul(Inv(y), x)

Then it returns z. If y is a zero divisor, then QuoL panics.

func (*InfraHamilton) QuoR

func (z *InfraHamilton) QuoR(x, y *InfraHamilton) *InfraHamilton

QuoR sets z equal to the right quotient of x and y:

Mul(x, Inv(y))

Then it returns z. If y is a zero divisor, then QuoR panics.

func (*InfraHamilton) Rats

func (z *InfraHamilton) Rats() (*big.Rat, *big.Rat, *big.Rat, *big.Rat,
	*big.Rat, *big.Rat, *big.Rat, *big.Rat)

Rats returns the eight components of z.

func (*InfraHamilton) Real

func (z *InfraHamilton) Real() *big.Rat

Real returns the (rational) real part of z.

func (*InfraHamilton) Scal

func (z *InfraHamilton) Scal(y *InfraHamilton, a *big.Rat) *InfraHamilton

Scal sets z equal to y scaled by a, and returns z.

func (*InfraHamilton) Set

Set sets z equal to y, and returns z.

func (*InfraHamilton) String

func (z *InfraHamilton) String() string

String returns the string representation of an InfraHamilton value.

If z corresponds to a + bi + cj + dk + eα + fβ + gγ + hδ, then the string is"(a+bi+cj+dk+eα+fβ+gγ+hδ)", similar to complex128 values.

func (*InfraHamilton) Sub

func (z *InfraHamilton) Sub(x, y *InfraHamilton) *InfraHamilton

Sub sets z equal to x-y, and returns z.

type InfraPerplex

type InfraPerplex struct {
	// contains filtered or unexported fields
}

An InfraPerplex represents a rational infra-perplex number.

func NewInfraPerplex

func NewInfraPerplex(a, b, c, d *big.Rat) *InfraPerplex

NewInfraPerplex returns a pointer to the InfraPerplex value a+bs+cτ+dυ.

func (*InfraPerplex) Add

func (z *InfraPerplex) Add(x, y *InfraPerplex) *InfraPerplex

Add sets z equal to x+y, and returns z.

func (*InfraPerplex) Commutator

func (z *InfraPerplex) Commutator(x, y *InfraPerplex) *InfraPerplex

Commutator sets z equal to the commutator of x and y:

Mul(x, y) - Mul(y, x)

Then it returns z.

func (*InfraPerplex) Conj

func (z *InfraPerplex) Conj(y *InfraPerplex) *InfraPerplex

Conj sets z equal to the conjugate of y, and returns z.

func (*InfraPerplex) CrossRatioL

func (z *InfraPerplex) CrossRatioL(v, w, x, y *InfraPerplex) *InfraPerplex

CrossRatioL sets z equal to the left cross-ratio of v, w, x, and y:

Inv(w - x) * (v - x) * Inv(v - y) * (w - y)

Then it returns z.

func (*InfraPerplex) CrossRatioR

func (z *InfraPerplex) CrossRatioR(v, w, x, y *InfraPerplex) *InfraPerplex

CrossRatioR sets z equal to the right cross-ratio of v, w, x, and y:

(v - x) * Inv(w - x) * (w - y) * Inv(v - y)

Then it returns z.

func (*InfraPerplex) Dot

func (z *InfraPerplex) Dot(y *InfraPerplex) *big.Rat

Dot returns the (rational) dot product of z and y.

func (*InfraPerplex) Equals

func (z *InfraPerplex) Equals(y *InfraPerplex) bool

Equals returns true if y and z are equal.

func (*InfraPerplex) Generate

func (z *InfraPerplex) Generate(rand *rand.Rand, size int) reflect.Value

Generate returns a random InfraPerplex value for quick.Check testing.

func (*InfraPerplex) Inv

Inv sets z equal to the inverse of y, and returns z. If y is a zero divisor, then Inv panics.

func (*InfraPerplex) IsZeroDivisor

func (z *InfraPerplex) IsZeroDivisor() bool

IsZeroDivisor returns true if z is a zero divisor. This is equivalent to z being nilpotent.

func (*InfraPerplex) Mul

func (z *InfraPerplex) Mul(x, y *InfraPerplex) *InfraPerplex

Mul sets z equal to the product of x and y, and returns z.

The multiplication rules are:

Mul(s, s) = +1
Mul(τ, τ) = Mul(υ, υ) = 0
Mul(τ, υ) = Mul(υ, τ) = 0
Mul(s, τ) = -Mul(τ, s) = υ
Mul(s, υ) = -Mul(υ, s) = τ

This binary operation is noncommutative but associative.

func (*InfraPerplex) MöbiusL

func (z *InfraPerplex) MöbiusL(y, a, b, c, d *InfraPerplex) *InfraPerplex

MöbiusL sets z equal to the left Möbius (fractional linear) transform of y:

Inv(y*c + d) * (y*a + b)

Then it returns z.

func (*InfraPerplex) MöbiusR

func (z *InfraPerplex) MöbiusR(y, a, b, c, d *InfraPerplex) *InfraPerplex

MöbiusR sets z equal to the right Möbius (fractional linear) transform of y:

(a*y + b) * Inv(c*y + d)

Then it returns z.

func (*InfraPerplex) Neg

Neg sets z equal to the negative of y, and returns z.

func (*InfraPerplex) Quad

func (z *InfraPerplex) Quad() *big.Rat

Quad returns the quadrance of z. If z = a+bs+cτ+dυ, then the quadrance is

a² - b²

This can be positive, negative, or zero.

func (*InfraPerplex) QuoL

func (z *InfraPerplex) QuoL(x, y *InfraPerplex) *InfraPerplex

QuoL sets z equal to the left quotient of x and y:

Mul(Inv(y), x)

Then it returns z. If y is a zero divisor, then QuoL panics.

func (*InfraPerplex) QuoR

func (z *InfraPerplex) QuoR(x, y *InfraPerplex) *InfraPerplex

QuoR sets z equal to the right quotient of x and y:

Mul(x, Inv(y))

Then it returns z. If y is a zero divisor, then QuoR panics.

func (*InfraPerplex) Rats

func (z *InfraPerplex) Rats() (*big.Rat, *big.Rat, *big.Rat, *big.Rat)

Rats returns the four rational components of z.

func (*InfraPerplex) Real

func (z *InfraPerplex) Real() *big.Rat

Real returns the (rational) real part of z.

func (*InfraPerplex) Scal

func (z *InfraPerplex) Scal(y *InfraPerplex, a *big.Rat) *InfraPerplex

Scal sets z equal to y scaled by a, and returns z.

func (*InfraPerplex) Set

Set sets z equal to y, and returns z.

func (*InfraPerplex) String

func (z *InfraPerplex) String() string

String returns the string representation of an InfraPerplex value.

If z corresponds to a + bs + cτ + dυ, then the string is"(a+bs+cτ+dυ)", similar to complex128 values.

func (*InfraPerplex) Sub

func (z *InfraPerplex) Sub(x, y *InfraPerplex) *InfraPerplex

Sub sets z equal to x-y, and returns z.

type Laurent

type Laurent map[int64]*big.Rat

Laurent represents a Laurent univariate polynomial with rational coefficients.

func (Laurent) Degrees

func (p Laurent) Degrees() (neg, nonneg []int64)

Degrees returns two sorted slices with the negative and non-negative degrees in p.

type Perplex

type Perplex struct {
	// contains filtered or unexported fields
}

A Perplex represents a rational split-complex number.

func NewPerplex

func NewPerplex(a, b *big.Rat) *Perplex

NewPerplex returns a pointer to the Perplex value a+bs.

func (*Perplex) Add

func (z *Perplex) Add(x, y *Perplex) *Perplex

Add sets z equal to x+y, and returns z.

func (*Perplex) Conj

func (z *Perplex) Conj(y *Perplex) *Perplex

Conj sets z equal to the conjugate of y, and returns z.

func (*Perplex) CrossRatio

func (z *Perplex) CrossRatio(v, w, x, y *Perplex) *Perplex

CrossRatio sets z equal to the cross-ratio of v, w, x, and y:

Inv(w - x) * (v - x) * Inv(v - y) * (w - y)

Then it returns z.

func (*Perplex) Dot

func (z *Perplex) Dot(y *Perplex) *big.Rat

Dot returns the (rational) dot product of z and y.

func (*Perplex) Equals

func (z *Perplex) Equals(y *Perplex) bool

Equals returns true if y and z are equal.

func (*Perplex) Generate

func (z *Perplex) Generate(rand *rand.Rand, size int) reflect.Value

Generate returns a random Perplex value for quick.Check testing.

func (*Perplex) Idempotent

func (z *Perplex) Idempotent(sign int) *Perplex

Idempotent sets z equal to a pointer to an idempotent Perplex.

func (*Perplex) Inv

func (z *Perplex) Inv(y *Perplex) *Perplex

Inv sets z equal to the inverse of y, and returns z. If y is a zero divisor, then Inv panics.

func (*Perplex) IsZeroDivisor

func (z *Perplex) IsZeroDivisor() bool

IsZeroDivisor returns true if z is a zero divisor.

func (*Perplex) Mul

func (z *Perplex) Mul(x, y *Perplex) *Perplex

Mul sets z equal to the product of x and y, and returns z.

The multiplication rule is:

Mul(s, s) = +1

This binary operation is commutative and associative.

func (*Perplex) Möbius

func (z *Perplex) Möbius(y, a, b, c, d *Perplex) *Perplex

Möbius sets z equal to the Möbius (fractional linear) transform of y:

(a*y + b) * Inv(c*y + d)

Then it returns z.

func (*Perplex) Neg

func (z *Perplex) Neg(y *Perplex) *Perplex

Neg sets z equal to the negative of y, and returns z.

func (*Perplex) Plus

func (z *Perplex) Plus(y *Perplex, a *big.Rat) *Perplex

Plus sets z equal to y shifted by the rational a, and returns z.

func (*Perplex) PolyEval

func (z *Perplex) PolyEval(y *Perplex, poly Laurent) *Perplex

PolyEval sets z equal to poly evaluated at y, and returns z.

func (*Perplex) Quad

func (z *Perplex) Quad() *big.Rat

Quad returns the quadrance of z. If z = a+bs, then the quadrance is

a² - b²

This can be positive, negative, or zero.

func (*Perplex) Quo

func (z *Perplex) Quo(x, y *Perplex) *Perplex

Quo sets z equal to the quotient of x and y, and returns z. If y is a zero divisor, then Quo panics.

func (*Perplex) Rats

func (z *Perplex) Rats() (*big.Rat, *big.Rat)

Rats returns the two rational components of z.

func (*Perplex) Real

func (z *Perplex) Real() *big.Rat

Real returns the (rational) real part of z.

func (*Perplex) Scal

func (z *Perplex) Scal(y *Perplex, a *big.Rat) *Perplex

Scal sets z equal to y scaled by a, and returns z.

func (*Perplex) Set

func (z *Perplex) Set(y *Perplex) *Perplex

Set sets z equal to y, and returns z.

func (*Perplex) String

func (z *Perplex) String() string

String returns the string version of a Perplex value.

If z corresponds to a + bs, then the string is "(a+bs)", similar to complex128 values.

func (*Perplex) Sub

func (z *Perplex) Sub(x, y *Perplex) *Perplex

Sub sets z equal to x-y, and returns z.

type Supra

type Supra struct {
	// contains filtered or unexported fields
}

A Supra represents a rational supra number.

func NewSupra

func NewSupra(a, b, c, d *big.Rat) *Supra

NewSupra returns a pointer to the Supra value a+bα+cβ+dγ.

func (*Supra) Add

func (z *Supra) Add(x, y *Supra) *Supra

Add sets z equal to x+y, and returns z.

func (*Supra) Commutator

func (z *Supra) Commutator(x, y *Supra) *Supra

Commutator sets z equal to the commutator of x and y:

Mul(x, y) - Mul(y, x)

Then it returns z.

func (*Supra) Conj

func (z *Supra) Conj(y *Supra) *Supra

Conj sets z equal to the conjugate of y, and returns z.

func (*Supra) CrossRatioL

func (z *Supra) CrossRatioL(v, w, x, y *Supra) *Supra

CrossRatioL sets z equal to the left cross-ratio of v, w, x, and y:

Inv(w - x) * (v - x) * Inv(v - y) * (w - y)

Then it returns z.

func (*Supra) CrossRatioR

func (z *Supra) CrossRatioR(v, w, x, y *Supra) *Supra

CrossRatioR sets z equal to the right cross-ratio of v, w, x, and y:

(v - x) * Inv(w - x) * (w - y) * Inv(v - y)

Then it returns z.

func (*Supra) Dot

func (z *Supra) Dot(y *Supra) *big.Rat

Dot returns the (rational) dot product of z and y.

func (*Supra) Equals

func (z *Supra) Equals(y *Supra) bool

Equals returns true if y and z are equal.

func (*Supra) Generate

func (z *Supra) Generate(rand *rand.Rand, size int) reflect.Value

Generate returns a random Supra value for quick.Check testing.

func (*Supra) Inv

func (z *Supra) Inv(y *Supra) *Supra

Inv sets z equal to the inverse of y, and returns z. If y is a zero divisor, then Inv panics.

func (*Supra) IsZeroDivisor

func (z *Supra) IsZeroDivisor() bool

IsZeroDivisor returns true if z is a zero divisor.

func (*Supra) Mul

func (z *Supra) Mul(x, y *Supra) *Supra

Mul sets z equal to the product of x and y, and returns z.

The multiplication rules are:

Mul(α, α) = Mul(β, β) = Mul(γ, γ) = 0
Mul(α, β) = -Mul(β, α) = γ
Mul(β, γ) = Mul(γ, β) = 0
Mul(γ, α) = Mul(α, γ) = 0

This binary operation is noncommutative but associative.

func (*Supra) MöbiusL

func (z *Supra) MöbiusL(y, a, b, c, d *Supra) *Supra

MöbiusL sets z equal to the left Möbius (fractional linear) transform of y:

Inv(y*c + d) * (y*a + b)

Then it returns z.

func (*Supra) MöbiusR

func (z *Supra) MöbiusR(y, a, b, c, d *Supra) *Supra

MöbiusR sets z equal to the right Möbius (fractional linear) transform of y:

(a*y + b) * Inv(c*y + d)

Then it returns z.

func (*Supra) Neg

func (z *Supra) Neg(y *Supra) *Supra

Neg sets z equal to the negative of y, and returns z.

func (*Supra) Quad

func (z *Supra) Quad() *big.Rat

Quad returns the quadrance of z. If z = a+bα+cβ+dγ, then the quadrance is

This is always non-negative.

func (*Supra) QuoL

func (z *Supra) QuoL(x, y *Supra) *Supra

QuoL sets z equal to the left quotient of x and y:

Mul(Inv(y), x)

Then it returns z. If y is a zero divisor, then QuoL panics.

func (*Supra) QuoR

func (z *Supra) QuoR(x, y *Supra) *Supra

QuoR sets z equal to the right quotient of x and y:

Mul(x, Inv(y))

Then it returns z. If y is a zero divisor, then QuoR panics.

func (*Supra) Rats

func (z *Supra) Rats() (*big.Rat, *big.Rat, *big.Rat, *big.Rat)

Rats returns the four rational components of z.

func (*Supra) Real

func (z *Supra) Real() *big.Rat

Real returns the (rational) real part of z.

func (*Supra) Scal

func (z *Supra) Scal(y *Supra, a *big.Rat) *Supra

Scal sets z equal to y scaled by a, and returns z.

func (*Supra) Set

func (z *Supra) Set(y *Supra) *Supra

Set sets z equal to y, and returns z.

func (*Supra) String

func (z *Supra) String() string

String returns the string representation of a Supra value.

If z corresponds to a + bα + cβ + dγ, then the string is "(a+bα+cβ+dγ)", similar to complex128 values.

func (*Supra) Sub

func (z *Supra) Sub(x, y *Supra) *Supra

Sub sets z equal to x-y, and returns z.

type SupraComplex

type SupraComplex struct {
	// contains filtered or unexported fields
}

A SupraComplex represents a rational supra-complex number.

func NewSupraComplex

func NewSupraComplex(a, b, c, d, e, f, g, h *big.Rat) *SupraComplex

NewSupraComplex returns a pointer to the SupraComplex value a+bi+cα+dβ+eγ+fδ+gε+hζ.

func (*SupraComplex) Add

func (z *SupraComplex) Add(x, y *SupraComplex) *SupraComplex

Add sets z equal to x+y, and returns z.

func (*SupraComplex) Associator

func (z *SupraComplex) Associator(w, x, y *SupraComplex) *SupraComplex

Associator sets z equal to the associator of w, x, and y:

Mul(Mul(w, x), y) - Mul(w, Mul(x, y))

Then it returns z.

func (*SupraComplex) Commutator

func (z *SupraComplex) Commutator(x, y *SupraComplex) *SupraComplex

Commutator sets z equal to the commutator of x and y:

Mul(x, y) - Mul(y, x)

Then it returns z.

func (*SupraComplex) Conj

func (z *SupraComplex) Conj(y *SupraComplex) *SupraComplex

Conj sets z equal to the conjugate of y, and returns z.

func (*SupraComplex) Equals

func (z *SupraComplex) Equals(y *SupraComplex) bool

Equals returns true if y and z are equal.

func (*SupraComplex) Generate

func (z *SupraComplex) Generate(rand *rand.Rand, size int) reflect.Value

Generate returns a random SupraComplex value for quick.Check testing.

func (*SupraComplex) Inv

Inv sets z equal to the inverse of y, and returns z. If y is a zero divisor, then Inv panics.

func (*SupraComplex) IsZeroDivisor

func (z *SupraComplex) IsZeroDivisor() bool

IsZeroDivisor returns true if z is a zero divisor. This is equivalent to z being nilpotent.

func (*SupraComplex) Mul

func (z *SupraComplex) Mul(x, y *SupraComplex) *SupraComplex

Mul sets z equal to the product of x and y, and returns z.

The multiplication rules are:

Mul(i, i) = -1
Mul(α, α) = Mul(β, β) = Mul(γ, γ) = 0
Mul(δ, δ) = Mul(ε, ε) = Mul(ζ, ζ) = 0
Mul(i, α) = -Mul(α, i) = +β
Mul(i, β) = -Mul(β, i) = -α
Mul(i, γ) = -Mul(γ, i) = +δ
Mul(i, δ) = -Mul(δ, i) = -γ
Mul(i, ε) = -Mul(ε, i) = -ζ
Mul(i, ζ) = -Mul(ζ, i) = +ε
Mul(α, β) = Mul(β, α) = 0
Mul(α, γ) = -Mul(γ, α) = +ε
Mul(α, δ) = -Mul(δ, α) = +ζ
Mul(α, ε) = Mul(ε, α) = 0
Mul(α, ζ) = Mul(ζ, α) = 0
Mul(β, γ) = -Mul(γ, β) = +ζ
Mul(β, δ) = -Mul(δ, β) = -ε
Mul(β, ε) = Mul(ε, β) = 0
Mul(β, ζ) = Mul(ζ, β) = 0
Mul(γ, δ) = Mul(δ, γ) = 0
Mul(γ, ε) = Mul(ε, γ) = 0
Mul(γ, ζ) = Mul(ζ, γ) = 0
Mul(δ, ε) = Mul(ε, δ) = 0
Mul(δ, ζ) = Mul(ζ, δ) = 0
Mul(ε, ζ) = Mul(ζ, ε) = 0

This binary operation is noncommutative and nonassociative.

func (*SupraComplex) Neg

Neg sets z equal to the negative of y, and returns z.

func (*SupraComplex) Quad

func (z *SupraComplex) Quad() *big.Rat

Quad returns the quadrance of z. If z = a+bi+cα+dβ+eγ+fδ+gε+hζ, then the quadrance is

a² + b²

This is always non-negative.

func (*SupraComplex) QuoL

func (z *SupraComplex) QuoL(x, y *SupraComplex) *SupraComplex

QuoL sets z equal to the left quotient of x and y:

Mul(Inv(y), x)

Then it returns z. If y is a zero divisor, then QuoL panics.

func (*SupraComplex) QuoR

func (z *SupraComplex) QuoR(x, y *SupraComplex) *SupraComplex

QuoR sets z equal to the right quotient of x and y:

Mul(x, Inv(y))

Then it returns z. If y is a zero divisor, then QuoR panics.

func (*SupraComplex) Rats

func (z *SupraComplex) Rats() (*big.Rat, *big.Rat, *big.Rat, *big.Rat,
	*big.Rat, *big.Rat, *big.Rat, *big.Rat)

Rats returns the eight rational components of z.

func (*SupraComplex) Real

func (z *SupraComplex) Real() *big.Rat

Real returns the (rational) real part of z.

func (*SupraComplex) Scal

func (z *SupraComplex) Scal(y *SupraComplex, a *big.Rat) *SupraComplex

Scal sets z equal to y scaled by a, and returns z.

func (*SupraComplex) Set

Set sets z equal to y, and returns z.

func (*SupraComplex) String

func (z *SupraComplex) String() string

String returns the string representation of a SupraComplex value.

If z corresponds to a + bi + cα + dβ + eγ + fδ + gε + hζ, then the string is"(a+bi+cα+dβ+eγ+fδ+gε+hζ)", similar to complex128 values.

func (*SupraComplex) Sub

func (z *SupraComplex) Sub(x, y *SupraComplex) *SupraComplex

Sub sets z equal to x-y, and returns z.

type SupraPerplex

type SupraPerplex struct {
	// contains filtered or unexported fields
}

An SupraPerplex represents a rational supra-perplex number.

func NewSupraPerplex

func NewSupraPerplex(a, b, c, d, e, f, g, h *big.Rat) *SupraPerplex

NewSupraPerplex returns a pointer to the SupraPerplex value a+bs+cρ+dσ+eτ+fυ+gφ+hψ.

func (*SupraPerplex) Add

func (z *SupraPerplex) Add(x, y *SupraPerplex) *SupraPerplex

Add sets z equal to x+y, and returns z.

func (*SupraPerplex) Associator

func (z *SupraPerplex) Associator(w, x, y *SupraPerplex) *SupraPerplex

Associator sets z equal to the associator of w, x, and y:

Mul(Mul(w, x), y) - Mul(w, Mul(x, y))

Then it returns z.

func (*SupraPerplex) Commutator

func (z *SupraPerplex) Commutator(x, y *SupraPerplex) *SupraPerplex

Commutator sets z equal to the commutator of x and y:

Mul(x, y) - Mul(y, x)

Then it returns z.

func (*SupraPerplex) Conj

func (z *SupraPerplex) Conj(y *SupraPerplex) *SupraPerplex

Conj sets z equal to the conjugate of y, and returns z.

func (*SupraPerplex) Equals

func (z *SupraPerplex) Equals(y *SupraPerplex) bool

Equals returns true if y and z are equal.

func (*SupraPerplex) Generate

func (z *SupraPerplex) Generate(rand *rand.Rand, size int) reflect.Value

Generate returns a random SupraPerplex value for quick.Check testing.

func (*SupraPerplex) Inv

Inv sets z equal to the inverse of y, and returns z. If y is a zero divisor, then Inv panics.

func (*SupraPerplex) IsZeroDivisor

func (z *SupraPerplex) IsZeroDivisor() bool

IsZeroDivisor returns true if z is a zero divisor. This is equivalent to z being nilpotent.

func (*SupraPerplex) Mul

func (z *SupraPerplex) Mul(x, y *SupraPerplex) *SupraPerplex

Mul sets z equal to the product of x and y, and returns z.

The multiplication rules are:

Mul(s, s) = +1
Mul(ρ, ρ) = Mul(σ, σ) = Mul(τ, τ) = 0
Mul(υ, υ) = Mul(φ, φ) = Mul(ψ, ψ) = 0
Mul(s, ρ) = -Mul(ρ, s) = +σ
Mul(s, σ) = -Mul(σ, s) = +ρ
Mul(s, τ) = -Mul(τ, s) = +υ
Mul(s, υ) = -Mul(υ, s) = +τ
Mul(s, φ) = -Mul(φ, s) = -ψ
Mul(s, ψ) = -Mul(ψ, s) = -φ
Mul(ρ, σ) = Mul(σ, ρ) = 0
Mul(ρ, τ) = -Mul(τ, ρ) = +φ
Mul(ρ, υ) = -Mul(υ, ρ) = +ψ
Mul(ρ, φ) = Mul(φ, ρ) = 0
Mul(ρ, ψ) = Mul(ψ, ρ) = 0
Mul(σ, τ) = -Mul(τ, σ) = +ψ
Mul(σ, υ) = -Mul(υ, σ) = +φ
Mul(σ, φ) = Mul(φ, σ) = 0
Mul(σ, ψ) = Mul(ψ, σ) = 0
Mul(τ, υ) = Mul(υ, τ) = 0
Mul(τ, φ) = Mul(φ, τ) = 0
Mul(τ, ψ) = Mul(ψ, τ) = 0
Mul(υ, φ) = Mul(φ, υ) = 0
Mul(υ, ψ) = Mul(ψ, υ) = 0
Mul(φ, ψ) = Mul(ψ, φ) = 0

This binary operation is noncommutative and nonassociative.

func (*SupraPerplex) Neg

Neg sets z equal to the negative of y, and returns z.

func (*SupraPerplex) Quad

func (z *SupraPerplex) Quad() *big.Rat

Quad returns the quadrance of z. If z = a+bs+cρ+dσ+eτ+fυ+gφ+hψ, then the quadrance is

a² - b²

This can be positive, negative, or zero.

func (*SupraPerplex) QuoL

func (z *SupraPerplex) QuoL(x, y *SupraPerplex) *SupraPerplex

QuoL sets z equal to the left quotient of x and y:

Mul(Inv(y), x)

Then it returns z. If y is a zero divisor, then QuoL panics.

func (*SupraPerplex) QuoR

func (z *SupraPerplex) QuoR(x, y *SupraPerplex) *SupraPerplex

QuoR sets z equal to the right quotient of x and y:

Mul(x, Inv(y))

Then it returns z. If y is a zero divisor, then QuoR panics.

func (*SupraPerplex) Rats

func (z *SupraPerplex) Rats() (*big.Rat, *big.Rat, *big.Rat, *big.Rat,
	*big.Rat, *big.Rat, *big.Rat, *big.Rat)

Rats returns the eight rational components of z.

func (*SupraPerplex) Real

func (z *SupraPerplex) Real() *big.Rat

Real returns the (rational) real part of z.

func (*SupraPerplex) Scal

func (z *SupraPerplex) Scal(y *SupraPerplex, a *big.Rat) *SupraPerplex

Scal sets z equal to y scaled by a, and returns z.

func (*SupraPerplex) Set

Set sets z equal to y, and returns z.

func (*SupraPerplex) String

func (z *SupraPerplex) String() string

String returns the string representation of an SupraPerplex value.

If z corresponds to a + bs + cρ + dσ + eτ + fυ + gφ + hψ, then the string is "(a+bs+cρ+dσ+eτ+fυ+gφ+hψ)", similar to complex128 values.

func (*SupraPerplex) Sub

func (z *SupraPerplex) Sub(x, y *SupraPerplex) *SupraPerplex

Sub sets z equal to x-y, and returns z.

type TriComplex

type TriComplex struct {
	// contains filtered or unexported fields
}

A TriComplex represents a rational tricomplex number.

func NewTriComplex

func NewTriComplex(a, b, c, d, e, f, g, h *big.Rat) *TriComplex

NewTriComplex returns a *TriComplex with value a+bi+cJ+diJ+eK+fiK+gJK+hiJK.

func (*TriComplex) Add

func (z *TriComplex) Add(x, y *TriComplex) *TriComplex

Add sets z equal to x+y, and returns z.

func (*TriComplex) Conj

func (z *TriComplex) Conj(y *TriComplex) *TriComplex

Conj sets z equal to the conjugate of y, and returns z.

func (*TriComplex) CrossRatio

func (z *TriComplex) CrossRatio(v, w, x, y *TriComplex) *TriComplex

CrossRatio sets z equal to the cross-ratio of v, w, x, and y:

Inv(w - x) * (v - x) * Inv(v - y) * (w - y)

Then it returns z.

func (*TriComplex) Equals

func (z *TriComplex) Equals(y *TriComplex) bool

Equals returns true if y and z are equal.

func (*TriComplex) Generate

func (z *TriComplex) Generate(rand *rand.Rand, size int) reflect.Value

Generate returns a random TriComplex value for quick.Check testing.

func (*TriComplex) Inv

func (z *TriComplex) Inv(y *TriComplex) *TriComplex

Inv sets z equal to the inverse of y, and returns z. If y is a zero divisor, then Inv panics.

func (*TriComplex) IsZeroDivisor

func (z *TriComplex) IsZeroDivisor() bool

IsZeroDivisor returns true if z is a zero divisor.

func (*TriComplex) Mul

func (z *TriComplex) Mul(x, y *TriComplex) *TriComplex

Mul sets z equal to the product of x and y, and returns z.

The multiplication rules are:

Mul(i, i) = Mul(J, J) = Mul(K, K) = -1
Mul(i, J) = Mul(J, i)
Mul(i, K) = Mul(K, i)
Mul(J, K) = Mul(K, J)

This binary operation is commutative and associative.

func (*TriComplex) Möbius

func (z *TriComplex) Möbius(y, a, b, c, d *TriComplex) *TriComplex

Möbius sets z equal to the Möbius (fractional linear) transform of y:

(a*y + b) * Inv(c*y + d)

Then it returns z.

func (*TriComplex) Neg

func (z *TriComplex) Neg(y *TriComplex) *TriComplex

Neg sets z equal to the negative of y, and returns z.

func (*TriComplex) Norm

func (z *TriComplex) Norm() *big.Rat

Norm returns the norm of z. If z = a+bi+cJ+dS, then the norm is

(a² - b² + c² - d²)² + 4(ab + cd)²

This can also be written as

((a - d)² + (b + c)²)((a + d)² + (b - c)²)

The norm is always non-negative.

func (*TriComplex) Quad

func (z *TriComplex) Quad() *BiComplex

Quad returns the quadrance of z. If z = a+bi+cJ+dS, then the quadrance is

a² - b² + c² - d² + 2(ab + cd)i

Note that this is a bicomplex number.

func (*TriComplex) Quo

func (z *TriComplex) Quo(x, y *TriComplex) *TriComplex

Quo sets z equal to the quotient of x and y. If y is a zero divisor, then Quo panics.

func (*TriComplex) Rats

func (z *TriComplex) Rats() (*big.Rat, *big.Rat, *big.Rat, *big.Rat,
	*big.Rat, *big.Rat, *big.Rat, *big.Rat)

Rats returns the eight rational components of z.

func (*TriComplex) Real

func (z *TriComplex) Real() *big.Rat

Real returns the (rational) real part of z.

func (*TriComplex) Scal

func (z *TriComplex) Scal(y *TriComplex, a *big.Rat) *TriComplex

Scal sets z equal to y scaled by a, and returns z.

func (*TriComplex) Set

func (z *TriComplex) Set(y *TriComplex) *TriComplex

Set sets z equal to y, and returns z.

func (*TriComplex) String

func (z *TriComplex) String() string

String returns the string representation of a TriComplex value.

func (*TriComplex) Sub

func (z *TriComplex) Sub(x, y *TriComplex) *TriComplex

Sub sets z equal to x-y, and returns z.

type TriNilplex

type TriNilplex struct {
	// contains filtered or unexported fields
}

A TriNilplex represents a rational trinilplex number.

func NewTriNilplex

func NewTriNilplex(a, b, c, d, e, f, g, h *big.Rat) *TriNilplex

NewTriNilplex returns a *TriNilplex with value a+bα+cΓ+dαΓ+eΛ+fαΛ+gΓΛ+hαΓΛ.

func (*TriNilplex) Add

func (z *TriNilplex) Add(x, y *TriNilplex) *TriNilplex

Add sets z equal to x+y, and returns z.

func (*TriNilplex) Conj

func (z *TriNilplex) Conj(y *TriNilplex) *TriNilplex

Conj sets z equal to the conjugate of y, and returns z.

func (*TriNilplex) CrossRatio

func (z *TriNilplex) CrossRatio(v, w, x, y *TriNilplex) *TriNilplex

CrossRatio sets z equal to the cross-ratio of v, w, x, and y:

Inv(w - x) * (v - x) * Inv(v - y) * (w - y)

Then it returns z.

func (*TriNilplex) Equals

func (z *TriNilplex) Equals(y *TriNilplex) bool

Equals returns true if y and z are equal.

func (*TriNilplex) Generate

func (z *TriNilplex) Generate(rand *rand.Rand, size int) reflect.Value

Generate returns a random TriNilplex value for quick.Check testing.

func (*TriNilplex) Inv

func (z *TriNilplex) Inv(y *TriNilplex) *TriNilplex

Inv sets z equal to the inverse of y, and returns z. If y is a zero divisor, then Inv panics.

func (*TriNilplex) IsZeroDivisor

func (z *TriNilplex) IsZeroDivisor() bool

IsZeroDivisor returns true if z is a zero divisor.

func (*TriNilplex) Mul

func (z *TriNilplex) Mul(x, y *TriNilplex) *TriNilplex

Mul sets z equal to the product of x and y, and returns z.

The multiplication rules are:

Mul(α, α) = Mul(Γ, Γ) = Mul(Λ, Λ) = 0
Mul(α, Γ) = Mul(Γ, α)
Mul(α, Λ) = Mul(Λ, α)
Mul(Γ, Λ) = Mul(Λ, Γ)

This binary operation is commutative and associative.

func (*TriNilplex) Möbius

func (z *TriNilplex) Möbius(y, a, b, c, d *TriNilplex) *TriNilplex

Möbius sets z equal to the Möbius (fractional linear) transform of y:

(a*y + b) * Inv(c*y + d)

Then it returns z.

func (*TriNilplex) Neg

func (z *TriNilplex) Neg(y *TriNilplex) *TriNilplex

Neg sets z equal to the negative of y, and returns z.

func (*TriNilplex) Norm

func (z *TriNilplex) Norm() *big.Rat

Norm returns the norm of z. If z = a+bα+cΓ+dαΓ+eΛ+fαΛ+gΓΛ+hαΓΛ, then the norm is

((a²)²)²

The norm is always non-negative.

func (*TriNilplex) Quad

func (z *TriNilplex) Quad() *Hyper

Quad returns the quadrance of z. If z = a+bα+cΓ+dαΓ+eΛ+fαΛ+gΓΛ+hαΓΛ, then the quadrance is

a² + 2abα + 2acΓ + 2(ad + bc)αΓ

Note that this is a bicomplex number.

func (*TriNilplex) Quo

func (z *TriNilplex) Quo(x, y *TriNilplex) *TriNilplex

Quo sets z equal to the quotient of x and y. If y is a zero divisor, then Quo panics.

func (*TriNilplex) Rats

func (z *TriNilplex) Rats() (*big.Rat, *big.Rat, *big.Rat, *big.Rat,
	*big.Rat, *big.Rat, *big.Rat, *big.Rat)

Rats returns the eight rational components of z.

func (*TriNilplex) Real

func (z *TriNilplex) Real() *big.Rat

Real returns the (rational) real part of z.

func (*TriNilplex) Scal

func (z *TriNilplex) Scal(y *TriNilplex, a *big.Rat) *TriNilplex

Scal sets z equal to y scaled by a, and returns z.

func (*TriNilplex) Set

func (z *TriNilplex) Set(y *TriNilplex) *TriNilplex

Set sets z equal to y, and returns z.

func (*TriNilplex) String

func (z *TriNilplex) String() string

String returns the string representation of a TriNilplex value.

func (*TriNilplex) Sub

func (z *TriNilplex) Sub(x, y *TriNilplex) *TriNilplex

Sub sets z equal to x-y, and returns z.

type TriPerplex

type TriPerplex struct {
	// contains filtered or unexported fields
}

A TriPerplex represents a rational triperplex number.

func NewTriPerplex

func NewTriPerplex(a, b, c, d, e, f, g, h *big.Rat) *TriPerplex

NewTriPerplex returns a *TriPerplex with value a+bs+cT+dsT+eU+fsU+gTU+hsTU.

func (*TriPerplex) Add

func (z *TriPerplex) Add(x, y *TriPerplex) *TriPerplex

Add sets z equal to x+y, and returns z.

func (*TriPerplex) Conj

func (z *TriPerplex) Conj(y *TriPerplex) *TriPerplex

Conj sets z equal to the conjugate of y, and returns z.

func (*TriPerplex) CrossRatio

func (z *TriPerplex) CrossRatio(v, w, x, y *TriPerplex) *TriPerplex

CrossRatio sets z equal to the cross-ratio of v, w, x, and y:

Inv(w - x) * (v - x) * Inv(v - y) * (w - y)

Then it returns z.

func (*TriPerplex) Equals

func (z *TriPerplex) Equals(y *TriPerplex) bool

Equals returns true if y and z are equal.

func (*TriPerplex) Generate

func (z *TriPerplex) Generate(rand *rand.Rand, size int) reflect.Value

Generate returns a random TriPerplex value for quick.Check testing.

func (*TriPerplex) Inv

func (z *TriPerplex) Inv(y *TriPerplex) *TriPerplex

Inv sets z equal to the inverse of y, and returns z. If y is a zero divisor, then Inv panics.

func (*TriPerplex) IsZeroDivisor

func (z *TriPerplex) IsZeroDivisor() bool

IsZeroDivisor returns true if z is a zero divisor.

func (*TriPerplex) Mul

func (z *TriPerplex) Mul(x, y *TriPerplex) *TriPerplex

Mul sets z equal to the product of x and y, and returns z.

The multiplication rules are:

Mul(s, s) = Mul(T, T) = Mul(U, U) = +1
Mul(s, T) = Mul(T, s)
Mul(s, U) = Mul(U, s)
Mul(T, U) = Mul(U, T)

This binary operation is commutative and associative.

func (*TriPerplex) Möbius

func (z *TriPerplex) Möbius(y, a, b, c, d *TriPerplex) *TriPerplex

Möbius sets z equal to the Möbius (fractional linear) transform of y:

(a*y + b) * Inv(c*y + d)

Then it returns z.

func (*TriPerplex) Neg

func (z *TriPerplex) Neg(y *TriPerplex) *TriPerplex

Neg sets z equal to the negative of y, and returns z.

func (*TriPerplex) Norm

func (z *TriPerplex) Norm() *big.Rat

Norm returns the norm of z. If z = a+bs+cT+dsT+eU+fsU+gTU+hsTU, then the norm is

(a² - b² + c² - d²)² + 4(ab + cd)²

This can also be written as

((a - d)² + (b + c)²)((a + d)² + (b - c)²)

The norm is always non-negative.

func (*TriPerplex) Quad

func (z *TriPerplex) Quad() *BiPerplex

Quad returns the quadrance of z. If z = a+bs+cT+dsT+eU+fsU+gTU+hsTU, then the quadrance is

a² - b² + c² - d² + 2(ab + cd)i

Note that this is a biperplex number.

func (*TriPerplex) Quo

func (z *TriPerplex) Quo(x, y *TriPerplex) *TriPerplex

Quo sets z equal to the quotient of x and y. If y is a zero divisor, then Quo panics.

func (*TriPerplex) Rats

func (z *TriPerplex) Rats() (*big.Rat, *big.Rat, *big.Rat, *big.Rat,
	*big.Rat, *big.Rat, *big.Rat, *big.Rat)

Rats returns the eight rational components of z.

func (*TriPerplex) Real

func (z *TriPerplex) Real() *big.Rat

Real returns the (rational) real part of z.

func (*TriPerplex) Scal

func (z *TriPerplex) Scal(y *TriPerplex, a *big.Rat) *TriPerplex

Scal sets z equal to y scaled by a, and returns z.

func (*TriPerplex) Set

func (z *TriPerplex) Set(y *TriPerplex) *TriPerplex

Set sets z equal to y, and returns z.

func (*TriPerplex) String

func (z *TriPerplex) String() string

String returns the string representation of a TriPerplex value.

func (*TriPerplex) Sub

func (z *TriPerplex) Sub(x, y *TriPerplex) *TriPerplex

Sub sets z equal to x-y, and returns z.

type Ultra

type Ultra struct {
	// contains filtered or unexported fields
}

An Ultra represents a rational ultra number.

func NewUltra

func NewUltra(a, b, c, d, e, f, g, h *big.Rat) *Ultra

NewUltra returns a pointer to the Ultra value a+bα+cβ+dγ+eδ+fε+gζ+hη.

func (*Ultra) Add

func (z *Ultra) Add(x, y *Ultra) *Ultra

Add sets z equal to the sum of x and y, and returns z.

func (*Ultra) Associator

func (z *Ultra) Associator(w, x, y *Ultra) *Ultra

Associator sets z equal to the associator of w, x, and y:

Mul(Mul(w, x), y) - Mul(w, Mul(x, y))

Then it returns z.

func (*Ultra) Commutator

func (z *Ultra) Commutator(x, y *Ultra) *Ultra

Commutator sets z equal to the commutator of x and y:

Mul(x, y) - Mul(y, x)

Then it returns z.

func (*Ultra) Conj

func (z *Ultra) Conj(y *Ultra) *Ultra

Conj sets z equal to the conjugate of y, and returns z.

func (*Ultra) Equals

func (z *Ultra) Equals(y *Ultra) bool

Equals returns true if y and z are equal.

func (*Ultra) Generate

func (z *Ultra) Generate(rand *rand.Rand, size int) reflect.Value

Generate returns a random Ultra value for quick.Check testing.

func (*Ultra) Inv

func (z *Ultra) Inv(y *Ultra) *Ultra

Inv sets z equal to the inverse of y, and returns z. If y is a zero divisor, then Inv panics.

func (*Ultra) IsZeroDivisor

func (z *Ultra) IsZeroDivisor() bool

IsZeroDivisor returns true if z is a zero divisor.

func (*Ultra) Mul

func (z *Ultra) Mul(x, y *Ultra) *Ultra

Mul sets z equal to the product of x and y, and returns z.

The multiplication rules are:

Mul(α, α) = Mul(β, β) = Mul(γ, γ) = 0
Mul(δ, δ) = Mul(ε, ε) = Mul(ζ, ζ) = Mul(η, η) = 0
Mul(α, β) = -Mul(β, α) = +γ
Mul(α, γ) = Mul(γ, α) = 0
Mul(α, δ) = -Mul(δ, α) = +ε
Mul(α, ε) = Mul(ε, α) = 0
Mul(α, ζ) = -Mul(ζ, α) = -η
Mul(α, η) = -Mul(η, α) = +ζ
Mul(β, γ) = Mul(γ, β) = 0
Mul(β, δ) = -Mul(δ, β) = +ζ
Mul(β, ε) = -Mul(ε, β) = +η
Mul(β, ζ) = Mul(ζ, β) = 0
Mul(β, η) = Mul(η, β) = 0
Mul(γ, δ) = -Mul(δ, γ) = +η
Mul(γ, ε) = Mul(ε, γ) = 0
Mul(γ, ζ) = Mul(ζ, γ) = 0
Mul(γ, η) = Mul(η, γ) = 0
Mul(δ, ε) = Mul(ε, δ) = 0
Mul(δ, ζ) = Mul(ζ, δ) = 0
Mul(δ, η) = Mul(η, δ) = 0
Mul(ε, ζ) = Mul(ζ, ε) = 0
Mul(ε, η) = Mul(η, ε) = 0
Mul(ζ, η) = Mul(η, ζ) = 0

This binary operation is noncommutative and nonassociative.

func (*Ultra) Neg

func (z *Ultra) Neg(y *Ultra) *Ultra

Neg sets z equal to the negative of y, and returns z.

func (*Ultra) Quad

func (z *Ultra) Quad() *big.Rat

Quad returns the quadrance of z. If z = a+bα+cβ+dγ+eδ+fε+gζ+hη, then the quadrance is

This is always non-negative.

func (*Ultra) QuoL

func (z *Ultra) QuoL(x, y *Ultra) *Ultra

QuoL sets z equal to the left quotient of x and y:

Mul(Inv(y), x)

Then it returns z. If y is a zero divisor, then QuoL panics.

func (*Ultra) QuoR

func (z *Ultra) QuoR(x, y *Ultra) *Ultra

QuoR sets z equal to the right quotient of x and y:

Mul(x, Inv(y))

Then it returns z. If y is a zero divisor, then QuoR panics.

func (*Ultra) Rats

func (z *Ultra) Rats() (*big.Rat, *big.Rat, *big.Rat, *big.Rat,
	*big.Rat, *big.Rat, *big.Rat, *big.Rat)

Rats returns the eight rational components of z.

func (*Ultra) Real

func (z *Ultra) Real() *big.Rat

Real returns the (rational) real part of z.

func (*Ultra) Scal

func (z *Ultra) Scal(y *Ultra, a *big.Rat) *Ultra

Scal sets z equal to y scaled by a, and returns z.

func (*Ultra) Set

func (z *Ultra) Set(y *Ultra) *Ultra

Set sets z equal to y, and returns z.

func (*Ultra) String

func (z *Ultra) String() string

String returns the string representation of an Ultra value.

If z corresponds to a + bα + cβ + dγ + eδ + fε + gζ + hη, then the string is "(a+bα+cβ+dγ+eδ+fε+gζ+hη)", similar to complex128 values.

func (*Ultra) Sub

func (z *Ultra) Sub(x, y *Ultra) *Ultra

Sub sets z equal to the difference of x and y, and returns z.

type Zorn

type Zorn struct {
	// contains filtered or unexported fields
}

A Zorn represents a rational Zorn octonion.

func NewZorn

func NewZorn(a, b, c, d, e, f, g, h *big.Rat) *Zorn

NewZorn returns a pointer to the Zorn value a+bi+cj+dk+er+fs+gt+hu.

func (*Zorn) Add

func (z *Zorn) Add(x, y *Zorn) *Zorn

Add sets z equal to x+y, and returns z.

func (*Zorn) Associator

func (z *Zorn) Associator(w, x, y *Zorn) *Zorn

Associator sets z equal to the associator of w, x, and y:

Mul(Mul(w, x), y) - Mul(w, Mul(x, y))

Then it returns z.

func (*Zorn) Commutator

func (z *Zorn) Commutator(x, y *Zorn) *Zorn

Commutator sets z equal to the commutator of x and y:

Mul(x, y) - Mul(y, x)

Then it returns z.

func (*Zorn) Conj

func (z *Zorn) Conj(y *Zorn) *Zorn

Conj sets z equal to the conjugate of y, and returns z.

func (*Zorn) Equals

func (z *Zorn) Equals(y *Zorn) bool

Equals returns true if y and z are equal.

func (*Zorn) Generate

func (z *Zorn) Generate(rand *rand.Rand, size int) reflect.Value

Generate returns a random Zorn value for quick.Check testing.

func (*Zorn) Inv

func (z *Zorn) Inv(y *Zorn) *Zorn

Inv sets z equal to the inverse of y, and returns z. If y is a zero divisor, then Inv panics.

func (*Zorn) IsZeroDivisor

func (z *Zorn) IsZeroDivisor() bool

IsZeroDivisor returns true if z is a zero divisor.

func (*Zorn) Mul

func (z *Zorn) Mul(x, y *Zorn) *Zorn

Mul sets z equal to the product of x and y, and returns z.

The multiplication rules are:

Mul(i, i) = Mul(j, j) = Mul(k, k) = -1
Mul(r, r) = Mul(s, s) = Mul(t, t) = Mul(u, u) = +1
Mul(i, j) = -Mul(j, i) = +k
Mul(i, k) = -Mul(k, i) = -j
Mul(i, r) = -Mul(r, i) = +s
Mul(i, s) = -Mul(s, i) = -r
Mul(i, t) = -Mul(t, i) = -u
Mul(i, u) = -Mul(u, i) = +t
Mul(j, k) = -Mul(k, j) = +i
Mul(j, r) = -Mul(r, j) = +t
Mul(j, s) = -Mul(s, j) = +u
Mul(j, t) = -Mul(t, j) = -r
Mul(j, u) = -Mul(u, j) = -s
Mul(k, r) = -Mul(r, k) = +u
Mul(k, s) = -Mul(s, k) = -t
Mul(k, t) = -Mul(t, k) = +s
Mul(k, u) = -Mul(u, k) = -r
Mul(r, s) = -Mul(s, r) = -i
Mul(r, t) = -Mul(t, r) = -j
Mul(r, u) = -Mul(u, r) = -k
Mul(s, t) = -Mul(t, s) = +k
Mul(s, u) = -Mul(u, s) = -j
Mul(t, u) = -Mul(u, t) = +i

This binary operation is noncommutative and nonassociative.

func (*Zorn) Neg

func (z *Zorn) Neg(y *Zorn) *Zorn

Neg sets z equal to the negative of y, and returns z.

func (*Zorn) Quad

func (z *Zorn) Quad() *big.Rat

Quad returns the quadrance of z. If z = a+bi+cj+dk+er+fs+gt+hu, then the quadrance is

a² + b² + c² + d² - e² - f² - g² - h²

This can be positive, negative, or zero.

func (*Zorn) QuoL

func (z *Zorn) QuoL(x, y *Zorn) *Zorn

QuoL sets z equal to the left quotient of x and y:

Mul(Inv(y), x)

Then it returns z. If y is a zero divisor, then QuoL panics.

func (*Zorn) QuoR

func (z *Zorn) QuoR(x, y *Zorn) *Zorn

QuoR sets z equal to the right quotient of x and y:

Mul(x, Inv(y))

Then it returns z. If y is a zero divisor, then QuoR panics.

func (*Zorn) Rats

func (z *Zorn) Rats() (*big.Rat, *big.Rat, *big.Rat, *big.Rat,
	*big.Rat, *big.Rat, *big.Rat, *big.Rat)

Rats returns the eight rational components of z.

func (*Zorn) Real

func (z *Zorn) Real() *big.Rat

Real returns the (rational) real part of z.

func (*Zorn) Scal

func (z *Zorn) Scal(y *Zorn, a *big.Rat) *Zorn

Scal sets z equal to y scaled by a, and returns z.

func (*Zorn) Set

func (z *Zorn) Set(y *Zorn) *Zorn

Set sets z equal to y, and returns z.

func (*Zorn) String

func (z *Zorn) String() string

String returns the string representation of a Zorn value.

If z corresponds to a + bi + cj + dk + er + fs + gt + hu, then the string is"(a+bi+cj+dk+er+fs+gt+hu)", similar to complex128 values.

func (*Zorn) Sub

func (z *Zorn) Sub(x, y *Zorn) *Zorn

Sub sets z equal to x-y, and returns z.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL