001/* 002* Evaluatable1D -- Interface for a 1D function y=fn(x) and it's slope dy/dx=d_fn(x)/dx. 003* 004* Copyright (C) 1999 - 2011 by Joseph A. Huwaldt. 005* All rights reserved. 006* 007* This library is free software; you can redistribute it and/or 008* modify it under the terms of the GNU Lesser General Public 009* License as published by the Free Software Foundation; either 010* version 2 of the License, or (at your option) any later version. 011* 012* This library is distributed in the hope that it will be useful, 013* but WITHOUT ANY WARRANTY; without even the implied warranty of 014* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 015* Lesser General Public License for more details. 016* 017* You should have received a copy of the GNU Lesser General Public License 018* along with this program; if not, write to the Free Software 019* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 020* Or visit: http://www.gnu.org/licenses/lgpl.html 021**/ 022package jahuwaldt.tools.math; 023 024 025/** 026* An interface that defines a 1D function y = fn(x) (named 027* "function") that can be called by math tools such as root 028* finders. Also defines the derivative of the function. 029* dy/dx = d fn(x)/dx (oddly enough, named "derivative"). 030* 031* <p> Modified by: Joseph A. Huwaldt </p> 032* 033* @author Joseph A. Huwaldt Date: October 7, 1998 034* @version November 12, 2011 035**/ 036public interface Evaluatable1D { 037 038 /** 039 * User supplied method that calculates the function y = fn(x). 040 * Classes implementing this interface must define this function. 041 * 042 * @param x Independent parameter to the function. 043 * @return The function value at x. 044 **/ 045 public double function(double x) throws RootException; 046 047 /** 048 * Calculates the derivative of the function dy/dx = d fn(x)/dx. 049 * Classes wanting to return the derivative of the function at x 050 * should override this function. 051 * If the method using this class doesn't require the 052 * derivative, do nothing and Double.NaN is returned. 053 * 054 * @param x Independent parameter to the function. 055 * @return The function value at x or Double.NaN if the derivative is not defined. 056 **/ 057 public double derivative(double x) throws RootException; 058 059} 060 061 062