SmartEquationSolver

Struct SmartEquationSolver 

Source
pub struct SmartEquationSolver { /* private fields */ }
Expand description

Master equation solver with smart dispatch

Implementations§

Source§

impl SmartEquationSolver

Source

pub fn new() -> Self

Source

pub fn solve_with_equation( &self, equation: &Expression, variable: &Symbol, ) -> (SolverResult, StepByStepExplanation)

Solve equation with educational explanation, including equation analysis

This is the primary entry point for solving equations with full educational integration. It automatically:

  1. Analyzes the equation type
  2. Explains the equation structure
  3. Selects the appropriate solver
  4. Provides step-by-step solution with explanations
§Arguments
  • equation - The equation expression to solve
  • variable - The variable to solve for
§Returns

A tuple containing:

  • The solver result (solutions or error)
  • Complete step-by-step explanation starting with equation analysis
Source

pub fn solve(&self) -> (SolverResult, StepByStepExplanation)

Legacy solve method (deprecated, use solve_with_equation instead)

Source

pub fn solve_system( &self, equations: &[Expression], variables: &[Symbol], ) -> SolverResult

Solve system of equations using the integrated system solver

This method exposes the system solving capability through SmartEquationSolver, allowing for solving both linear and polynomial systems (via Grobner basis).

§Arguments
  • equations - Array of equations to solve
  • variables - Array of variables to solve for
§Returns

SolverResult containing solutions, no solution, or partial solutions

§Examples
use mathhook_core::algebra::equation_analyzer::SmartEquationSolver;
use mathhook_core::{symbol, Expression};

let solver = SmartEquationSolver::new();
let x = symbol!(x);
let y = symbol!(y);

// Linear 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 result = solver.solve_system(&[eq1, eq2], &[x, y]);

Trait Implementations§

Source§

impl Default for SmartEquationSolver

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.