Linear Expressions#
- class cake.expressions.linear.LinearExpression(m: M, c: C)[source]#
Bases:
PolynomialExpression,Generic[M,C]Represents a basic linear expression, this expression can also be expressed as
y = mx + c.- Parameters:
- as_expression() Expression[source]#
Returns a
Expressionin the form of aLinearExpression
- classmethod from_expression(expr: Expression) LinearExpression[source]#
Creates a
LinearExpressionfrom aExpression.- Parameters:
expr (
Expression) – Expression to use, must be in the formAdd(variable, Any, ...)Any values afterAnywill expressed asAdd(Any, ...)- Raises:
TypeError – Invalid expression was given, either operation was not Add or it didn’t match the valid pattern.
- classmethod from_points(point1: cake.geometry.Point2D, point2: cake.geometry.Point2D, /) LinearExpression[source]#
Returns a linear expression from 2 given 2D points
- Parameters:
point1 (
geometry.Point2D) – A 2D point to usepoint2 (
geometry.Point2D) – A 2D point to use
- classmethod generic() LinearExpression[source]#
Returns a generic linear expression
- property gradient: M#
Returns the gradient of the expression
- property intercept: C#
Returns the intercept of the expression
- r_solve(y: Any, **kwds) Any[source]#
Returns a value for when
yis given, kwargs for other values may be passed as well butyis always overwritten>>> y = LinearExpression(2, 10) >>> y 2*x + 10 >>> y.r_solve(y=10) 0 >>> y.r_solve(y=3) -3.5
- solve(x: Any, **kwds) Any[source]#
Returns a value for when
xis given, kwargs for other values may be passed as well butxis always overwritten.>>> y = LinearExpression(Real(0.5), 10) >>> y 0.5*x + 10 >>> y.solve(x=5) 12.5
- classmethod through_origin(m: Any) LinearExpression[source]#
Returns a linear expression which passes through the origin
- Parameters:
m (Any[Like[cake.BasicNode]]) – Gradient of the expression