""" Ex. 7.1 from "A primer on... Implement a class F that represents a mathematical function and supports the use cases given in the exercise text. """ import numpy as np class F: def __init__(self, a, w): self.a = a self.w = w def value(self, x): return np.exp(-self.a * x) * np.sin(self.w * x) f = F(a=1.0, w=0.1) print(f(x = np.pi)) print(f.value(x = np.pi)) f.a = 2 print(f.value(np.pi))