Extension of class StringFunction1 to an arbitrary
number of independent variables. Example on usage:
>>> from StringFunction import StringFunction_alt
>>> f = StringFunction_alt('1+sin(2x)')
>>> f(1.2)
1.6754631805511511
>>> f = StringFunction_alt('1+sin(2t)', independent_variables=t )
>>> f(1.2)
1.6754631805511511
>>> f = StringFunction_alt('1+Asin(wt)', independent_variables=t , set_parameters=A=0.1; w=3.14159 )
>>> f(1.2)
0.94122173238695939
>>> f.set_parameters(A=1; w=1 )
>>> f(1.2)
1.9320390859672263
>>> # function of two variables:
>>> f = StringFunction_alt('1+sin(2x)cos(y)', independent_variables=(x ,y ))
>>> f(1.2,-1.1)
1.3063874788637866
>>> f = StringFunction_alt('1+Vsin(wx)exp(-bt)', independent_variables=(x ,t ))
>>> f.set_parameters(V=0.1; w=1; b=0.1 )
>>> f(1.0,0.1)
1.0833098208613807
Methods
|
|
__call__
__init__
|
|
__call__
|
__call__ ( self, *args )
|
|
__init__
|
__init__ (
self,
expression,
independent_variables='x',
set_parameters='',
)
|
|