pub struct SystemSolver;Expand description
System equation solver
Implementations§
Source§impl SystemSolver
impl SystemSolver
Trait Implementations§
Source§impl Clone for SystemSolver
impl Clone for SystemSolver
Source§fn clone(&self) -> SystemSolver
fn clone(&self) -> SystemSolver
Returns a duplicate of the value. Read more
1.0.0§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for SystemSolver
impl Debug for SystemSolver
Source§impl Default for SystemSolver
impl Default for SystemSolver
Source§impl EquationSolver for SystemSolver
impl EquationSolver for SystemSolver
Source§fn solve(&self, equation: &Expression, variable: &Symbol) -> SolverResult
fn solve(&self, equation: &Expression, variable: &Symbol) -> SolverResult
Solve equation for given variable
Source§fn solve_with_explanation(
&self,
equation: &Expression,
variable: &Symbol,
) -> (SolverResult, StepByStepExplanation)
fn solve_with_explanation( &self, equation: &Expression, variable: &Symbol, ) -> (SolverResult, StepByStepExplanation)
Solve with step-by-step explanation
Source§fn can_solve(&self, _equation: &Expression) -> bool
fn can_solve(&self, _equation: &Expression) -> bool
Check if solver can handle this equation type
Source§impl SystemEquationSolver for SystemSolver
impl SystemEquationSolver for SystemSolver
Source§fn solve_system(
&self,
equations: &[Expression],
variables: &[Symbol],
) -> SolverResult
fn solve_system( &self, equations: &[Expression], variables: &[Symbol], ) -> SolverResult
Solve system of linear or polynomial equations
Automatically detects system type and routes to appropriate solver:
- Linear systems: LU decomposition via Matrix::solve()
- Polynomial systems: Gröbner basis computation (Buchberger’s algorithm)
§Examples
Linear system:
ⓘ
use mathhook_core::algebra::solvers::{SystemSolver, SystemEquationSolver};
use mathhook_core::{Expression, symbol};
let x = symbol!(x);
let y = symbol!(y);
// System: 2x + y = 5, x - y = 1
let eq1 = Expression::add(vec![
Expression::mul(vec![Expression::integer(2), Expression::symbol(x.clone())]),
Expression::symbol(y.clone()),
Expression::integer(-5)
]);
let eq2 = Expression::add(vec![
Expression::symbol(x.clone()),
Expression::mul(vec![Expression::integer(-1), Expression::symbol(y.clone())]),
Expression::integer(-1)
]);
let solver = SystemSolver::new();
let result = solver.solve_system(&[eq1, eq2], &[x, y]);
// Solution: x = 2, y = 1Polynomial system:
ⓘ
use mathhook_core::algebra::solvers::{SystemSolver, SystemEquationSolver};
use mathhook_core::{Expression, symbol, expr};
let x = symbol!(x);
let y = symbol!(y);
// System: x² + y² = 1, x - y = 0
let eq1 = Expression::add(vec![expr!(x^2), expr!(y^2), expr!(-1)]);
let eq2 = expr!(x - y);
let solver = SystemSolver::new();
let result = solver.solve_system(&[eq1, eq2], &[x, y]);
// Finds intersection of circle and lineSource§fn solve_system_with_explanation(
&self,
equations: &[Expression],
variables: &[Symbol],
) -> (SolverResult, StepByStepExplanation)
fn solve_system_with_explanation( &self, equations: &[Expression], variables: &[Symbol], ) -> (SolverResult, StepByStepExplanation)
Solve system with step-by-step explanation
Auto Trait Implementations§
impl Freeze for SystemSolver
impl RefUnwindSafe for SystemSolver
impl Send for SystemSolver
impl Sync for SystemSolver
impl Unpin for SystemSolver
impl UnwindSafe for SystemSolver
Blanket Implementations§
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
🔬This is a nightly-only experimental API. (
clone_to_uninit)Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more