01: /*
02: * Copyright 2003-2004 The Apache Software Foundation.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
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
28: DifferentiableUnivariateRealFunction, Serializable {
29:
30: private static final long serialVersionUID = -8866263034920607152L;
31:
32: /* Evaluate quintic.
33: * @see org.apache.commons.math.UnivariateRealFunction#value(double)
34: */
35: public double value(double x) throws FunctionEvaluationException {
36: return (x - 1) * (x - 0.5) * x * (x + 0.5) * (x + 1);
37: }
38:
39: public UnivariateRealFunction derivative() {
40: return new UnivariateRealFunction() {
41: public double value(double x)
42: throws FunctionEvaluationException {
43: return (5 * x * x - 3.75) * x * x + 0.25;
44: }
45: };
46: }
47: }
|