1 /* 2 * Licensed to the Apache Software Foundation (ASF) under one or more 3 * contributor license agreements. See the NOTICE file distributed with 4 * this work for additional information regarding copyright ownership. 5 * The ASF licenses this file to You under the Apache License, Version 2.0 6 * (the "License"); you may not use this file except in compliance with 7 * the License. You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 */ 17 18 package org.apache.commons.math.ode.nonstiff; 19 20 21 /** 22 * This class implements a simple Euler integrator for Ordinary 23 * Differential Equations. 24 * 25 * <p>The Euler algorithm is the simplest one that can be used to 26 * integrate ordinary differential equations. It is a simple inversion 27 * of the forward difference expression : 28 * <code>f'=(f(t+h)-f(t))/h</code> which leads to 29 * <code>f(t+h)=f(t)+hf'</code>. The interpolation scheme used for 30 * dense output is the linear scheme already used for integration.</p> 31 * 32 * <p>This algorithm looks cheap because it needs only one function 33 * evaluation per step. However, as it uses linear estimates, it needs 34 * very small steps to achieve high accuracy, and small steps lead to 35 * numerical errors and instabilities.</p> 36 * 37 * <p>This algorithm is almost never used and has been included in 38 * this package only as a comparison reference for more useful 39 * integrators.</p> 40 * 41 * @see MidpointIntegrator 42 * @see ClassicalRungeKuttaIntegrator 43 * @see GillIntegrator 44 * @see ThreeEighthesIntegrator 45 * @version $Revision: 810196 $ $Date: 2009-09-01 21:47:46 +0200 (mar. 01 sept. 2009) $ 46 * @since 1.2 47 */ 48 49 public class EulerIntegrator extends RungeKuttaIntegrator { 50 51 /** Time steps Butcher array. */ 52 private static final double[] STATIC_C = { 53 }; 54 55 /** Internal weights Butcher array. */ 56 private static final double[][] STATIC_A = { 57 }; 58 59 /** Propagation weights Butcher array. */ 60 private static final double[] STATIC_B = { 61 1.0 62 }; 63 64 /** Simple constructor. 65 * Build an Euler integrator with the given step. 66 * @param step integration step 67 */ 68 public EulerIntegrator(final double step) { 69 super("Euler", STATIC_C, STATIC_A, STATIC_B, new EulerStepInterpolator(), step); 70 } 71 72 } 73