pub trait ComplexOperations {
// Required methods
fn complex_add(&self, other: &Expression) -> Expression;
fn complex_subtract(&self, other: &Expression) -> Expression;
fn complex_multiply(&self, other: &Expression) -> Expression;
fn complex_divide(&self, other: &Expression) -> Expression;
fn complex_conjugate(&self) -> Expression;
fn complex_modulus(&self) -> Expression;
fn complex_argument(&self) -> Expression;
fn to_polar_form(&self) -> (Expression, Expression);
fn is_real(&self) -> bool;
fn is_imaginary(&self) -> bool;
fn is_pure_imaginary(&self) -> bool;
}Expand description
Trait for complex number operations
Provides methods for performing arithmetic and other operations on complex numbers represented as expressions with symbolic real and imaginary parts.
Required Methods§
Sourcefn complex_add(&self, other: &Expression) -> Expression
fn complex_add(&self, other: &Expression) -> Expression
Add two complex expressions
§Examples
use mathhook_core::{Expression, ComplexOperations, expr};
let z1 = Expression::complex(expr!(3), expr!(4));
let z2 = Expression::complex(expr!(1), expr!(2));
let result = z1.complex_add(&z2);Sourcefn complex_subtract(&self, other: &Expression) -> Expression
fn complex_subtract(&self, other: &Expression) -> Expression
Subtract two complex expressions
§Examples
use mathhook_core::{Expression, ComplexOperations, expr};
let z1 = Expression::complex(expr!(5), expr!(3));
let z2 = Expression::complex(expr!(2), expr!(1));
let result = z1.complex_subtract(&z2);Sourcefn complex_multiply(&self, other: &Expression) -> Expression
fn complex_multiply(&self, other: &Expression) -> Expression
Multiply two complex expressions
§Examples
use mathhook_core::{Expression, ComplexOperations, expr};
let z1 = Expression::complex(expr!(3), expr!(4));
let z2 = Expression::complex(expr!(1), expr!(2));
let result = z1.complex_multiply(&z2);Sourcefn complex_divide(&self, other: &Expression) -> Expression
fn complex_divide(&self, other: &Expression) -> Expression
Divide two complex expressions
§Examples
use mathhook_core::{Expression, ComplexOperations, expr};
let z1 = Expression::complex(expr!(6), expr!(8));
let z2 = Expression::complex(expr!(3), expr!(4));
let result = z1.complex_divide(&z2);Sourcefn complex_conjugate(&self) -> Expression
fn complex_conjugate(&self) -> Expression
Get the complex conjugate
§Examples
use mathhook_core::{Expression, ComplexOperations, expr};
let z = Expression::complex(expr!(3), expr!(4));
let conjugate = z.complex_conjugate();Sourcefn complex_modulus(&self) -> Expression
fn complex_modulus(&self) -> Expression
Get the modulus (absolute value)
§Examples
use mathhook_core::{Expression, ComplexOperations, expr};
let z = Expression::complex(expr!(3), expr!(4));
let modulus = z.complex_modulus();Sourcefn complex_argument(&self) -> Expression
fn complex_argument(&self) -> Expression
Get the argument (angle in radians)
§Examples
use mathhook_core::{Expression, ComplexOperations, expr};
let z = Expression::complex(expr!(1), expr!(1));
let argument = z.complex_argument();Sourcefn to_polar_form(&self) -> (Expression, Expression)
fn to_polar_form(&self) -> (Expression, Expression)
Convert to polar form (magnitude, angle)
§Examples
use mathhook_core::{Expression, ComplexOperations, expr};
let z = Expression::complex(expr!(3), expr!(4));
let (magnitude, angle) = z.to_polar_form();Sourcefn is_real(&self) -> bool
fn is_real(&self) -> bool
Check if the expression is real
§Examples
use mathhook_core::{Expression, ComplexOperations, expr};
let z = Expression::complex(expr!(5), expr!(0));
assert!(z.is_real());Sourcefn is_imaginary(&self) -> bool
fn is_imaginary(&self) -> bool
Check if the expression has an imaginary component
§Examples
use mathhook_core::{Expression, ComplexOperations, expr};
let z = Expression::complex(expr!(3), expr!(4));
assert!(z.is_imaginary());Sourcefn is_pure_imaginary(&self) -> bool
fn is_pure_imaginary(&self) -> bool
Check if the expression is pure imaginary
§Examples
use mathhook_core::{Expression, ComplexOperations, expr};
let z = Expression::complex(expr!(0), expr!(5));
assert!(z.is_pure_imaginary());