EulerIntegrator.java

  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. package org.apache.commons.math4.legacy.ode.nonstiff;


  18. /**
  19.  * This class implements a simple Euler integrator for Ordinary
  20.  * Differential Equations.
  21.  *
  22.  * <p>The Euler algorithm is the simplest one that can be used to
  23.  * integrate ordinary differential equations. It is a simple inversion
  24.  * of the forward difference expression :
  25.  * <code>f'=(f(t+h)-f(t))/h</code> which leads to
  26.  * <code>f(t+h)=f(t)+hf'</code>. The interpolation scheme used for
  27.  * dense output is the linear scheme already used for integration.</p>
  28.  *
  29.  * <p>This algorithm looks cheap because it needs only one function
  30.  * evaluation per step. However, as it uses linear estimates, it needs
  31.  * very small steps to achieve high accuracy, and small steps lead to
  32.  * numerical errors and instabilities.</p>
  33.  *
  34.  * <p>This algorithm is almost never used and has been included in
  35.  * this package only as a comparison reference for more useful
  36.  * integrators.</p>
  37.  *
  38.  * @see MidpointIntegrator
  39.  * @see ClassicalRungeKuttaIntegrator
  40.  * @see GillIntegrator
  41.  * @see ThreeEighthesIntegrator
  42.  * @see LutherIntegrator
  43.  * @since 1.2
  44.  */

  45. public class EulerIntegrator extends RungeKuttaIntegrator {

  46.   /** Time steps Butcher array. */
  47.   private static final double[] STATIC_C = {
  48.   };

  49.   /** Internal weights Butcher array. */
  50.   private static final double[][] STATIC_A = {
  51.   };

  52.   /** Propagation weights Butcher array. */
  53.   private static final double[] STATIC_B = {
  54.     1.0
  55.   };

  56.   /** Simple constructor.
  57.    * Build an Euler integrator with the given step.
  58.    * @param step integration step
  59.    */
  60.   public EulerIntegrator(final double step) {
  61.     super("Euler", STATIC_C, STATIC_A, STATIC_B, new EulerStepInterpolator(), step);
  62.   }
  63. }