symmath.expr¶
-
exception
symmath.expr.
SymmathError
¶ Bases:
ValueError
-
class
symmath.expr.
Expr
(other=None, tolerance=1e-08)¶ Class used for symbolic computations. Introduction to symmath describes what operations this class supports.
-
terms
¶ A mapping from symbol names to their coefficients.
-
tolerance
¶ Numbers smaller than the tolerance in absolute value are converted to 0.
-
scalar
()¶ If x contains no symbols,
x.scalar()
returns a regular float equal to the scalar part of x. Otherwise an exception is raised.>>> a = sym('a') >>> x = a + 3 >>> x.scalar() Traceback (most recent call last): ... SymmathError: Not a scalar >>> x -= a >>> x Expr(3) >>> x.scalar() 3
-
substitue
(symbol, arg)¶ Replace all occurances of symbol with arg.
>>> from symmath import sym >>> x = sym("x") >>> y = sym("y") >>> z = sym("z") >>> e = 2 * x + y + 1 >>> e.substitue("x", y + z) >>> print(e) 3 y + 2 z + 1
-
-
symmath.expr.
sym
(symbol)¶ Create an expression containing just the given symbol.
>>> sym('a') Expr(a)