finesse.symbols.Variable

Overview

class finesse.symbols.Variable(name)

Bases: finesse.symbols.Symbol

Makes a variable symbol that can be used in symbolic math. Values must be substituted in when evaluating an expression.

Parameters

value : float, int

Value of constant

name : str, optional

Name of the constant to use when printing

Examples

Using some variables to make an expression and evaluating it:

>>> import numpy as np
>>> x = Variable('x')
>>> y = Variable('y')
>>> z = 4*x**2 - np.cos(y)
>>> print(f"{z} = {z.eval(subs={x:2, y:3})} : x={2}, y={3}")
(4*x**2-y) = 13 : x=2, y=3

Properties

Variable.name

Methods

Variable.__init__(self, name)

Variable.eval(self[, subs])