com.phasmidsoftware.number.expression.expr

Members list

Type members

Classlikes

sealed abstract class AbstractRoot(equ: Equation, branch: Int, maybeName: Option[String]) extends Root

Represents the root of an equation, associated with a specific branch.

Represents the root of an equation, associated with a specific branch.

This class models the concept of a mathematical root, where an equation is solved for a specific branch index, yielding a solution that adheres to the constraints defined in the Algebraic trait. It extends AtomicExpression to integrate with the broader mathematical expression framework.

Value parameters

branch

the branch index used to solve the equation

equ

the mathematical equation whose solution is represented by this root

Attributes

Supertypes
trait Root
trait Branched[Root]
trait Nameable
trait Expression
trait Approximate
trait Lazy
trait Valuable
trait TypeSafe
trait Exactitude
trait Unitary
trait Zeroable
trait Numeric
trait Renderable
class Object
trait Matchable
class Any
Show all
Known subtypes
sealed abstract class AbstractTranscendental(val name: String, val expression: Expression) extends Transcendental

An abstract class representing a transcendental mathematical entity, extending the Transcendental trait. This class encapsulates a human-readable name and an Expression representing its value.

An abstract class representing a transcendental mathematical entity, extending the Transcendental trait. This class encapsulates a human-readable name and an Expression representing its value.

Value parameters

expression

An Expression representing the mathematical definition or value of the transcendental entity.

name

A String representing the name of the transcendental entity.

Attributes

Constructor

Creates a new instance of AbstractTranscendental.

Supertypes
trait Nameable
trait Expression
trait Approximate
trait Lazy
trait Valuable
trait TypeSafe
trait Exactitude
trait Unitary
trait Zeroable
trait Numeric
trait Renderable
class Object
trait Matchable
class Any
Show all
Known subtypes
object L2
object LgE

Extractor for commutative additive operations with an identity element (zero).

Extractor for commutative additive operations with an identity element (zero).

This object is a specialized implementation of the CommutativeExtractor trait, specifically designed to handle expressions where one side of a commutative addition operation is an additive identity (e.g., zero).

It operates under the assumption that addition is commutative and attempts to extract sub-expressions from either side of a binary expression in a manner that accounts for the commutativity of the operation.

The left-hand side of the expression is simply returned as-is, while the right-hand side is inspected to check if it represents the additive identity (zero). If the right-hand side is zero, its associated sub-expression is extracted.

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
case class Aggregate(function: ExpressionBiFunction, xs: Seq[Expression]) extends Multiple

Represents a composite expression that computes the total of a sequence of expressions. The sequence must be non-empty.

Represents a composite expression that computes the total of a sequence of expressions. The sequence must be non-empty.

Value parameters

xs

A non-empty sequence of expressions to be totaled.

Attributes

Constructor

Constructs an Aggregate instance with a sequence of expressions.

Companion
object
Supertypes
trait Serializable
trait Product
trait Equals
trait Multiple
trait Expression
trait Approximate
trait Lazy
trait Valuable
trait TypeSafe
trait Exactitude
trait Unitary
trait Zeroable
trait Numeric
trait Renderable
class Object
trait Matchable
class Any
Show all
object Aggregate

Companion object for the Aggregate class.

Companion object for the Aggregate class.

Attributes

Companion
class
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
Aggregate.type
case object Atan extends ExpressionBiFunction

Represents an arctangent operation as a binary function. Calculates the angle (in radians) whose tangent is the quotient of the two provided Valuables. If either input is not a real number, the result will be NaN encapsulated in a Real.

Represents an arctangent operation as a binary function. Calculates the angle (in radians) whose tangent is the quotient of the two provided Valuables. If either input is not a real number, the result will be NaN encapsulated in a Real.

  • Operates on two Valuable values as the input.
  • Uses the atan function to compute the angle between the two numbers.
  • Returns a Real result if both inputs can be interpreted as numbers; otherwise, returns Real(Number.NaN).

Constraints:

  • This operation is not commutative.
  • May yield inexact results if the inputs are not exact.

Attributes

Supertypes
trait Singleton
trait Product
trait Mirror
trait Serializable
trait Product
trait Equals
trait ((Eager, Eager)) => Valuable
class Object
trait Matchable
class Any
Show all
Self type
Atan.type

Companion object for the AtomicExpression trait. Provides utility methods for working with instances of AtomicExpression.

Companion object for the AtomicExpression trait. Provides utility methods for working with instances of AtomicExpression.

The unapply method enables pattern matching on AtomicExpression instances, providing an optional Valuable as a result based on the type of the expression. The behavior of this method varies for different subtypes of AtomicExpression, such as Complex, ValueExpression, Literal, Valuable, Noop, and ReducedQuadraticRoot.

Notes:

  • For Complex, the method directly returns the Complex instance as a Valuable.
  • For ValueExpression and Literal, the value of the Valuable is returned, but the name might be discarded during extraction.
  • For Valuable, the method directly returns the Valuable.
  • For ReducedQuadraticRoot, the method attempts to evaluate it "as-is."
  • For Noop, the method returns None.

Considerations:

  • The use of Complex and Valuable directly in the extraction may warrant re-evaluation.
  • The potential loss of the name in ValueExpression and Literal is noted as a trade-off.

Attributes

Companion
trait
Supertypes
class Object
trait Matchable
class Any
Self type

An Expression that is based on one simple constant value. The four subtypes of AtomicExpression are:

An Expression that is based on one simple constant value. The four subtypes of AtomicExpression are:

  • ValueExpression
  • Root
  • Transcendental
  • Noop

Attributes

Companion
object
Supertypes
trait Nameable
trait Expression
trait Approximate
trait Lazy
trait Valuable
trait TypeSafe
trait Exactitude
trait Unitary
trait Zeroable
trait Numeric
trait Renderable
class Object
trait Matchable
class Any
Show all
Known subtypes
class Noop
trait Root
class AbstractRoot
class LinearRoot
object L2
object LgE
class Literal
object E
object I
object Infinity
object Half
object MinusOne
object One
object Pi
object Two
object Zero
Show all

This class represents a dyadic function of the two given expressions.

This class represents a dyadic function of the two given expressions.

Value parameters

a

the first expression being operated on.

b

the second expression being operated on.

f

the function to be applied to a and b.

Attributes

Companion
object
Supertypes
trait Serializable
trait Product
trait Equals
trait Multiple
trait Expression
trait Approximate
trait Lazy
trait Valuable
trait TypeSafe
trait Exactitude
trait Unitary
trait Zeroable
trait Numeric
trait Renderable
class Object
trait Matchable
class Any
Show all
object BiFunction

Attributes

Companion
class
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
BiFunction.type

This class represents a dyadic function of the two given expressions.

This class represents a dyadic function of the two given expressions.

Value parameters

a

the first expression being operated on.

b

the second expression being operated on.

f

the function to be applied to a and b.

Attributes

Supertypes
trait Multiple
trait Expression
trait Approximate
trait Lazy
trait Valuable
trait TypeSafe
trait Exactitude
trait Unitary
trait Zeroable
trait Numeric
trait Renderable
class Object
trait Matchable
class Any
Show all
Known subtypes
class BiFunction
abstract class CommutativeExtractor[A, B]

Abstract extractor for commutative binary operations. Handles trying both (left, right) and (right, left) orderings automatically.

Abstract extractor for commutative binary operations. Handles trying both (left, right) and (right, left) orderings automatically.

Type parameters

A

the type extracted from the "left" position

B

the type extracted from the "right" position

Attributes

Supertypes
class Object
trait Matchable
class Any
Known subtypes
object Commutes

The Commutes object provides a mechanism to extract instances of ExpressionBiFunction that exhibit the property of commutativity. A binary function is considered commutative if the order of operands does not affect the result of the operation.

The Commutes object provides a mechanism to extract instances of ExpressionBiFunction that exhibit the property of commutativity. A binary function is considered commutative if the order of operands does not affect the result of the operation.

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
Commutes.type

A trait representing a composite mathematical or logical expression. It is a higher-order expression that combines multiple sub-expressions into a structured form. This trait provides methods and utilities for simplifying, rendering, and interpreting such expressions.

