SSJ API Documentation
Stochastic Simulation in Java
Loading...
Searching...
No Matches
PowerMathFunction.java
1/*
2 * Class: PowerMathFunction
3 * Description:
4 * Environment: Java
5 * Software: SSJ
6 * Copyright (C) 2001 Pierre L'Ecuyer and Universite de Montreal
7 * Organization: DIRO, Universite de Montreal
8 * @author Éric Buist
9 * @since
10 *
11 *
12 * Licensed under the Apache License, Version 2.0 (the "License");
13 * you may not use this file except in compliance with the License.
14 * You may obtain a copy of the License at
15 *
16 * http://www.apache.org/licenses/LICENSE-2.0
17 *
18 * Unless required by applicable law or agreed to in writing, software
19 * distributed under the License is distributed on an "AS IS" BASIS,
20 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21 * See the License for the specific language governing permissions and
22 * limitations under the License.
23 *
24 */
25package umontreal.ssj.functions;
26
33public class PowerMathFunction implements MathFunction
34
36 private MathFunction func;
37 private double a, b;
38 private double power;
39
47 public PowerMathFunction(MathFunction func, double power) {
48 this(func, 1, 0, power);
49 }
50
60 public PowerMathFunction(MathFunction func, double a, double b, double power) {
61 if (func == null)
62 throw new NullPointerException();
63 this.func = func;
64 this.a = a;
65 this.b = b;
66 this.power = power;
67 }
68
75 return func;
76 }
77
83 public double getA() {
84 return a;
85 }
86
92 public double getB() {
93 return b;
94 }
95
101 public double getPower() {
102 return power;
103 }
104
105 public double derivative(double x) {
106 final double fder = MathFunctionUtil.derivative(func, x);
107 return getA() * getPower() * Math.pow(getA() * func.evaluate(x) + getB(), getPower() - 1) * fder;
108 }
109
110 public double evaluate(double x) {
111 final double v = func.evaluate(x);
112 return Math.pow(a * v + b, power);
113 }
114}
Provides utility methods for computing derivatives and integrals of functions.
static double derivative(MathFunction func, double x)
Returns the first derivative of the function func evaluated at x.
PowerMathFunction(MathFunction func, double a, double b, double power)
Constructs a new power function for function func, power power, and constants a and b.
MathFunction getFunction()
Returns the function .
double derivative(double x)
Computes (or estimates) the first derivative of the function at point x.
PowerMathFunction(MathFunction func, double power)
Constructs a new power function for function func and power power.
double evaluate(double x)
Returns the value of the function evaluated at .
Represents a mathematical function whose derivative can be computed using derivative(double).
This interface should be implemented by classes which represent univariate mathematical functions.