[][src]Enum symbolics_core::expr::Expr

pub enum Expr {
    Num(f64),
    Symbol(String),
    Add(Box<Expr>, Box<Expr>),
    Mul(Box<Expr>, Box<Expr>),
    Pow(Box<Expr>, Box<Expr>),
    Log(Box<Expr>, Box<Expr>),
    Sin(Box<Expr>),
    Cos(Box<Expr>),
    Arcsin(Box<Expr>),
    Arccos(Box<Expr>),
    Arctan(Box<Expr>),
}

Variants

Num(f64)Symbol(String)Add(Box<Expr>, Box<Expr>)Mul(Box<Expr>, Box<Expr>)Pow(Box<Expr>, Box<Expr>)Log(Box<Expr>, Box<Expr>)Sin(Box<Expr>)Cos(Box<Expr>)Arcsin(Box<Expr>)Arccos(Box<Expr>)Arctan(Box<Expr>)

Methods

impl Expr[src]

pub fn is_num(self) -> bool[src]

Return whether the expression represents a literal number, i.e. whether it is of variant Num.

pub fn val(self) -> Option<f64>[src]

Return the numeric value of the expression, if all symbols have been applied. If there are unapplied symbols, returns None.

impl Expr[src]

pub fn apply1<T, S: AsRef<str>>(self, name_raw: S, value: T) -> Expr where
    T: Clone + Into<Expr>, 
[src]

Apply a single substitution, then simplify purely numeric sub-expressions. The substitution can be anything that can be converted to an expression.

Examples

      let y = 3*s!(x).squared() + 2;
      let y_2 = y.apply1("x", 2);
      assert_eq!(y_2.val().unwrap(), 14.);
      let y = 3*s!(x) + 2;
      let y_t = y.apply1("x", s!(t).squared());
      assert_eq!(format!("{:?}", y_t), "Add(Mul(Num(3.0), Pow(Symbol(\"t\"), Num(2.0))), Num(2.0))")

impl Expr[src]

pub fn log<T>(self, base: T) -> Expr where
    T: Into<Expr>, 
[src]

Logarithm of arbitrary base.

pub fn log2(self) -> Expr[src]

Logarithm with base 2.

pub fn log10(self) -> Expr[src]

Logarithm with base 10.

pub fn ln(self) -> Expr[src]

Natural logarithm, i.e. log base e, where e is Euler's number.

impl Expr[src]

pub fn sqrt(self) -> Expr[src]

Square root.

Provided as a convenience; expr.sqrt() is equivalent to expr ^ 0.5.

pub fn squared(self) -> Expr[src]

Raise to the second power.

Provided as a convenience; expr.squared() is equivalent to expr ^ 2.

pub fn cubed(self) -> Expr[src]

Raise to the third power.

Provided as a convenience; expr.cubed() is equivalent to expr ^ 3.

impl Expr[src]

pub fn sin(self) -> Expr[src]

pub fn cos(self) -> Expr[src]

pub fn tan(self) -> Expr[src]

pub fn csc(self) -> Expr[src]

pub fn sec(self) -> Expr[src]

pub fn cot(self) -> Expr[src]

pub fn asin(self) -> Expr[src]

pub fn acos(self) -> Expr[src]

pub fn atan(self) -> Expr[src]

Trait Implementations

impl Clone for Expr[src]

fn clone_from(&mut self, source: &Self)
1.0.0
[src]

Performs copy-assignment from source. Read more

impl From<f64> for Expr[src]

impl From<i64> for Expr[src]

impl<T> Add<T> for Expr where
    T: Into<Expr>, 
[src]

type Output = Expr

The resulting type after applying the + operator.

impl Add<Expr> for f64[src]

type Output = Expr

The resulting type after applying the + operator.

impl Add<Expr> for i64[src]

type Output = Expr

The resulting type after applying the + operator.

impl<T> Sub<T> for Expr where
    T: Into<Expr>, 
[src]

type Output = Expr

The resulting type after applying the - operator.

impl Sub<Expr> for f64[src]

type Output = Expr

The resulting type after applying the - operator.

impl Sub<Expr> for i64[src]

type Output = Expr

The resulting type after applying the - operator.

impl<T> Mul<T> for Expr where
    T: Into<Expr>, 
[src]

type Output = Expr

The resulting type after applying the * operator.

impl Mul<Expr> for f64[src]

type Output = Expr

The resulting type after applying the * operator.

impl Mul<Expr> for i64[src]

type Output = Expr

The resulting type after applying the * operator.

impl<T> Div<T> for Expr where
    T: Into<Expr>, 
[src]

type Output = Expr

The resulting type after applying the / operator.

impl Div<Expr> for f64[src]

type Output = Expr

The resulting type after applying the / operator.

impl Div<Expr> for i64[src]

type Output = Expr

The resulting type after applying the / operator.

impl Neg for Expr[src]

type Output = Expr

The resulting type after applying the - operator.

impl<T> AddAssign<T> for Expr where
    T: Into<Expr>, 
[src]

impl<T> SubAssign<T> for Expr where
    T: Into<Expr>, 
[src]

impl<T> MulAssign<T> for Expr where
    T: Into<Expr>, 
[src]

impl<T> DivAssign<T> for Expr where
    T: Into<Expr>, 
[src]

impl<'a> Not for &'a Expr[src]

type Output = Expr

The resulting type after applying the ! operator.

impl<T> BitXor<T> for Expr where
    T: Into<Expr>, 
[src]

type Output = Expr

The resulting type after applying the ^ operator.

impl BitXor<Expr> for f64[src]

type Output = Expr

The resulting type after applying the ^ operator.

impl BitXor<Expr> for i64[src]

type Output = Expr

The resulting type after applying the ^ operator.

impl<T> BitXorAssign<T> for Expr where
    T: Into<Expr>, 
[src]

impl Debug for Expr[src]

Auto Trait Implementations

impl Send for Expr

impl Sync for Expr

Blanket Implementations

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

impl<T> From for T[src]

impl<T, U> TryFrom for T where
    U: Into<T>, 
[src]

type Error = !

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

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

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]