The Root companion object contains utility methods, predefined constants, and typeclass instances for working with roots. Angles are represented using rational numbers and comply with the algebraic structure of a commutative group.
Attributes
- Companion
- class
- Graph
-
- Supertypes
-
class Objecttrait Matchableclass Any
- Self type
-
InversePower.type
Members list
Value members
Concrete methods
Creates a new instance of InversePower using the provided parameters.
Creates a new instance of InversePower using the provided parameters.
Value parameters
- n
-
The integer exponent to be used in the computation.
- x
-
The base number for the inverse power calculation.
Attributes
- Returns
-
An instance of InversePower computed with the specified parameters.
Creates an instance of InversePower using the given parameters. TODO why is this showing it's recursive?
Creates an instance of InversePower using the given parameters. TODO why is this showing it's recursive?
Value parameters
- n
-
The exponent value to be used in the
InversePowerinstance. - x
-
The numeric value to be wrapped within the
WholeNumbertype and used in theInversePowerinstance.
Attributes
- Returns
-
A new instance of
InversePowerwith the specified parameters.
Creates a new instance of InversePower using the provided parameters.
Creates a new instance of InversePower using the provided parameters.
Value parameters
- n
-
The integer exponent to be used in the computation.
- s
-
The input structure to be converted or processed for the inverse power calculation.
Attributes
- Returns
-
An instance of
InversePowercomputed with the specified parameters. - Throws
-
AlgebraException
If the input structure cannot be converted to a
Real.
Computes the cube root of a given number by creating an InversePower instance where the exponent is set to 3.
Computes the cube root of a given number by creating an InversePower instance where the exponent is set to 3.
TODO move this to Eager.
Value parameters
- x
-
The number for which the cube root is to be computed.
Attributes
- Returns
-
An instance of
InversePowerrepresenting the cube root of the input number.
Computes the cube root of a given rational number by creating an instance of InversePower where the exponent is set to 3.
Computes the cube root of a given rational number by creating an instance of InversePower where the exponent is set to 3.
Value parameters
- x
-
The rational number for which the cube root is to be computed.
Attributes
- Returns
-
An instance of
InversePowerrepresenting the cube root of the input rational number.
Normalizes a given radicand with respect to a specified root degree. The method calculates the product of factors that can be extracted outside of the root and the product of factors that remain inside the root.
Normalizes a given radicand with respect to a specified root degree. The method calculates the product of factors that can be extracted outside of the root and the product of factors that remain inside the root.
Value parameters
- radicand
-
The radicand value to normalize. It must be a positive integer.
- rootDegree
-
The root degree (e.g., square root, cube root) to consider. It must be a positive integer greater than zero.
Attributes
- Returns
-
A tuple where the first element represents the extracted product (outside the root) and the second element represents the remaining product (inside the root).
- Throws
-
AlgebraException
If any prime factor of the radicand is out of range for an Int.
Computes the square root of a given number by creating an InversePower instance where the exponent is set to 2.
Computes the square root of a given number by creating an InversePower instance where the exponent is set to 2.
TODO move this to Eager.
Value parameters
- x
-
The number for which the square root is to be computed.
Attributes
- Returns
-
An instance of
InversePowerrepresenting the square root of the input number.
Computes the square root of a given rational number by creating an instance of InversePower.
Computes the square root of a given rational number by creating an instance of InversePower.
Value parameters
- x
-
The rational number for which the square root is to be computed.
Attributes
- Returns
-
An instance of
InversePowerrepresenting the square root of the input rational number.
Concrete fields
Represents the multiplicative identity for roots.
Represents the multiplicative identity for roots.
This value denotes a root of zero base, serving as the identity element in the group structure of roots. It is constructed using the Root companion object initialized with the additive identity of RationalNumber.
Attributes
Givens
Givens
A given instance of DyadicOperator for the InversePower type. This instance allows the application of a binary operation on two operands of types InversePower and a subtype of InversePower (B <: InversePower), producing a result wrapped in a Try.
A given instance of DyadicOperator for the InversePower type. This instance allows the application of a binary operation on two operands of types InversePower and a subtype of InversePower (B <: InversePower), producing a result wrapped in a Try.
Attributes
- Returns
-
A
Try[Z]containing the result of applying the provided operationfto the operandsxandy, or an exception if the operation fails.
Defines an equality Eq instance for the InversePower type, utilizing a dyadic operator to determine equivalence between two InversePower instances. The equality comparison is performed by delegating to an eagerly evaluated function x.eqv(y), where x and y are Eager instances, and the result is optionally returned.
Defines an equality Eq instance for the InversePower type, utilizing a dyadic operator to determine equivalence between two InversePower instances. The equality comparison is performed by delegating to an eagerly evaluated function x.eqv(y), where x and y are Eager instances, and the result is optionally returned.
Attributes
- Returns
-
An instance of
Eq[InversePower]that provides a mechanism to compareInversePowerinstances for equality by applying the dyadic operator and resolving the result.
Provides a fuzzy equality instance for the InversePower type.
Provides a fuzzy equality instance for the InversePower type.
This implementation allows comparing two InversePower instances, x and y, based on a given probability p. Two instances are considered approximately equal if they are either strictly equal (x === y) or satisfy the fuzzy equality predicate when evaluated against p.
Attributes
- Returns
-
A
FuzzyEqinstance specific to theInversePowertype.
Provides a Show instance for the InversePower type, enabling the conversion of an InversePower instance into a human-readable String representation.
Provides a Show instance for the InversePower type, enabling the conversion of an InversePower instance into a human-readable String representation.
Attributes
- Returns
-
A
Showinstance for theInversePowertype.
Implicits
Implicits
LatexRenderer for InversePower.
LatexRenderer for InversePower.
Renders as:
- \sqrt{base} for power 2
- \sqrt[n]{base} for other powers
Attributes
Provides an implicit Show instance for the Root class, enabling conversion of a Root instance to a string representation using its render method.
Provides an implicit Show instance for the Root class, enabling conversion of a Root instance to a string representation using its render method.
This allows the Root class to integrate seamlessly with libraries or frameworks requiring a Show typeclass instance for displaying or logging purposes.