LinearEquation

com.phasmidsoftware.number.expression.algebraic.LinearEquation
case class LinearEquation(r: Rational) extends Equation

Represents a linear equation of the form x + r = 0 where r is a rational number. The slope of the line representing the equation is one, therefore the intercepts are: x = -r when y = 0 (the solution/root); and y = r when x = 0. This class provides various operations and transformations specific to linear equations.

Attributes

Graph
Supertypes
trait Serializable
trait Product
trait Equals
trait Equation
trait Renderable
class Object
trait Matchable
class Any
Show all

Members list

Value members

Concrete methods

infix def *(factor: Rational): Equation

Scales the current instance by the given factor.

Scales the current instance by the given factor.

This method applies a scaling operation on the instance using the provided rational factor and returns the resulting scaled instance.

Value parameters

factor

the rational number representing the scale factor

Attributes

Returns

the scaled instance of type T

def branched(index: Int): Expression

Retrieves the branch at the specified index.

Retrieves the branch at the specified index.

Value parameters

index

the index of the branch to retrieve, where the index starts from 0.

Attributes

Returns

the element of type T at the specified branch index. If the index is out of range, the behavior is implementation-specific.

def branches: Int

Method to compute the number of branches related to a specific computation or process. For example, a solution to a quadratic equation has two branches, one for the real part and one for the imaginary part.

Method to compute the number of branches related to a specific computation or process. For example, a solution to a quadratic equation has two branches, one for the real part and one for the imaginary part.

Attributes

Returns

the number of branches as an integer.

Evaluates the provided Solution within the context of this LinearEquation.

Evaluates the provided Solution within the context of this LinearEquation.

If the Solution is an instance of LinearSolution with a numerical value, the method evaluates it by adding a predefined offset r. If the Solution does not match the expected type or structure, an AlgebraException is thrown.

Value parameters

s

the Solution to be evaluated. It is expected to be an instance of LinearSolution containing a numerical value.

Attributes

Returns

the result of the evaluation as an instance of Eager. The exact nature of the result depends on the structure of the provided Solution.

Note

Throws AlgebraException if the Solution cannot be evaluated within the constraints of this LinearEquation.

Produces an inverted version of the current equation. The inversion process involves switching or rearranging key components of the equation, depending on its mathematical structure.

Produces an inverted version of the current equation. The inversion process involves switching or rearranging key components of the equation, depending on its mathematical structure.

Attributes

Returns

a new Equation instance representing the inverted form of the current equation.

Shifts the origin of the given equation by the specified rational value. This method adjusts the equation's reference point, effectively translating it to a new position in its domain.

Shifts the origin of the given equation by the specified rational value. This method adjusts the equation's reference point, effectively translating it to a new position in its domain.

Given this equation P(x) = 0, such that z is a solution, this method returns the equation P(y) = 0 such that z + c is a solution.

CONSIDER a better name for this.

Value parameters

c

the rational value by which to shift the origin of the equation.

Attributes

Returns

a new Equation instance with its origin shifted by the specified value.

def solve(branch: Int): Solution

Attempts to find a solution for a mathematical equation corresponding to the given branch. Solutions are represented as an instance of the Algebraic or of Complex class.

Attempts to find a solution for a mathematical equation corresponding to the given branch. Solutions are represented as an instance of the Algebraic or of Complex class.

Value parameters

branch

the branch index for which the solution is being sought. The branch index identifies specific solutions for equations that may have multiple solutions.

Attributes

Returns

a Field, which is either an Algebraic (real-valued) or a Complex.

Transforms the current equation by applying the provided functions to its components.

Transforms the current equation by applying the provided functions to its components.

Value parameters

fP

a function that takes two Rational parameters and produces a Rational result. It is applied to the first component of the equation.

fQ

a function that takes two Rational parameters and produces a Rational result. It is applied to the second component of the equation.

Attributes

Returns

a new Equation instance that is the result of applying the specified transformations to the components of the current equation.

Inherited methods

infix def *(factor: Int): Equation

Multiplies the current instance by the specified integer factor.

Multiplies the current instance by the specified integer factor.

Value parameters

factor

the integer value to multiply with the current instance

Attributes

Returns

a new instance of type T representing the result of the multiplication

Inherited from:
Scalable
def productElementNames: Iterator[String]

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
def productIterator: Iterator[Any]

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

Concrete fields

lazy val render: String

Method to render this Valuable for presentation to the user.

Method to render this Valuable for presentation to the user.

Attributes

Returns

a String