SquareRoot
This object represents the square root factor.
Attributes
- Graph
-
- Supertypes
-
trait Singletontrait Producttrait Mirrortrait Serializabletrait Producttrait Equalsclass NthRoottrait InversePowertrait Factorclass Objecttrait Matchableclass AnyShow all
- Self type
-
SquareRoot.type
Members list
Type members
Classlikes
Provides an implicit conversion from an Int to an imaginary number representation.
Provides an implicit conversion from an Int to an imaginary number representation.
This class allows integers to be interpreted as imaginary numbers by appending .i to an integer. The imaginary number is constructed using the square of the integer negated, combined with the square root notation.
Value parameters
- x
-
the integer to be converted into an imaginary number
Attributes
- Supertypes
-
class Objecttrait Matchableclass Any
Inherited types
The names of the product elements.
The names of the product elements.
Attributes
- Inherited from:
- Singleton
Attributes
- Inherited from:
- Singleton
The mirrored *-type.
The mirrored *-type.
Attributes
- Inherited from:
- Singleton
Attributes
- Inherited from:
- Singleton
Inherited and Abstract types
The name of the type.
The name of the type.
Attributes
- Inherited from:
- Mirror
Value members
Concrete methods
Attempts to add two Value instances under the influence of a given Factor.
Attempts to add two Value instances under the influence of a given Factor.
The method verifies whether the operation can be applied with the given factor (e.g., a square root) and performs rational arithmetic to compute the result. The operation ensures that the values can be combined via integer arithmetic after factoring out common divisors and applies root simplifications where necessary.
Value parameters
- f
-
the factor defining the context for the addition (e.g., square root)
- negative
-
true if the
yvalue should be considered as being subtracted from the x value. NOTE this is not the same thing as theyvalue being negative, which would imply an imaginary number. - x
-
the first value to be added
- y
-
the second value to be added
Attributes
- Returns
-
an optional
ProtoNumberthat contains the resultantValue, its factor, and optional metadata;Noneif the operation cannot be performed - Definition Classes
Constructs an optional string representation of the current root object concatenated with the string representation of the specified value.
Constructs an optional string representation of the current root object concatenated with the string representation of the specified value.
Value parameters
- value
-
the value to be represented as part of the root string.
Attributes
- Returns
-
an Option containing the concatenated string representation of the root and the value, or None if the string construction is unsuccessful.
Raises the value x to the power of the value y.
Raises the value x to the power of the value y.
TODO move this up into NthRoot.
Value parameters
- x
-
the base value to be raised
- y
-
the exponent value (from a PureNumber)
Attributes
- Returns
-
an optional result of type
ProtoNumber, representing the computed value if the operation is valid, orNoneotherwise - Definition Classes
Renders the input string with a square root symbol.
Renders the input string with a square root symbol.
Value parameters
- x
-
the input string to be rendered
Attributes
- Returns
-
a string prefixed with the square root symbol
- Definition Classes
Converts the object into its string representation.
Converts the object into its string representation.
Attributes
- Returns
-
a string representation of the object
- Definition Classes
-
InversePower -> Any
Inherited methods
Converts a given Value into its imaginary representation, if applicable.
Converts a given Value into its imaginary representation, if applicable.
The method checks if the provided value can be represented as an imaginary number based on specific mathematical conditions, such as whether it is a negative integer and has a corresponding square root.
Value parameters
- value
-
the Value object to be evaluated and potentially converted into its imaginary representation.
Attributes
- Returns
-
an optional String representing the imaginary form of the value, or None if the value does not meet the conditions for conversion to an imaginary number.
- Inherited from:
- InversePower
Determines whether the current factor can be augmented by the given factor. CONSIDER do we need this method now that we have add(x, y, this)?
Determines whether the current factor can be augmented by the given factor. CONSIDER do we need this method now that we have add(x, y, this)?
Value parameters
- f
-
the factor to be checked for compatibility with addition.
Attributes
- Returns
-
true if the factors can be added; false otherwise.
- Inherited from:
- Factor
Determines whether the current factor can be multiplied by the given factor.
Determines whether the current factor can be multiplied by the given factor.
TODO check the logic here
Value parameters
- f
-
the factor to be checked for compatibility with multiplication.
Attributes
- Returns
-
true if the factors can be multiplied; false otherwise.
- Inherited from:
- NthRoot
Determines whether the current factor can be raised by the given factor.
Determines whether given value with this Factor can be rendered exactly.
Determines whether given value with this Factor can be rendered exactly.
Attributes
- Returns
-
true if this
Factorcan be rendered exactly; false otherwise. - Inherited from:
- InversePower
Cleans a given optional ProtoNumber by potentially simplifying its root quantities based on specific conditions and returning the modified result.
Cleans a given optional ProtoNumber by potentially simplifying its root quantities based on specific conditions and returning the modified result.
Value parameters
- po
-
an optional ProtoNumber that may be simplified
Attributes
- Returns
-
an optional ProtoNumber, simplified if applicable, or
Noneif input isNone - Inherited from:
- Factor
Converts a given Value v from one Factor this to another Factor f, if possible. Specifically handles cases where the target factor f is of type NthRoot.
Converts a given Value v from one Factor this to another Factor f, if possible. Specifically handles cases where the target factor f is of type NthRoot.
Value parameters
- f
-
the target factor for the conversion.
- v
-
the value to be converted.
Attributes
- Returns
-
an optional Value which represents the same quantity as
vunder the factorf, orNoneif the conversion is not possible. - Inherited from:
- NthRoot
Creates a new instance of type T with elements taken from product p.
Creates a new instance of type T with elements taken from product p.
Attributes
- Inherited from:
- Singleton
Retrieves the root degree represented by this factor in the form of a Rational.
Retrieves the root degree represented by this factor in the form of a Rational.
The root degree indicates the mathematical nth root applicable to this factor. For instance, a root degree of 2 represents a square root, a root degree of 3 represents a cube root, and so on.
Attributes
- Returns
-
the integer value of the root degree.
- Inherited from:
- NthRoot
Inverts the given value by raising it to the power of -1, using a pure number factor.
Inverts the given value by raising it to the power of -1, using a pure number factor.
Value parameters
- x
-
the value to be inverted
Attributes
- Returns
-
an optional result of type
ProtoNumber, representing the inverted value if the operation is valid, orNoneotherwise - Inherited from:
- InversePower
Determines if the current factor satisfies certain conditions within the given context.
Determines if the current factor satisfies certain conditions within the given context.
Value parameters
- context
-
the context in which the factor is evaluated.
Attributes
- Returns
-
a Boolean indicating whether the factor satisfies the specified conditions in the given context.
- Inherited from:
- InversePower
Determines if the current factor operates additively.
Determines if the current factor operates additively.
Attributes
- Returns
-
false.
- Inherited from:
- InversePower
Modulates the given value according to the context or rules defined by this factor.
Modulates the given value according to the context or rules defined by this factor.
Value parameters
- v
-
the value to be modulated
Attributes
- Returns
-
the modulated value
- Inherited from:
- InversePower
Multiplies two values together and computes an appropriate factor for the result.
Multiplies two values together and computes an appropriate factor for the result.
Value parameters
- f
-
the factor associated with y
- x
-
the first value
- y
-
the multiplicand
Attributes
- Returns
-
an optional tuple containing the resultant value and its factor
- Inherited from:
- InversePower
Multiplies the root values of two given Value objects based on their respective root degrees.
Multiplies the root values of two given Value objects based on their respective root degrees.
This method computes the product of the rational representations of x and y, each raised to their specified root degrees (r and s respectively). The result is wrapped with an associated factor and optional additional information if the operation is valid. The method ensures that the input values are positive and can be represented rationally.
Value parameters
- r
-
the root degree of the first value
- s
-
the root degree of the second value
- x
-
the first value to be multiplied
- y
-
the second value to be multiplied
Attributes
- Returns
-
an optional tuple containing the resultant value, its associated factor, and optional metadata;
Noneif the values are not positive or cannot be represented rationally - Inherited from:
- InversePower
Negates the given value and computes an appropriate output tuple. The computation may include a value, its associated factor, and an optional fuzziness.
Negates the given value and computes an appropriate output tuple. The computation may include a value, its associated factor, and an optional fuzziness.
Value parameters
- x
-
the value to be negated
Attributes
- Returns
-
an optional tuple containing the negated value, its factor, and an optional fuzziness;
Noneif the operation is not applicable - Inherited from:
- InversePower
An iterator over the names of all the elements of this product.
An iterator over the names of all the elements of this product.
Attributes
- Inherited from:
- Product
An iterator over all the elements of this product.
An iterator over all the elements of this product.
Attributes
- Returns
-
in the default implementation, an
Iterator[Any] - Inherited from:
- Product
Raises x to the power of y and compute an appropriate factor for the result. NOTE: for now, we only allow raising to a power of a PureNumber. TODO: enable powers of Radian factor.
Raises x to the power of y and compute an appropriate factor for the result. NOTE: for now, we only allow raising to a power of a PureNumber. TODO: enable powers of Radian factor.
Value parameters
- f
-
the factor associated with y
- x
-
the first value
- y
-
the power
Attributes
- Returns
-
an optional tuple containing the resultant value and its factor
- Inherited from:
- Factor
Method to render a Value in the context of this Factor.
Method to render a Value in the context of this Factor.
Value parameters
- x
-
the Value.
Attributes
- Returns
-
a String.
- Definition Classes
- Inherited from:
- InversePower
Simplifies a root representation of a number based on the given parameters. The method computes whether the provided value v can be converted into a simpler root form using the provided divisor (e.g., square root for divisor 2, cube root for divisor 3).
Simplifies a root representation of a number based on the given parameters. The method computes whether the provided value v can be converted into a simpler root form using the provided divisor (e.g., square root for divisor 2, cube root for divisor 3).
Value parameters
- divisor
-
the root degree (e.g., 2 for square root, 3 for cube root)
- p
-
the prototype number containing initial value and metadata
- r
-
the rational factor determining the type of root operation
- v
-
the value to be simplified
Attributes
- Returns
-
an optional ProtoNumber containing the simplified root representation, or the original input if simplification is not applicable
- Inherited from:
- InversePower
Inherited fields
Determines whether the current scalar can be exactly converted to a PureNumber.
Determines whether the current scalar can be exactly converted to a PureNumber.
Attributes
- Returns
-
true if the scalar represents an exact value; false otherwise.
- Inherited from:
- InversePower
A value which can be used to convert a value associated with this Factor to a different Factor.
A value which can be used to convert a value associated with this Factor to a different Factor.
Attributes
- Inherited from:
- InversePower
Implicits
Implicits
Provides an implicit conversion from an Int to an imaginary number representation.
Provides an implicit conversion from an Int to an imaginary number representation.
This class allows integers to be interpreted as imaginary numbers by appending .i to an integer. The imaginary number is constructed using the square of the integer negated, combined with the square root notation.
Value parameters
- x
-
the integer to be converted into an imaginary number