1 /* 2 * Copyright 2003-2004 The Apache Software Foundation. 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 package org.apache.commons.math.analysis; 17 18 import java.io.Serializable; 19 20 import org.apache.commons.math.FunctionEvaluationException; 21 22 /** 23 * Auxillary class for testing solvers. 24 * 25 * @version $Revision: 348519 $ $Date: 2005-11-23 12:12:18 -0700 (Wed, 23 Nov 2005) $ 26 */ 27 public class QuinticFunction implements DifferentiableUnivariateRealFunction, Serializable { 28 29 private static final long serialVersionUID = -8866263034920607152L; 30 31 /* Evaluate quintic. 32 * @see org.apache.commons.math.UnivariateRealFunction#value(double) 33 */ 34 public double value(double x) throws FunctionEvaluationException { 35 return (x-1)*(x-0.5)*x*(x+0.5)*(x+1); 36 } 37 38 public UnivariateRealFunction derivative() { 39 return new UnivariateRealFunction() { 40 public double value(double x) throws FunctionEvaluationException { 41 return (5*x*x-3.75)*x*x+0.25; 42 } 43 }; 44 } 45 }