SSJ API Documentation
Stochastic Simulation in Java
Loading...
Searching...
No Matches
ShiftedMathFunction.java
1/*
2 * Class: ShiftedMathFunction
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 ShiftedMathFunction implements MathFunction
34
36 MathFunction func;
37 double delta;
38
45 public ShiftedMathFunction(MathFunction func, double delta) {
46 if (func == null)
47 throw new NullPointerException();
48 this.func = func;
49 this.delta = delta;
50 }
51
58 return func;
59 }
60
66 public double getDelta() {
67 return delta;
68 }
69
70 public double evaluate(double x) {
71 return func.evaluate(x) - delta;
72 }
73
74 public double derivative(double x) {
75 return MathFunctionUtil.derivative(func, x);
76 }
77
78 public double derivative(double x, int n) {
79 return MathFunctionUtil.derivative(func, x, n);
80 }
81
82 public double integral(double a, double b) {
83 return MathFunctionUtil.integral(func, a, b) - (b - a) * getDelta();
84 }
85}
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.
static double integral(MathFunction func, double a, double b)
Returns the integral of the function func over .
double evaluate(double x)
Returns the value of the function evaluated at .
double derivative(double x)
Computes (or estimates) the first derivative of the function at point x.
double integral(double a, double b)
Computes (or estimates) the integral of the function over the interval .
MathFunction getFunction()
Returns the function .
double getDelta()
Returns the shift = delta.
double derivative(double x, int n)
Computes (or estimates) the th derivative of the function at point x.
ShiftedMathFunction(MathFunction func, double delta)
Constructs a new function shifting the function func by a shift delta.
Represents a mathematical function whose th derivative can be computed using derivative(double,...
Represents a mathematical function whose derivative can be computed using derivative(double).
Represents a mathematical function whose integral can be computed by the integral(double,...
This interface should be implemented by classes which represent univariate mathematical functions.