A trait representing a composite mathematical or logical expression. It is a higher-order expression that combines multiple sub-expressions into a structured form. This trait provides methods and utilities for simplifying, rendering, and interpreting such expressions.

CompositeExpression inherits from the Expression trait and serves as a foundation for more specific composite structures, such as aggregates or compound expressions.

NOTE: this trait was formerly sealed. It has been unsealed to allow splitting across multiple files.

Attributes

Companion
object
Supertypes
trait Expression
trait Approximate
trait Lazy
trait Valuable
trait TypeSafe
trait Exactitude
trait Unitary
trait Zeroable
trait Numeric
trait Renderable
class Object
trait Matchable
class Any
Show all
Known subtypes
class Euler
trait Multiple
class Aggregate
class BiFunction
class UniFunction
Show all

Companion object for the CompositeExpression case class.

Companion object for the CompositeExpression case class.

Provides a utility method to create an Expression from a function and a sequence of Expressions.

Attributes

Companion
trait
Supertypes
class Object
trait Matchable
class Any
Self type
object Cos

Matches cos(θ) → UniFunction(θ, Cosine), returns θ.

Matches cos(θ) → UniFunction(θ, Cosine), returns θ.

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
Cos.type
case object Cosh extends Hyperbolic

Represents the cosine trigonometric function.

Represents the cosine trigonometric function.

Cosine is a specific instance of the SineCos class with sine set to false, meaning it applies the cosine (cos) function to an Expression.

Attributes

Supertypes
trait Singleton
trait Product
trait Mirror
trait Serializable
trait Product
trait Equals
class Hyperbolic
trait Eager => Valuable
class Object
trait Matchable
class Any
Show all
Self type
Cosh.type
object CoshX

Matches cosh(x) → UniFunction(x, Cosh), returns x.

Matches cosh(x) → UniFunction(x, Cosh), returns x.

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
CoshX.type
case object Cosine extends SineCos

Represents the cosine trigonometric function.

Represents the cosine trigonometric function.

Cosine is a specific instance of the SineCos class with sine set to false, meaning it applies the cosine (cos) function to an Expression.

Attributes

Supertypes
trait Singleton
trait Product
trait Mirror
trait Serializable
trait Product
trait Equals
class SineCos
trait Eager => Valuable
class Object
trait Matchable
class Any
Show all
Self type
Cosine.type
object CubeRoot

Object CubeRoot provides an extractor method for matching and decomposing expressions that represent cube root operations. This is specifically aimed at identifying instances of NthRoot where the root value is 3.

Object CubeRoot provides an extractor method for matching and decomposing expressions that represent cube root operations. This is specifically aimed at identifying instances of NthRoot where the root value is 3.

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
CubeRoot.type
case object E extends NamedConstant

The constant e. Yes, this is an exact number.

The constant e. Yes, this is an exact number.

Attributes

Supertypes
trait Singleton
trait Product
trait Mirror
trait Serializable
trait Product
trait Equals
trait Nameable
trait Expression
trait Approximate
trait Lazy
trait Valuable
trait TypeSafe
trait Exactitude
trait Unitary
trait Zeroable
trait Numeric
trait Renderable
class Object
trait Matchable
class Any
Show all
Self type
E.type
object EagerOps

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
EagerOps.type
object Empty

Represents an object with no functionality or state.

Represents an object with no functionality or state.

This is only defined here so that we no longer have a file without a corresponding class or object.

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
Empty.type
object Euler

Companion object for Euler.

Companion object for Euler.

Attributes

Companion
class
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
Euler.type
case class Euler(r: Expression, θ: Expression) extends CompositeExpression

Represents the canonical lazy complex form re^(itheta), per Euler's formula.

Represents the canonical lazy complex form re^(itheta), per Euler's formula.

This is the canonical lazy representation for complex exponential and trigonometric expressions in the Number library. It materialises to ComplexPolar on evaluation.

Conversion rules (applied by the simplification pipeline, not at construction):

  • cos(theta) + i*sin(theta) => Euler(one, theta) (Euler recognition)
  • exp(i*theta) => Euler(one, theta) (Euler recognition)
  • exp(a + i*b) => Euler(exp(a), b) (Euler recognition)

