Home : Map : Chapter 2 : Java : Tech : Physics Chapter 2: Basic Simulations with Differential Equations
 Introduction Essentials Structure Keywords Primitive Types Comments Literals Expressions Operators Statements Casts & Mixing Strings Console Output     Demo Exercises
 Supplements Conditional: if-else Repetitions Flow Control Java vs C/C++ JVM Instructions 1
 About JavaTech      Codes List      Exercises      Feedback      References      Resources      Tips      Topic Index      Course Guide      What's New
 In this chapter we do our first simple simulations and introduce some basic numerical methods techniques involving the solution of ordinary differential equations. Such equations are common in physics and here we look a some simple examples that deal with the motion of a mass in a gravitational field and a mass attached to a spring. Thus far we presented only the basic syntax of the language, so we will carry out the computations in a purely procedural programming manner. That is, we will put all the code within the main() method of an application (or the init() method of an applet) and not use any methods or any object oriented features of the language. For similar reasons, we will only use console output here and not employ any other I/O or graphics techniques until we cover those topics in later chapters. The topics here include: A brief review of Ordinary Differential Equations Euler Method for solving ODE Demonstration program using Euler to solve for the motion of an object falling in a constant gravitational field Predictor-Corrector method that improves on the Euler method Demonstration of the predictor-corrector method for solving the motion of a mass attached to a spring. Exercises The demo programs will also illustrate some of the floating point issues like round-off errors that we briefly discussed in the Chapter 1: Tech section.   Latest update: Dec.12.2003
 Tech Arithmetic Ops Math Class More on Integers FP : Overview FP : Java     Demo 1 More Mix/Cast   Demo 2 Exercises
 Part I Part II Part III Java Core 1  2  3  4  5  6  7  8  9  10  11  12 13 14 15 16 17 18 19 20 21 22 23 24 Supplements 1  2  3  4  5  6  7  8  9  10  11  12 Tech 1  2  3  4  5  6  7  8  9  10  11  12 Physics 1  2  3  4  5  6  7  8  9  10  11  12

Java is a trademark of Sun Microsystems, Inc.