Predefined Constants#

class cake.Pi(coefficient: Any = 1, power: Any = 1)[source]#

Bases: Constant

Represents the PI constant, value is equal to math.pi.

property c_value: Real#

Returns default value of the constant

copy() Constant#

Returns a shallow copy of the variable

static is_similar(x: Variable, y: Variable) bool#

Returns whether 2 Variables can interact with one another,

so Variable.is_similar(3x, 4x) is True but Variable.is_similar(4y, 3x) is False.

classmethod many(*symbols) List[Variable]#

Returns a list of Variables from the input given

>>> Variable.many('x', 'y')
[Variable('x'), Variable('y')]
>>> Variable.many(('x', 5), ('y', 1, 2), 'z')
[Variable('x', coefficient=5), Variable('y', coefficient=1, power=2), Variable('z')]
solve(*_, **kwds) Any#

Solves the variable with provided values

>>> x = Variable('x')
>>> x *= 3
>>> x **= 2
>>> x
3x**2
>>> x.solve(5)
75
>>> x.solve(x=5)
75
>>> x = Variable('x', coefficient=Variable('y', power=2))
>>> x
y**2x
>>> x.solve(2, y=3)
18
>>> x.solve(x=2, y=3)
18