InversePower

com.phasmidsoftware.number.algebra.eager.InversePower
See theInversePower companion class
object InversePower

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 Object
trait Matchable
class Any
Self type

Members list

Value members

Concrete methods

def apply(n: Int, x: Number): InversePower

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.

def apply(n: Int, x: Int): InversePower

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 InversePower instance.

x

The numeric value to be wrapped within the WholeNumber type and used in the InversePower instance.

Attributes

Returns

A new instance of InversePower with the specified parameters.

def create(n: Int, s: Structure): InversePower

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 InversePower computed 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 InversePower representing the cube root of the input number.

def cubeRoot(x: Int): InversePower

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 InversePower representing the cube root of the input rational number.

def normalizeIntegralRoot(radicand: Int, rootDegree: Int): (Int, Int)

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 InversePower representing the square root of the input number.

def squareRoot(x: Int): InversePower

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 InversePower representing the square root of the input rational number.

Concrete fields

val logger: Logger

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 operation f to the operands x and y, 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 compare InversePower instances 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 FuzzyEq instance specific to the InversePower type.

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 Show instance for the InversePower type.

Implicits

Implicits

LatexRenderer for InversePower.

LatexRenderer for InversePower.

Renders as:

  • \sqrt{base} for power 2
  • \sqrt[n]{base} for other powers

Attributes

implicit val showInversePower: Show[InversePower]

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.

Attributes