from sympy import *
init_printing()
x = symbols('x')
type(x)
x**2
x,y = symbols('x,y')
(x+y)**2
expand((x+y)**2)
w = x**2 + 3*x + 6
w
diff(w,x)
integrate(w,x)
integrate(w,(x,0,4))
y = sin(x)
diff(y,x)
See lambdify for conveting sympy expressions to numpy-friendly functions
from numpy import *
class segment:
# constructor
def __init__(self, point,direction,length):
self.p = array(point,dtype=float)
self.u = array(direction,dtype=float)
self.u /= linalg.norm(self.u)
self.l = length
def __repr__(self):
#return 'Wow! My basepoint is ' + str(self.p)
return '('+str(self.p)+','+str(self.u)+','+str(self.l)+')'
#return 'Wow! My basepoint is ' + str(self.p)
s = segment([3,4],[1.2,4],7)
print(s)
class interface(segment):
def __init__(self,point,direction,length,refindexL,refindexR):
segment.__init__(self,point,direction,length)
self.nL = refindexL
self.nR = refindexR
def __repr__(self):
return 'Hahaha'
i = interface([0,0],[1,1],7,1.3,1.5)
i