Provides the basic functionality to interact with the Collatz conjecture. The parameterisation uses the same (P,a,b) notation as Conway's generalisations. Besides the function and reverse function, there is also functionality to retrieve the hailstone sequence, the "stopping time"/"total stopping time", or tree-graph.
import collatz "github.com/Skenvy/Collatz/go"
This section is empty.
This section is empty.
func DEFAULT_A() (DEFAULT_A *big.Int)
Returns DEFAULT_A, the default value for a, the input's multiplicand.
func DEFAULT_B() (DEFAULT_B *big.Int)
Returns DEFAULT_B, the default value for b, the value added to the multiplied value.
func DEFAULT_P() (DEFAULT_P *big.Int)
Returns DEFAULT_P, the default value for P, the modulus condition.
Returns the result of a single application of the Collatz function.
func KNOWN_CYCLES() (KNOWN_CYCLES [4]*[]*big.Int)
The four KNOWN_CYCLES for the standard parameterisation.
Return a big.Int with a value of 1.
Returns the result of a single application of a Collatz-esque function.
Returns the output of a single application of a Collatz-esque reverse function. If there is no error in the parameters, then the value of preNDivP will always be an actual result, while preANplusB may either be a result, or nil.
Returns the stopping time, the amount of iterations required to reach a value less than the initial value, or -Inf if maxStoppingTime is exceeded. Alternatively, if totalStoppingTime is True, then it will instead count the amount of iterations to reach 1. If the sequence does not stop, but instead ends in a cycle, the result will be +Inf. If (P,a,b) are such that it is possible to get stuck on zero, the result will be the negative of what would otherwise be the "total stopping time" to reach 1, where 0 is considered a "total stop" that should not occur as it does form a cycle of length 1.
return (float64): The stopping time, or, in a special case, infinity, null or a negative.
Returns the output of a single application of the Collatz reverse function. The value of preNDivP will always be an actual result, while preANplusB may either be a result, or nil.
Returns the stopping time, the amount of iterations required to reach a value less than the initial value, or -Inf if maxStoppingTime is exceeded.
return float64: The stopping time, or, in a cycle case, infinity.
The equality between TreeGraphs is determined by the equality check on subtrees. A subtree check will be done on both TreeGraph's root nodes.
func VERIFIED_MAXIMUM() (VERIFIED_MAXIMUM *big.Int)
The current value up to which the standard parameterisation has been verified.
func VERIFIED_MINIMUM() (VERIFIED_MINIMUM *big.Int)
The current value down to which the standard parameterisation has been verified.
Return a big.Int with a value of 0.
Thrown when either P, the modulus, or a, the multiplicand, are zero. Create as either or;
FailedSaneParameterCheck(SANE_PARAMS_P) FailedSaneParameterCheck(SANE_PARAMS_A)
Construct a FailedSaneParameterCheck with a message associated with the provided enum.
type HailstoneSequence struct { }
Contains the results of computing a hailstone sequence. Can be created via;
ParameterisedHailstoneSequence(~) NewHailstoneSequence(~)
Initialise and compute a new Hailstone Sequence.
Initialise and compute a new Hailstone Sequence.
type SaneParameterErrMsg int64
Error message constants, to be used as input to the FailedSaneParameterCheck
Get the string associated with the SaneParameterErrMsg
SequenceState for Cycle Control: Descriptive flags to indicate when some event occurs in the hailstone sequences or tree graph reversal, when set to verbose, or stopping time check.
const ( NO_STATE SequenceState = iota STOPPING_TIME TOTAL_STOPPING_TIME CYCLE_INIT CYCLE_LENGTH MAX_STOP_OUT_OF_BOUNDS ZERO_STOP )
Get the string associated with the SequenceState
type TreeGraph struct { }
Contains the results, in a "root node" of computing the Tree Graph via;
ParameterisedTreeGraph(~) NewTreeGraph(~)
Create a new TreeGraph with the root node defined by the inputs. Returns a directed tree graph of the reverse function values up to a maximum nesting of maxOrbitDistance, with the initialValue as the root.
Create a new TreeGraph with the root node defined by the inputs. Returns a directed tree graph of the reverse function values up to a maximum nesting of maxOrbitDistance, with the initialValue as the root.
type TreeGraphNode struct { }
Nodes that form a "tree graph", structured as a tree, with their own node's value, as well as references to either possible child node, where a node can only ever have two children, as there are only ever two reverse values. Also records any possible "terminal sequence state", whether that be that the "orbit distance" has been reached, as an "out of bounds" stop, which is the regularly expected terminal state. Other terminal states possible however include the cycle state and cycle length (end) states.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4