001/* 002 * Licensed to the Apache Software Foundation (ASF) under one or more 003 * contributor license agreements. See the NOTICE file distributed with 004 * this work for additional information regarding copyright ownership. 005 * The ASF licenses this file to You under the Apache License, Version 2.0 006 * (the "License"); you may not use this file except in compliance with 007 * the License. You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017 018package org.apache.commons.math3.ode.nonstiff; 019 020 021/** 022 * This class implements a simple Euler integrator for Ordinary 023 * Differential Equations. 024 * 025 * <p>The Euler algorithm is the simplest one that can be used to 026 * integrate ordinary differential equations. It is a simple inversion 027 * of the forward difference expression : 028 * <code>f'=(f(t+h)-f(t))/h</code> which leads to 029 * <code>f(t+h)=f(t)+hf'</code>. The interpolation scheme used for 030 * dense output is the linear scheme already used for integration.</p> 031 * 032 * <p>This algorithm looks cheap because it needs only one function 033 * evaluation per step. However, as it uses linear estimates, it needs 034 * very small steps to achieve high accuracy, and small steps lead to 035 * numerical errors and instabilities.</p> 036 * 037 * <p>This algorithm is almost never used and has been included in 038 * this package only as a comparison reference for more useful 039 * integrators.</p> 040 * 041 * @see MidpointIntegrator 042 * @see ClassicalRungeKuttaIntegrator 043 * @see GillIntegrator 044 * @see ThreeEighthesIntegrator 045 * @see LutherIntegrator 046 * @since 1.2 047 */ 048 049public class EulerIntegrator extends RungeKuttaIntegrator { 050 051 /** Time steps Butcher array. */ 052 private static final double[] STATIC_C = { 053 }; 054 055 /** Internal weights Butcher array. */ 056 private static final double[][] STATIC_A = { 057 }; 058 059 /** Propagation weights Butcher array. */ 060 private static final double[] STATIC_B = { 061 1.0 062 }; 063 064 /** Simple constructor. 065 * Build an Euler integrator with the given step. 066 * @param step integration step 067 */ 068 public EulerIntegrator(final double step) { 069 super("Euler", STATIC_C, STATIC_A, STATIC_B, new EulerStepInterpolator(), step); 070 } 071 072}