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