Physics Modeling: Chapter 2 Examples

The numerical solution of a simple ODE: dy/dx=2x.

Euler's Method

The Euler's Method model computes and displays the numerical solution of a first order ordinary differential equation (ODE) using Euler's method.  The columns show the solution step counter, the independent variable x, and the solution y. The user can input the initial value y[0], the rate f(x), and the independent variable step Δx.  The numerical solution y is usually an approximation of the true solution because of approximation errors in the numerical algorithm truncation errors due to the finite precision of computer arithmetic.  Truncation errors are negligible compared to the approximation errors in Euler's method.

Mathematical Expression Parser

In order to build models that allow users to input functions, we need to convert a sequence of characters into a mathematical expression. This conversion is done using a parser.  The ODE Solution with Euler's Method Model evaluates the rate function y = f(x) using a parser that recognizes the following functions:

Related Models

The following EJS models are described in Chapter 2.

Credits:

The ODE Solution with Euler's Method Model was created by Wolfgang Christian using the Easy Java Simulations (EJS) modeling tool version 4.1.  You can examine and modify the model for this simulation if you have Ejs installed by right-clicking within the program and selecting "Open Ejs Model" from the pop-up menu. 

 

Information about Ejs is available at: <http://www.um.es/fem/Ejs/> and in the OSP comPADRE collection <http://www.compadre.org/OSP/>.