An Introduction to Numerical Methods in C++, Revised Edition

A9: Ordinary differential equations

A9 Ordinary differential equations

Although TScreen provides a perfectly adequate base, additional functionality is again required for displaying graphically the solutions of differential equations, especially when two or more simultaneous equations are involved. In this section we construct the functions required for solving single ordinary differential equations of the form dy/ dx = f( x, y); in the last section we treat two simultaneous equations.

Of course, we must first include the header files:

#include 

and then the definition of the function type:

typedef double(*func)(double, double);

We shall restrict ourselves to Runge-Kutta methods for simplicity ( cf 18.5), although we give ourselves a choice of the order of RK approximation (the technique may easily be extended to include other possibilities). These methods are encapsulated in the class TRKOneDim:

<a name="860"></a><a name="page517"></a>class TRKOneDim {public:      typedef void(TRKOneDim: :*trkf)(func, double,                        double&, double, bool&);      void RK1(func, double, double&, double, bool&);      void RK2(func, double, double&, double, bool&);      void RK4(func, double, double&, double, bool&);};

Notice the appearance of a typedef statement inside the class declaration, and the form that it takes. This allows us to refer to a RK method without initially specifying which one The RK functions are familiar to us from...

UNLIMITED FREE
ACCESS
TO THE WORLD'S BEST IDEAS

SUBMIT
Already a GlobalSpec user? Log in.

This is embarrasing...

An error occurred while processing the form. Please try again in a few minutes.

Customize Your GlobalSpec Experience

Category: Waveplates and Retardation Plates
Finish!
Privacy Policy

This is embarrasing...

An error occurred while processing the form. Please try again in a few minutes.