Special materialisation cases:

  • Euler(r, 0) => r (real result)
  • Euler(r, Pi) => Negate(r) (negative real)
  • Euler(1, 0) => 1
  • Euler(1, Pi) => -1 (Euler's identity)
  • Euler(1, Pi/2) => i
  • Euler(0, theta) => 0 (zero modulus)

Arithmetic rules (applied by the simplification pipeline):

  • Euler(r1,t1) * Euler(r2,t2) => Euler(r1*r2, t1+t2) (de Moivre multiplication)
  • Euler(r1,t1) / Euler(r2,t2) => Euler(r1/r2, t1-t2) (de Moivre division)
  • Euler(r,t) ^ n => Euler(r^n, n*t) (de Moivre's theorem)
  • Euler(r,t) + Euler(r,-t) => 2*r*cos(t) (conjugate sum => real)
  • Euler(r,t) - Euler(r,-t) => 2*i*r*sin(t) (conjugate diff => imaginary)

Value parameters

r

the modulus expression (non-negative real)

θ

the argument (angle) expression, in radians

Attributes

Companion
object
Supertypes
trait Serializable
trait Product
trait Equals
trait Expression
trait Approximate
trait Lazy
trait Valuable
trait TypeSafe
trait Exactitude
trait Unitary
trait Zeroable
trait Numeric
trait Renderable
class Object
trait Matchable
class Any
Show all

Singleton object representing the Euler-Mascheroni constant (𝛾), a fundamental mathematical constant. It extends AbstractTranscendental to encapsulate its symbolic representation and mathematical definition.

Singleton object representing the Euler-Mascheroni constant (𝛾), a fundamental mathematical constant. It extends AbstractTranscendental to encapsulate its symbolic representation and mathematical definition.

The Euler-Mascheroni constant is a transcendental entity commonly used in number theory and analysis.

Attributes

Supertypes
trait Singleton
trait Product
trait Mirror
trait Serializable
trait Product
trait Equals
trait Nameable
trait Expression
trait Approximate
trait Lazy
trait Valuable
trait TypeSafe
trait Exactitude
trait Unitary
trait Zeroable
trait Numeric
trait Renderable
class Object
trait Matchable
class Any
Show all
Self type

Commutative extractor for the Euler recognition pattern cos(θ) + i·sin(θ).

Commutative extractor for the Euler recognition pattern cos(θ) + i·sin(θ).

Matches a pair (left, right) where one side is cos(θ) and the other is i·sin(θ) (in either multiplication order), returning (θ_from_cos, θ_from_sin). The caller guards with θ1 == θ2.

extractLeft excludes the i·sin shape so the two roles are mutually exclusive, preventing the swap path from producing spurious matches.

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
object Even

An extractor object used to identify whether a given ExpressionMonoFunction has a parity of Parity.Even.

An extractor object used to identify whether a given ExpressionMonoFunction has a parity of Parity.Even.

This is useful in scenarios where the specific parity attribute of an ExpressionMonoFunction needs to be matched or validated.

The unapply method returns true if the parity field of the provided ExpressionMonoFunction is equal to Parity.Even; otherwise, it returns false.

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
Even.type
case object Exp extends ExpressionMonoFunction

Represents a mathematical exponential function, exp(x), where e is the base of natural logarithms. This case object extends ExpressionMonoFunction and applies the exp operation on a given number. It defines the exponential operation for transformation or evaluation within expressions.

Represents a mathematical exponential function, exp(x), where e is the base of natural logarithms. This case object extends ExpressionMonoFunction and applies the exp operation on a given number. It defines the exponential operation for transformation or evaluation within expressions.

Attributes

Supertypes
trait Singleton
trait Product
trait Mirror
trait Serializable
trait Product
trait Equals
trait Eager => Valuable
class Object
trait Matchable
class Any
Show all
Self type
Exp.type
object ExpX

Matches exp(x) → UniFunction(x, Exp), returns x.

Matches exp(x) → UniFunction(x, Exp), returns x.

NOTE: if the name Exp clashes with the ExpressionFunction case object of the same name inside the match body, rename this extractor to ExpX.

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
ExpX.type
object Expression

The Expression companion object provides utilities for creating, manipulating, and parsing expressions.

The Expression companion object provides utilities for creating, manipulating, and parsing expressions.

Methods and values within this object help in constructing expressions from various types like Field or Int, perform conversions, parse string representations of expressions, define constants, and offer implicit operators for working with expressions.

It offers functionalities for mathematical operations, common constants, and extensions to manipulate operations in a lazy manner.

Attributes

Companion
trait
Supertypes
class Object
trait Matchable
class Any
Self type
Expression.type
trait Expression extends Lazy, Approximate

Trait Expression which defines the behavior of a lazily evaluated tree of mathematical operations and operands.

Trait Expression which defines the behavior of a lazily evaluated tree of mathematical operations and operands.

NOTE there are only two subtypes of Expression: AtomicExpression and CompositeExpression We do not use "sealed" because this module would grow much too large.

Attributes

Companion
object
Supertypes
trait Approximate
trait Lazy
trait Valuable
trait TypeSafe
trait Exactitude
trait Unitary
trait Zeroable
trait Numeric
trait Renderable
class Object
trait Matchable
class Any
Show all
Known subtypes
class Noop
trait Root
class AbstractRoot
class LinearRoot
object L2
object LgE
class Literal
object E
object I
object Infinity
object Half
object MinusOne
object One
object Pi
object Two
object Zero
class Euler
trait Multiple
class Aggregate
class BiFunction
class UniFunction
Show all
sealed abstract class ExpressionBiFunction(val name: String, val f: (Eager, Eager) => Eager, val isExact: Boolean, val maybeIdentityL: Option[Eager], val maybeIdentityR: Option[Eager]) extends ExpressionFunction[(Eager, Eager)]

Represents a binary function used in expression evaluation. This abstraction encapsulates the logic for applying a binary operation to two Eager objects while supporting features such as exactness, commutativity, and optional identity elements.

Represents a binary function used in expression evaluation. This abstraction encapsulates the logic for applying a binary operation to two Eager objects while supporting features such as exactness, commutativity, and optional identity elements.

Value parameters

f

the underlying binary function to be applied to the Eager inputs.

isExact

a flag indicating whether the function is strictly exact (producing precise results).

maybeIdentityL

an optional identity element for the left-hand operand; if defined, evaluation recognizes and simplifies the operation when this value is encountered.

maybeIdentityR

an optional identity element for the right-hand operand; if defined, evaluation recognizes and simplifies the operation when this value is encountered.

name

the unique name identifying the binary function.

Attributes

Companion
object
Supertypes
trait ((Eager, Eager)) => Valuable
class Object
trait Matchable
class Any
Known subtypes
object Atan
object Log
object Power
object Product
object Sum

Companion object for the ExpressionBiFunction class.

Companion object for the ExpressionBiFunction class.

Provides an extractor method to deconstruct ExpressionBiFunction instances into their associated function and name.

Attributes

Companion
class
Supertypes
trait Sum
trait Mirror
class Object
trait Matchable
class Any
Self type

Extractor object for handling negation expressions in a commutative manner. Matches pairs of expressions where one is a plain Expression and the other is its negation UniFunction(x, Negate).

Extractor object for handling negation expressions in a commutative manner. Matches pairs of expressions where one is a plain Expression and the other is its negation UniFunction(x, Negate).

extractLeft excludes negated expressions so that the two roles are mutually exclusive. This prevents the swap path in CommutativeExtractor from binding a to a negated expression and producing a spurious a == b match.

With this fix the commented-out shorthand in structuralMatcher works correctly:

 case ProductExpression(ExpressionComplementaryCommutative(a, b)) if a == b =>
   minusXSquared(a)

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type

A configuration object for expression-related settings. This object is responsible for loading and providing specific configurations used to control behavior such as log levels during expression matching.

A configuration object for expression-related settings. This object is responsible for loading and providing specific configurations used to control behavior such as log levels during expression matching.

It uses the ConfigFactory to load configuration settings and determines the appropriate log level for expression matching based on the number.expression.match-log-level property from the configuration.

The supported log levels are:

  • "off": Corresponds to LogOff.
  • "info": Corresponds to LogInfo.
  • "debug": Corresponds to LogDebug.

If the property is not specified or does not match any of the expected values, the log level defaults to LogOff.

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
object ExpressionEq

Cats Eq instance for Expression providing structural equality. Two expressions are equal if they are structurally identical.

Cats Eq instance for Expression providing structural equality. Two expressions are equal if they are structurally identical.

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
case class ExpressionException(str: String, x: Throwable = ...) extends Exception

A custom exception that represents errors related to expressions.

A custom exception that represents errors related to expressions.

Value parameters

str

The error message providing details about the expression error.

Attributes

Supertypes
trait Product
trait Equals
class Exception
class Throwable
trait Serializable
class Object
trait Matchable
class Any
Show all
sealed trait ExpressionFunction[P] extends P => Valuable

Represents a named, generic computation or transformation from an input of type P to an output value of type Valuable. The ExpressionFunction trait defines an abstract function by extending the (P => Valuable) function type. It can be used to model mathematical or computational expressions with a specific name. It is the super-type of ExpressionMonoFunction and ExpressionBiFunction.

Represents a named, generic computation or transformation from an input of type P to an output value of type Valuable. The ExpressionFunction trait defines an abstract function by extending the (P => Valuable) function type. It can be used to model mathematical or computational expressions with a specific name. It is the super-type of ExpressionMonoFunction and ExpressionBiFunction.

Type parameters

P

the type of the input parameter to the function

Attributes

Companion
object
Supertypes
trait P => Valuable
class Object
trait Matchable
class Any
Known subtypes
object Atan
object Log
object Power
object Product
object Sum
object Exp
class Hyperbolic
object Cosh
object Sinh
object Ln
object Negate
object Reciprocal
class SineCos
object Cosine
object Sine
Show all

Object containing utility methods for working with functions in the context of mathematical or computational expressions. The ExpressionFunction object provides helpers to lift operations between Field types to operations between Valuable types.

Object containing utility methods for working with functions in the context of mathematical or computational expressions. The ExpressionFunction object provides helpers to lift operations between Field types to operations between Valuable types.

Attributes

Companion
trait
Supertypes
class Object
trait Matchable
class Any
Self type
class ExpressionMatchers(using val matchLogger: MatchLogger) extends MatchersExtras

Matchers whose input is generally an Expression.

Matchers whose input is generally an Expression.

These Matchers are used to simplify (lazy) Expressions before those Expressions get evaluated, thus sometimes avoiding loss of precision.

Rules for matching: (1) All substitution is based on a successful match -- no match, no substitution; CONSIDER this second rules seems strange (2) The first match to try for any expression is the exactMaterializer which returns Match(Literal(value)); (2) Some matches return non-exact match results -- these should be passed to flatMap simplifier; NOTE: do not pass anything to flatMap simplifier if it could possibly be the same as the input (else stack overflow).

Attributes

Companion
object
Supertypes
trait Matchers
class Object
trait Matchable
class Any
Self type

The ExpressionMatchers object provides utilities for evaluating relationships between two Expression objects using a given ExpressionBiFunction. It enables analysis of complementary expressions under specific mathematical or logical contexts.

The ExpressionMatchers object provides utilities for evaluating relationships between two Expression objects using a given ExpressionBiFunction. It enables analysis of complementary expressions under specific mathematical or logical contexts.

These methods are here so that they're not part of the ExpressionMatchers API.

Attributes

Companion
class
Supertypes
class Object
trait Matchable
class Any
Self type

The companion object for the ExpressionMonoFunction class. Provides utility methods for working with ExpressionMonoFunction instances.

The companion object for the ExpressionMonoFunction class. Provides utility methods for working with ExpressionMonoFunction instances.

Attributes

Companion
class
Supertypes
class Object
trait Matchable
class Any
Self type
sealed abstract class ExpressionMonoFunction(val name: String, val f: Eager => Eager, val parity: Parity) extends ExpressionFunction[Eager]

A lazy monadic expression function.

A lazy monadic expression function.

TODO need to mark whether this function is exact or not (but I can't think of many which are exact).

TODO implement also for other Valuables than Numbers.

Value parameters

f

the function Number => Number.

name

the name of this function.

Attributes

Companion
object
Supertypes
trait Eager => Valuable
class Object
trait Matchable
class Any
Known subtypes
object Exp
class Hyperbolic
object Cosh
object Sinh
object Ln
object Negate
object Reciprocal
class SineCos
object Cosine
object Sine
Show all

Extractor object for handling negation expressions in a commutative manner. Matches pairs of expressions where one is an Expression and the other is a negated ValueExpression(-1).

Extractor object for handling negation expressions in a commutative manner. Matches pairs of expressions where one is an Expression and the other is a negated ValueExpression(-1).

This object extends the CommutativeExtractor to allow the extraction of operands in any order (i.e., it supports both (A, B) and (B, A) configurations).

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
case object Half extends ScalarConstant

Represents the mathematical constant 1/2 (half).

Represents the mathematical constant 1/2 (half).

This object is a specific implementation of the Constant trait and is used to represent the value of half within mathematical expressions.

It provides:

  • An evaluation method that returns the predefined constant value of half.
  • A context definition for the constant.
  • A string representation of the constant.

Attributes

Supertypes
trait Singleton
trait Product
trait Mirror
trait Serializable
trait Product
trait Equals
trait Nameable
trait Expression
trait Approximate
trait Lazy
trait Valuable
trait TypeSafe
trait Exactitude
trait Unitary
trait Zeroable
trait Numeric
trait Renderable
class Object
trait Matchable
class Any
Show all
Self type
Half.type
object HasEuler

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
HasEuler.type
abstract class Hyperbolic(sinh: Boolean, parity: Parity) extends ExpressionMonoFunction

Represents a hyperbolic trigonometric function (sinh or cosh) as a specialized monadic expression. This abstract class extends the ExpressionMonoFunction and defines behavior specific to hyperbolic sine (sinh) or hyperbolic cosine (cosh) operations. The choice between sinh and cosh is determined by the sinh parameter.

Represents a hyperbolic trigonometric function (sinh or cosh) as a specialized monadic expression. This abstract class extends the ExpressionMonoFunction and defines behavior specific to hyperbolic sine (sinh) or hyperbolic cosine (cosh) operations. The choice between sinh and cosh is determined by the sinh parameter.

Value parameters

parity

The parity of the function, which can be odd, even, or neither. For example, sinh has odd parity, while cosh has even parity.

sinh

A boolean value indicating whether the function represents sinh (true) or cosh (false).

Attributes

Constructor

Creates a new instance of the Hyperbolic class.

Companion
object
Supertypes
trait Eager => Valuable
class Object
trait Matchable
class Any
Show all
Known subtypes
object Cosh
object Sinh
object Hyperbolic

Attributes

Companion
class
Supertypes
class Object
trait Matchable
class Any
Self type
Hyperbolic.type
case object I extends NamedConstant

The constant i (viz., the square root of 2) Yes, this is an exact number.

The constant i (viz., the square root of 2) Yes, this is an exact number.

Attributes

Supertypes
trait Singleton
trait Product
trait Mirror
trait Serializable
trait Product
trait Equals
trait Nameable
trait Expression
trait Approximate
trait Lazy
trait Valuable
trait TypeSafe
trait Exactitude
trait Unitary
trait Zeroable
trait Numeric
trait Renderable
class Object
trait Matchable
class Any
Show all
Self type
I.type
object IPi

Companion object providing an extractor for identifying expressions involving specific patterns with mathematical constants i (imaginary unit) and π (pi).

Companion object providing an extractor for identifying expressions involving specific patterns with mathematical constants i (imaginary unit) and π (pi).

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
IPi.type
case object Infinity extends NamedConstant

Represents an infinite value in the Valuable of expressions.

Represents an infinite value in the Valuable of expressions.

The Infinity object is a special case of NamedConstant with a value of positive infinity. It is immutable and serves as a singleton instance to represent the mathematical concept of infinity in calculations or expressions. It overrides certain behaviors of ValueExpression to handle operations specific to infinity.

Attributes

Supertypes
trait Singleton
trait Product
trait Mirror
trait Serializable
trait Product
trait Equals
trait Nameable
trait Expression
trait Approximate
trait Lazy
trait Valuable
trait TypeSafe
trait Exactitude
trait Unitary
trait Zeroable
trait Numeric
trait Renderable
class Object
trait Matchable
class Any
Show all
Self type
Infinity.type

Extractor object for commutative operations between an InversePower and a value that can be powered, represented by CanPower[eager.Number].

Extractor object for commutative operations between an InversePower and a value that can be powered, represented by CanPower[eager.Number].

This object extends CommutativeExtractor, enabling it to automatically handle both (left, right) and (right, left) orderings in commutative binary operations. Specifically, it extracts:

  • An InversePower from the "left" side of the expression, provided the base of the inverse power (n) is greater than 1.
  • A CanPower[eager.Number] from the "right" side of the expression.

The unapply method allows pattern matching to operate on pairs of expressions, extracting valid (InversePower, CanPower[eager.Number]) pairs regardless of their position in the tuple.

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
object IsCommutative

Matches a commutative BiFunction, exposing all three components. Currently Sum and Product are commutative; Power is not.

Matches a commutative BiFunction, exposing all three components. Currently Sum and Product are commutative; Power is not.

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
object IsCosSquared

Extractor matching cos²(z), i.e. BiFunction(UniFunction(z, Cosine), Two, Power). Returns the argument z.

Extractor matching cos²(z), i.e. BiFunction(UniFunction(z, Cosine), Two, Power). Returns the argument z.

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
object IsCoshSquared

Extractor matching cosh²(z), i.e. BiFunction(UniFunction(z, Cosh), Two, Power). Returns the argument z.

Extractor matching cosh²(z), i.e. BiFunction(UniFunction(z, Cosh), Two, Power). Returns the argument z.

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
object IsEager

Companion object providing an extractor for retrieving the Eager value associated with a given Expression. The extractor is used to match on Expression instances and specifically identify instances that are ValueExpression containing an Eager component.

Companion object providing an extractor for retrieving the Eager value associated with a given Expression. The extractor is used to match on Expression instances and specifically identify instances that are ValueExpression containing an Eager component.

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
IsEager.type
object IsEuler

The IsEuler object provides functionality to extract an instance of Euler from a given Expression if the expression conforms to a known form of Euler's representation. It enables pattern matching for expressions representing Euler's equation or its variations.

The IsEuler object provides functionality to extract an instance of Euler from a given Expression if the expression conforms to a known form of Euler's representation. It enables pattern matching for expressions representing Euler's equation or its variations.

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
IsEuler.type
object IsHyperbolic

An extractor object that checks if a given expression is hyperbolic by matching it against the hyperbolic sine (sinh) or hyperbolic cosine (cosh) functions.

An extractor object that checks if a given expression is hyperbolic by matching it against the hyperbolic sine (sinh) or hyperbolic cosine (cosh) functions.

The object provides an unapply method that takes an Expression as input and attempts to extract the inner expression z if the input expression matches the form of a hyperbolic function.

Cases:

  • Matches expressions of the form UniFunction(z, Sinh) or UniFunction(z, Cosh) and returns the inner expression z in a Some if matched.
  • Returns None if the input expression does not match the hyperbolic form.

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type

An object that provides pattern matching for determining whether a given Expression represents an imaginary value.

An object that provides pattern matching for determining whether a given Expression represents an imaginary value.

It attempts to evaluate the Expression and checks if it can be identified as an imaginary value through the IsImaginary extractor.

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type

An extractor object that determines if a pair of expressions is related through an imaginary expression in a commutative manner. This means that the imaginary component can appear on either side of the tuple, and the extractor will match in both cases.

An extractor object that determines if a pair of expressions is related through an imaginary expression in a commutative manner. This means that the imaginary component can appear on either side of the tuple, and the extractor will match in both cases.

The extractor takes a tuple of two Expression objects as input and attempts to find one of the expressions being an IsImaginaryExpression. If a match is found, it extracts the eager value from the IsImaginaryExpression and returns it along with the other expression in the tuple.

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
object IsIntegral

Provides a mechanism to determine whether an Expression can be represented as an integer value and, if so, extracts the corresponding integer value.

Provides a mechanism to determine whether an Expression can be represented as an integer value and, if so, extracts the corresponding integer value.

The IsIntegral object acts as an extractor, allowing pattern matching against Expression instances to identify those that represent whole numbers. This is particularly useful when working with complex expressions that may or may not simplify to integers.

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
IsIntegral.type
object IsMinusOne

Object IsMinusOne is used to identify and extract instances of Expression that represent -1.

Object IsMinusOne is used to identify and extract instances of Expression that represent -1.

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
IsMinusOne.type
object IsSinSquared

Extractor matching sin²(z), i.e. BiFunction(UniFunction(z, Sine), Two, Power). Returns the argument z.

Extractor matching sin²(z), i.e. BiFunction(UniFunction(z, Sine), Two, Power). Returns the argument z.

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
object IsSinhSquared

Extractor matching sinh²(z), i.e. BiFunction(UniFunction(z, Sinh), Two, Power). Returns the argument z.

Extractor matching sinh²(z), i.e. BiFunction(UniFunction(z, Sinh), Two, Power). Returns the argument z.

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
object IsUnity

Object IsUnity is used to identify and extract instances of Expression that represent unity. Unity is determined based on the isUnity property of the Expression.

Object IsUnity is used to identify and extract instances of Expression that represent unity. Unity is determined based on the isUnity property of the Expression.

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
IsUnity.type
object IsZero

Companion object for the IsZero extractor.

Companion object for the IsZero extractor.

This object provides a custom pattern matching mechanism for the Expression trait. It matches any Expression that evaluates to a zero value, allowing concise and readable extraction of such cases.

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
IsZero.type
case object L2 extends AbstractTranscendental

Represents the natural logarithm of 2 as a transcendental constant. NOTE that L2 evaluates to None because generating a Double from L2 would lose precision.

Represents the natural logarithm of 2 as a transcendental constant. NOTE that L2 evaluates to None because generating a Double from L2 would lose precision.

This is a case object extending the AbstractTranscendental class, encapsulating the mathematical expression for the natural log of 2 (ln(2)) and the corresponding expression (Two.log).

The L2 object is defined as a named transcendental entity and can be used in operations or expressions involving transcendental numbers.

Attributes

Supertypes
trait Singleton
trait Product
trait Mirror
trait Serializable
trait Product
trait Equals
trait Nameable
trait Expression
trait Approximate
trait Lazy
trait Valuable
trait TypeSafe
trait Exactitude
trait Unitary
trait Zeroable
trait Numeric
trait Renderable
class Object
trait Matchable
class Any
Show all
Self type
L2.type
case object LgE extends AbstractTranscendental

Represents the natural logarithm of 2 as a transcendental constant. NOTE that L2 evaluates to None because generating a Double from L2 would lose precision.

Represents the natural logarithm of 2 as a transcendental constant. NOTE that L2 evaluates to None because generating a Double from L2 would lose precision.

This is a case object extending the AbstractTranscendental class, encapsulating the mathematical expression for the natural log of 2 (ln(2)) and the corresponding expression (Two.log).

The L2 object is defined as a named transcendental entity and can be used in operations or expressions involving transcendental numbers.

Attributes

Supertypes
trait Singleton
trait Product
trait Mirror
trait Serializable
trait Product
trait Equals
trait Nameable
trait Expression
trait Approximate
trait Lazy
trait Valuable
trait TypeSafe
trait Exactitude
trait Unitary
trait Zeroable
trait Numeric
trait Renderable
class Object
trait Matchable
class Any
Show all
Self type
LgE.type
case class LinearRoot(equ: Equation) extends AbstractRoot

Represents the linear root of a given equation. A LinearRoot is an extension of the AbstractRoot class, specialized for cases where the root corresponds to a degree-1 (linear) polynomial equation.

Represents the linear root of a given equation. A LinearRoot is an extension of the AbstractRoot class, specialized for cases where the root corresponds to a degree-1 (linear) polynomial equation.

This implementation assumes the linear root is unique and thus corresponds to the only solution available for a first-degree equation.

Value parameters

equ

the Equation instance associated with this root. Assumes the equation is linear (degree 1).

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
class AbstractRoot
trait Root
trait Branched[Root]
trait Nameable
trait Expression
trait Approximate
trait Lazy
trait Valuable
trait TypeSafe
trait Exactitude
trait Unitary
trait Zeroable
trait Numeric
trait Renderable
class Object
trait Matchable
class Any
Show all
case class Literal(value: Eager, maybeName: Option[String] = ...) extends ValueExpression

A ValueExpression based on a literal Valuable.

A ValueExpression based on a literal Valuable.

Value parameters

maybeName

an optional name (typically this will be None).

value

the Valuable.

Attributes

Companion
object
Supertypes
trait Serializable
trait Product
trait Equals
trait Nameable
trait Expression
trait Approximate
trait Lazy
trait Valuable
trait TypeSafe
trait Exactitude
trait Unitary
trait Zeroable
trait Numeric
trait Renderable
class Object
trait Matchable
class Any
Show all
object Literal

Companion object for the Literal class, providing factory methods and pattern matching support.

Companion object for the Literal class, providing factory methods and pattern matching support.

Attributes

Companion
class
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
Literal.type
case object Ln extends ExpressionMonoFunction

Represents the natural logarithmic function as an ExpressionMonoFunction.

Represents the natural logarithmic function as an ExpressionMonoFunction.

Renaming this function as Ln (logarithmus naturalis).

This object provides functionality to compute the natural logarithm (ln) of a given Number. The underlying implementation utilizes the log method of the Number type.

Attributes

Supertypes
trait Singleton
trait Product
trait Mirror
trait Serializable
trait Product
trait Equals
trait Eager => Valuable
class Object
trait Matchable
class Any
Show all
Self type
Ln.type
case object Log extends ExpressionBiFunction

The Log object represents a mathematical logarithmic operation as a binary function. It extends the ExpressionBiFunction, enabling evaluation of logarithmic expressions with specific constraints and rules for exactness.

The Log object represents a mathematical logarithmic operation as a binary function. It extends the ExpressionBiFunction, enabling evaluation of logarithmic expressions with specific constraints and rules for exactness.

Thus the value is log to the base b of a, where a and b are the expressions in the BiFunction.

This class supports restricted evaluation contexts and provides mechanisms for exact computation or fallback to default behavior when exact evaluation is not possible.

Attributes

Supertypes
trait Singleton
trait Product
trait Mirror
trait Serializable
trait Product
trait Equals
trait ((Eager, Eager)) => Valuable
class Object
trait Matchable
class Any
Show all
Self type
Log.type
trait MathematicalEq[A]

Typeclass for mathematical equality that considers expressions equal if they simplify to structurally equivalent forms.

Typeclass for mathematical equality that considers expressions equal if they simplify to structurally equivalent forms.

This is distinct from structural equality (Eq) which only considers the syntactic structure of expressions.

Attributes

Companion
object
Supertypes
class Object
trait Matchable
class Any

Attributes

Companion
trait
Supertypes
class Object
trait Matchable
class Any
Self type

Syntax extensions for MathematicalEq.

Syntax extensions for MathematicalEq.

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
case object MinusOne extends ScalarConstant

Represents the constant value -1.

Represents the constant value -1.

MinusOne is a specific instance of the ScalarConstant class, which evaluates to the numerical value -1 regardless of the context.

This constant can be used in mathematical expressions involving Valuables and supports operations defined in the Valuable trait.

Attributes

Supertypes
trait Singleton
trait Product
trait Mirror
trait Serializable
trait Product
trait Equals
trait Nameable
trait Expression
trait Approximate
trait Lazy
trait Valuable
trait TypeSafe
trait Exactitude
trait Unitary
trait Zeroable
trait Numeric
trait Renderable
class Object
trait Matchable
class Any
Show all
Self type
MinusOne.type
object Multiple

An extractor for the Multiple trait, allowing deconstruction into its sequence of terms.

An extractor for the Multiple trait, allowing deconstruction into its sequence of terms.

This object provides a pattern matching mechanism for Multiple, enabling access to its underlying sequence of sub-expressions.

Attributes

Companion
trait
Supertypes
class Object
trait Matchable
class Any
Self type
Multiple.type

Represents a composite expression consisting of multiple terms. Multiple is a specialized trait that inherits from CompositeExpression and provides functionality to manage a sequence of sub-expressions.

Represents a composite expression consisting of multiple terms. Multiple is a specialized trait that inherits from CompositeExpression and provides functionality to manage a sequence of sub-expressions.

Would like this to be package-sealed if they ever add that feature.

Attributes

Companion
object
Supertypes
trait Expression
trait Approximate
trait Lazy
trait Valuable
trait TypeSafe
trait Exactitude
trait Unitary
trait Zeroable
trait Numeric
trait Renderable
class Object
trait Matchable
class Any
Show all
Known subtypes
class Aggregate
class BiFunction

An object that extracts and matches expressions based on the commutative property of multiplication with the identity element (unity).

An object that extracts and matches expressions based on the commutative property of multiplication with the identity element (unity).

This object extends CommutativeExtractor and provides the specific implementation for extracting expressions in the form of a multiplicative operation where one operand is the multiplicative identity (unity), and the other is the remaining expression.

It defines the following extraction rules:

  • The extractLeft method always extracts and returns the input expression as-is.
  • The extractRight method matches an expression that is the multiplicative identity (IsUnity(x)) and extracts the contained value x.

The unapply mechanism allows this extractor to match pairs of expressions in a commutative manner, ensuring symmetry in the analysis of multiplicative operations.

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
sealed abstract class NamedConstant(x: Eager, name: String) extends ValueExpression

Represents a specific constant whose value is a Valuable with an associated name.

Represents a specific constant whose value is a Valuable with an associated name.

This abstract class extends ValueExpression, allowing for named representation of constants in mathematical expressions, while being tied to a specific Valuable type.

Value parameters

name

the name associated with this constant.

x

the mathematical Valuable to which this constant belongs.

Attributes

Constructor

Creates a named constant within the context of the provided Eager.

Supertypes
trait Nameable
trait Expression
trait Approximate
trait Lazy
trait Valuable
trait TypeSafe
trait Exactitude
trait Unitary
trait Zeroable
trait Numeric
trait Renderable
class Object
trait Matchable
class Any
Show all
Known subtypes
object E
object I
object Infinity
object Half
object MinusOne
object One
object Pi
object Two
object Zero
Show all
case object Negate extends ExpressionMonoFunction

Negate is a specific implementation of the ExpressionMonoFunction that changes the sign of a numeric value.

Negate is a specific implementation of the ExpressionMonoFunction that changes the sign of a numeric value.

This object represents the mathematical negation operation ("-") applied to a numeric input. It uses the negate method, which evaluates the negation of a given Number while handling specific cases like imaginary numbers and converting non-pure factors to PureNumber form as necessary.

The function is exact and operates lazily.

Attributes

Supertypes
trait Singleton
trait Product
trait Mirror
trait Serializable
trait Product
trait Equals
trait Eager => Valuable
class Object
trait Matchable
class Any
Show all
Self type
Negate.type
case class Noop(w: String) extends AtomicExpression

The Noop object is an atomic expression that represents a no-operation placeholder in an expression tree. It cannot be evaluated, simplified, or associated with any specific factor. It is a concrete implementation of the AtomicExpression trait.

The Noop object is an atomic expression that represents a no-operation placeholder in an expression tree. It cannot be evaluated, simplified, or associated with any specific factor. It is a concrete implementation of the AtomicExpression trait.

Attributes

Companion
object
Supertypes
trait Serializable
trait Product
trait Equals
trait Nameable
trait Expression
trait Approximate
trait Lazy
trait Valuable
trait TypeSafe
trait Exactitude
trait Unitary
trait Zeroable
trait Numeric
trait Renderable
class Object
trait Matchable
class Any
Show all
object Noop

Attributes

Companion
class
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
Noop.type
object NthRoot

An object that provides utilities for working with nth root expressions. Specifically, it allows for the deconstruction and extraction of components from expressions that match specific root-related patterns.

An object that provides utilities for working with nth root expressions. Specifically, it allows for the deconstruction and extraction of components from expressions that match specific root-related patterns.

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
NthRoot.type
object Odd

An extractor object for identifying whether a given ExpressionMonoFunction has an odd parity. This is determined by evaluating the parity property of the provided function and checking if it is Parity.Odd.

An extractor object for identifying whether a given ExpressionMonoFunction has an odd parity. This is determined by evaluating the parity property of the provided function and checking if it is Parity.Odd.

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
Odd.type
case object One extends ScalarConstant

Represents the constant numeric value 1.

Represents the constant numeric value 1.

One is a case object that extends ScalarConstant, indicating that it is a well-defined, immutable, and atomic mathematical value.

Attributes

Supertypes
trait Singleton
trait Product
trait Mirror
trait Serializable
trait Product
trait Equals
trait Nameable
trait Expression
trait Approximate
trait Lazy
trait Valuable
trait TypeSafe
trait Exactitude
trait Unitary
trait Zeroable
trait Numeric
trait Renderable
class Object
trait Matchable
class Any
Show all
Self type
One.type
enum Parity

Represents the parity of a number.

Represents the parity of a number.

Parity can either be:

  • Odd: Indicates the given ExpressionMonoFunction is odd.
  • Even: Indicates the given ExpressionMonoFunction is even.
  • Neither: Indicates the given ExpressionMonoFunction does not have a defined parity, such as in the case of certain non-integral or undefined inputs.

Attributes

Supertypes
trait Enum
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
case object Pi extends ScalarConstant

Pi represents the mathematical constant π (pi) exactly.

Pi represents the mathematical constant π (pi) exactly.

Attributes

Supertypes
trait Singleton
trait Product
trait Mirror
trait Serializable
trait Product
trait Equals
trait Nameable
trait Expression
trait Approximate
trait Lazy
trait Valuable
trait TypeSafe
trait Exactitude
trait Unitary
trait Zeroable
trait Numeric
trait Renderable
class Object
trait Matchable
class Any
Show all
Self type
Pi.type
case object Power extends ExpressionBiFunction

Represents the power operation as a binary function within expressions. This operation raises the first operand to the power of the second operand. It is not exact for all inputs and does not commute.

Represents the power operation as a binary function within expressions. This operation raises the first operand to the power of the second operand. It is not exact for all inputs and does not commute.

TODO check on Eager.zero as identityL.

Extends ExpressionBiFunction where the specific function is implemented using the power method from the Valuable class.

Attributes

Supertypes
trait Singleton
trait Product
trait Mirror
trait Serializable
trait Product
trait Equals
trait ((Eager, Eager)) => Valuable
class Object
trait Matchable
class Any
Show all
Self type
Power.type
case object Product extends ExpressionBiFunction

Represents a specific implementation of the ExpressionBiFunction that performs multiplication between two Valuable values.

Represents a specific implementation of the ExpressionBiFunction that performs multiplication between two Valuable values.

This object embodies a binary operation where the function takes two inputs and computes their product using the multiply method defined on Valuable. The operation is represented by the symbol "*".

  • The operation is marked as exact, ensuring the result is always precise when the inputs are exact.
  • It inherits the commutative property from ExpressionBiFunction, as multiplication is commutative.

Attributes

Supertypes
trait Singleton
trait Product
trait Mirror
trait Serializable
trait Product
trait Equals
trait ((Eager, Eager)) => Valuable
class Object
trait Matchable
class Any
Show all
Self type
Product.type

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
object QuadraticRoot

The QuadraticRoot object provides functionality to construct and manipulate roots of quadratic equations. Basically, this method tries to reverse-engineer a QuadraticSolution into a QuadraticRoot. We don't currently manage it for all possibilities (understatement!) TODO complete more cases.

The QuadraticRoot object provides functionality to construct and manipulate roots of quadratic equations. Basically, this method tries to reverse-engineer a QuadraticSolution into a QuadraticRoot. We don't currently manage it for all possibilities (understatement!) TODO complete more cases.

This object acts as a factory for creating instances of QuadraticRoot using algebraic data, and offers methods for working with quadratic equations and their solutions.

Attributes

Companion
class
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
case class QuadraticRoot(equ: Equation, branch: Int, maybeName: Option[String] = ...) extends AbstractRoot

Represents a root of a quadratic equation with a specified branch. This class is a case class extending the AbstractRoot, which models the root of an equation and provides required functionality for specific implementations.

Represents a root of a quadratic equation with a specified branch. This class is a case class extending the AbstractRoot, which models the root of an equation and provides required functionality for specific implementations.

The QuadraticRoot works specifically with quadratic equations, which have two branches corresponding to their solutions. Each instance of QuadraticRoot is associated with one branch of the equation.

Value parameters

branch

the branch index indicating the solution branch of the equation. This value should be within the valid range of branches supported by the equation, typically 0 or 1 for quadratic equations.

equ

the equation whose root is being represented. It must be an instance of the Equation trait.

Attributes

Companion
object
Supertypes
trait Serializable
trait Product
trait Equals
class AbstractRoot
trait Root
trait Branched[Root]
trait Nameable
trait Expression
trait Approximate
trait Lazy
trait Valuable
trait TypeSafe
trait Exactitude
trait Unitary
trait Zeroable
trait Numeric
trait Renderable
class Object
trait Matchable
class Any
Show all

The QuadraticValue object provides functionality for extracting components of a quadratic-related Expression through pattern matching. It identifies specific cases such as Root or Literal with a QuadraticSolution and produces structured data accordingly.

The QuadraticValue object provides functionality for extracting components of a quadratic-related Expression through pattern matching. It identifies specific cases such as Root or Literal with a QuadraticSolution and produces structured data accordingly.

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
case object Reciprocal extends ExpressionMonoFunction

Reciprocal is an ExpressionMonoFunction representing the mathematical reciprocal operation. The function takes a numeric input x and computes 1 / x. It is identified by the name "rec". CONSIDER eliminating this and forcing any reciprocal to be power of negative one.

Reciprocal is an ExpressionMonoFunction representing the mathematical reciprocal operation. The function takes a numeric input x and computes 1 / x. It is identified by the name "rec". CONSIDER eliminating this and forcing any reciprocal to be power of negative one.

The operation is performed lazily and adheres to the behavior defined in its parent class.

Attributes

Supertypes
trait Singleton
trait Product
trait Mirror
trait Serializable
trait Product
trait Equals
trait Eager => Valuable
class Object
trait Matchable
class Any
Show all
Self type
Reciprocal.type
sealed trait Root extends AtomicExpression, Branched[Root], Zeroable

The Root trait represents a mathematical root derived from a specific equation. It corresponds to a solution of a multivalued mathematical expression that is typically associated with a monic polynomial equation. Each root is uniquely identified by its underlying equation and a branch index that represents a specific solution when multiple solutions are possible.

The Root trait represents a mathematical root derived from a specific equation. It corresponds to a solution of a multivalued mathematical expression that is typically associated with a monic polynomial equation. Each root is uniquely identified by its underlying equation and a branch index that represents a specific solution when multiple solutions are possible.

Attributes

Companion
object
Supertypes
trait Branched[Root]
trait Nameable
trait Expression
trait Approximate
trait Lazy
trait Valuable
trait TypeSafe
trait Exactitude
trait Unitary
trait Zeroable
trait Numeric
trait Renderable
class Object
trait Matchable
class Any
Show all
Known subtypes
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.

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
Supertypes
trait Sum
trait Mirror
class Object
trait Matchable
class Any
Self type
Root.type
sealed abstract class ScalarConstant(x: Eager, val name: String) extends NamedConstant

An abstract representation of a scalar constant in a specific mathematical Valuable, for example, π (pi), 1, 0, but not e.

An abstract representation of a scalar constant in a specific mathematical Valuable, for example, π (pi), 1, 0, but not e.

This class extends NamedConstant, tying the scalar constant to a particular Valuable instance and associating it with a specific name. It is designed to represent immutable scalar constants in mathematical expressions, leveraging the properties and operations of the Valuable.

Value parameters

name

the name associated with the scalar constant.

x

the Valuable instance representing the value of the scalar constant.

Attributes

Supertypes
trait Nameable
trait Expression
trait Approximate
trait Lazy
trait Valuable
trait TypeSafe
trait Exactitude
trait Unitary
trait Zeroable
trait Numeric
trait Renderable
class Object
trait Matchable
class Any
Show all
Known subtypes
object Half
object MinusOne
object One
object Pi
object Two
object Zero
Show all
object Sin

Matches sin(θ) → UniFunction(θ, Sine), returns θ.

Matches sin(θ) → UniFunction(θ, Sine), returns θ.

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
Sin.type
case object Sine extends SineCos

Represents the sine trigonometric function.

Represents the sine trigonometric function.

Sine is a case object of the SineCos abstract class with the sine parameter set to true, which designates that the sine (sin) function is to be applied to expressions.

It applies the sine function to a given mathematical expression and inherits all behavior defined in the SineCos abstract class.

Attributes

Supertypes
trait Singleton
trait Product
trait Mirror
trait Serializable
trait Product
trait Equals
class SineCos
trait Eager => Valuable
class Object
trait Matchable
class Any
Show all
Self type
Sine.type
object SineCos

Attributes

Companion
class
Supertypes
class Object
trait Matchable
class Any
Self type
SineCos.type
abstract class SineCos(sine: Boolean, parity: Parity) extends ExpressionMonoFunction

Represents a trigonometric function, either sine or cosine, that is derived from the abstract ExpressionMonoFunction.

Represents a trigonometric function, either sine or cosine, that is derived from the abstract ExpressionMonoFunction.

The SineCos class applies a specified trigonometric function (sin or cos) to an Expression. The function to be applied is determined by the given sine boolean parameter.

If sine is true, the sine (sin) function is applied, otherwise, the cosine (cos) function is applied.

Value parameters

sine

a boolean indicating whether the sine function should be used (true for sine, false for cosine).

Attributes

Companion
object
Supertypes
trait Eager => Valuable
class Object
trait Matchable
class Any
Show all
Known subtypes
object Cosine
object Sine
case object Sinh extends Hyperbolic

Represents the sine trigonometric function.

Represents the sine trigonometric function.

Sine is a case object of the SineCos abstract class with the sine parameter set to true, which designates that the sine (sin) function is to be applied to expressions.

It applies the sine function to a given mathematical expression and inherits all behavior defined in the SineCos abstract class.

Attributes

Supertypes
trait Singleton
trait Product
trait Mirror
trait Serializable
trait Product
trait Equals
class Hyperbolic
trait Eager => Valuable
class Object
trait Matchable
class Any
Show all
Self type
Sinh.type
object SinhX

Matches sinh(x) → UniFunction(x, Sinh), returns x.

Matches sinh(x) → UniFunction(x, Sinh), returns x.

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
SinhX.type
object SquareRoot

Object SquareRoot provides a mechanism to extract and match square root operations represented as a specific Expression.

Object SquareRoot provides a mechanism to extract and match square root operations represented as a specific Expression.

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
SquareRoot.type
case object Sum extends ExpressionBiFunction

Represents a sum operation as a binary function that adds two Valuable values.

Represents a sum operation as a binary function that adds two Valuable values.

This object extends ExpressionBiFunction by defining its operation as addition (add) with the corresponding symbol "+" and is flagged as not always exact (isExact = false).

Attributes

Supertypes
trait Singleton
trait Product
trait Mirror
trait Serializable
trait Product
trait Equals
trait ((Eager, Eager)) => Valuable
class Object
trait Matchable
class Any
Show all
Self type
Sum.type
object SumExpression

Extractor for BiFunction(a, b, Sum) — returns (a, b) as a tuple suitable for use with CommutativeExtractor subtypes.

Extractor for BiFunction(a, b, Sum) — returns (a, b) as a tuple suitable for use with CommutativeExtractor subtypes.

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type

Fully symmetric commutative extractor for Sum expressions. Both positions accept any Expression; the inner match in matchBiFunctionIdentitiesSum applies the specific guards. Used for Pythagorean and related identities where both operands are CompositeExpression and no asymmetric role distinction applies.

Fully symmetric commutative extractor for Sum expressions. Both positions accept any Expression; the inner match in matchBiFunctionIdentitiesSum applies the specific guards. Used for Pythagorean and related identities where both operands are CompositeExpression and no asymmetric role distinction applies.

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
sealed trait Transcendental extends AtomicExpression

Represents a type of AtomicExpression that embodies a transcendental entity. A transcendental entity typically includes non-algebraic constants or functions that cannot arise from finite polynomial equations with rational coefficients.

Represents a type of AtomicExpression that embodies a transcendental entity. A transcendental entity typically includes non-algebraic constants or functions that cannot arise from finite polynomial equations with rational coefficients.

This trait extends the characteristics of AtomicExpression by enabling the application of a transformation or computation defined as an ExpressionMonoFunction.

Attributes

Supertypes
trait Nameable
trait Expression
trait Approximate
trait Lazy
trait Valuable
trait TypeSafe
trait Exactitude
trait Unitary
trait Zeroable
trait Numeric
trait Renderable
class Object
trait Matchable
class Any
Show all
Known subtypes
object L2
object LgE
Show all
case object Two extends ScalarConstant

Represents the constant number 2 as a case object, extending the ScalarConstant class.

Represents the constant number 2 as a case object, extending the ScalarConstant class.

This object evaluates to the numeric constant 2 within the given context. It can be used in mathematical expressions and operations involving constants.

Attributes

Supertypes
trait Singleton
trait Product
trait Mirror
trait Serializable
trait Product
trait Equals
trait Nameable
trait Expression
trait Approximate
trait Lazy
trait Valuable
trait TypeSafe
trait Exactitude
trait Unitary
trait Zeroable
trait Numeric
trait Renderable
class Object
trait Matchable
class Any
Show all
Self type
Two.type
object UniFunction

The UniFunction companion object provides utility methods for initializing and converting UniFunction instances. It includes methods to construct a UniFunction from a MonadicDuple as well as an implicit conversion mechanism.

The UniFunction companion object provides utility methods for initializing and converting UniFunction instances. It includes methods to construct a UniFunction from a MonadicDuple as well as an implicit conversion mechanism.

Attributes

Companion
class
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type

This class represents a monadic function of the given expression.

This class represents a monadic function of the given expression.

Value parameters

f

the function to be applied to x.

x

the expression being operated on.

Attributes

Companion
object
Supertypes
trait Serializable
trait Product
trait Equals
trait Expression
trait Approximate
trait Lazy
trait Valuable
trait TypeSafe
trait Exactitude
trait Unitary
trait Zeroable
trait Numeric
trait Renderable
class Object
trait Matchable
class Any
Show all

The ValueExpression companion object provides a mechanism to extract elements from a ValueExpression instance. It defines the unapply method to enable pattern matching and decomposition of ValueExpression objects.

The ValueExpression companion object provides a mechanism to extract elements from a ValueExpression instance. It defines the unapply method to enable pattern matching and decomposition of ValueExpression objects.

The extraction operation retrieves the underlying Eager and an optional name, if available. It handles two main cases:

  1. For instances of Literal, it extracts the Eager value along with None for the optional name.
  2. For other cases, it extracts the Eager value along with its associated optional name.

Attributes

See also

ValueExpression

Literal

Companion
class
Supertypes
trait Sum
trait Mirror
class Object
trait Matchable
class Any
Self type
sealed abstract class ValueExpression(val value: Eager, val maybeName: Option[String] = ...) extends AtomicExpression

Represents an abstract expression for a Valuable that can optionally be associated with a name.

Represents an abstract expression for a Valuable that can optionally be associated with a name.

A ValueExpression provides methods for evaluating its qualifications within a given context, rendering its representation, and determining equality or hashing. It extends the AtomicExpression trait, allowing it to be used wherever atomic expressions are valid.

CONSIDER placing maybeName in the second parameter list.

Value parameters

maybeName

an optional name for the Valuable expression

value

the Valuable associated with the expression

Attributes

Companion
object
Supertypes
trait Nameable
trait Expression
trait Approximate
trait Lazy
trait Valuable
trait TypeSafe
trait Exactitude
trait Unitary
trait Zeroable
trait Numeric
trait Renderable
class Object
trait Matchable
class Any
Show all
Known subtypes
class Literal
object E
object I
object Infinity
object Half
object MinusOne
object One
object Pi
object Two
object Zero
Show all
case object Zero extends ScalarConstant

Represents the mathematical constant zero. This object extends the ScalarConstant class, providing implementation specific to zero.

Represents the mathematical constant zero. This object extends the ScalarConstant class, providing implementation specific to zero.

Attributes

Supertypes
trait Singleton
trait Product
trait Mirror
trait Serializable
trait Product
trait Equals
trait Nameable
trait Expression
trait Approximate
trait Lazy
trait Valuable
trait TypeSafe
trait Exactitude
trait Unitary
trait Zeroable
trait Numeric
trait Renderable
class Object
trait Matchable
class Any
Show all
Self type
Zero.type
object ∅

The ∅ object represents the identity element in mathematical operations on expressions. It serves as a symbolic representation of the "empty" or neutral element in addition and multiplication operations.

The ∅ object represents the identity element in mathematical operations on expressions. It serves as a symbolic representation of the "empty" or neutral element in addition and multiplication operations.

This object supports operations such as addition, subtraction, multiplication, and division, which adhere to mathematical identity properties or represent specific transformations when combined with expressions.

Functions:

  • Addition (+): Performs addition with an expression or integer. For expressions, it returns the operand itself, acting as the addition identity. For integers, it creates a Literal representation of the integer and returns that.

  • Multiplication (*): Performs multiplication with an expression or integer. For expressions, it returns the operand itself, acting as the multiplication identity. For integers, it creates a Literal representation of the integer and returns that.

  • Division (/): Represents the division operation. For expressions or integers, it creates a transformed expression wrapped in the Reciprocal operation.

  • Subtraction (-): Represents subtraction or negation. For expressions or integers, it creates a transformed expression wrapped in the Negate operation.

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
∅.type

Deprecated classlikes

Case object representing the transcendental constant e.

Case object representing the transcendental constant e.

Extends the AbstractTranscendental class, providing implementations specific to the mathematical constant e (Euler's number), known for its importance in the Valuable of mathematics, particularly in calculus and exponential growth behavior.

The name parameter is set to "xD835DF00", which represents a unique identifier for this transcendental, and its expression is given by the constant E.

The E object inherits all methods and properties from AbstractTranscendental, allowing it to be treated as an atomic and exact mathematical expression with various evaluative and comparison capabilities. It also ensures consistency in rendering and context-based operations.

Attributes

Deprecated
[Since version 0.1.0] use E instead.
Supertypes
trait Singleton
trait Product
trait Mirror
trait Serializable
trait Product
trait Equals
trait Nameable
trait Expression
trait Approximate
trait Lazy
trait Valuable
trait TypeSafe
trait Exactitude
trait Unitary
trait Zeroable
trait Numeric
trait Renderable
class Object
trait Matchable
class Any
Show all
Self type

PiTranscendental is a case object representing the mathematical constant π (pi). It extends the AbstractTranscendental class, with a symbolic name "π" and Pi as its exact value.

PiTranscendental is a case object representing the mathematical constant π (pi). It extends the AbstractTranscendental class, with a symbolic name "π" and Pi as its exact value.

This object provides an exact representation of π and inherits capabilities for evaluation, materialization, and comparison from its abstract superclass.

Attributes

Deprecated

use Pi instead.

Supertypes
trait Singleton
trait Product
trait Mirror
trait Serializable
trait Product
trait Equals
trait Nameable
trait Expression
trait Approximate
trait Lazy
trait Valuable
trait TypeSafe
trait Exactitude
trait Unitary
trait Zeroable
trait Numeric
trait Renderable
class Object
trait Matchable
class Any
Show all
Self type