Root

com.phasmidsoftware.number.expression.expr.Root
See theRoot companion trait
object Root

The Root object provides predefined mathematical constants or solutions to well-known equations modeled as roots. These constants are instances of QuadraticRoot or LinearRoot corresponding to specific root solutions of their respective equations.

Attributes

Companion
trait
Graph
Supertypes
trait Sum
trait Mirror
class Object
trait Matchable
class Any
Self type
Root.type

Members list

Type members

Inherited and Abstract types

type MirroredElemLabels <: Tuple

The names of the product elements.

The names of the product elements.

Attributes

Inherited from:
Mirror
type MirroredLabel <: String

The name of the type.

The name of the type.

Attributes

Inherited from:
Mirror

Value members

Concrete methods

def apply(equation: Equation, branch: Int): Root

Applies the given Equation instance and a branch index to determine the corresponding Root. Depending on the type of the equation, the method computes and returns an appropriate Root representation.

Applies the given Equation instance and a branch index to determine the corresponding Root. Depending on the type of the equation, the method computes and returns an appropriate Root representation.

Value parameters

branch

an integer representing the branch index to compute. The branch identifies a specific solution for equations with multiple branches.

equation

the Equation instance to process, which represents a mathematical relationship. It may include multiple solutions or branches (e.g., quadratic or linear equations).

Attributes

Returns

a Root instance that corresponds to the given Equation and branch index. The returned Root is specialized for Quadratic or LinearEquation types.

def squareRoot(r: Rational, branch: Int = ...): Root

Computes the square root of a given rational number and selects a specific branch of the solution.

Computes the square root of a given rational number and selects a specific branch of the solution.

Value parameters

branch

an integer representing the branch index to compute. The branch identifies a specific solution when there are multiple possible square root results. 0 gives the positive root, 1 gives the negative root.

r

the Rational number for which the square root is to be calculated. The input represents a rational value that serves as the operand.

Attributes

Returns

a QuadraticRoot instance representing the square root computation and branch selection.

def unapply(expr: Expression): Option[(Equation, Int)]

Extractor for Root expressions. Matches Root(n, x) where n is the root degree and x is the radicand.

Extractor for Root expressions. Matches Root(n, x) where n is the root degree and x is the radicand.

Attributes

def √(r: Int): Root

Computes the square root of a given integer and returns the corresponding Root.

Computes the square root of a given integer and returns the corresponding Root.

Value parameters

r

the integer value for which the square root is to be calculated. This value is converted to a Rational before computing the square root.

Attributes

Returns

a Root instance representing the square root of the given integer.

Concrete fields

Represents the value one-half as a linear root, constructed from a linear equation with a negated half-rational coefficient.

Represents the value one-half as a linear root, constructed from a linear equation with a negated half-rational coefficient.

Attributes

Represents the negative root of the quadratic equation x² - 2 = 0. This equation defines the square root of 2, with the two roots being ±√2. The branch parameter set to 1 in this instance corresponds to the negative root (i.e., -√2).

Represents the negative root of the quadratic equation x² - 2 = 0. This equation defines the square root of 2, with the two roots being ±√2. The branch parameter set to 1 in this instance corresponds to the negative root (i.e., -√2).

Attributes

Represents the constant root 1 of a quadratic equation. This value is a particular solution of the quadratic equation -2x + 1 = 0 on branch 0.

Represents the constant root 1 of a quadratic equation. This value is a particular solution of the quadratic equation -2x + 1 = 0 on branch 0.

Attributes

Represents the mathematical constant φ (phi), also known as the golden ratio. The golden ratio is defined as the positive root of the quadratic equation x² + x - 1 = 0. It is an irrational number approximately equal to 1.6180339887498948.

Represents the mathematical constant φ (phi), also known as the golden ratio. The golden ratio is defined as the positive root of the quadratic equation x² + x - 1 = 0. It is an irrational number approximately equal to 1.6180339887498948.

This value is modeled using a QuadraticRoot instance, which takes the predefined golden ratio quadratic equation (Quadratic.goldenRatioEquation) and specifies the branch 0, representing the positive root.

Attributes

Represents the conjugate root of the golden ratio equation (x² + x - 1 = 0), commonly referred to as ψ (psi). This value is the second root of the quadratic equation, distinct from the golden ratio (φ, phi). It is calculated using the QuadraticRoot constructor, with the golden ratio equation as its basis and branch index set to 1.

Represents the conjugate root of the golden ratio equation (x² + x - 1 = 0), commonly referred to as ψ (psi). This value is the second root of the quadratic equation, distinct from the golden ratio (φ, phi). It is calculated using the QuadraticRoot constructor, with the golden ratio equation as its basis and branch index set to 1.

Attributes

Represents the root solution corresponding to the quadratic equation for ±√2.

Represents the root solution corresponding to the quadratic equation for ±√2.

The rootTwo value is an instance of QuadraticRoot that is initialized with the predefined quadratic equation x² - 2 = 0 (Quadratic.rootTwoEquation) and specifies the primary root (branch 0).

This root is a well-known mathematical constant (the square root of 2), widely used in geometry, algebra, and various other mathematical applications.

Attributes

Represents the quadratic root when both the quadratic coefficients and the branch index are zero. This constant corresponds to the simplest quadratic equation with all coefficients as zero and the solution at branch zero.

Represents the quadratic root when both the quadratic coefficients and the branch index are zero. This constant corresponds to the simplest quadratic equation with all coefficients as zero and the solution at branch zero.

Attributes