SSJ API Documentation
Stochastic Simulation in Java
Loading...
Searching...
No Matches
SquareMathFunction.java
1/*
2 * Class: SquareMathFunction
3 * Description: function computing the square of another function
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
34 private MathFunction func;
35 private double a, b;
36
44 this(func, 1, 0);
45 }
46
55 public SquareMathFunction(MathFunction func, double a, double b) {
56 if (func == null)
57 throw new NullPointerException();
58 this.func = func;
59 this.a = a;
60 this.b = b;
61 }
62
69 return func;
70 }
71
77 public double getA() {
78 return a;
79 }
80
86 public double getB() {
87 return b;
88 }
89
90 public double evaluate(double x) {
91 final double v = a * func.evaluate(x) + b;
92 return v * v;
93 }
94
95 public double derivative(double x) {
96 final double fder = MathFunctionUtil.derivative(func, x);
97 return 2 * a * (a * func.evaluate(x) + b) * fder;
98 }
99}
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.
SquareMathFunction(MathFunction func)
Constructs a new square function for function func.
MathFunction getFunction()
Returns the function .
double evaluate(double x)
Returns the value of the function evaluated at .
SquareMathFunction(MathFunction func, double a, double b)
Constructs a new power function for function func, and constants a and b.
double derivative(double x)
Computes (or estimates) the first derivative of the function at point x.
Represents a mathematical function whose derivative can be computed using derivative(double).
This interface should be implemented by classes which represent univariate mathematical functions.