A technique for solving systems of coupled ordinary differential equations with initial, boundary, and/or intermediate conditions is given. This method has a number of inherent advantages over existing techniques as well as being efficient in terms of computer time and space requirements. Optimal control problems can be solved by this technique by using Pontryagin's Maximum Principle to transform the state equations and their associated performance index into a system of coupled differential equations. An example of computing the optimal control for a spatially dependent reactor model with and without temperature feedback is given.