Subclassing and inheritance
In this section, we will introduce some central concepts from object-oriented programming: abstract classes, subclasses, and inheritance. To guide you through these concepts, we consider another mathematical example: one-step methods for solving a differential equation. The generic form of an ordinary initial value problem is
The data is the right-hand side function f, the initial value x0, and the interval of interest [t0, te]. The solution of this problem is a function . A numerical algorithm gives this solution as a vector u of discrete values ui being approximations to x(ti). Here, are discretized values of the independent variable t, which in physical models often represents time.
A one-step method constructs the solution values ui by the recursion steps:
Here, Φ is a step function that characterizes the individual methods (refer to [28]):
- Explicit Euler:
- Midpoint Rule:
- Runge–Kutta 4: with
What...