""" Exercise 7.11 from "A primer on... Extend the function class from 7.1 with special methods. """ import numpy as np class F: def __init__(self, a, w): self.a = a self.w = w def __call__(self, x): return np.exp(-self.a * x) * np.sin(self.w * x) def __str__(self): return 'exp(-a*x)*sin(w*x)' f = F(a=1.0, w=0.1) print(f(x=np.pi)) #0.013353835137 print(f)