Documentation ¶
Index ¶
- type BigComplex
- func Add(bcs ...*BigComplex) *BigComplex
- func Cube(a *BigComplex) *BigComplex
- func Div(bc1, bc2 *BigComplex) *BigComplex
- func FromInt(i int) *BigComplex
- func Mul(bcs ...*BigComplex) *BigComplex
- func Product(a, b *BigComplex) *BigComplex
- func Sq(a *BigComplex) *BigComplex
- func Sub(a, b *BigComplex) *BigComplex
- func Unique(in []*BigComplex) []*BigComplex
- func (bc *BigComplex) Cbrt() *BigComplex
- func (bc *BigComplex) Complex128() complex128
- func (bc *BigComplex) Equals(other *BigComplex) bool
- func (bc *BigComplex) IsZero() bool
- func (bc *BigComplex) Magnitude() *maybebig.Float
- func (bc *BigComplex) Pow(e *maybebig.Float) *BigComplex
- func (bc *BigComplex) Sqrt() *BigComplex
- func (bc *BigComplex) Theta() *maybebig.Float
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BigComplex ¶
func Add ¶
func Add(bcs ...*BigComplex) *BigComplex
func Cube ¶
func Cube(a *BigComplex) *BigComplex
func Div ¶
func Div(bc1, bc2 *BigComplex) *BigComplex
func FromInt ¶
func FromInt(i int) *BigComplex
func Mul ¶
func Mul(bcs ...*BigComplex) *BigComplex
func Product ¶
func Product(a, b *BigComplex) *BigComplex
func Sq ¶
func Sq(a *BigComplex) *BigComplex
func Sub ¶
func Sub(a, b *BigComplex) *BigComplex
func Unique ¶
func Unique(in []*BigComplex) []*BigComplex
func (*BigComplex) Cbrt ¶
func (bc *BigComplex) Cbrt() *BigComplex
func (*BigComplex) Complex128 ¶
func (bc *BigComplex) Complex128() complex128
func (*BigComplex) Equals ¶
func (bc *BigComplex) Equals(other *BigComplex) bool
func (*BigComplex) IsZero ¶
func (bc *BigComplex) IsZero() bool
func (*BigComplex) Magnitude ¶
func (bc *BigComplex) Magnitude() *maybebig.Float
func (*BigComplex) Pow ¶
func (bc *BigComplex) Pow(e *maybebig.Float) *BigComplex
func (*BigComplex) Sqrt ¶
func (bc *BigComplex) Sqrt() *BigComplex
On it's face this is likely wrong - it occasionally produces 4 roots!!!
// Uses a simplified version of this code // https://www.geeksforgeeks.org/square-root-of-two-complex-numbers/
func (bc *BigComplex) Sqrt() []*BigComplex { result := []*BigComplex{} a := bc.Real b := bc.Imag two := fromInt(2) negOne := fromInt(-1) magSq := add(sq(a), sq(b)) x1 := abs(sqrtSimple(div(add(a, sqrtSimple(magSq)), two))) if isZero(x1) { y1 := sqrtSimple(mul(fromInt(-1), a)) result = append(result, &BigComplex{Real: x1, Imag: y1}) } else { y1 := div(b, mul(two, x1)) result = append(result, &BigComplex{Real: x1, Imag: y1}) x2 := mul(negOne, x1) y2 := div(b, mul(two, x2)) result = append(result, &BigComplex{Real: x2, Imag: y2}) } x3 := div(sub(a, sqrtSimple(magSq)), two) if positive(x3) { x3 = abs(sqrtSimple(x3)) y3 := div(b, mul(two, x3)) result = append(result, &BigComplex{Real: x3, Imag: y3}) x4 := mul(negOne, x3) y4 := div(b, mul(two, x3)) result = append(result, &BigComplex{Real: x4, Imag: y4}) } return result }
func (*BigComplex) Theta ¶
func (bc *BigComplex) Theta() *maybebig.Float
Click to show internal directories.
Click to hide internal directories.